Search in sources :

Example 31 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor 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 32 with TextEditor

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

the class EditorAgentImpl method finalizeInit.

private void finalizeInit(final VirtualFile file, final OpenEditorCallback callback, final EditorPartPresenter editor, EditorProvider editorProvider) {
    openedEditors.add(editor);
    openedEditorsToProviders.put(editor, editorProvider.getId());
    workspaceAgent.setActivePart(editor);
    editor.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            if (propId == EditorPartPresenter.PROP_INPUT) {
                if (editor instanceof HasReadOnlyProperty) {
                    ((HasReadOnlyProperty) editor).setReadOnly(file.isReadOnly());
                }
                if (editor instanceof TextEditor) {
                    editorContentSynchronizerProvider.get().trackEditor(editor);
                }
                callback.onEditorOpened(editor);
                eventBus.fireEvent(new EditorOpenedEvent(file, editor));
            }
        }
    });
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) HasReadOnlyProperty(org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 33 with TextEditor

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

the class EditorAgentImpl method storeEditors.

private JsonArray storeEditors(EditorPartStack partStack) {
    JsonArray result = Json.createArray();
    int i = 0;
    List<EditorPartPresenter> parts = partStack.getParts();
    for (EditorPartPresenter part : parts) {
        JsonObject file = Json.createObject();
        file.put("PATH", part.getEditorInput().getFile().getLocation().toString());
        file.put("EDITOR_PROVIDER", openedEditorsToProviders.get(part));
        if (part instanceof TextEditor) {
            file.put("CURSOR_OFFSET", ((TextEditor) part).getCursorOffset());
            file.put("TOP_VISIBLE_LINE", ((TextEditor) part).getTopVisibleLine());
        }
        if (partStack.getActivePart().equals(part)) {
            file.put("ACTIVE", true);
        }
        result.set(i++, file);
    }
    return result;
}
Also used : JsonArray(elemental.json.JsonArray) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) JsonObject(elemental.json.JsonObject) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)33 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)21 Project (org.eclipse.che.ide.api.resources.Project)8 Resource (org.eclipse.che.ide.api.resources.Resource)8 OperationException (org.eclipse.che.api.promises.client.OperationException)7 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)7 Operation (org.eclipse.che.api.promises.client.Operation)6 Document (org.eclipse.che.ide.api.editor.document.Document)5 TextEditorConfiguration (org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)5 LanguageServerEditorConfiguration (org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)4 File (org.eclipse.che.ide.api.resources.File)4 Optional (com.google.common.base.Optional)3 ServerCapabilities (io.typefox.lsapi.ServerCapabilities)3 TextDocumentPositionParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO)3 Collections.singletonList (java.util.Collections.singletonList)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)2 JsPromise (org.eclipse.che.api.promises.client.js.JsPromise)2