-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "#1913 Deprecates some of Editor API classes and interfaces"
This reverts commit cc51c0e.
- Loading branch information
1 parent
4ca6074
commit 94f04e6
Showing
54 changed files
with
480 additions
and
1,602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...ide-api/src/main/java/org/eclipse/che/ide/api/editor/texteditor/AbstractEditorModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
/** | ||
* Handle on an editor view instance. | ||
*/ | ||
@Deprecated | ||
public interface EditorHandle { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.