Android: General java editor related code consolidation

Merge editor files, convert to new editor setup scheme.

Change-Id: Ie498ac5dcb1efc288e55082a285e6daada6b5ebf
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-20 01:09:56 +02:00
parent 03eb2f97cf
commit b86269edbd
6 changed files with 45 additions and 143 deletions

View File

@@ -42,7 +42,6 @@ HEADERS += \
androidpotentialkit.h \ androidpotentialkit.h \
androidsignaloperation.h \ androidsignaloperation.h \
javaeditor.h \ javaeditor.h \
javaeditorfactory.h \
javaindenter.h \ javaindenter.h \
javaautocompleter.h \ javaautocompleter.h \
javacompletionassistprovider.h \ javacompletionassistprovider.h \
@@ -86,7 +85,6 @@ SOURCES += \
androidpotentialkit.cpp \ androidpotentialkit.cpp \
androidsignaloperation.cpp \ androidsignaloperation.cpp \
javaeditor.cpp \ javaeditor.cpp \
javaeditorfactory.cpp \
javaindenter.cpp \ javaindenter.cpp \
javaautocompleter.cpp \ javaautocompleter.cpp \
javacompletionassistprovider.cpp \ javacompletionassistprovider.cpp \

View File

@@ -101,8 +101,6 @@ QtcPlugin {
"javacompletionassistprovider.h", "javacompletionassistprovider.h",
"javaeditor.cpp", "javaeditor.cpp",
"javaeditor.h", "javaeditor.h",
"javaeditorfactory.cpp",
"javaeditorfactory.h",
"javafilewizard.cpp", "javafilewizard.cpp",
"javafilewizard.h", "javafilewizard.h",
"javaindenter.cpp", "javaindenter.cpp",

View File

@@ -33,6 +33,7 @@
#include "androidconstants.h" #include "androidconstants.h"
#include "javacompletionassistprovider.h" #include "javacompletionassistprovider.h"
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/normalindenter.h> #include <texteditor/normalindenter.h>
#include <texteditor/highlighterutils.h> #include <texteditor/highlighterutils.h>
@@ -41,8 +42,8 @@
#include <QFileInfo> #include <QFileInfo>
using namespace Android; namespace Android {
using namespace Android::Internal; namespace Internal {
// //
// JavaEditor // JavaEditor
@@ -50,33 +51,20 @@ using namespace Android::Internal;
JavaEditor::JavaEditor() JavaEditor::JavaEditor()
{ {
setContext(Core::Context(Constants::C_JAVA_EDITOR, addContext(Constants::C_JAVA_EDITOR);
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true); setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle); setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>()); setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>());
setEditorCreator([]() { return new JavaEditor; });
setDocumentCreator([]() { return new JavaDocument; });
setWidgetCreator([]() -> TextEditor::BaseTextEditorWidget * {
auto widget = new TextEditor::BaseTextEditorWidget;
widget->setAutoCompleter(new JavaAutoCompleter);
return widget;
});
} }
Core::IEditor *JavaEditor::duplicate()
{
JavaEditorWidget *ret = new JavaEditorWidget;
ret->setTextDocument(editorWidget()->textDocumentPtr());
return ret->editor();
}
//
// JavaEditorWidget
//
JavaEditorWidget::JavaEditorWidget()
{
setAutoCompleter(new JavaAutoCompleter);
}
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
{
return new JavaEditor;
}
// //
// JavaDocument // JavaDocument
@@ -101,3 +89,25 @@ QString JavaDocument::suggestedFileName() const
QFileInfo fi(filePath()); QFileInfo fi(filePath());
return fi.fileName(); return fi.fileName();
} }
//
// JavaEditorFactory
//
JavaEditorFactory::JavaEditorFactory()
{
setId(Android::Constants::JAVA_EDITOR_ID);
setDisplayName(tr("Java Editor"));
addMimeType(Android::Constants::JAVA_MIMETYPE);
new TextEditor::TextEditorActionHandler(this, Constants::C_JAVA_EDITOR,
TextEditor::TextEditorActionHandler::UnCommentSelection);
}
Core::IEditor *JavaEditorFactory::createEditor()
{
return new JavaEditor;
}
} // namespace Internal
} // namespace Android

View File

@@ -33,12 +33,11 @@
#include <texteditor/basetextdocument.h> #include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <utils/uncommentselection.h> #include <utils/uncommentselection.h>
#include <coreplugin/editormanager/ieditorfactory.h>
namespace Android { namespace Android {
namespace Internal { namespace Internal {
class JavaEditorFactory;
class JavaEditor : public TextEditor::BaseTextEditor class JavaEditor : public TextEditor::BaseTextEditor
{ {
Q_OBJECT Q_OBJECT
@@ -46,21 +45,9 @@ class JavaEditor : public TextEditor::BaseTextEditor
public: public:
JavaEditor(); JavaEditor();
Core::IEditor *duplicate();
TextEditor::CompletionAssistProvider *completionAssistProvider(); TextEditor::CompletionAssistProvider *completionAssistProvider();
}; };
class JavaEditorWidget : public TextEditor::BaseTextEditorWidget
{
Q_OBJECT
public:
JavaEditorWidget();
protected:
TextEditor::BaseTextEditor *createEditor();
};
class JavaDocument : public TextEditor::BaseTextDocument class JavaDocument : public TextEditor::BaseTextDocument
{ {
Q_OBJECT Q_OBJECT
@@ -71,6 +58,16 @@ public:
QString suggestedFileName() const; QString suggestedFileName() const;
}; };
class JavaEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
JavaEditorFactory();
Core::IEditor *createEditor();
};
} // namespace Internal } // namespace Internal
} // namespace Android } // namespace Android

View File

@@ -1,53 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "javaeditorfactory.h"
#include "javaeditor.h"
#include "androidconstants.h"
#include <texteditor/texteditoractionhandler.h>
using namespace Android;
using namespace Android::Internal;
JavaEditorFactory::JavaEditorFactory()
{
setId(Android::Constants::JAVA_EDITOR_ID);
setDisplayName(tr("Java Editor"));
addMimeType(Android::Constants::JAVA_MIMETYPE);
new TextEditor::TextEditorActionHandler(this, Constants::C_JAVA_EDITOR,
TextEditor::TextEditorActionHandler::UnCommentSelection);
}
Core::IEditor *JavaEditorFactory::createEditor()
{
JavaEditorWidget *editor = new JavaEditorWidget;
editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new JavaDocument));
return editor->editor();
}

View File

@@ -1,48 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef JAVAEDITORFACTORY_H
#define JAVAEDITORFACTORY_H
#include <coreplugin/editormanager/ieditorfactory.h>
namespace Android {
namespace Internal {
class JavaEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
JavaEditorFactory();
Core::IEditor *createEditor();
};
}
}
#endif // JAVAEDITORFACTORY_H