Search in sources :

Example 6 with EditorPartPresenter

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

the class OrganizeImportsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final EditorPartPresenter editor = editorAgent.getActiveEditor();
    organizeImportsPresenter.organizeImports(editor);
}
Also used : EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 7 with EditorPartPresenter

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

the class FileWatcher method reparseAllOpenedFiles.

private void reparseAllOpenedFiles() {
    for (EditorPartPresenter editorPartPresenter : editorAgent.getOpenedEditors()) {
        if (editorPartPresenter instanceof TextEditor) {
            final TextEditor editor = (TextEditor) editorPartPresenter;
            editor.refreshEditor();
        }
    }
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 8 with EditorPartPresenter

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

the class FindDefinitionAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor instanceof TextEditor) {
        TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
        if (configuration instanceof LanguageServerEditorConfiguration) {
            ServerCapabilities capabilities = ((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
            event.getPresentation().setEnabledAndVisible(capabilities.isDefinitionProvider() != null && capabilities.isDefinitionProvider());
            return;
        }
    }
    event.getPresentation().setEnabledAndVisible(false);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) LanguageServerEditorConfiguration(org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration) ServerCapabilities(io.typefox.lsapi.ServerCapabilities)

Example 9 with EditorPartPresenter

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

the class FindReferencesAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor instanceof TextEditor) {
        TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
        if (configuration instanceof LanguageServerEditorConfiguration) {
            ServerCapabilities capabilities = ((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
            event.getPresentation().setEnabledAndVisible(capabilities.isReferencesProvider() != null && capabilities.isReferencesProvider());
            return;
        }
    }
    event.getPresentation().setEnabledAndVisible(false);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) LanguageServerEditorConfiguration(org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration) ServerCapabilities(io.typefox.lsapi.ServerCapabilities)

Example 10 with EditorPartPresenter

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

the class PublishDiagnosticsProcessor method processDiagnostics.

public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
    EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
    //TODO add markers
    if (openedEditor == null) {
        return;
    }
    if (openedEditor instanceof TextEditor) {
        TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
        AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
        if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
            DiagnosticCollector collector = (DiagnosticCollector) annotationModel;
            collector.beginReporting();
            try {
                for (DiagnosticDTO diagnostic : diagnosticsMessage.getDiagnostics()) {
                    collector.acceptDiagnostic(diagnostic);
                }
            } finally {
                collector.endReporting();
            }
        }
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) DiagnosticDTO(org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO) AnnotationModel(org.eclipse.che.ide.api.editor.annotation.AnnotationModel) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)

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