Search in sources :

Example 1 with ArrayOf

use of elemental.util.ArrayOf in project che by eclipse.

the class EditorAgentImpl method loadState.

@Override
@SuppressWarnings("unchecked")
public void loadState(@NotNull final JsonObject state) {
    if (state.hasKey("FILES")) {
        JsonObject files = state.getObject("FILES");
        EditorPartStack partStack = editorMultiPartStack.createRootPartStack();
        final Map<EditorPartPresenter, EditorPartStack> activeEditors = new HashMap<>();
        List<Promise<Void>> restore = restore(files, partStack, activeEditors);
        Promise<ArrayOf<?>> promise = promiseProvider.all2(restore.toArray(new Promise[restore.size()]));
        promise.then(new Operation() {

            @Override
            public void apply(Object arg) throws OperationException {
                String activeFile = "";
                if (state.hasKey("ACTIVE_EDITOR")) {
                    activeFile = state.getString("ACTIVE_EDITOR");
                }
                EditorPartPresenter activeEditorPart = null;
                for (Map.Entry<EditorPartPresenter, EditorPartStack> entry : activeEditors.entrySet()) {
                    entry.getValue().setActivePart(entry.getKey());
                    if (activeFile.equals(entry.getKey().getEditorInput().getFile().getLocation().toString())) {
                        activeEditorPart = entry.getKey();
                    }
                }
                workspaceAgent.setActivePart(activeEditorPart);
            }
        });
    }
}
Also used : ArrayOf(elemental.util.ArrayOf) HashMap(java.util.HashMap) JsonObject(elemental.json.JsonObject) Operation(org.eclipse.che.api.promises.client.Operation) Promise(org.eclipse.che.api.promises.client.Promise) HasDataObject(org.eclipse.che.ide.api.data.HasDataObject) JsonObject(elemental.json.JsonObject) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartStack(org.eclipse.che.ide.api.parts.EditorPartStack) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

JsonObject (elemental.json.JsonObject)1 ArrayOf (elemental.util.ArrayOf)1 HashMap (java.util.HashMap)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 Promise (org.eclipse.che.api.promises.client.Promise)1 HasDataObject (org.eclipse.che.ide.api.data.HasDataObject)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)1