Search in sources :

Example 6 with PartPresenter

use of org.eclipse.che.ide.api.parts.PartPresenter in project che by eclipse.

the class EditorContentSynchronizerImpl method onActivePartChanged.

@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
    PartPresenter activePart = event.getActivePart();
    if (!(activePart instanceof EditorPartPresenter)) {
        return;
    }
    EditorPartPresenter activeEditor = (EditorPartPresenter) activePart;
    Path path = activeEditor.getEditorInput().getFile().getLocation();
    if (editorGroups.containsKey(path)) {
        editorGroups.get(path).onActiveEditorChanged(activeEditor);
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 7 with PartPresenter

use of org.eclipse.che.ide.api.parts.PartPresenter in project che by eclipse.

the class EditorMultiPartStackPresenter method onActivePartChanged.

@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
    PartPresenter activePart = event.getActivePart();
    if (activePart instanceof EditorPartPresenter) {
        activeEditor = activePart;
        activeEditorPartStack = getPartStackByPart(activePart);
    }
}
Also used : PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 8 with PartPresenter

use of org.eclipse.che.ide.api.parts.PartPresenter in project che by eclipse.

the class RecipeEditorPanel method initializeEditor.

private void initializeEditor(@NotNull final VirtualFile file) {
    FileType fileType = fileTypeRegistry.getFileTypeByFile(file);
    editor = getEditor();
    editor.activate();
    editor.onOpen();
    view.showEditor(editor);
    // wait when editor is initialized
    editor.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            switch(propId) {
                case PROP_INPUT:
                    view.showEditor(editor);
                    break;
                case PROP_DIRTY:
                    if (validateUndoOperation()) {
                        setEnableSaveAndCancelButtons(true);
                    }
                    break;
                default:
            }
        }
    });
    editor.init(new RecipeEditorInput(fileType, file), new OpenEditorCallbackImpl());
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) OpenEditorCallbackImpl(org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 9 with PartPresenter

use of org.eclipse.che.ide.api.parts.PartPresenter in project che by eclipse.

the class AbstractPerspective method loadState.

@Override
public void loadState(@NotNull JsonObject state) {
    if (state.hasKey("PART_STACKS")) {
        JsonObject part_stacks = state.getObject("PART_STACKS");
        for (String partStackType : part_stacks.keys()) {
            JsonObject partStack = part_stacks.getObject(partStackType);
            switch(PartStackType.valueOf(partStackType)) {
                case INFORMATION:
                    restorePartController(partStacks.get(INFORMATION), belowPartController, partStack);
                    break;
                case NAVIGATION:
                    restorePartController(partStacks.get(NAVIGATION), leftPartController, partStack);
                    break;
                case TOOLING:
                    restorePartController(partStacks.get(TOOLING), rightPartController, partStack);
                    break;
            }
        }
    }
    if (state.hasKey("ACTIVE_PART")) {
        String activePart = state.getString("ACTIVE_PART");
        Provider<PartPresenter> provider = dynaProvider.getProvider(activePart);
        if (provider != null) {
            setActivePart(provider.get());
        }
    }
}
Also used : JsonObject(elemental.json.JsonObject) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter)

Example 10 with PartPresenter

use of org.eclipse.che.ide.api.parts.PartPresenter in project che by eclipse.

the class FileWatcher method editorOpened.

public void editorOpened(final EditorPartPresenter editor) {
    final PropertyListener propertyListener = new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            if (propId == EditorPartPresenter.PROP_DIRTY) {
                if (!editor.isDirty()) {
                    reparseAllOpenedFiles();
                    //remove just saved editor
                    editor2reconcile.remove(editor);
                }
            }
        }
    };
    editor.addPropertyListener(propertyListener);
}
Also used : PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)16 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)9 JsonObject (elemental.json.JsonObject)6 JsonArray (elemental.json.JsonArray)4 PropertyListener (org.eclipse.che.ide.api.parts.PropertyListener)4 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)3 FileType (org.eclipse.che.ide.api.filetypes.FileType)2 EditorTab (org.eclipse.che.ide.api.parts.EditorTab)2 Path (org.eclipse.che.ide.resource.Path)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 HasDataObject (org.eclipse.che.ide.api.data.HasDataObject)1 AbstractEditorPresenter (org.eclipse.che.ide.api.editor.AbstractEditorPresenter)1 AsyncEditorProvider (org.eclipse.che.ide.api.editor.AsyncEditorProvider)1 EditorOpenedEvent (org.eclipse.che.ide.api.editor.EditorOpenedEvent)1 EditorProvider (org.eclipse.che.ide.api.editor.EditorProvider)1 EditorWithErrors (org.eclipse.che.ide.api.editor.EditorWithErrors)1 EditorState (org.eclipse.che.ide.api.editor.EditorWithErrors.EditorState)1