Search in sources :

Example 71 with EditorPartPresenter

use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.

the class AppContextImpl method onWorkspaceStopped.

@Override
public void onWorkspaceStopped(WorkspaceStoppedEvent event) {
    appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> {
        for (Project project : projects) {
            eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED)));
        }
        projects = NO_PROJECTS;
        resourceManager = null;
    });
    //goto close all editors
    final EditorAgent editorAgent = editorAgentProvider.get();
    final List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
    for (EditorPartPresenter editor : openedEditors) {
        editorAgent.closeEditor(editor);
    }
    runtime = null;
}
Also used : ResourceDeltaImpl(org.eclipse.che.ide.resources.impl.ResourceDeltaImpl) Project(org.eclipse.che.ide.api.resources.Project) EditorAgent(org.eclipse.che.ide.api.editor.EditorAgent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 72 with EditorPartPresenter

use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.

the class EditorAgentImpl method doSave.

private void doSave(final AsyncCallback callback) {
    final EditorPartPresenter partPresenter = dirtyEditors.get(0);
    partPresenter.doSave(new AsyncCallback<EditorInput>() {

        @Override
        public void onFailure(Throwable caught) {
            callback.onFailure(caught);
        }

        @Override
        public void onSuccess(EditorInput result) {
            dirtyEditors.remove(partPresenter);
            if (dirtyEditors.isEmpty()) {
                callback.onSuccess("Success");
            } else {
                doSave(callback);
            }
        }
    });
}
Also used : EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorInput(org.eclipse.che.ide.api.editor.EditorInput)

Example 73 with EditorPartPresenter

use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.

the class SaveAction method updateProjectAction.

@Override
public void updateProjectAction(ActionEvent e) {
    EditorPartPresenter editor = editorAgent.getActiveEditor();
    if (editor != null) {
        if (editor instanceof EditorWithAutoSave) {
            if (((EditorWithAutoSave) editor).isAutoSaveEnabled()) {
                e.getPresentation().setEnabledAndVisible(false);
                return;
            }
        }
        e.getPresentation().setVisible(true);
        e.getPresentation().setEnabled(editor.isDirty());
    } else {
        e.getPresentation().setEnabledAndVisible(false);
    }
}
Also used : EditorWithAutoSave(org.eclipse.che.ide.api.editor.EditorWithAutoSave) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 74 with EditorPartPresenter

use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.

the class SaveAllAction method save.

private void save(final List<EditorPartPresenter> editors) {
    if (editors.isEmpty()) {
        return;
    }
    final EditorPartPresenter editorPartPresenter = editors.get(0);
    if (editorPartPresenter.isDirty()) {
        editorPartPresenter.doSave(new AsyncCallback<EditorInput>() {

            @Override
            public void onFailure(Throwable caught) {
                Log.error(SaveAllAction.class, caught);
                //try to save other files
                editors.remove(editorPartPresenter);
                save(editors);
            }

            @Override
            public void onSuccess(EditorInput result) {
                editors.remove(editorPartPresenter);
                save(editors);
            }
        });
    } else {
        editors.remove(editorPartPresenter);
        save(editors);
    }
}
Also used : EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorInput(org.eclipse.che.ide.api.editor.EditorInput)

Example 75 with EditorPartPresenter

use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.

the class SignatureHelpAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    final EditorPartPresenter editor = editorAgent.getActiveEditor();
    boolean isCanDoOperation = false;
    HandlesTextOperations handlesOperations;
    if (editor instanceof HandlesTextOperations) {
        handlesOperations = (HandlesTextOperations) editor;
        isCanDoOperation = handlesOperations.canDoOperation(TextEditorOperations.SIGNATURE_HELP);
    }
    event.getPresentation().setEnabledAndVisible(isCanDoOperation);
}
Also used : HandlesTextOperations(org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)79 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)21 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)19 OperationException (org.eclipse.che.api.promises.client.OperationException)13 Project (org.eclipse.che.ide.api.resources.Project)13 Resource (org.eclipse.che.ide.api.resources.Resource)11 Test (org.junit.Test)10 Operation (org.eclipse.che.api.promises.client.Operation)9 Path (org.eclipse.che.ide.resource.Path)8 File (org.eclipse.che.ide.api.resources.File)7 Scheduler (com.google.gwt.core.client.Scheduler)6 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)6 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)6 Optional (com.google.common.base.Optional)5 OpenEditorCallbackImpl (org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl)5 LanguageServerEditorConfiguration (org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration)5 HandlesTextOperations (org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations)4 ResourceDelta (org.eclipse.che.ide.api.resources.ResourceDelta)4 ClassContent (org.eclipse.che.ide.ext.java.shared.dto.ClassContent)4 JsonObject (elemental.json.JsonObject)3