From 94f04e6577d55dc48f18af1ffb954e2a57aee8d9 Mon Sep 17 00:00:00 2001 From: rnavagamuwa Date: Mon, 15 Aug 2016 23:44:53 +0530 Subject: [PATCH] Revert "#1913 Deprecates some of Editor API classes and interfaces" This reverts commit cc51c0ef2701b5860a58470f3f6e2c22ee92d3f8. --- .../api/editor/document/DocumentStorage.java | 10 - .../editor/document/DocumentStorageImpl.java | 13 +- .../api/editor/events/DocumentReadyEvent.java | 5 +- .../editor/events/DocumentReadyHandler.java | 1 - .../texteditor/AbstractEditorModule.java | 116 +++ .../api/editor/texteditor/EditorHandle.java | 1 - .../editor/texteditor/EditorInitCallback.java | 1 - .../api/editor/texteditor/EditorModule.java | 5 +- .../ide/api/editor/texteditor/TextEditor.java | 5 - .../texteditor/TextEditorCursorModel.java | 1 - .../api/editor/texteditor/TextEditorInit.java | 38 +- .../texteditor/TextEditorPresenter.java | 39 +- .../TextEditorPresenterFactory.java | 1 - .../texteditor/TextEditorPresenterTest.java | 2 +- .../che/ide/debug/BreakpointManagerImpl.java | 6 +- .../ide/part/editor/EditorPartStackView.java | 6 +- .../che-plugin-java-ext-lang-client/pom.xml | 4 - .../client/action/ParametersHintsAction.java | 6 +- .../action/QuickDocumentationAction.java | 6 +- .../java/client/action/QuickFixAction.java | 13 +- .../documentation/QuickDocPresenter.java | 11 +- .../ext/java/client/editor/FileWatcher.java | 16 +- .../editor/JavaQuickAssistProcessor.java | 21 +- .../client/editor/JavaReconcilerStrategy.java | 33 +- .../editor/JavaReconcilerStrategyFactory.java | 4 +- .../editor/JsJavaEditorConfiguration.java | 4 +- .../JsJavaEditorConfigurationFactory.java | 4 +- .../client/editor/JsJavaEditorProvider.java | 6 +- .../client/editor/OpenDeclarationFinder.java | 22 +- .../filestructure/FileStructurePresenter.java | 20 +- .../OpenImplementationPresenter.java | 26 +- .../paraminfo/ParametersHintsPresenter.java | 8 +- .../rename/JavaRefactoringRename.java | 6 +- .../java/client/search/node/MatchNode.java | 8 +- .../recipe/editor/RecipeEditorPanel.java | 28 +- .../recipe/editor/RecipeEditorPanelTest.java | 25 +- .../plugin-maven/che-plugin-maven-ide/pom.xml | 4 - .../editor/ClassFileSourcesDownloader.java | 12 +- .../client/editor/PomEditorConfiguration.java | 6 +- .../editor/PomEditorConfigurationFactory.java | 4 +- .../client/editor/PomEditorProvider.java | 6 +- .../client/editor/PomReconcilingStrategy.java | 11 +- .../editor/PomReconcilingStrategyFactory.java | 4 +- .../che-plugin-orion-editor/pom.xml | 4 - .../client/EditorInitializePromiseHolder.java | 35 - .../client/OrionContentTypeRegistrant.java | 29 +- .../editor/orion/client/OrionCursorModel.java | 72 -- .../orion/client/OrionEditorBuilder.java | 11 +- .../orion/client/OrionEditorExtension.java | 56 +- .../editor/orion/client/OrionEditorInit.java | 307 ------ .../orion/client/OrionEditorModule.java | 22 + .../orion/client/OrionEditorPresenter.java | 933 +----------------- .../orion/client/OrionTextEditorFactory.java | 34 + .../client/inject/OrionEditorGinModule.java | 11 + 54 files changed, 480 insertions(+), 1602 deletions(-) create mode 100644 ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/AbstractEditorModule.java delete mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/EditorInitializePromiseHolder.java delete mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionCursorModel.java delete mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorModule.java create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionTextEditorFactory.java diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorage.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorage.java index af5263635b72..e13c60fd3d93 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorage.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorage.java @@ -13,7 +13,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.inject.ImplementedBy; -import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.ide.api.editor.EditorInput; import org.eclipse.che.ide.api.resources.VirtualFile; @@ -37,15 +36,6 @@ public interface DocumentStorage { void getDocument(@NotNull VirtualFile file, @NotNull final DocumentCallback callback); - /** - * Retrieves the file content. - * @param file - * the file - * @return the promise which should return content - */ - @NotNull - Promise getDocument(@NotNull VirtualFile file); - /** * Saves the file content. * diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorageImpl.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorageImpl.java index c440139492ca..75fbc6ecb19a 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorageImpl.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/document/DocumentStorageImpl.java @@ -10,18 +10,16 @@ *******************************************************************************/ package org.eclipse.che.ide.api.editor.document; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.inject.Inject; -import com.google.web.bindery.event.shared.EventBus; - import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; -import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.editor.EditorInput; import org.eclipse.che.ide.api.event.FileEvent; import org.eclipse.che.ide.api.resources.VirtualFile; import org.eclipse.che.ide.util.loging.Log; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; +import com.google.web.bindery.event.shared.EventBus; import javax.validation.constraints.NotNull; @@ -62,11 +60,6 @@ public void apply(PromiseError arg) throws OperationException { }); } - @Override - public Promise getDocument(@NotNull VirtualFile file) { - return file.getContent(); - } - @Override public void saveDocument(final EditorInput editorInput, @NotNull final Document document, final boolean overwrite, @NotNull final AsyncCallback callback) { diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyEvent.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyEvent.java index 8f96b383a6ca..8361da364bda 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyEvent.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyEvent.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.che.ide.api.editor.events; -import com.google.gwt.event.shared.GwtEvent; - import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.texteditor.EditorHandle; -@Deprecated +import com.google.gwt.event.shared.GwtEvent; + public class DocumentReadyEvent extends GwtEvent { /** The type instance for this event. */ diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyHandler.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyHandler.java index 41c6234a0839..79dfca0116c1 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyHandler.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/events/DocumentReadyHandler.java @@ -12,7 +12,6 @@ import com.google.gwt.event.shared.EventHandler; -@Deprecated public interface DocumentReadyHandler extends EventHandler { void onDocumentReady(DocumentReadyEvent event); diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/AbstractEditorModule.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/AbstractEditorModule.java new file mode 100644 index 000000000000..606278197e0a --- /dev/null +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/AbstractEditorModule.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.api.editor.texteditor; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.che.ide.api.editor.texteditor.EditorModule; +import org.eclipse.che.ide.api.editor.texteditor.EditorWidget; +import org.eclipse.che.ide.util.loging.Log; + +/** + * Abstract implementation of {@link EditorModule}. + * @param the type of the editor + */ +public abstract class AbstractEditorModule implements EditorModule { + + private boolean ready = false; + private boolean error = false; + private boolean initializing = false; + + /** The registered callbacks. Will be set to ull once the editor is ready and all callbacks are called once. */ + private List callbacks = new ArrayList<>(); + + /** The process to initialize the editor. */ + private EditorInitializer initializer; + + @Override + public boolean isReady() { + return this.ready; + } + + /** Change the state of the module to 'ready'. */ + public void setReady() { + this.ready = true; + this.initializing = false; + if (callbacks == null) { + return; + } + // use all the callback to inform all the components that are waiting of the success + for (final EditorModuleReadyCallback callback : callbacks) { + callback.onEditorModuleReady(); + } + this.callbacks = null; + } + + /** Change the state of the module to 'error'. */ + public boolean isError() { + return this.error; + } + + public void setError() { + this.error = true; + this.initializing = false; + if (callbacks == null) { + return; + } + // use all the callback to inform all the components that are waiting of the failure + for (final EditorModuleReadyCallback callback : callbacks) { + callback.onEditorModuleError(); + } + this.callbacks = null; + } + + @Override + public void waitReady(final EditorModuleReadyCallback callback) { + if (ready) { + Log.warn(this.getClass(), "Attempt to add a callback for 'editor ready' - ignored."); + return; + } + if (!initializing ) { + if (this.initializer == null) { + throw new RuntimeException("Editor initializer not set"); + } + this.initializing = true; + this.initializer.initialize(new InitializerCallback() { + @Override + public void onSuccess() { + setReady(); + } + @Override + public void onFailure(final Throwable e) { + setError(); + } + }); + } + this.callbacks.add(callback); + } + + /** + * Sets the initializer. + * @param initializer the initializer + */ + public void setEditorInitializer(final EditorInitializer initializer) { + this.initializer = initializer; + } + + /** Process to initialize the editor module. */ + public interface EditorInitializer { + /** initializes the editor module. */ + void initialize(InitializerCallback callback); + } + + public interface InitializerCallback { + void onSuccess(); + void onFailure(Throwable e); + } +} diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorHandle.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorHandle.java index b4025c2ff88a..749d60d51e78 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorHandle.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorHandle.java @@ -13,7 +13,6 @@ /** * Handle on an editor view instance. */ -@Deprecated public interface EditorHandle { } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorInitCallback.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorInitCallback.java index 9095e59286cf..d80fe585ebcd 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorInitCallback.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorInitCallback.java @@ -19,7 +19,6 @@ * Composite callback that waits for both the editor module initialization and the document content. * @param the type of the editor widget */ -@Deprecated abstract class EditorInitCallback implements DocumentCallback, EditorModule.EditorModuleReadyCallback { /** Loader used to wait for editor impl initialization. */ diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorModule.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorModule.java index b51f7c25a445..89136fa25eae 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorModule.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/EditorModule.java @@ -12,9 +12,9 @@ /** * Front for an editor module, that allows to be warned when it's initialized. + * @param the type of the editor widget. */ -@Deprecated -public interface EditorModule { +public interface EditorModule { /** * Tells if the editor module is initialized. @@ -35,7 +35,6 @@ public interface EditorModule { void waitReady(EditorModuleReadyCallback callback); /** Callback to call when the module is ready of failed. */ - @Deprecated interface EditorModuleReadyCallback { /** Used when the initialization is done. */ void onEditorModuleReady(); diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditor.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditor.java index 21413eeabe91..bd0b08d2ea2f 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditor.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditor.java @@ -47,11 +47,6 @@ public interface TextEditor extends EditorPartPresenter { */ TextEditorPartView getView(); - /** - * @return the text editor widget - */ - EditorWidget getEditorWidget(); - /** * Add an editor-specific key binding. * diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorCursorModel.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorCursorModel.java index b25472f20643..9fe8065af806 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorCursorModel.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorCursorModel.java @@ -25,7 +25,6 @@ * * @author "Mickaƫl Leduque" */ -@Deprecated class TextEditorCursorModel implements CursorModelWithHandler, CursorActivityHandler { private final Document document; diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorInit.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorInit.java index 29963d252a0e..17b361cabc3b 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorInit.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorInit.java @@ -55,7 +55,6 @@ * Initialization controller for the text editor. * Sets-up (when available) the different components that depend on the document being ready. */ -@Deprecated public class TextEditorInit { /** The logger. */ @@ -106,13 +105,6 @@ public void initialize(final DocumentHandle documentHandle, final TextEditorInit new DocReadyWrapper>(generalEventBus, this.textEditor.getEditorHandle(), init, this); } - public void uninstall() { - Reconciler reconciler = configuration.getReconciler(); - if (reconciler != null) { - reconciler.uninstall(); - } - } - /** * Configures the editor's DocumentPartitioner. * @param documentHandle the handle to the document @@ -157,6 +149,36 @@ private void configureAnnotationModel(final DocumentHandle documentHandle) { // the model listens to QueryAnnotation events documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel); +// // gutter renderer +// if (textEditor instanceof HasGutter && ((HasGutter)this.textEditor).getGutter() != null) { +//// final GutterAnnotationRenderer annotationRenderer = new GutterAnnotationRenderer(); +//// annotationRenderer.setDocument(documentHandle.getDocument()); +//// annotationRenderer.setHasGutter(((HasGutter)this.textEditor).getGutter()); +//// documentHandle.getDocEventBus().addHandler(AnnotationModelEvent.TYPE, annotationRenderer); +//// documentHandle.getDocEventBus().addHandler(ClearAnnotationModelEvent.TYPE, annotationRenderer); +// } +// +// // inline renderer +// final InlineAnnotationRenderer inlineAnnotationRenderer = new InlineAnnotationRenderer(); +// inlineAnnotationRenderer.setDocument(documentHandle.getDocument()); +// inlineAnnotationRenderer.setHasTextMarkers(this.textEditor.getHasTextMarkers()); +// documentHandle.getDocEventBus().addHandler(AnnotationModelEvent.TYPE, inlineAnnotationRenderer); +// documentHandle.getDocEventBus().addHandler(ClearAnnotationModelEvent.TYPE, inlineAnnotationRenderer); +// +// // minimap renderer +// if (this.textEditor instanceof HasMinimap && ((HasMinimap)this.textEditor).getMinimap() != null) { +// final MinimapAnnotationRenderer minimapAnnotationRenderer = new MinimapAnnotationRenderer(); +// minimapAnnotationRenderer.setDocument(documentHandle.getDocument()); +// minimapAnnotationRenderer.setMinimap(((HasMinimap)this.textEditor).getMinimap()); +// documentHandle.getDocEventBus().addHandler(AnnotationModelEvent.TYPE, minimapAnnotationRenderer); +// documentHandle.getDocEventBus().addHandler(ClearAnnotationModelEvent.TYPE, minimapAnnotationRenderer); +// } +// +// annotationModel.setDocumentHandle(documentHandle); +// documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, annotationModel); +// +// // the model listens to QueryAnnotation events +// documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel); } /** diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenter.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenter.java index 9d315f16b944..03294117da7b 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenter.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenter.java @@ -11,7 +11,6 @@ package org.eclipse.che.ide.api.editor.texteditor; import com.google.common.base.Optional; -import com.google.gwt.core.client.Callback; import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; @@ -28,8 +27,6 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.debug.BreakpointManager; import org.eclipse.che.ide.api.debug.BreakpointRenderer; @@ -107,10 +104,7 @@ /** * Presenter part for the editor implementations. - * - * @deprecated use {@link TextEditor} instead */ -@Deprecated public class TextEditorPresenter extends AbstractEditorPresenter implements TextEditor, FileEventHandler, UndoableEditor, @@ -133,7 +127,7 @@ public class TextEditorPresenter extends AbstractEditorP private final DocumentStorage documentStorage; private final EditorLocalizationConstants constant; private final EditorWidgetFactory editorWidgetFactory; - private final EditorModule editorModule; + private final EditorModule editorModule; private final TextEditorPartView editorView; private final EventBus generalEventBus; private final FileTypeIdentifier fileTypeIdentifier; @@ -161,7 +155,6 @@ public class TextEditorPresenter extends AbstractEditorP private List fileTypes; private TextPosition cursorPosition; private HandlerRegistration resourceChangeHandler; - private TextEditorInit editorInit; @AssistedInject public TextEditorPresenter(final CodeAssistantFactory codeAssistantFactory, @@ -171,7 +164,7 @@ public TextEditorPresenter(final CodeAssistantFactory codeAssistantFactory, final DocumentStorage documentStorage, final EditorLocalizationConstants constant, @Assisted final EditorWidgetFactory editorWidgetFactory, - final EditorModule editorModule, + final EditorModule editorModule, final TextEditorPartView editorView, final EventBus eventBus, final FileTypeIdentifier fileTypeIdentifier, @@ -211,20 +204,11 @@ protected void initializeEditor(final OpenEditorCallback callback) { quickAssistant = quickAssistantFactory.createQuickAssistant(this); quickAssistant.setQuickAssistProcessor(processor); } - - - Promise documentPromice = CallbackPromiseHelper.createFromCallback(new CallbackPromiseHelper.Call() { - @Override - public void makeCall(Callback callback) { - - } - }); - editorInit = new TextEditorInit<>(configuration, - generalEventBus, - this.codeAssistantFactory, - this.quickAssistant, - this); - editorInit.init(); + new TextEditorInit(configuration, + generalEventBus, + this.codeAssistantFactory, + this.quickAssistant, + this).init(); if (editorModule.isError()) { displayErrorPanel(constant.editorInitErrorMessage()); @@ -452,7 +436,11 @@ public void restoreState() { @Override public void close(final boolean save) { this.documentStorage.documentClosed(this.document); - editorInit.uninstall(); + final Reconciler reconciler = configuration.getReconciler(); + if (reconciler != null) { + reconciler.uninstall(); + } + workspaceAgent.removePart(this); } @@ -856,8 +844,7 @@ public void setReadOnly(final boolean readOnly) { this.editorWidget.setReadOnly(readOnly); } - @Override - public EditorWidget getEditorWidget() { + protected EditorWidget getEditorWidget() { return this.editorWidget; } diff --git a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterFactory.java b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterFactory.java index 3fd679eefb63..5c42560b0165 100644 --- a/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterFactory.java +++ b/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterFactory.java @@ -16,7 +16,6 @@ * @param * the type of the editor */ -@Deprecated public interface TextEditorPresenterFactory { /** diff --git a/ide/che-core-ide-api/src/test/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterTest.java b/ide/che-core-ide-api/src/test/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterTest.java index 5b534e060f8d..5e941942e378 100644 --- a/ide/che-core-ide-api/src/test/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterTest.java +++ b/ide/che-core-ide-api/src/test/java/org/eclipse/che/ide/api/editor/texteditor/TextEditorPresenterTest.java @@ -62,7 +62,7 @@ public class TextEditorPresenterTest { @Mock private EditorWidgetFactory editorWidgetFactory; @Mock - private EditorModule editorModule; + private EditorModule editorModule; @Mock private TextEditorPartView editorView; @Mock diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/debug/BreakpointManagerImpl.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/debug/BreakpointManagerImpl.java index 71e4c0fcd39e..6fee37601c08 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/debug/BreakpointManagerImpl.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/debug/BreakpointManagerImpl.java @@ -38,7 +38,7 @@ import org.eclipse.che.ide.api.editor.EditorOpenedEventHandler; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.event.project.DeleteProjectEvent; import org.eclipse.che.ide.api.event.project.DeleteProjectHandler; import org.eclipse.che.ide.api.resources.File; @@ -235,8 +235,8 @@ public void onLineChange(VirtualFile file, int firstLine, int linesAdded, int li */ private boolean isLineNotEmpty(final VirtualFile activeFile, int lineNumber) { EditorPartPresenter editor = getEditorForFile(activeFile.getPath()); - if (editor instanceof TextEditor) { - Document document = ((TextEditor)editor).getDocument(); + if (editor instanceof TextEditorPresenter) { + Document document = ((TextEditorPresenter)editor).getDocument(); return !document.getLineContent(lineNumber).trim().isEmpty(); } diff --git a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/editor/EditorPartStackView.java b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/editor/EditorPartStackView.java index ae15bd2f001f..9a197f7cb717 100644 --- a/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/editor/EditorPartStackView.java +++ b/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/editor/EditorPartStackView.java @@ -25,7 +25,7 @@ import com.google.gwt.user.client.ui.Widget; import com.google.inject.Inject; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.parts.PartPresenter; import org.eclipse.che.ide.api.parts.PartStackUIResources; import org.eclipse.che.ide.api.parts.PartStackView; @@ -224,8 +224,8 @@ public void selectTab(@NotNull PartPresenter partPresenter) { contentPanel.showWidget(viewIndex); setActiveTab(partPresenter); - if (partPresenter instanceof TextEditor) { - ((TextEditor)partPresenter).activate(); + if (partPresenter instanceof TextEditorPresenter) { + ((TextEditorPresenter)partPresenter).activate(); } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml b/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml index 1d059f3d48e4..76bc0d496496 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/pom.xml @@ -94,10 +94,6 @@ org.eclipse.che.plugin che-plugin-orion-compare - - org.eclipse.che.plugin - che-plugin-orion-editor - org.vectomatic lib-gwt-svg diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ParametersHintsAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ParametersHintsAction.java index ac1cdda0bfab..1fd3efea5d45 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ParametersHintsAction.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ParametersHintsAction.java @@ -16,10 +16,10 @@ import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant; import org.eclipse.che.ide.ext.java.client.navigation.paraminfo.ParametersHintsPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * @author Dmitry Shnurenko @@ -42,10 +42,10 @@ public ParametersHintsAction(EditorAgent editorAgent, @Override public void actionPerformed(ActionEvent event) { EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); - if (!(activeEditor instanceof TextEditor)) { + if (!(activeEditor instanceof TextEditorPresenter)) { return; } - parametersHintsPresenter.show((TextEditor)activeEditor); + parametersHintsPresenter.show((TextEditorPresenter)activeEditor); } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickDocumentationAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickDocumentationAction.java index 02dc97a28c6d..528acbf15137 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickDocumentationAction.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickDocumentationAction.java @@ -16,12 +16,12 @@ import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant; import org.eclipse.che.ide.ext.java.client.JavaResources; import org.eclipse.che.ide.ext.java.client.documentation.QuickDocumentation; import org.eclipse.che.ide.api.editor.codeassist.HasCompletionInformation; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * @author Evgen Vidolob @@ -51,8 +51,8 @@ public void actionPerformed(ActionEvent e) { if(activeEditor == null){ return; } - if(activeEditor instanceof TextEditor && activeEditor instanceof HasCompletionInformation) { - if (((TextEditor)activeEditor).getEditorWidget().isCompletionProposalsShowing() ) { + if(activeEditor instanceof TextEditorPresenter && activeEditor instanceof HasCompletionInformation) { + if (((TextEditorPresenter)activeEditor).isCompletionProposalsShowing() ) { ((HasCompletionInformation)activeEditor).showCompletionInformation(); return; } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickFixAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickFixAction.java index f14432c08dd0..22d9eadd60e9 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickFixAction.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/QuickFixAction.java @@ -16,10 +16,9 @@ import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations; -import org.eclipse.che.ide.api.editor.texteditor.TextEditorOperations; import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * Action to show Quick fix in editor. @@ -43,15 +42,11 @@ public QuickFixAction(JavaLocalizationConstant locale, @Override public void actionPerformed(ActionEvent e) { EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); - if (activeEditor == null) { + if(activeEditor == null){ return; } - if (activeEditor instanceof HandlesTextOperations) { - - HandlesTextOperations textEditor = (HandlesTextOperations)activeEditor; - if (textEditor.canDoOperation(TextEditorOperations.QUICK_ASSIST)) { - textEditor.doOperation(TextEditorOperations.QUICK_ASSIST); - } + if(activeEditor instanceof TextEditorPresenter) { + ((TextEditorPresenter)activeEditor).showQuickAssist(); } } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/documentation/QuickDocPresenter.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/documentation/QuickDocPresenter.java index 40c45be98be4..fb28b993a963 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/documentation/QuickDocPresenter.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/documentation/QuickDocPresenter.java @@ -17,9 +17,10 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.position.PositionConverter; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.machine.WsAgentURLModifier; +import org.eclipse.che.ide.ext.java.client.projecttree.JavaSourceFolderUtil; +import org.eclipse.che.ide.api.editor.position.PositionConverter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; @@ -56,12 +57,12 @@ public void showDocumentation() { return; } - if (!(activeEditor instanceof TextEditor)) { - Log.error(getClass(), "Quick Document support only TextEditor as editor"); + if (!(activeEditor instanceof TextEditorPresenter)) { + Log.error(getClass(), "Quick Document support only TextEditorPresenter as editor"); return; } - TextEditor editor = ((TextEditor)activeEditor); + TextEditorPresenter editor = ((TextEditorPresenter)activeEditor); int offset = editor.getCursorOffset(); final PositionConverter.PixelCoordinates coordinates = editor.getPositionConverter().offsetToPixel(offset); diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/FileWatcher.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/FileWatcher.java index 089573e34bd3..9eb02d073b66 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/FileWatcher.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/FileWatcher.java @@ -17,11 +17,11 @@ import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.event.ActivePartChangedEvent; import org.eclipse.che.ide.api.event.ActivePartChangedHandler; import org.eclipse.che.ide.api.parts.PartPresenter; import org.eclipse.che.ide.api.parts.PropertyListener; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.api.resources.ResourceChangedEvent; import org.eclipse.che.ide.ext.java.client.resource.SourceFolderMarker; @@ -41,7 +41,7 @@ public class FileWatcher { @Inject private EditorAgent editorAgent; - private Set editor2reconcile = new HashSet<>(); + private Set editor2reconcile = new HashSet<>(); @Inject private void handleFileOperations(EventBus eventBus) { @@ -69,16 +69,16 @@ public void onResourceChanged(ResourceChangedEvent event) { eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() { @Override public void onActivePartChanged(ActivePartChangedEvent event) { - if (event.getActivePart() instanceof TextEditor) { + if (event.getActivePart() instanceof TextEditorPresenter) { if (editor2reconcile.contains(event.getActivePart())) { - reParseEditor((TextEditor)event.getActivePart()); + reParseEditor((TextEditorPresenter)event.getActivePart()); } } } }); } - private void reParseEditor(TextEditor editor) { + private void reParseEditor(TextEditorPresenter editor) { editor.refreshEditor(); editor2reconcile.remove(editor); } @@ -91,7 +91,7 @@ public void propertyChanged(PartPresenter source, int propId) { if (!editor.isDirty()) { reparseAllOpenedFiles(); //remove just saved editor - editor2reconcile.remove(editor); + editor2reconcile.remove((TextEditorPresenter)editor); } } } @@ -101,8 +101,8 @@ public void propertyChanged(PartPresenter source, int propId) { private void reparseAllOpenedFiles() { for (EditorPartPresenter editorPartPresenter: editorAgent.getOpenedEditors()) { - if (editorPartPresenter instanceof TextEditor) { - final TextEditor editor = (TextEditor)editorPartPresenter; + if (editorPartPresenter instanceof TextEditorPresenter) { + final TextEditorPresenter< ? > editor = (TextEditorPresenter< ? >)editorPartPresenter; editor.refreshEditor(); } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaQuickAssistProcessor.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaQuickAssistProcessor.java index 96a52478e4b1..62bc64adcb47 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaQuickAssistProcessor.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaQuickAssistProcessor.java @@ -13,17 +13,8 @@ import com.google.common.base.Optional; import org.eclipse.che.ide.api.editor.EditorAgent; -import org.eclipse.che.ide.api.editor.annotation.QueryAnnotationsEvent; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback; -import org.eclipse.che.ide.api.editor.codeassist.CompletionProposal; -import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.link.HasLinkedMode; -import org.eclipse.che.ide.api.editor.quickfix.QuickAssistInvocationContext; -import org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor; -import org.eclipse.che.ide.api.editor.text.LinearRange; import org.eclipse.che.ide.api.editor.text.Position; import org.eclipse.che.ide.api.editor.text.annotation.Annotation; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.api.resources.VirtualFile; @@ -34,6 +25,16 @@ import org.eclipse.che.ide.ext.java.shared.dto.Problem; import org.eclipse.che.ide.ext.java.shared.dto.ProposalPresentation; import org.eclipse.che.ide.ext.java.shared.dto.Proposals; +import org.eclipse.che.ide.api.editor.annotation.QueryAnnotationsEvent; +import org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback; +import org.eclipse.che.ide.api.editor.codeassist.CompletionProposal; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.link.HasLinkedMode; +import org.eclipse.che.ide.api.editor.quickfix.QuickAssistInvocationContext; +import org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.rest.AsyncRequestCallback; import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; import org.eclipse.che.ide.rest.Unmarshallable; @@ -110,7 +111,7 @@ public void respond(final Map annotations) { /*final Map problems =*/ int offset = collectQuickFixableAnnotations(range, document, annotations, goToClosest, problems); if (offset != range.getStartOffset()) { - TextEditor presenter = ((TextEditor)textEditor); + TextEditorPresenter presenter = ((TextEditorPresenter)textEditor); presenter.getCursorModel().setCursorPosition(offset); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategy.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategy.java index effd020eff6e..4ae75f632d49 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategy.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategy.java @@ -20,7 +20,7 @@ import org.eclipse.che.ide.api.editor.reconciler.DirtyRegion; import org.eclipse.che.ide.api.editor.reconciler.ReconcilingStrategy; import org.eclipse.che.ide.api.editor.text.Region; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.api.resources.VirtualFile; @@ -43,19 +43,17 @@ public class JavaReconcilerStrategy implements ReconcilingStrategy, ResolvingProjectStateListener { - private final TextEditor editor; + private final TextEditorPresenter editor; private final JavaCodeAssistProcessor codeAssistProcessor; private final AnnotationModel annotationModel; private final SemanticHighlightRenderer highlighter; private final ResolvingProjectStateHolderRegistry resolvingProjectStateHolderRegistry; private final JavaLocalizationConstant localizationConstant; private final JavaReconcileClient client; - - private EditorWithErrors editorWithErrors; - private ResolvingProjectStateHolder resolvingProjectStateHolder; + private ResolvingProjectStateHolder resolvingProjectStateHolder; @AssistedInject - public JavaReconcilerStrategy(@Assisted @NotNull final TextEditor editor, + public JavaReconcilerStrategy(@Assisted @NotNull final TextEditorPresenter editor, @Assisted final JavaCodeAssistProcessor codeAssistProcessor, @Assisted final AnnotationModel annotationModel, final JavaReconcileClient client, @@ -69,14 +67,11 @@ public JavaReconcilerStrategy(@Assisted @NotNull final TextEditor editor, this.highlighter = highlighter; this.resolvingProjectStateHolderRegistry = resolvingProjectStateHolderRegistry; this.localizationConstant = localizationConstant; - if (editor instanceof EditorWithErrors) { - this.editorWithErrors = ((EditorWithErrors)editor); - } } @Override public void setDocument(final Document document) { - highlighter.init(editor.getEditorWidget(), document); + highlighter.init(editor.getHasTextMarkers(), document); if (getFile() instanceof Resource) { final Optional project = ((Resource)getFile()).getRelatedProject(); @@ -157,9 +152,7 @@ private void doReconcile(final List problems) { problemRequester = (ProblemRequester)this.annotationModel; problemRequester.beginReporting(); } else { - if (editorWithErrors != null) { - editorWithErrors.setErrorState(EditorWithErrors.EditorState.NONE); - } + editor.setErrorState(EditorWithErrors.EditorState.NONE); return; } try { @@ -175,14 +168,12 @@ private void doReconcile(final List problems) { } problemRequester.acceptProblem(problem); } - if(editorWithErrors != null) { - if (error) { - editorWithErrors.setErrorState(EditorWithErrors.EditorState.ERROR); - } else if (warning) { - editorWithErrors.setErrorState(EditorWithErrors.EditorState.WARNING); - } else { - editorWithErrors.setErrorState(EditorWithErrors.EditorState.NONE); - } + if (error) { + editor.setErrorState(EditorWithErrors.EditorState.ERROR); + } else if (warning) { + editor.setErrorState(EditorWithErrors.EditorState.WARNING); + } else { + editor.setErrorState(EditorWithErrors.EditorState.NONE); } } catch (final Exception e) { Log.error(getClass(), e); diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategyFactory.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategyFactory.java index 9560ed16a31e..725d012589fd 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategyFactory.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcilerStrategyFactory.java @@ -11,13 +11,13 @@ package org.eclipse.che.ide.ext.java.client.editor; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * Factory of reconciler factories for java documents. */ public interface JavaReconcilerStrategyFactory { - JavaReconcilerStrategy create(TextEditor editor, + JavaReconcilerStrategy create(TextEditorPresenter< ? > editor, JavaCodeAssistProcessor codeAssistProcessor, AnnotationModel annotationModel); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfiguration.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfiguration.java index 5351a9f172f0..23f721842409 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfiguration.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfiguration.java @@ -24,7 +24,7 @@ import org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor; import org.eclipse.che.ide.api.editor.reconciler.Reconciler; import org.eclipse.che.ide.api.editor.reconciler.ReconcilerFactory; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import java.util.HashMap; import java.util.Map; @@ -47,7 +47,7 @@ public class JsJavaEditorConfiguration extends DefaultTextEditorConfiguration { private final ContentFormatter contentFormatter; @AssistedInject - public JsJavaEditorConfiguration(@Assisted final TextEditor editor, + public JsJavaEditorConfiguration(@Assisted final TextEditorPresenter editor, final JavaCodeAssistProcessorFactory codeAssistProcessorFactory, final JavaQuickAssistProcessorFactory quickAssistProcessorFactory, final ReconcilerFactory reconcilerFactory, diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfigurationFactory.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfigurationFactory.java index a4c08c89e341..8c5a8c51e021 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfigurationFactory.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorConfigurationFactory.java @@ -10,8 +10,8 @@ *******************************************************************************/ package org.eclipse.che.ide.ext.java.client.editor; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; public interface JsJavaEditorConfigurationFactory { - JsJavaEditorConfiguration create(TextEditor editor); + JsJavaEditorConfiguration create(TextEditorPresenter< ? > editor); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorProvider.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorProvider.java index 9fa2c5079e7b..165eee5388f9 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorProvider.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JsJavaEditorProvider.java @@ -16,7 +16,7 @@ import org.eclipse.che.ide.api.editor.reconciler.Reconciler; import org.eclipse.che.ide.api.editor.reconciler.ReconcilingStrategy; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import javax.inject.Inject; import java.util.logging.Logger; @@ -53,8 +53,8 @@ public TextEditor getEditor() { final TextEditor textEditor = super.getEditor(); - if (textEditor instanceof OrionEditorPresenter) { - final OrionEditorPresenter editor = (OrionEditorPresenter)textEditor; + if (textEditor instanceof TextEditorPresenter) { + final TextEditorPresenter editor = (TextEditorPresenter)textEditor; final TextEditorConfiguration configuration = configurationFactory.create(editor); editor.initialize(configuration); editor.addEditorUpdateAction(new EditorUpdateAction() { diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/OpenDeclarationFinder.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/OpenDeclarationFinder.java index b82f7685a2d6..6e0f0515d108 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/OpenDeclarationFinder.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/OpenDeclarationFinder.java @@ -22,8 +22,6 @@ import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.File; import org.eclipse.che.ide.api.resources.Project; @@ -36,6 +34,8 @@ import org.eclipse.che.ide.ext.java.client.util.JavaUtil; import org.eclipse.che.ide.ext.java.shared.JarEntry; import org.eclipse.che.ide.ext.java.shared.OpenDeclarationDescriptor; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.ext.java.shared.dto.ClassContent; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.loging.Log; @@ -69,11 +69,11 @@ public void openDeclaration() { return; } - if (!(activeEditor instanceof TextEditor)) { - Log.error(getClass(), "Open Declaration support only TextEditor as editor"); + if (!(activeEditor instanceof TextEditorPresenter)) { + Log.error(getClass(), "Open Declaration support only TextEditorPresenter as editor"); return; } - TextEditor editor = ((TextEditor)activeEditor); + TextEditorPresenter editor = ((TextEditorPresenter)activeEditor); int offset = editor.getCursorOffset(); final VirtualFile file = editor.getEditorInput().getFile(); @@ -122,8 +122,8 @@ private void setCursorAndActivateEditor(final EditorPartPresenter editor, final new DelayedTask(){ @Override public void onExecute() { - if (editor instanceof TextEditor) { - ((TextEditor)editor).getDocument().setSelectedRange(LinearRange.createWithStart(offset).andLength(0), true); + if (editor instanceof TextEditorPresenter) { + ((TextEditorPresenter)editor).getDocument().setSelectedRange(LinearRange.createWithStart(offset).andLength(0), true); editor.activate(); //force set focus to the editor } } @@ -165,8 +165,8 @@ public void onEditorOpened(final EditorPartPresenter editor) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { - if (editor instanceof TextEditor) { - ((TextEditor)editor).getDocument().setSelectedRange( + if (editor instanceof TextEditorPresenter) { + ((TextEditorPresenter)editor).getDocument().setSelectedRange( LinearRange.createWithStart(descriptor.getOffset()) .andLength(0), true); editor.activate(); @@ -190,8 +190,8 @@ public void onEditorOpened(final EditorPartPresenter editor) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { - if (editor instanceof TextEditor) { - ((TextEditor)editor).getDocument().setSelectedRange( + if (editor instanceof TextEditorPresenter) { + ((TextEditorPresenter)editor).getDocument().setSelectedRange( LinearRange.createWithStart(descriptor.getOffset()).andLength(0), true); editor.activate(); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/filestructure/FileStructurePresenter.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/filestructure/FileStructurePresenter.java index 579cad3e9dc5..69d3cb61a86f 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/filestructure/FileStructurePresenter.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/filestructure/FileStructurePresenter.java @@ -22,8 +22,6 @@ import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.File; import org.eclipse.che.ide.api.resources.Project; @@ -38,6 +36,8 @@ import org.eclipse.che.ide.ext.java.shared.dto.Region; import org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit; import org.eclipse.che.ide.ext.java.shared.dto.model.Member; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.ui.loaders.request.LoaderFactory; import org.eclipse.che.ide.ui.loaders.request.MessageLoader; @@ -57,9 +57,9 @@ public class FileStructurePresenter implements FileStructure.ActionDelegate { private final EditorAgent editorAgent; private final MessageLoader loader; - private TextEditor activeEditor; - private boolean showInheritedMembers; - private int cursorOffset; + private TextEditorPresenter activeEditor; + private boolean showInheritedMembers; + private int cursorOffset; @Inject public FileStructurePresenter(FileStructure view, @@ -85,11 +85,11 @@ public void show(EditorPartPresenter editorPartPresenter) { loader.show(); view.setTitle(editorPartPresenter.getEditorInput().getFile().getName()); - if (!(editorPartPresenter instanceof TextEditor)) { - Log.error(getClass(), "Open Declaration support only TextEditor as editor"); + if (!(editorPartPresenter instanceof TextEditorPresenter)) { + Log.error(getClass(), "Open Declaration support only TextEditorPresenter as editor"); return; } - activeEditor = ((TextEditor)editorPartPresenter); + activeEditor = ((TextEditorPresenter)editorPartPresenter); cursorOffset = activeEditor.getCursorOffset(); VirtualFile file = activeEditor.getEditorInput().getFile(); @@ -196,8 +196,8 @@ private void setCursorPosition(Region region) { } private void setCursor(EditorPartPresenter editor, int offset) { - if (editor instanceof TextEditor) { - ((TextEditor)editor).getDocument().setSelectedRange(LinearRange.createWithStart(offset).andLength(0), true); + if (editor instanceof TextEditorPresenter) { + ((TextEditorPresenter)editor).getDocument().setSelectedRange(LinearRange.createWithStart(offset).andLength(0), true); } } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/openimplementation/OpenImplementationPresenter.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/openimplementation/OpenImplementationPresenter.java index b984513ac838..1b7c985f7a24 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/openimplementation/OpenImplementationPresenter.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/openimplementation/OpenImplementationPresenter.java @@ -21,9 +21,6 @@ import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl; -import org.eclipse.che.ide.api.editor.position.PositionConverter; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.File; import org.eclipse.che.ide.api.resources.Project; @@ -44,6 +41,9 @@ import org.eclipse.che.ide.ext.java.shared.dto.model.Type; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.ui.popup.PopupResources; +import org.eclipse.che.ide.api.editor.position.PositionConverter; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.util.loging.Log; import static com.google.common.base.Strings.isNullOrEmpty; @@ -63,7 +63,7 @@ public class OpenImplementationPresenter { private final PopupResources popupResources; private final JavaLocalizationConstant locale; - private TextEditor activeEditor; + private TextEditorPresenter activeEditor; @Inject public OpenImplementationPresenter(JavaNavigationService javaNavigationService, @@ -89,11 +89,11 @@ public OpenImplementationPresenter(JavaNavigationService javaNavigationService, * the active editor */ public void show(final EditorPartPresenter editorPartPresenter) { - if (!(editorPartPresenter instanceof TextEditor)) { - Log.error(getClass(), "Open Declaration support only TextEditor as editor"); + if (!(editorPartPresenter instanceof TextEditorPresenter)) { + Log.error(getClass(), "Open Declaration support only TextEditorPresenter as editor"); return; } - activeEditor = ((TextEditor)editorPartPresenter); + activeEditor = ((TextEditorPresenter)editorPartPresenter); final VirtualFile file = activeEditor.getEditorInput().getFile(); if (file instanceof Resource) { @@ -124,9 +124,9 @@ public void apply(ImplementationsDescriptorDTO impls) throws OperationException } else if (overridingSize > 1) { openOneImplementation(impls, noImplementationWidget, - (TextEditor)editorPartPresenter); + (TextEditorPresenter)editorPartPresenter); } else if (!isNullOrEmpty(impls.getMemberName()) && overridingSize == 0) { - showNoImplementations(noImplementationWidget, (TextEditor)editorPartPresenter); + showNoImplementations(noImplementationWidget, (TextEditorPresenter)editorPartPresenter); } } }); @@ -188,7 +188,7 @@ public void execute() { }); } - private void showNoImplementations(NoImplementationWidget noImplementationWidget, TextEditor editorPartPresenter) { + private void showNoImplementations(NoImplementationWidget noImplementationWidget, TextEditorPresenter editorPartPresenter) { int offset = editorPartPresenter.getCursorOffset(); PositionConverter.PixelCoordinates coordinates = editorPartPresenter.getPositionConverter().offsetToPixel(offset); Type type = dtoFactory.createDto(Type.class); @@ -199,7 +199,7 @@ private void showNoImplementations(NoImplementationWidget noImplementationWidget private void openOneImplementation(ImplementationsDescriptorDTO implementationsDescriptor, NoImplementationWidget implementationWidget, - TextEditor editorPartPresenter) { + TextEditorPresenter editorPartPresenter) { int offset = editorPartPresenter.getCursorOffset(); PositionConverter.PixelCoordinates coordinates = editorPartPresenter.getPositionConverter().offsetToPixel(offset); for (Type type : implementationsDescriptor.getImplementations()) { @@ -210,13 +210,13 @@ private void openOneImplementation(ImplementationsDescriptorDTO implementationsD } private void setCursor(final Region region) { - if (!(editorAgent.getActiveEditor() instanceof TextEditor)) { + if (!(editorAgent.getActiveEditor() instanceof TextEditorPresenter)) { return; } Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { - TextEditor editor = (TextEditor)editorAgent.getActiveEditor(); + TextEditorPresenter editor = (TextEditorPresenter)editorAgent.getActiveEditor(); editor.setFocus(); editor.getDocument().setSelectedRange(LinearRange.createWithStart(region.getOffset()).andLength(0), true); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/paraminfo/ParametersHintsPresenter.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/paraminfo/ParametersHintsPresenter.java index e4212e2d7e0f..bbec75056f27 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/paraminfo/ParametersHintsPresenter.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/paraminfo/ParametersHintsPresenter.java @@ -17,7 +17,6 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.PromiseError; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.api.resources.VirtualFile; @@ -26,6 +25,7 @@ import org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.position.PositionConverter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.util.loging.Log; import java.util.List; @@ -54,7 +54,7 @@ public ParametersHintsPresenter(JavaNavigationService navigationService, Paramet * @param activeEditor * active editor which contains method or constructor for which parameters will be displayed */ - public void show(final TextEditor activeEditor) { + public void show(final TextEditorPresenter activeEditor) { final int offset = activeEditor.getCursorOffset(); if (!isCursorInRightPlace(activeEditor, offset)) { @@ -92,7 +92,7 @@ public void apply(PromiseError error) throws OperationException { } - private boolean isCursorInRightPlace(TextEditor activeEditor, int offset) { + private boolean isCursorInRightPlace(TextEditorPresenter activeEditor, int offset) { Document document = activeEditor.getDocument(); int lineIndex = document.getLineAtOffset(offset); @@ -104,7 +104,7 @@ private boolean isCursorInRightPlace(TextEditor activeEditor, int offset) { return contentRange.contains(")"); } - private int getLineStartOffset(TextEditor activeEditor, int offset) { + private int getLineStartOffset(TextEditorPresenter activeEditor, int offset) { Document document = activeEditor.getDocument(); int lineIndex = document.getLineAtOffset(offset); return document.getLineStart(lineIndex); diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/rename/JavaRefactoringRename.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/rename/JavaRefactoringRename.java index e29020a29712..ab8c6f518123 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/rename/JavaRefactoringRename.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/rename/JavaRefactoringRename.java @@ -31,7 +31,7 @@ import org.eclipse.che.ide.api.editor.link.LinkedModelGroup; import org.eclipse.che.ide.api.editor.text.Position; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.api.editor.texteditor.UndoableEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.api.event.FileEvent; import org.eclipse.che.ide.api.event.FileEventHandler; import org.eclipse.che.ide.api.notification.NotificationManager; @@ -302,8 +302,8 @@ private void enableAutoSave() { } private void undoChanges() { - if (linkedEditor instanceof UndoableEditor) { - ((UndoableEditor)linkedEditor).getUndoRedo().undo(); + if (linkedEditor instanceof TextEditorPresenter) { + ((TextEditorPresenter)linkedEditor).getUndoRedo().undo(); } } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/node/MatchNode.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/node/MatchNode.java index 11ae4cc39092..874c600317e9 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/node/MatchNode.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/node/MatchNode.java @@ -27,8 +27,6 @@ import org.eclipse.che.ide.api.editor.EditorAgent; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; import org.eclipse.che.ide.api.resources.File; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; @@ -41,6 +39,8 @@ import org.eclipse.che.ide.ext.java.shared.dto.model.ClassFile; import org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit; import org.eclipse.che.ide.ext.java.shared.dto.search.Match; +import org.eclipse.che.ide.api.editor.text.LinearRange; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.ui.smartTree.TreeStyles; import org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation; @@ -184,8 +184,8 @@ public void onEditorOpened(EditorPartPresenter editor) { } private void fileOpened(EditorPartPresenter editor) { - if (editor instanceof TextEditor) { - ((TextEditor)editor).getDocument().setSelectedRange( + if (editor instanceof TextEditorPresenter) { + ((TextEditorPresenter)editor).getDocument().setSelectedRange( LinearRange.createWithStart(match.getFileMatchRegion().getOffset()).andLength(match.getFileMatchRegion().getLength()), true); } diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanel.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanel.java index c9b298d670be..673cc6b0ab44 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanel.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/main/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanel.java @@ -12,24 +12,26 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.gwt.user.client.ui.IsWidget; -import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; import org.eclipse.che.ide.api.editor.EditorPartPresenter; import org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl; -import org.eclipse.che.ide.api.editor.editorconfig.DefaultTextEditorConfiguration; -import org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.api.editor.texteditor.UndoableEditor; import org.eclipse.che.ide.api.filetypes.FileType; import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; import org.eclipse.che.ide.api.parts.PartPresenter; import org.eclipse.che.ide.api.parts.PropertyListener; +import org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo; +import org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty; +import org.eclipse.che.ide.api.editor.texteditor.UndoableEditor; import org.eclipse.che.ide.api.resources.VirtualFile; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; +import org.eclipse.che.ide.editor.orion.client.OrionEditorWidget; +import org.eclipse.che.ide.editor.orion.client.OrionTextEditorFactory; import org.eclipse.che.ide.extension.machine.client.perspective.widgets.tab.content.TabPresenter; +import org.eclipse.che.ide.api.editor.editorconfig.DefaultTextEditorConfiguration; +import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import javax.validation.constraints.NotNull; import java.util.List; @@ -43,11 +45,11 @@ * @author Valeriy Svydenko */ public class RecipeEditorPanel implements TabPresenter, RecipeEditorView.ActionDelegate { - private final RecipeEditorView view; - private final RecipeFileFactory recipeFileFactory; - private final FileTypeRegistry fileTypeRegistry; - private final RecipeDescriptor recipeDescriptor; - private final Provider orionTextEditorFactory; + private final RecipeEditorView view; + private final RecipeFileFactory recipeFileFactory; + private final FileTypeRegistry fileTypeRegistry; + private final RecipeDescriptor recipeDescriptor; + private final OrionTextEditorFactory orionTextEditorFactory; private EditorPartPresenter editor; private ActionDelegate delegate; @@ -58,7 +60,7 @@ public class RecipeEditorPanel implements TabPresenter, RecipeEditorView.ActionD @AssistedInject public RecipeEditorPanel(RecipeFileFactory recipeFileFactory, FileTypeRegistry fileTypeRegistry, - Provider orionTextEditorFactory, + OrionTextEditorFactory orionTextEditorFactory, RecipeEditorView view, @Assisted @NotNull RecipeDescriptor recipeDescriptor) { this.view = view; @@ -165,7 +167,7 @@ public void propertyChanged(PartPresenter source, int propId) { } private TextEditor getEditor() { - OrionEditorPresenter editor = orionTextEditorFactory.get(); + TextEditorPresenter editor = orionTextEditorFactory.createTextEditor(); editor.initialize(new DefaultTextEditorConfiguration()); return editor; diff --git a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanelTest.java b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanelTest.java index da92d2f91081..e26754631a28 100644 --- a/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanelTest.java +++ b/plugins/plugin-machine/che-plugin-machine-ext-client/src/test/java/org/eclipse/che/ide/extension/machine/client/perspective/widgets/recipe/editor/RecipeEditorPanelTest.java @@ -11,14 +11,15 @@ package org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor; import com.google.gwtmockito.GwtMockitoTestRunner; -import com.google.inject.Provider; import org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor; -import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.filetypes.FileType; import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; import org.eclipse.che.ide.api.resources.VirtualFile; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; +import org.eclipse.che.ide.editor.orion.client.OrionEditorWidget; +import org.eclipse.che.ide.editor.orion.client.OrionTextEditorFactory; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -43,22 +44,22 @@ public class RecipeEditorPanelTest { //constructor mocks @Mock - private RecipeEditorView view; + private RecipeEditorView view; @Mock - private RecipeFileFactory recipeFileFactory; + private RecipeFileFactory recipeFileFactory; @Mock - private FileTypeRegistry fileTypeRegistry; + private FileTypeRegistry fileTypeRegistry; @Mock - private RecipeDescriptor recipeDescriptor; + private RecipeDescriptor recipeDescriptor; @Mock - private Provider orionTextEditorFactory; + private OrionTextEditorFactory orionTextEditorFactory; @Mock private VirtualFile recipeFile; @Mock private RecipeEditorPanel.ActionDelegate delegate; @Mock - private OrionEditorPresenter editor; + private TextEditorPresenter editor; private RecipeEditorPanel presenter; @@ -66,7 +67,7 @@ public class RecipeEditorPanelTest { public void setUp() throws Exception { when(recipeDescriptor.getScript()).thenReturn(SOME_TEXT); when(recipeFileFactory.newInstance(anyString())).thenReturn(recipeFile); - when(orionTextEditorFactory.get()).thenReturn(editor); + when(orionTextEditorFactory.createTextEditor()).thenReturn(editor); presenter = new RecipeEditorPanel(recipeFileFactory, fileTypeRegistry, @@ -129,7 +130,7 @@ public void editorShouldBeInitializedAndShowed() throws Exception { verify(recipeDescriptor).getScript(); verify(recipeFileFactory).newInstance(SOME_TEXT); - verify(orionTextEditorFactory).get(); + verify(orionTextEditorFactory).createTextEditor(); verify(editor).activate(); verify(editor).onOpen(); verify(view).showEditor(editor); @@ -146,7 +147,7 @@ public void editorShouldBeShowed() throws Exception { verify(recipeDescriptor).getScript(); verify(recipeFileFactory).newInstance(SOME_TEXT); - verify(orionTextEditorFactory).get(); + verify(orionTextEditorFactory).createTextEditor(); verify(editor).activate(); verify(editor).onOpen(); verify(view).showEditor(editor); diff --git a/plugins/plugin-maven/che-plugin-maven-ide/pom.xml b/plugins/plugin-maven/che-plugin-maven-ide/pom.xml index 35b3beab30fc..2e74f5bbad9c 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/pom.xml +++ b/plugins/plugin-maven/che-plugin-maven-ide/pom.xml @@ -104,10 +104,6 @@ org.eclipse.che.plugin che-plugin-maven-shared - - org.eclipse.che.plugin - che-plugin-orion-editor - org.vectomatic lib-gwt-svg diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/ClassFileSourcesDownloader.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/ClassFileSourcesDownloader.java index 49142d307031..c49a6b960a00 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/ClassFileSourcesDownloader.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/ClassFileSourcesDownloader.java @@ -27,15 +27,15 @@ import org.eclipse.che.ide.api.editor.EditorOpenedEvent; import org.eclipse.che.ide.api.editor.EditorOpenedEventHandler; import org.eclipse.che.ide.api.editor.EditorPartPresenter; -import org.eclipse.che.ide.api.editor.texteditor.HasNotificationPanel; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView; import org.eclipse.che.ide.api.event.FileContentUpdateEvent; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; +import org.eclipse.che.ide.api.editor.texteditor.HasNotificationPanel; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; +import org.eclipse.che.ide.util.dom.Elements; import org.eclipse.che.ide.api.resources.VirtualFile; import org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode; -import org.eclipse.che.ide.util.dom.Elements; import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant; import org.eclipse.che.plugin.maven.client.MavenResources; import org.eclipse.che.plugin.maven.client.service.MavenServerServiceClient; @@ -78,8 +78,8 @@ public void onEditorOpened(EditorOpenedEvent event) { if (file instanceof JarFileNode) { final JarFileNode jarFileNode = (JarFileNode)file; if (jarFileNode.isContentGenerated()) { - if (editor instanceof TextEditor) { - final TextEditor presenter = (TextEditor)editor; + if (editor instanceof TextEditorPresenter) { + final TextEditorPresenter presenter = (TextEditorPresenter)editor; TextEditorPartView view = presenter.getView(); final DivElement divElement = Elements.createDivElement(); divElement.setClassName(resources.css().editorInfoPanel()); diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfiguration.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfiguration.java index e8196b251f80..0e2bfbacfea8 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfiguration.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfiguration.java @@ -14,12 +14,12 @@ import com.google.inject.Provider; import com.google.inject.assistedinject.Assisted; +import org.eclipse.che.ide.ext.java.client.editor.JavaAnnotationModelFactory; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; import org.eclipse.che.ide.api.editor.editorconfig.AutoSaveTextEditorConfiguration; import org.eclipse.che.ide.api.editor.partition.DocumentPositionMap; import org.eclipse.che.ide.api.editor.reconciler.Reconciler; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; -import org.eclipse.che.ide.ext.java.client.editor.JavaAnnotationModelFactory; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import javax.validation.constraints.NotNull; @@ -36,7 +36,7 @@ public class PomEditorConfiguration extends AutoSaveTextEditorConfiguration { public PomEditorConfiguration(Provider docPositionMapProvider, JavaAnnotationModelFactory javaAnnotationModelFactory, PomReconcilingStrategyFactory reconcilingStrategyFactory, - @Assisted @NotNull final OrionEditorPresenter editor) { + @Assisted @NotNull final TextEditorPresenter editor) { annotationModel = javaAnnotationModelFactory.create(docPositionMapProvider.get()); PomReconcilingStrategy reconsilingStrategy = reconcilingStrategyFactory.create(annotationModel, editor); Reconciler reconciler = getReconciler(); diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfigurationFactory.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfigurationFactory.java index 498895470800..dab8f9f4b238 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfigurationFactory.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorConfigurationFactory.java @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.che.plugin.maven.client.editor; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * @author Evgen Vidolob */ public interface PomEditorConfigurationFactory { - PomEditorConfiguration create(OrionEditorPresenter editor); + PomEditorConfiguration create(TextEditorPresenter editor); } diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorProvider.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorProvider.java index 51c3223527c0..a73a0b77dbe5 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorProvider.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomEditorProvider.java @@ -15,7 +15,7 @@ import org.eclipse.che.ide.api.editor.defaulteditor.AbstractTextEditorProvider; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * Creates editor for pom.xml file @@ -46,8 +46,8 @@ public String getDescription() { @Override public TextEditor getEditor() { TextEditor editor = super.getEditor(); - if (editor instanceof OrionEditorPresenter) { - PomEditorConfiguration configuration = configurationFactory.create((OrionEditorPresenter)editor); + if (editor instanceof TextEditorPresenter) { + PomEditorConfiguration configuration = configurationFactory.create((TextEditorPresenter)editor); editor.initialize(configuration); } diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategy.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategy.java index 9ed6a8d0dd86..14a2978a6911 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategy.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategy.java @@ -17,13 +17,14 @@ import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.editor.EditorWithErrors; +import org.eclipse.che.ide.api.editor.text.Region; +import org.eclipse.che.ide.ext.java.client.editor.ProblemRequester; +import org.eclipse.che.ide.ext.java.shared.dto.Problem; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.reconciler.DirtyRegion; import org.eclipse.che.ide.api.editor.reconciler.ReconcilingStrategy; -import org.eclipse.che.ide.api.editor.text.Region; -import org.eclipse.che.ide.ext.java.client.editor.ProblemRequester; -import org.eclipse.che.ide.ext.java.shared.dto.Problem; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; import org.eclipse.che.ide.util.loging.Log; import org.eclipse.che.plugin.maven.client.service.MavenServerServiceClient; @@ -38,13 +39,13 @@ public class PomReconcilingStrategy implements ReconcilingStrategy { private final AnnotationModel annotationModel; - private final EditorWithErrors editor; + private final TextEditorPresenter editor; private final MavenServerServiceClient client; private String pomPath; @Inject public PomReconcilingStrategy(@Assisted AnnotationModel annotationModel, - @Assisted @NotNull final EditorWithErrors editor, + @Assisted @NotNull final TextEditorPresenter editor, MavenServerServiceClient client) { this.annotationModel = annotationModel; this.editor = editor; diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategyFactory.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategyFactory.java index 3eef91966ef0..fab4db643f4d 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategyFactory.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/editor/PomReconcilingStrategyFactory.java @@ -10,8 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.maven.client.editor; -import org.eclipse.che.ide.api.editor.EditorWithErrors; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * Factory class for creating PomReconcilingStrategy @@ -20,5 +20,5 @@ */ public interface PomReconcilingStrategyFactory { - PomReconcilingStrategy create(AnnotationModel annotationModel, EditorWithErrors editor); + PomReconcilingStrategy create(AnnotationModel annotationModel, TextEditorPresenter editor); } diff --git a/plugins/plugin-orion/che-plugin-orion-editor/pom.xml b/plugins/plugin-orion/che-plugin-orion-editor/pom.xml index 9366b1fc59ca..a52eba2f17f4 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/pom.xml +++ b/plugins/plugin-orion/che-plugin-orion-editor/pom.xml @@ -64,10 +64,6 @@ javax.inject javax.inject - - javax.validation - validation-api - org.eclipse.che.core che-core-commons-gwt diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/EditorInitializePromiseHolder.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/EditorInitializePromiseHolder.java deleted file mode 100644 index 34b441d95bbd..000000000000 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/EditorInitializePromiseHolder.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.editor.orion.client; - -import com.google.inject.Singleton; - -import org.eclipse.che.api.promises.client.Promise; - -/** - * Holds promise that resolve when all editor js scripts are loaded ad initialized - */ -@Singleton -public class EditorInitializePromiseHolder { - - private Promise initializerPromise; - - public void setInitializerPromise(Promise initializerPromise) { - this.initializerPromise = initializerPromise; - } - - public Promise getInitializerPromise() { - if (initializerPromise == null) { - throw new RuntimeException("Editor initializer not set"); - } - return initializerPromise; - } -} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionContentTypeRegistrant.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionContentTypeRegistrant.java index 014270f811c0..c38bf59733ce 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionContentTypeRegistrant.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionContentTypeRegistrant.java @@ -10,20 +10,19 @@ *******************************************************************************/ package org.eclipse.che.ide.editor.orion.client; -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.core.client.JsArrayString; -import com.google.inject.Inject; -import com.google.inject.Provider; +import static com.google.common.collect.Lists.newArrayList; -import org.eclipse.che.api.promises.client.Operation; -import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.ide.api.editor.filetype.MultipleMethodFileIdentifier; +import org.eclipse.che.ide.api.editor.texteditor.EditorModule.EditorModuleReadyCallback; import org.eclipse.che.ide.editor.orion.client.jso.OrionCodeEditWidgetOverlay; import org.eclipse.che.ide.editor.orion.client.jso.OrionContentTypeOverlay; import org.eclipse.che.ide.editor.orion.client.jso.OrionHighlightingConfigurationOverlay; import org.eclipse.che.ide.editor.orion.client.jso.OrionServiceRegistryOverlay; -import static com.google.common.collect.Lists.newArrayList; +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.JsArrayString; +import com.google.inject.Inject; +import com.google.inject.Provider; /** * Component to register new content types and corresponding highlighting configuration. @@ -32,15 +31,15 @@ */ public class OrionContentTypeRegistrant { - final MultipleMethodFileIdentifier fileTypeIdentifier; + final MultipleMethodFileIdentifier fileTypeIdentifier; final Provider codeEditWidgetProvider; - final EditorInitializePromiseHolder editorModule; + final OrionEditorModule editorModule; @Inject public OrionContentTypeRegistrant( final MultipleMethodFileIdentifier fileTypeIdentifier, final Provider codeEditWidgetProvider, - final EditorInitializePromiseHolder editorModule) { + final OrionEditorModule editorModule) { this.fileTypeIdentifier = fileTypeIdentifier; this.codeEditWidgetProvider = codeEditWidgetProvider; this.editorModule = editorModule; @@ -53,13 +52,19 @@ public void registerFileType(final OrionContentTypeOverlay contentType, final Or String extension = extensions.get(i); fileTypeIdentifier.registerNewExtension(extension, newArrayList(contentType.getId())); } - editorModule.getInitializerPromise().then(new Operation() { + + editorModule.waitReady(new EditorModuleReadyCallback() { + @Override - public void apply(Void arg) throws OperationException { + public void onEditorModuleReady() { OrionServiceRegistryOverlay serviceRegistry = codeEditWidgetProvider.get().getServiceRegistry(); serviceRegistry.doRegisterService("orion.core.contenttype", JavaScriptObject.createObject(), contentType.toServiceObject()); serviceRegistry.doRegisterService("orion.edit.highlighter", JavaScriptObject.createObject(), config); } + + @Override + public void onEditorModuleError() { + } }); } diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionCursorModel.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionCursorModel.java deleted file mode 100644 index e9c3f9558577..000000000000 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionCursorModel.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.editor.orion.client; - -import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.events.CursorActivityEvent; -import org.eclipse.che.ide.api.editor.events.CursorActivityHandler; -import org.eclipse.che.ide.api.editor.text.Position; -import org.eclipse.che.ide.api.editor.text.TextPosition; -import org.eclipse.che.ide.api.editor.texteditor.CursorModelWithHandler; -import org.eclipse.che.ide.util.ListenerManager; -import org.eclipse.che.ide.util.ListenerManager.Dispatcher; -import org.eclipse.che.ide.util.ListenerRegistrar.Remover; - -/** - * {@link CursorModelWithHandler} implementation for the text editors. - * - * @author "Mickaƫl Leduque" - */ -class OrionCursorModel implements CursorModelWithHandler, CursorActivityHandler { - - private final Document document; - private final ListenerManager cursorHandlerManager = ListenerManager.create(); - - public OrionCursorModel(final Document document) { - this.document = document; - this.document.addCursorHandler(this); - } - - @Override - public void setCursorPosition(int offset) { - TextPosition position = document.getPositionFromIndex(offset); - document.setCursorPosition(position); - } - - @Override - public Position getCursorPosition() { - TextPosition position = document.getCursorPosition(); - int offset = document.getIndexFromPosition(position); - return new Position(offset); - } - - @Override - public Remover addCursorHandler(CursorHandler handler) { - return this.cursorHandlerManager.add(handler); - } - - private void dispatchCursorChange(final boolean isExplicitChange) { - final TextPosition position = this.document.getCursorPosition(); - - - cursorHandlerManager.dispatch(new Dispatcher() { - @Override - public void dispatch(CursorHandler listener) { - listener.onCursorChange(position.getLine(), position.getCharacter(), isExplicitChange); - } - }); - } - - @Override - public void onCursorActivity(final CursorActivityEvent event) { - dispatchCursorChange(true); - } -} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorBuilder.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorBuilder.java index da097b175582..5e9236494aa4 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorBuilder.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorBuilder.java @@ -11,11 +11,11 @@ package org.eclipse.che.ide.editor.orion.client; import com.google.inject.Inject; -import com.google.inject.Provider; import org.eclipse.che.ide.api.editor.defaulteditor.EditorBuilder; import org.eclipse.che.ide.api.editor.editorconfig.AutoSaveTextEditorConfiguration; import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; /** * Builder for Orion editor. @@ -24,17 +24,16 @@ */ public class OrionEditorBuilder implements EditorBuilder { - - private final Provider orionTextEditorProvider; + private final OrionTextEditorFactory orionTextEditorFactory; @Inject - public OrionEditorBuilder(Provider orionTextEditorProvider) { - this.orionTextEditorProvider = orionTextEditorProvider; + public OrionEditorBuilder(OrionTextEditorFactory orionTextEditorFactory) { + this.orionTextEditorFactory = orionTextEditorFactory; } @Override public TextEditor buildEditor() { - final OrionEditorPresenter editor = orionTextEditorProvider.get(); + final TextEditorPresenter editor = orionTextEditorFactory.createTextEditor(); editor.initialize(new AutoSaveTextEditorConfiguration()); return editor; } diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java index b859d28f1d74..0bd72f63c634 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java @@ -15,22 +15,19 @@ import com.google.gwt.core.client.JavaScriptException; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArrayString; +import com.google.gwt.core.client.RunAsyncCallback; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.LinkElement; -import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.inject.Singleton; -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper; -import org.eclipse.che.ide.api.editor.EditorLocalizationConstants; +import org.eclipse.che.ide.api.editor.texteditor.AbstractEditorModule.EditorInitializer; +import org.eclipse.che.ide.api.editor.texteditor.AbstractEditorModule.InitializerCallback; import org.eclipse.che.ide.api.extension.Extension; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.editor.orion.client.jso.OrionTextThemeOverlay; import org.eclipse.che.ide.requirejs.RequireJsLoader; import org.eclipse.che.ide.requirejs.RequirejsErrorHandler.RequireError; -import org.eclipse.che.ide.ui.loaders.request.LoaderFactory; -import org.eclipse.che.ide.ui.loaders.request.MessageLoader; import org.eclipse.che.ide.util.loging.Log; import javax.inject.Inject; @@ -46,40 +43,43 @@ public class OrionEditorExtension { /** The logger. */ private static final Logger LOG = Logger.getLogger(OrionEditorExtension.class.getSimpleName()); - private final NotificationManager notificationManager; - private final RequireJsLoader requireJsLoader; - private final OrionResource orionResource; - private final MessageLoader loader; - private final String waitEditorMessage; + private final NotificationManager notificationManager; + private final RequireJsLoader requireJsLoader; + private final OrionResource orionResource; private boolean initFailedWarnedOnce = false; @Inject public OrionEditorExtension(final NotificationManager notificationManager, final RequireJsLoader requireJsLoader, - final EditorInitializePromiseHolder editorModule, - final OrionResource orionResource, - final LoaderFactory loaderFactory, - final EditorLocalizationConstants constants) { + final OrionEditorModule editorModule, + final OrionResource orionResource) { this.notificationManager = notificationManager; this.requireJsLoader = requireJsLoader; this.orionResource = orionResource; - this.loader = loaderFactory.newLoader(); - this.waitEditorMessage = constants.waitEditorInitMessage(); - Promise promise = AsyncPromiseHelper.createFromAsyncRequest(new AsyncPromiseHelper.RequestCall() { + editorModule.setEditorInitializer(new EditorInitializer() { @Override - public void makeCall(AsyncCallback callback) { - injectOrion(callback); + public void initialize(final InitializerCallback callback) { + // add code-splitting of the whole orion editor + GWT.runAsync(new RunAsyncCallback() { + @Override + public void onSuccess() { + injectOrion(callback); + } + + @Override + public void onFailure(final Throwable reason) { + callback.onFailure(reason); + } + }); } }); - editorModule.setInitializerPromise(promise); KeyMode.init(); } - private void injectOrion(final AsyncCallback callback) { - loader.setMessage(waitEditorMessage); + private void injectOrion(final InitializerCallback callback) { final String[] scripts = new String[]{ "built-codeEdit-11.0/code_edit/built-codeEdit-amd", "orion/CheContentAssistMode" @@ -121,7 +121,7 @@ private static void injectCssLink(final String url) { Document.get().getHead().appendChild(link); } - private void requireOrion(final AsyncCallback callback) { + private void requireOrion(final InitializerCallback callback) { requireJsLoader.require(new Callback() { @Override @@ -151,10 +151,9 @@ public void onSuccess(final JavaScriptObject[] result) { "UiUtils"}); } - private void endConfiguration(final AsyncCallback callback) { + private void endConfiguration(final InitializerCallback callback) { defineDefaultTheme(); - loader.hide(); - callback.onSuccess(null); + callback.onSuccess(); } private void defineDefaultTheme() { @@ -163,11 +162,10 @@ private void defineDefaultTheme() { OrionTextThemeOverlay.setDefaultTheme("orionCodenvy", "orion-codenvy-theme.css"); } - private void initializationFailed(final AsyncCallback callback, final String errorMessage, Throwable e) { + private void initializationFailed(final InitializerCallback callback, final String errorMessage, Throwable e) { if (initFailedWarnedOnce) { return; } - loader.hide(); initFailedWarnedOnce = true; notificationManager.notify(errorMessage, StatusNotification.Status.FAIL, FLOAT_MODE); LOG.log(Level.SEVERE, errorMessage + " - ", e); diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java deleted file mode 100644 index 81a08b40a0ce..000000000000 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorInit.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.editor.orion.client; - -import elemental.events.KeyboardEvent.KeyCode; - -import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; -import org.eclipse.che.ide.api.editor.annotation.HasAnnotationRendering; -import org.eclipse.che.ide.api.editor.annotation.QueryAnnotationsEvent; -import org.eclipse.che.ide.api.editor.changeintercept.ChangeInterceptorProvider; -import org.eclipse.che.ide.api.editor.changeintercept.TextChange; -import org.eclipse.che.ide.api.editor.changeintercept.TextChangeInterceptor; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistCallback; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistant; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistantFactory; -import org.eclipse.che.ide.api.editor.codeassist.CompletionProposal; -import org.eclipse.che.ide.api.editor.codeassist.CompletionReadyCallback; -import org.eclipse.che.ide.api.editor.codeassist.CompletionsSource; -import org.eclipse.che.ide.api.editor.document.Document; -import org.eclipse.che.ide.api.editor.document.DocumentHandle; -import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration; -import org.eclipse.che.ide.api.editor.events.CompletionRequestEvent; -import org.eclipse.che.ide.api.editor.events.CompletionRequestHandler; -import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; -import org.eclipse.che.ide.api.editor.events.TextChangeEvent; -import org.eclipse.che.ide.api.editor.events.TextChangeHandler; -import org.eclipse.che.ide.api.editor.keymap.KeyBinding; -import org.eclipse.che.ide.api.editor.keymap.KeyBindingAction; -import org.eclipse.che.ide.api.editor.partition.DocumentPartitioner; -import org.eclipse.che.ide.api.editor.position.PositionConverter; -import org.eclipse.che.ide.api.editor.quickfix.QuickAssistAssistant; -import org.eclipse.che.ide.api.editor.reconciler.Reconciler; -import org.eclipse.che.ide.api.editor.text.TextPosition; -import org.eclipse.che.ide.api.editor.text.TypedRegion; -import org.eclipse.che.ide.api.editor.texteditor.HasKeyBindings; -import org.eclipse.che.ide.util.browser.UserAgent; - -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -/** - * Initialization controller for the text editor. - * Sets-up (when available) the different components that depend on the document being ready. - */ -public class OrionEditorInit { - - /** The logger. */ - private static final Logger LOG = Logger.getLogger(OrionEditorInit.class.getName()); - - private static final String CONTENT_ASSIST = "Content assist"; - private static final String QUICK_FIX = "Quick fix"; - - private final TextEditorConfiguration configuration; - private final CodeAssistantFactory codeAssistantFactory; - private final OrionEditorPresenter textEditor; - private final QuickAssistAssistant quickAssist; - - /** - * The quick assist assistant. - */ - public OrionEditorInit(final TextEditorConfiguration configuration, - final CodeAssistantFactory codeAssistantFactory, - final QuickAssistAssistant quickAssist, - final OrionEditorPresenter textEditor) { - this.configuration = configuration; - this.codeAssistantFactory = codeAssistantFactory; - this.quickAssist = quickAssist; - this.textEditor = textEditor; - } - - /** - * Initialize the text editor. - * - * @param document to initialise with - */ - public void init(Document document) { - DocumentHandle documentHandle = document.getDocumentHandle(); - configurePartitioner(documentHandle); - configureReconciler(documentHandle); - configureAnnotationModel(documentHandle); - configureCodeAssist(documentHandle); - configureChangeInterceptors(documentHandle); - addQuickAssistKeyBinding(); - } - - public void uninstall() { - Reconciler reconciler = configuration.getReconciler(); - if (reconciler != null) { - reconciler.uninstall(); - } - } - - /** - * Configures the editor's DocumentPartitioner. - * @param documentHandle the handle to the document - */ - private void configurePartitioner(final DocumentHandle documentHandle) { - final DocumentPartitioner partitioner = configuration.getPartitioner(); - if (partitioner != null) { - partitioner.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, partitioner); - partitioner.initialize(); - } - } - - /** - * Configures the editor's Reconciler. - * @param documentHandle the handle to the document - */ - private void configureReconciler(final DocumentHandle documentHandle) { - final Reconciler reconciler = configuration.getReconciler(); - if (reconciler != null) { - reconciler.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, reconciler); - reconciler.install(textEditor); - } - } - - /** - * Configures the editor's annotation model. - * @param documentHandle the handle on the editor - */ - private void configureAnnotationModel(final DocumentHandle documentHandle) { - final AnnotationModel annotationModel = configuration.getAnnotationModel(); - if (annotationModel == null) { - return; - } - // add the renderers (event handler) before the model (event source) - if (textEditor instanceof HasAnnotationRendering) { - ((HasAnnotationRendering)textEditor).configure(annotationModel, documentHandle); - } - annotationModel.setDocumentHandle(documentHandle); - documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, annotationModel); - - // the model listens to QueryAnnotation events - documentHandle.getDocEventBus().addHandler(QueryAnnotationsEvent.TYPE, annotationModel); - } - - /** - * Configure the editor's code assistant. - * @param documentHandle the handle on the document - */ - private void configureCodeAssist(final DocumentHandle documentHandle) { - if (this.codeAssistantFactory == null) { - return; - } - final Map processors = configuration.getContentAssistantProcessors(); - - if (processors != null && !processors.isEmpty()) { - LOG.info("Creating code assistant."); - - final CodeAssistant codeAssistant = this.codeAssistantFactory.create(this.textEditor, - this.configuration.getPartitioner()); - for (String key : processors.keySet()) { - codeAssistant.setCodeAssistantProcessor(key, processors.get(key)); - } - - final KeyBindingAction action = new KeyBindingAction() { - @Override - public void action() { - showCompletion(codeAssistant); - } - }; - final HasKeyBindings hasKeyBindings = this.textEditor.getHasKeybindings(); - hasKeyBindings.addKeyBinding(new KeyBinding(true, false, false, false, KeyCode.SPACE, action), CONTENT_ASSIST); - - // handle CompletionRequest events that come from text operations instead of simple key binding - documentHandle.getDocEventBus().addHandler(CompletionRequestEvent.TYPE, new CompletionRequestHandler() { - @Override - public void onCompletionRequest(final CompletionRequestEvent event) { - showCompletion(codeAssistant); - } - }); - } else { - final KeyBindingAction action = new KeyBindingAction() { - @Override - public void action() { - showCompletion(); - } - }; - final HasKeyBindings hasKeyBindings = this.textEditor.getHasKeybindings(); - if (UserAgent.isMac()) { - hasKeyBindings.addKeyBinding(new KeyBinding(false, false, false, true, KeyCode.SPACE, action), CONTENT_ASSIST); - hasKeyBindings.addKeyBinding(new KeyBinding(false, false, true, true, KeyCode.SPACE, action), CONTENT_ASSIST); - } else { - hasKeyBindings.addKeyBinding(new KeyBinding(true, false, false, false, KeyCode.SPACE, action), CONTENT_ASSIST); - } - // handle CompletionRequest events that come from text operations instead of simple key binding - documentHandle.getDocEventBus().addHandler(CompletionRequestEvent.TYPE, new CompletionRequestHandler() { - @Override - public void onCompletionRequest(final CompletionRequestEvent event) { - showCompletion(); - } - }); - } - } - - /** - * Show the available completions. - * - * @param codeAssistant the code assistant - */ - private void showCompletion(final CodeAssistant codeAssistant) { - final int cursor = textEditor.getCursorOffset(); - if (cursor < 0) { - return; - } - final CodeAssistProcessor processor = codeAssistant.getProcessor(cursor); - if (processor != null) { - this.textEditor.showCompletionProposals(new CompletionsSource() { - @Override - public void computeCompletions(final CompletionReadyCallback callback) { - // cursor must be computed here again so it's original value is not baked in - // the SMI instance closure - important for completion update when typing - final int cursor = textEditor.getCursorOffset(); - codeAssistant.computeCompletionProposals(cursor, new CodeAssistCallback() { - @Override - public void proposalComputed(final List proposals) { - callback.onCompletionReady(proposals); - } - }); - } - }); - } else { - showCompletion(); - } - } - - /** Show the available completions. */ - private void showCompletion() { - this.textEditor.showCompletionProposals(); - } - - /** - * Add key binding to quick assist assistant. - */ - private void addQuickAssistKeyBinding() { - if (this.quickAssist != null) { - final KeyBindingAction action = new KeyBindingAction() { - @Override - public void action() { - final PositionConverter positionConverter = textEditor.getPositionConverter(); - if (positionConverter != null) { - textEditor.showQuickAssist(); - } - } - }; - final HasKeyBindings hasKeyBindings = this.textEditor.getHasKeybindings(); - hasKeyBindings.addKeyBinding(new KeyBinding(false, false, true, false, KeyCode.ENTER, action), QUICK_FIX); - } - } - - private void configureChangeInterceptors(final DocumentHandle documentHandle) { - final ChangeInterceptorProvider interceptors = configuration.getChangeInterceptorProvider(); - if (interceptors != null) { - documentHandle.getDocEventBus().addHandler(TextChangeEvent.TYPE, new TextChangeHandler() { - @Override - public void onTextChange(final TextChangeEvent event) { - final TextChange change = event.getChange(); - if (change == null) { - return; - } - final TextPosition from = change.getFrom(); - if (from == null) { - return; - } - final int startOffset = documentHandle.getDocument().getIndexFromPosition(from); - final TypedRegion region = configuration.getPartitioner().getPartition(startOffset); - if (region == null) { - return; - } - final List filteredInterceptors = interceptors.getInterceptors(region.getType()); - if (filteredInterceptors == null || filteredInterceptors.isEmpty()) { - return; - } - // don't apply the interceptors if the range end doesn't belong to the same partition - final TextPosition to = change.getTo(); - if (to != null && !from.equals(to)) { - final int endOffset = documentHandle.getDocument().getIndexFromPosition(to); - if (endOffset < region.getOffset() || endOffset > region.getOffset() + region.getLength()) { - return; - } - } - // stop as soon as one interceptors has modified the content - for (final TextChangeInterceptor interceptor : filteredInterceptors) { - final TextChange result = interceptor.processChange(change, - documentHandle.getDocument().getReadOnlyDocument()); - if (result != null) { - event.update(result); - break; - } - } - } - }); - } - } -} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorModule.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorModule.java new file mode 100644 index 000000000000..b3b4113fb6b4 --- /dev/null +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorModule.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.editor.orion.client; + +import javax.inject.Singleton; + +import org.eclipse.che.ide.api.editor.texteditor.AbstractEditorModule; + +/** + * {@link EditorModule} for the orion editor. + */ +@Singleton +public class OrionEditorModule extends AbstractEditorModule { +} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorPresenter.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorPresenter.java index 61f21ab35c4b..c691c52548ed 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorPresenter.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorPresenter.java @@ -10,191 +10,65 @@ *******************************************************************************/ package org.eclipse.che.ide.editor.orion.client; -import com.google.common.base.Optional; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.AcceptsOneWidget; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Widget; -import com.google.inject.Inject; +import com.google.inject.assistedinject.Assisted; +import com.google.inject.assistedinject.AssistedInject; import com.google.web.bindery.event.shared.EventBus; -import com.google.web.bindery.event.shared.HandlerRegistration; -import org.eclipse.che.api.promises.client.Function; -import org.eclipse.che.api.promises.client.FunctionException; -import org.eclipse.che.api.promises.client.Operation; -import org.eclipse.che.api.promises.client.OperationException; -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.debug.BreakpointManager; -import org.eclipse.che.ide.api.debug.BreakpointRenderer; -import org.eclipse.che.ide.api.debug.BreakpointRendererFactory; -import org.eclipse.che.ide.api.debug.HasBreakpointRenderer; -import org.eclipse.che.ide.api.dialogs.CancelCallback; -import org.eclipse.che.ide.api.dialogs.ConfirmCallback; -import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.api.editor.AbstractEditorPresenter; -import org.eclipse.che.ide.api.editor.EditorAgent; -import org.eclipse.che.ide.api.editor.EditorInput; import org.eclipse.che.ide.api.editor.EditorLocalizationConstants; -import org.eclipse.che.ide.api.editor.EditorWithAutoSave; -import org.eclipse.che.ide.api.editor.EditorWithErrors; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.parts.WorkspaceAgent; +import org.eclipse.che.ide.api.debug.BreakpointManager; +import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelDataOverlay; +import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelGroupOverlay; +import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelOverlay; import org.eclipse.che.ide.api.editor.annotation.AnnotationModel; import org.eclipse.che.ide.api.editor.annotation.AnnotationModelEvent; import org.eclipse.che.ide.api.editor.annotation.AnnotationModelHandler; import org.eclipse.che.ide.api.editor.annotation.ClearAnnotationModelEvent; import org.eclipse.che.ide.api.editor.annotation.ClearAnnotationModelHandler; import org.eclipse.che.ide.api.editor.annotation.HasAnnotationRendering; -import org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor; import org.eclipse.che.ide.api.editor.codeassist.CodeAssistantFactory; -import org.eclipse.che.ide.api.editor.codeassist.CompletionsSource; import org.eclipse.che.ide.api.editor.codeassist.HasCompletionInformation; -import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.debug.BreakpointRendererFactory; import org.eclipse.che.ide.api.editor.document.DocumentHandle; import org.eclipse.che.ide.api.editor.document.DocumentStorage; -import org.eclipse.che.ide.api.editor.editorconfig.EditorUpdateAction; -import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration; -import org.eclipse.che.ide.api.editor.events.CompletionRequestEvent; -import org.eclipse.che.ide.api.editor.events.GutterClickEvent; -import org.eclipse.che.ide.api.editor.events.GutterClickHandler; import org.eclipse.che.ide.api.editor.filetype.FileTypeIdentifier; -import org.eclipse.che.ide.api.editor.formatter.ContentFormatter; import org.eclipse.che.ide.api.editor.gutter.Gutter; -import org.eclipse.che.ide.api.editor.gutter.Gutters; import org.eclipse.che.ide.api.editor.gutter.HasGutter; -import org.eclipse.che.ide.api.editor.keymap.KeyBinding; -import org.eclipse.che.ide.api.editor.keymap.KeyBindingAction; import org.eclipse.che.ide.api.editor.link.HasLinkedMode; import org.eclipse.che.ide.api.editor.link.LinkedMode; import org.eclipse.che.ide.api.editor.link.LinkedModel; import org.eclipse.che.ide.api.editor.link.LinkedModelData; import org.eclipse.che.ide.api.editor.link.LinkedModelGroup; -import org.eclipse.che.ide.api.editor.position.PositionConverter; -import org.eclipse.che.ide.api.editor.quickfix.QuickAssistAssistant; -import org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor; import org.eclipse.che.ide.api.editor.quickfix.QuickAssistantFactory; -import org.eclipse.che.ide.api.editor.reconciler.Reconciler; -import org.eclipse.che.ide.api.editor.reconciler.ReconcilerWithAutoSave; -import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.text.TextPosition; -import org.eclipse.che.ide.api.editor.text.TextRange; -import org.eclipse.che.ide.api.editor.texteditor.ContentInitializedHandler; -import org.eclipse.che.ide.api.editor.texteditor.CursorModelWithHandler; +import org.eclipse.che.ide.api.editor.texteditor.EditorModule; import org.eclipse.che.ide.api.editor.texteditor.EditorWidget; import org.eclipse.che.ide.api.editor.texteditor.EditorWidgetFactory; -import org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations; -import org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo; -import org.eclipse.che.ide.api.editor.texteditor.HasKeyBindings; -import org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty; -import org.eclipse.che.ide.api.editor.texteditor.TemporaryKeyBindingsManager; -import org.eclipse.che.ide.api.editor.texteditor.TextEditor; -import org.eclipse.che.ide.api.editor.texteditor.TextEditorOperations; import org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView; -import org.eclipse.che.ide.api.editor.texteditor.UndoableEditor; -import org.eclipse.che.ide.api.event.FileContentUpdateEvent; -import org.eclipse.che.ide.api.event.FileContentUpdateHandler; -import org.eclipse.che.ide.api.event.FileEvent; -import org.eclipse.che.ide.api.event.FileEventHandler; -import org.eclipse.che.ide.api.hotkeys.HasHotKeyItems; -import org.eclipse.che.ide.api.hotkeys.HotKeyItem; -import org.eclipse.che.ide.api.notification.NotificationManager; -import org.eclipse.che.ide.api.parts.WorkspaceAgent; -import org.eclipse.che.ide.api.resources.File; -import org.eclipse.che.ide.api.resources.Resource; -import org.eclipse.che.ide.api.resources.ResourceChangedEvent; -import org.eclipse.che.ide.api.resources.ResourceDelta; -import org.eclipse.che.ide.api.resources.VirtualFile; -import org.eclipse.che.ide.api.selection.Selection; -import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelDataOverlay; -import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelGroupOverlay; -import org.eclipse.che.ide.editor.orion.client.jso.OrionLinkedModelOverlay; -import org.eclipse.che.ide.resource.Path; -import org.vectomatic.dom.svg.ui.SVGResource; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.NOT_EMERGE_MODE; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; -import static org.eclipse.che.ide.api.resources.ResourceDelta.ADDED; -import static org.eclipse.che.ide.api.resources.ResourceDelta.DERIVED; -import static org.eclipse.che.ide.api.resources.ResourceDelta.MOVED_FROM; -import static org.eclipse.che.ide.api.resources.ResourceDelta.MOVED_TO; -import static org.eclipse.che.ide.api.resources.ResourceDelta.REMOVED; -import static org.eclipse.che.ide.api.resources.ResourceDelta.UPDATED; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; +import org.eclipse.che.ide.api.dialogs.DialogFactory; /** - * {@link TextEditor} using orion. + * {@link TextEditorPresenter} using orion. * This class is only defined to allow the Gin binding to be performed. */ -public class OrionEditorPresenter extends AbstractEditorPresenter implements TextEditor, - FileEventHandler, - UndoableEditor, - HasBreakpointRenderer, - HasReadOnlyProperty, - HandlesTextOperations, - EditorWithAutoSave, - EditorWithErrors, - HasHotKeyItems, - TextEditorPartView.Delegate, - HasAnnotationRendering, - HasLinkedMode, - HasCompletionInformation, - HasGutter { - /** File type used when we have no idea of the actual content type. */ - public static final String DEFAULT_CONTENT_TYPE = "text/plain"; - - private static final String TOGGLE_LINE_BREAKPOINT = "Toggle line breakpoint"; - - private final CodeAssistantFactory codeAssistantFactory; - private final BreakpointManager breakpointManager; - private final BreakpointRendererFactory breakpointRendererFactory; - private final DialogFactory dialogFactory; - private final DocumentStorage documentStorage; - private final EditorLocalizationConstants constant; - private final EditorWidgetFactory editorWidgetFactory; - private final EditorInitializePromiseHolder editorModule; - private final TextEditorPartView editorView; - private final EventBus generalEventBus; - private final FileTypeIdentifier fileTypeIdentifier; - private final QuickAssistantFactory quickAssistantFactory; - private final WorkspaceAgent workspaceAgent; - private final NotificationManager notificationManager; - private final AppContext appContext; +public class OrionEditorPresenter extends TextEditorPresenter implements HasAnnotationRendering, + HasLinkedMode, + HasCompletionInformation, + HasGutter { private final AnnotationRendering rendering = new AnnotationRendering(); - private HasKeyBindings keyBindingsManager; - private List updateActions; - private TextEditorConfiguration configuration; - private EditorWidget editorWidget; - private Document document; - private CursorModelWithHandler cursorModel; - private QuickAssistAssistant quickAssistant; - /** The editor's error state. */ - private EditorState errorState; - private boolean delayedFocus; - private boolean isFocused; - private BreakpointRenderer breakpointRenderer; - private List fileTypes; - private TextPosition cursorPosition; - private HandlerRegistration resourceChangeHandler; - private OrionEditorInit editorInit; - @Inject + @AssistedInject public OrionEditorPresenter(final CodeAssistantFactory codeAssistantFactory, final BreakpointManager breakpointManager, final BreakpointRendererFactory breakpointRendererFactory, final DialogFactory dialogFactory, final DocumentStorage documentStorage, final EditorLocalizationConstants constant, - final EditorWidgetFactory editorWigetFactory, - final EditorInitializePromiseHolder editorModule, + @Assisted final EditorWidgetFactory editorWigetFactory, + final EditorModule editorModule, final TextEditorPartView editorView, final EventBus eventBus, final FileTypeIdentifier fileTypeIdentifier, @@ -202,691 +76,21 @@ public OrionEditorPresenter(final CodeAssistantFactory codeAssistantFactory, final WorkspaceAgent workspaceAgent, final NotificationManager notificationManager, final AppContext appContext) { - this.codeAssistantFactory = codeAssistantFactory; - this.breakpointManager = breakpointManager; - this.breakpointRendererFactory = breakpointRendererFactory; - this.dialogFactory = dialogFactory; - this.documentStorage = documentStorage; - this.constant = constant; - this.editorWidgetFactory = editorWigetFactory; - this.editorModule = editorModule; - this.editorView = editorView; - this.generalEventBus = eventBus; - this.fileTypeIdentifier = fileTypeIdentifier; - this.quickAssistantFactory = quickAssistantFactory; - this.workspaceAgent = workspaceAgent; - this.notificationManager = notificationManager; - this.appContext = appContext; - - keyBindingsManager = new TemporaryKeyBindingsManager(); - - this.editorView.setDelegate(this); - eventBus.addHandler(FileEvent.TYPE, this); - } - - @Override - protected void initializeEditor(final EditorAgent.OpenEditorCallback callback) { - QuickAssistProcessor processor = configuration.getQuickAssistProcessor(); - if (quickAssistantFactory != null && processor != null) { - quickAssistant = quickAssistantFactory.createQuickAssistant(this); - quickAssistant.setQuickAssistProcessor(processor); - } - - editorInit = new OrionEditorInit(configuration, - this.codeAssistantFactory, - this.quickAssistant, - this); - - Promise initializerPromise = editorModule.getInitializerPromise(); - initializerPromise.catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - displayErrorPanel(constant.editorInitErrorMessage()); - callback.onInitializationFailed(); - } - }).thenPromise(new Function>() { - @Override - public Promise apply(Void arg) throws FunctionException { - return documentStorage.getDocument(input.getFile()); - } - }).then(new Operation() { - @Override - public void apply(String content) throws OperationException { - createEditor(content); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - displayErrorPanel(constant.editorFileErrorMessage()); - callback.onInitializationFailed(); - } - }); - - } - - private void createEditor(final String content) { - this.fileTypes = detectFileType(getEditorInput().getFile()); - editorWidgetFactory.createEditorWidget(fileTypes, new EditorWidgetInitializedCallback(content)); - } - - private void setupEventHandlers() { - this.editorWidget.addChangeHandler(new ChangeHandler() { - @Override - public void onChange(final ChangeEvent event) { - handleDocumentChanged(); - } - }); - this.editorWidget.addGutterClickHandler(new GutterClickHandler() { - @Override - public void onGutterClick(final GutterClickEvent event) { - if (Gutters.BREAKPOINTS_GUTTER.equals(event.getGutterId()) - || Gutters.LINE_NUMBERS_GUTTER.equals(event.getGutterId())) { - breakpointManager.changeBreakpointState(event.getLineNumber()); - } - } - }); - this.editorWidget.addKeyBinding(new KeyBinding(true, false, false, false, KeyCodes.KEY_F8, new KeyBindingAction() { - @Override - public void action() { - int currentLine = editorWidget.getDocument().getCursorPosition().getLine(); - breakpointManager.changeBreakpointState(currentLine); - } - }), TOGGLE_LINE_BREAKPOINT); - } - - private void setupFileContentUpdateHandler() { - - resourceChangeHandler = - generalEventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() { - @Override - public void onResourceChanged(ResourceChangedEvent event) { - final ResourceDelta delta = event.getDelta(); - - switch (delta.getKind()) { - case ADDED: - onResourceCreated(delta); - break; - case REMOVED: - onResourceRemoved(delta); - break; - case UPDATED: - onResourceUpdated(delta); - } - } - }); - - this.generalEventBus.addHandler(FileContentUpdateEvent.TYPE, new FileContentUpdateHandler() { - @Override - public void onFileContentUpdate(final FileContentUpdateEvent event) { - if (event.getFilePath() != null && Path.valueOf(event.getFilePath()).equals(document.getFile().getLocation())) { - updateContent(); - } - } - }); - } - - private void onResourceCreated(ResourceDelta delta) { - if ((delta.getFlags() & (MOVED_FROM | MOVED_TO)) == 0) { - return; - } - - //file moved directly - if (delta.getFromPath().equals(document.getFile().getLocation())) { - final Resource resource = delta.getResource(); - final Path movedFrom = delta.getFromPath(); - - if (document.getFile().getLocation().equals(movedFrom)) { - document.setFile((File)resource); - input.setFile((File)resource); - } - - updateContent(); - } else if (delta.getFromPath().isPrefixOf(document.getFile().getLocation())) { //directory where file moved - final Path relPath = document.getFile().getLocation().removeFirstSegments(delta.getFromPath().segmentCount()); - final Path newPath = delta.getToPath().append(relPath); - - appContext.getWorkspaceRoot().getFile(newPath).then(new Operation>() { - @Override - public void apply(Optional file) throws OperationException { - if (file.isPresent()) { - document.setFile(file.get()); - input.setFile(file.get()); - - updateContent(); - } - } - }); - } - - - } - - private void onResourceRemoved(ResourceDelta delta) { - if ((delta.getFlags() & DERIVED) == 0) { - return; - } - - final Resource resource = delta.getResource(); - - if (resource.isFile() && document.getFile().getLocation().equals(resource.getLocation())) { - if (resourceChangeHandler != null) { - resourceChangeHandler.removeHandler(); - resourceChangeHandler = null; - } - close(false); - } - } - - private void onResourceUpdated(ResourceDelta delta) { - if ((delta.getFlags() & DERIVED) == 0) { - return; - } - - if (delta.getResource().isFile() && document.getFile().getLocation().equals(delta.getResource().getLocation())) { - updateContent(); - } - } - - private void updateContent() { - /* -save current cursor and (ideally) viewport - * -set editor content which is also expected to - * -reset dirty flag - * -clear history - * -restore current cursor position - */ - final TextPosition currentCursor = getCursorPosition(); - this.documentStorage.getDocument(document.getFile(), new DocumentStorage.DocumentCallback() { - - @Override - public void onDocumentReceived(final String content) { - editorWidget.setValue(content, new ContentInitializedHandler() { - @Override - public void onContentInitialized() { - document.setCursorPosition(currentCursor); - } - }); - } - - @Override - public void onDocumentLoadFailure(final Throwable caught) { - displayErrorPanel(constant.editorFileErrorMessage()); - } - }); - } - - private void displayErrorPanel(final String message) { - this.editorView.showPlaceHolder(new Label(message)); - } - - private void handleDocumentChanged() { - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { - @Override - public void execute() { - updateDirtyState(editorWidget.isDirty()); - } - }); - } - - protected void showQuickAssist() { - if (quickAssistant == null) { - return; - } - PositionConverter positionConverter = getPositionConverter(); - if (positionConverter != null) { - TextPosition cursor = getCursorPosition(); - PositionConverter.PixelCoordinates pixelPos = positionConverter.textToPixel(cursor); - quickAssistant.showPossibleQuickAssists(getCursorModel().getCursorPosition().getOffset(), - pixelPos.getX(), - pixelPos.getY()); - } - } - - @Override - public void storeState() { - cursorPosition = getCursorPosition(); - } - - @Override - public void restoreState() { - if (cursorPosition != null) { - setFocus(); - - getDocument().setCursorPosition(cursorPosition); - } - } - - @Override - public void close(boolean save) { - this.documentStorage.documentClosed(this.document); - editorInit.uninstall(); - workspaceAgent.removePart(this); - } - - @Override - public boolean isEditable() { - return false; - } - - @Override - public void doRevertToSaved() { - // do nothing - } - - - protected Widget getWidget() { - return this.editorView.asWidget(); - } - - @Override - public void go(AcceptsOneWidget container) { - container.setWidget(getWidget()); - } - - @Override - public String getTitleToolTip() { - return null; - } - - @Override - public void onClose(@NotNull final AsyncCallback callback) { - if (isDirty()) { - dialogFactory.createConfirmDialog( - constant.askWindowCloseTitle(), - constant.askWindowSaveChangesMessage(getEditorInput().getName()), - new ConfirmCallback() { - @Override - public void accepted() { - doSave(); - handleClose(); - callback.onSuccess(null); - } - }, - new CancelCallback() { - @Override - public void cancelled() { - handleClose(); - callback.onSuccess(null); - } - }).show(); - } else { - handleClose(); - callback.onSuccess(null); - } - } - - @Override - protected void handleClose() { - if (resourceChangeHandler != null) { - resourceChangeHandler.removeHandler(); - resourceChangeHandler = null; - } - super.handleClose(); - } - - @Override - public TextEditorPartView getView() { - return this.editorView; - } - - @Override - public void activate() { - if (editorWidget != null) { - editorWidget.refresh(); - editorWidget.setFocus(); - setSelection(new Selection<>(input.getFile())); - } else { - this.delayedFocus = true; - } - } - - @Override - public void onFileOperation(FileEvent event) { - if (event.getOperationType() != FileEvent.FileOperation.CLOSE) { - return; - } - - if (input.getFile().equals(event.getFile())) { - close(false); - } - } - - @Override - public void initialize(@NotNull TextEditorConfiguration configuration) { - this.configuration = configuration; - } - - @Override - public TextEditorConfiguration getConfiguration() { - return configuration; - } - - @Override - public SVGResource getTitleImage() { - return input.getSVGResource(); - } - - @Override - public String getTitle() { - return input.getFile().getDisplayName(); - } - - @Override - public void doSave() { - doSave(new AsyncCallback() { - @Override - public void onSuccess(final EditorInput result) { - // do nothing - } - - @Override - public void onFailure(final Throwable caught) { - // do nothing - } - }); - } - - @Override - public void doSave(final AsyncCallback callback) { - - this.documentStorage.saveDocument(getEditorInput(), this.document, false, new AsyncCallback() { - @Override - public void onSuccess(EditorInput editorInput) { - updateDirtyState(false); - editorWidget.markClean(); - afterSave(); - if (callback != null) { - callback.onSuccess(editorInput); - } - } - - @Override - public void onFailure(Throwable caught) { - notificationManager.notify(constant.failedToUpdateContentOfFiles(), caught.getMessage(), FAIL, NOT_EMERGE_MODE); - if (callback != null) { - callback.onFailure(caught); - } - } - }); - } - - @Override - public void doSaveAs() { - - } - - protected void afterSave() { - } - - @Override - public HandlesUndoRedo getUndoRedo() { - if (this.editorWidget != null) { - return this.editorWidget.getUndoRedo(); - } else { - return null; - } - } - - @Override - public EditorState getErrorState() { - return this.errorState; - } - - @Override - public void setErrorState(EditorState errorState) { - this.errorState = errorState; - firePropertyChange(ERROR_STATE); - } - - @Override - public BreakpointRenderer getBreakpointRenderer() { - if (this.breakpointRenderer == null && this.editorWidget != null && this instanceof HasGutter) { - this.breakpointRenderer = this.breakpointRendererFactory.create(((HasGutter)this).getGutter(), - this.editorWidget.getLineStyler(), - this.document); - } - return this.breakpointRenderer; - } - - @Override - public Document getDocument() { - return this.document; - } - - @Override - public String getContentType() { - // Before the editor content is ready, the content type is not defined - if (this.fileTypes == null || this.fileTypes.isEmpty()) { - return null; - } else { - return this.fileTypes.get(0); - } - } - - @Override - public TextRange getSelectedTextRange() { - return getDocument().getSelectedTextRange(); - } - - @Override - public LinearRange getSelectedLinearRange() { - return getDocument().getSelectedLinearRange(); - } - - @Override - public void showMessage(String message) { - this.editorWidget.showMessage(message); - } - - @Override - public TextPosition getCursorPosition() { - return getDocument().getCursorPosition(); - } - - @Override - public int getCursorOffset() { - final TextPosition textPosition = getDocument().getCursorPosition(); - return getDocument().getIndexFromPosition(textPosition); - } - - @Override - public void refreshEditor() { - if (this.updateActions != null) { - for (final EditorUpdateAction action : this.updateActions) { - action.doRefresh(); - } - } - } - - @Override - public void addEditorUpdateAction(EditorUpdateAction action) { - if (action == null) { - return; - } - if (this.updateActions == null) { - this.updateActions = new ArrayList<>(); - } - this.updateActions.add(action); - } - - @Override - public void addKeybinding(KeyBinding keyBinding) { - // the actual HasKeyBindings object can change, so use indirection - getHasKeybindings().addKeyBinding(keyBinding); - } - - private List detectFileType(final VirtualFile file) { - final List result = new ArrayList<>(); - if (file != null) { - // use the identification patterns - final List types = this.fileTypeIdentifier.identifyType(file); - if (types != null && !types.isEmpty()) { - result.addAll(types); - } - } - - // ultimate fallback - can't make more generic for text - result.add(DEFAULT_CONTENT_TYPE); - - return result; - } - - public HasKeyBindings getHasKeybindings() { - return this.keyBindingsManager; - } - - @Override - public CursorModelWithHandler getCursorModel() { - return this.cursorModel; - } - - @Override - public PositionConverter getPositionConverter() { - return this.editorWidget.getPositionConverter(); - } - - public void showCompletionProposals(CompletionsSource source) { - this.editorView.showCompletionProposals(this.editorWidget, source); - } - - public void showCompletionProposals() { - this.editorView.showCompletionProposals(this.editorWidget); - } - - private void switchHasKeybinding() { - final HasKeyBindings current = getHasKeybindings(); - if (!(current instanceof TemporaryKeyBindingsManager)) { - return; - } - // change the key binding instance and add all bindings to the new one - this.keyBindingsManager = this.editorWidget; - final List bindings = ((TemporaryKeyBindingsManager)current).getbindings(); - for (final KeyBinding binding : bindings) { - this.keyBindingsManager.addKeyBinding(binding); - } - } - - @Override - public List getHotKeys() { - return editorWidget.getHotKeys(); - } - - @Override - public void onResize() { - if (this.editorWidget != null) { - this.editorWidget.onResize(); - } - } - - @Override - public void editorLostFocus() { - this.editorView.updateInfoPanelUnfocused(this.document.getLineCount()); - this.isFocused = false; - } - - @Override - public void editorGotFocus() { - this.isFocused = true; - this.editorView.updateInfoPanelPosition(this.document.getCursorPosition()); - } - - @Override - public void editorCursorPositionChanged() { - this.editorView.updateInfoPanelPosition(this.document.getCursorPosition()); - } - - @Override - public boolean canDoOperation(int operation) { - if (TextEditorOperations.CODEASSIST_PROPOSALS == operation) { - Map contentAssistProcessors = getConfiguration().getContentAssistantProcessors(); - if (contentAssistProcessors != null && !contentAssistProcessors.isEmpty()) { - return true; - } - } - if (TextEditorOperations.FORMAT == operation) { - if (getConfiguration().getContentFormatter() != null) { - return true; - } - } - - if (TextEditorOperations.QUICK_ASSIST == operation) { - if (quickAssistant != null) { - return true; - } - } - return false; - } - - @Override - public void doOperation(int operation) { - switch (operation) { - case TextEditorOperations.CODEASSIST_PROPOSALS: - if (this.document != null) { - this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); - } - break; - case TextEditorOperations.FORMAT: - ContentFormatter formatter = getConfiguration().getContentFormatter(); - if (this.document != null && formatter != null) { - formatter.format(getDocument()); - } - break; - case TextEditorOperations.QUICK_ASSIST: - showQuickAssist(); - break; - default: - throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); - } - } - - @Override - public boolean isReadOnly() { - return this.editorWidget.isReadOnly(); - } - - @Override - public void setReadOnly(boolean readOnly) { - this.editorWidget.setReadOnly(readOnly); - } - - @Override - public EditorWidget getEditorWidget() { - return this.editorWidget; - } - - @Override - public boolean isFocused() { - return this.isFocused; - } - - @Override - public boolean isAutoSaveEnabled() { - ReconcilerWithAutoSave autoSave = getAutoSave(); - return autoSave != null && autoSave.isAutoSaveEnabled(); - } - - private ReconcilerWithAutoSave getAutoSave() { - Reconciler reconciler = getConfiguration().getReconciler(); - - if (reconciler != null && reconciler instanceof ReconcilerWithAutoSave) { - return ((ReconcilerWithAutoSave)reconciler); - } - return null; - } - - @Override - public void enableAutoSave() { - ReconcilerWithAutoSave autoSave = getAutoSave(); - if (autoSave != null) { - autoSave.enableAutoSave(); - } - } - - @Override - public void disableAutoSave() { - ReconcilerWithAutoSave autoSave = getAutoSave(); - if (autoSave != null) { - autoSave.disableAutoSave(); - } + super(codeAssistantFactory, + breakpointManager, + breakpointRendererFactory, + dialogFactory, + documentStorage, + constant, + editorWigetFactory, + editorModule, + editorView, + eventBus, + fileTypeIdentifier, + quickAssistantFactory, + workspaceAgent, + notificationManager, + appContext); } @Override @@ -898,7 +102,7 @@ public void configure(AnnotationModel model, DocumentHandle document) { @Override public LinkedMode getLinkedMode() { EditorWidget editorWidget = getEditorWidget(); - if (editorWidget != null) { + if(editorWidget != null){ OrionEditorWidget orion = ((OrionEditorWidget)editorWidget); return orion.getLinkedMode(); } @@ -923,7 +127,7 @@ public LinkedModelData createLinkedModelData() { @Override public void showCompletionInformation() { EditorWidget editorWidget = getEditorWidget(); - if (editorWidget != null) { + if(editorWidget != null){ OrionEditorWidget orion = ((OrionEditorWidget)editorWidget); orion.showCompletionInformation(); } @@ -943,7 +147,7 @@ public Gutter getGutter() { @Override public void setFocus() { EditorWidget editorWidget = getEditorWidget(); - if (editorWidget != null) { + if(editorWidget != null){ OrionEditorWidget orion = ((OrionEditorWidget)editorWidget); orion.setFocus(); } @@ -955,7 +159,7 @@ private class AnnotationRendering implements AnnotationModelHandler, ClearAnnota @Override public void onAnnotationModel(AnnotationModelEvent event) { EditorWidget editorWidget = getEditorWidget(); - if (editorWidget != null) { + if(editorWidget != null){ OrionEditorWidget orion = ((OrionEditorWidget)editorWidget); orion.showErrors(event); } @@ -964,67 +168,10 @@ public void onAnnotationModel(AnnotationModelEvent event) { @Override public void onClearModel(ClearAnnotationModelEvent event) { EditorWidget editorWidget = getEditorWidget(); - if (editorWidget != null) { + if(editorWidget != null){ OrionEditorWidget orion = ((OrionEditorWidget)editorWidget); orion.clearErrors(); } } } - - private class EditorWidgetInitializedCallback implements EditorWidget.WidgetInitializedCallback { - private final String content; - - private boolean isInitialized; - - private EditorWidgetInitializedCallback(String content) { - this.content = content; - } - - @Override - public void initialized(EditorWidget widget) { - editorWidget = widget; - // finish editor initialization - editorView.setEditorWidget(editorWidget); - - document = editorWidget.getDocument(); - document.setFile(input.getFile()); - cursorModel = new OrionCursorModel(document); - - editorWidget.setTabSize(configuration.getTabWidth()); - - // initialize info panel - editorView.initInfoPanel(editorWidget.getMode(), - editorWidget.getKeymap(), - document.getLineCount(), - configuration.getTabWidth()); - - //TODO: delayed activation - // handle delayed focus (initialization editor widget) - // should also check if I am visible, but how ? - if (delayedFocus) { - editorWidget.refresh(); - editorWidget.setFocus(); - setSelection(new Selection<>(input.getFile())); - delayedFocus = false; - } - - // delayed keybindings creation ? - switchHasKeybinding(); - - editorWidget.setValue(content, new ContentInitializedHandler() { - @Override - public void onContentInitialized() { - if (isInitialized) { - return; - } - editorInit.init(document); - firePropertyChange(PROP_INPUT); - setupEventHandlers(); - setupFileContentUpdateHandler(); - - isInitialized = true; - } - }); - } - } } diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionTextEditorFactory.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionTextEditorFactory.java new file mode 100644 index 000000000000..c3379524de67 --- /dev/null +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionTextEditorFactory.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.editor.orion.client; + +import javax.inject.Inject; + +import org.eclipse.che.ide.api.editor.texteditor.EditorWidget; +import org.eclipse.che.ide.api.editor.texteditor.EditorWidgetFactory; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenterFactory; + +/** Editor presenter factory that produces orion-based editors. */ +public class OrionTextEditorFactory { + + /** The {@link EditorWidget} factory. */ + @Inject + private EditorWidgetFactory editorWidgetFactory; + + /** The base {@link TextEditorPresenter} factory. */ + @Inject + private TextEditorPresenterFactory presenterFactory; + + public TextEditorPresenter createTextEditor() { + return this.presenterFactory.createTextEditor(this.editorWidgetFactory); + } +} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java index 39fd0ec49310..503d4a5c0e4b 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java @@ -16,10 +16,15 @@ import com.google.inject.TypeLiteral; import org.eclipse.che.ide.api.editor.defaulteditor.EditorBuilder; +import org.eclipse.che.ide.api.editor.texteditor.EditorModule; import org.eclipse.che.ide.api.editor.texteditor.EditorWidgetFactory; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter; +import org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenterFactory; import org.eclipse.che.ide.api.extension.ExtensionGinModule; import org.eclipse.che.ide.editor.orion.client.ContentAssistWidgetFactory; import org.eclipse.che.ide.editor.orion.client.OrionEditorBuilder; +import org.eclipse.che.ide.editor.orion.client.OrionEditorModule; +import org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter; import org.eclipse.che.ide.editor.orion.client.OrionEditorWidget; import org.eclipse.che.ide.editor.orion.client.jso.OrionCodeEditWidgetOverlay; import org.eclipse.che.ide.requirejs.ModuleHolder; @@ -34,10 +39,16 @@ protected void configure() { bind(EditorBuilder.class).to(OrionEditorBuilder.class); install(new GinFactoryModuleBuilder().build(new TypeLiteral>() {})); + bind(new TypeLiteral>() {}).to(OrionEditorModule.class); bind(OrionCodeEditWidgetOverlay.class).toProvider(OrionCodeEditWidgetProvider.class); install(new GinFactoryModuleBuilder().build(ContentAssistWidgetFactory.class)); + install(new GinFactoryModuleBuilder() + .implement(new TypeLiteral>() { + }, OrionEditorPresenter.class) + .build(new TypeLiteral>() { + })); } }