Search in sources :

Example 56 with EditorPartPresenter

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

the class JavaFormatter method applyChanges.

private void applyChanges(List<Change> changes, Document document) {
    HandlesUndoRedo undoRedo = null;
    EditorPartPresenter editorPartPresenter = editorAgent.getActiveEditor();
    if (editorPartPresenter instanceof UndoableEditor) {
        undoRedo = ((UndoableEditor) editorPartPresenter).getUndoRedo();
    }
    try {
        if (undoRedo != null) {
            undoRedo.beginCompoundChange();
        }
        for (Change change : changes) {
            document.replace(change.getOffset(), change.getLength(), change.getText());
        }
    } catch (final Exception e) {
        Log.error(getClass(), e);
    } finally {
        if (undoRedo != null) {
            undoRedo.endCompoundChange();
        }
    }
}
Also used : HandlesUndoRedo(org.eclipse.che.ide.api.editor.texteditor.HandlesUndoRedo) UndoableEditor(org.eclipse.che.ide.api.editor.texteditor.UndoableEditor) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) Change(org.eclipse.che.ide.ext.java.shared.dto.Change) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 57 with EditorPartPresenter

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

the class ParametersHintsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (!(activeEditor instanceof TextEditor)) {
        return;
    }
    parametersHintsPresenter.show((TextEditor) activeEditor);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 58 with EditorPartPresenter

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

the class QuickDocumentationAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor == null) {
        return;
    }
    if (activeEditor instanceof TextEditor && activeEditor instanceof HasCompletionInformation) {
        if (((TextEditor) activeEditor).getEditorWidget().isCompletionProposalsShowing()) {
            ((HasCompletionInformation) activeEditor).showCompletionInformation();
            return;
        }
    }
    quickDocumentation.showDocumentation();
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) HasCompletionInformation(org.eclipse.che.ide.api.editor.codeassist.HasCompletionInformation) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 59 with EditorPartPresenter

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

the class BreakpointManagerImpl method setCurrentBreakpoint.

private void setCurrentBreakpoint(String filePath, int lineNumber) {
    deleteCurrentBreakpoint();
    EditorPartPresenter editor = getEditorForFile(filePath);
    if (editor != null) {
        VirtualFile activeFile = editor.getEditorInput().getFile();
        doSetCurrentBreakpoint(activeFile, lineNumber);
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 60 with EditorPartPresenter

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

the class EditorAgentImpl method onActivePartChanged.

@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
    activePart = event.getActivePart();
    if (!(event.getActivePart() instanceof EditorPartPresenter)) {
        return;
    }
    activeEditor = (EditorPartPresenter) event.getActivePart();
    activeEditor.activate();
    final String isLinkedWithEditor = preferencesManager.getValue(LinkWithEditorAction.LINK_WITH_EDITOR);
    if (parseBoolean(isLinkedWithEditor)) {
        final VirtualFile file = activeEditor.getEditorInput().getFile();
        eventBus.fireEvent(new RevealResourceEvent(file.getLocation()));
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) RevealResourceEvent(org.eclipse.che.ide.resources.reveal.RevealResourceEvent)

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