Skip to content

Commit

Permalink
Revert "#1913 Deprecates some of Editor API classes and interfaces"
Browse files Browse the repository at this point in the history
This reverts commit cc51c0e.
  • Loading branch information
rnavagamuwa committed Aug 15, 2016
1 parent 4ca6074 commit 94f04e6
Show file tree
Hide file tree
Showing 54 changed files with 480 additions and 1,602 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> getDocument(@NotNull VirtualFile file);

/**
* Saves the file content.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -62,11 +60,6 @@ public void apply(PromiseError arg) throws OperationException {
});
}

@Override
public Promise<String> getDocument(@NotNull VirtualFile file) {
return file.getContent();
}

@Override
public void saveDocument(final EditorInput editorInput, @NotNull final Document document,
final boolean overwrite, @NotNull final AsyncCallback<EditorInput> callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocumentReadyHandler> {

/** The type instance for this event. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.google.gwt.event.shared.EventHandler;

@Deprecated
public interface DocumentReadyHandler extends EventHandler {

void onDocumentReady(DocumentReadyEvent event);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <T> the type of the editor
*/
public abstract class AbstractEditorModule<T extends EditorWidget> implements EditorModule<T> {

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<EditorModuleReadyCallback> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
/**
* Handle on an editor view instance.
*/
@Deprecated
public interface EditorHandle {

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Composite callback that waits for both the editor module initialization and the document content.
* @param <T> the type of the editor widget
*/
@Deprecated
abstract class EditorInitCallback<T extends EditorWidget> implements DocumentCallback, EditorModule.EditorModuleReadyCallback {

/** Loader used to wait for editor impl initialization. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

/**
* Front for an editor module, that allows to be warned when it's initialized.
* @param <T> the type of the editor widget.
*/
@Deprecated
public interface EditorModule {
public interface EditorModule<T extends EditorWidget> {

/**
* Tells if the editor module is initialized.
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public interface TextEditor extends EditorPartPresenter {
*/
TextEditorPartView getView();

/**
* @return the text editor widget
*/
EditorWidget getEditorWidget();

/**
* Add an editor-specific key binding.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* @author "Mickaël Leduque"
*/
@Deprecated
class TextEditorCursorModel implements CursorModelWithHandler, CursorActivityHandler {

private final Document document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends EditorWidget> {

/** The logger. */
Expand Down Expand Up @@ -106,13 +105,6 @@ public void initialize(final DocumentHandle documentHandle, final TextEditorInit
new DocReadyWrapper<TextEditorInit<T>>(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
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Loading

0 comments on commit 94f04e6

Please sign in to comment.