Commit b86269ed authored by hjk's avatar hjk

Android: General java editor related code consolidation

Merge editor files, convert to new editor setup scheme.

Change-Id: Ie498ac5dcb1efc288e55082a285e6daada6b5ebf
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 03eb2f97
......@@ -42,7 +42,6 @@ HEADERS += \
androidpotentialkit.h \
androidsignaloperation.h \
javaeditor.h \
javaeditorfactory.h \
javaindenter.h \
javaautocompleter.h \
javacompletionassistprovider.h \
......@@ -86,7 +85,6 @@ SOURCES += \
androidpotentialkit.cpp \
androidsignaloperation.cpp \
javaeditor.cpp \
javaeditorfactory.cpp \
javaindenter.cpp \
javaautocompleter.cpp \
javacompletionassistprovider.cpp \
......
......@@ -101,8 +101,6 @@ QtcPlugin {
"javacompletionassistprovider.h",
"javaeditor.cpp",
"javaeditor.h",
"javaeditorfactory.cpp",
"javaeditorfactory.h",
"javafilewizard.cpp",
"javafilewizard.h",
"javaindenter.cpp",
......
......@@ -33,6 +33,7 @@
#include "androidconstants.h"
#include "javacompletionassistprovider.h"
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/normalindenter.h>
#include <texteditor/highlighterutils.h>
......@@ -41,8 +42,8 @@
#include <QFileInfo>
using namespace Android;
using namespace Android::Internal;
namespace Android {
namespace Internal {
//
// JavaEditor
......@@ -50,33 +51,20 @@ using namespace Android::Internal;
JavaEditor::JavaEditor()
{
setContext(Core::Context(Constants::C_JAVA_EDITOR,
TextEditor::Constants::C_TEXTEDITOR));
addContext(Constants::C_JAVA_EDITOR);
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>());
}
Core::IEditor *JavaEditor::duplicate()
{
JavaEditorWidget *ret = new JavaEditorWidget;
ret->setTextDocument(editorWidget()->textDocumentPtr());
return ret->editor();
}
//
// JavaEditorWidget
//
setEditorCreator([]() { return new JavaEditor; });
setDocumentCreator([]() { return new JavaDocument; });
JavaEditorWidget::JavaEditorWidget()
{
setAutoCompleter(new JavaAutoCompleter);
setWidgetCreator([]() -> TextEditor::BaseTextEditorWidget * {
auto widget = new TextEditor::BaseTextEditorWidget;
widget->setAutoCompleter(new JavaAutoCompleter);
return widget;
});
}
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
{
return new JavaEditor;
}
//
// JavaDocument
......@@ -101,3 +89,25 @@ QString JavaDocument::suggestedFileName() const
QFileInfo fi(filePath());
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
......@@ -33,12 +33,11 @@
#include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h>
#include <utils/uncommentselection.h>
#include <coreplugin/editormanager/ieditorfactory.h>
namespace Android {
namespace Internal {
class JavaEditorFactory;
class JavaEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
......@@ -46,29 +45,27 @@ class JavaEditor : public TextEditor::BaseTextEditor
public:
JavaEditor();
Core::IEditor *duplicate();
TextEditor::CompletionAssistProvider *completionAssistProvider();
};
class JavaEditorWidget : public TextEditor::BaseTextEditorWidget
class JavaDocument : public TextEditor::BaseTextDocument
{
Q_OBJECT
public:
JavaEditorWidget();
protected:
TextEditor::BaseTextEditor *createEditor();
JavaDocument();
QString defaultPath() const;
QString suggestedFileName() const;
};
class JavaDocument : public TextEditor::BaseTextDocument
class JavaEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
JavaDocument();
QString defaultPath() const;
QString suggestedFileName() const;
JavaEditorFactory();
Core::IEditor *createEditor();
};
} // namespace Internal
......
/****************************************************************************
**
** 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();
}
/****************************************************************************
**
** 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment