Search in sources :

Example 21 with TextEditor

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

the class FindReferencesAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    //TODO replace this
    if (!(activeEditor instanceof TextEditor)) {
        return;
    }
    TextEditor textEditor = ((TextEditor) activeEditor);
    String path = activeEditor.getEditorInput().getFile().getLocation().toString();
    ReferenceParamsDTO paramsDTO = dtoFactory.createDto(ReferenceParamsDTO.class);
    PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
    positionDTO.setLine(textEditor.getCursorPosition().getLine());
    positionDTO.setCharacter(textEditor.getCursorPosition().getCharacter());
    TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
    identifierDTO.setUri(path);
    ReferenceContextDTO contextDTO = dtoFactory.createDto(ReferenceContextDTO.class);
    contextDTO.setIncludeDeclaration(true);
    paramsDTO.setUri(path);
    paramsDTO.setPosition(positionDTO);
    paramsDTO.setTextDocument(identifierDTO);
    paramsDTO.setContext(contextDTO);
    Promise<List<LocationDTO>> promise = client.references(paramsDTO);
    presenter.openLocation(promise);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) ReferenceContextDTO(org.eclipse.che.api.languageserver.shared.lsapi.ReferenceContextDTO) TextDocumentIdentifierDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO) ReferenceParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) PositionDTO(org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)

Example 22 with TextEditor

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

the class EditorPartStackView method selectTab.

/** {@inheritDoc} */
@Override
public void selectTab(@NotNull PartPresenter partPresenter) {
    IsWidget view = partPresenter.getView();
    // set/remove attribute 'active' for Selenium tests
    for (int i = 0; i < contentPanel.getWidgetCount(); i++) {
        contentPanel.getWidget(i).getElement().removeAttribute("active");
    }
    view.asWidget().getElement().setAttribute("active", "");
    int viewIndex = contentPanel.getWidgetIndex(view);
    if (viewIndex < 0) {
        partPresenter.go(partViewContainer);
        viewIndex = contentPanel.getWidgetIndex(view);
    }
    contentPanel.showWidget(viewIndex);
    setActiveTab(partPresenter);
    if (partPresenter instanceof TextEditor) {
        ((TextEditor) partPresenter).activate();
    }
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor)

Example 23 with TextEditor

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

the class OrganizeImportsPresenter method onFinishButtonClicked.

/** {@inheritDoc} */
@Override
public void onFinishButtonClicked() {
    selected.put(page, view.getSelectedImport());
    ConflictImportDTO result = dtoFactory.createDto(ConflictImportDTO.class).withTypeMatches(new ArrayList<>(selected.values()));
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        javaCodeAssistClient.applyChosenImports(project.get().getLocation().toString(), JavaUtil.resolveFQN(file), result).then(new Operation<List<Change>>() {

            @Override
            public void apply(List<Change> result) throws OperationException {
                applyChanges(((TextEditor) editor).getDocument(), result);
                view.hide();
                ((TextEditor) editor).setFocus();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                String title = locale.failedToProcessOrganizeImports();
                String message = arg.getMessage();
                notificationManager.notify(title, message, FAIL, FLOAT_MODE);
            }
        });
    }
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Change(org.eclipse.che.ide.ext.java.shared.dto.Change) Project(org.eclipse.che.ide.api.resources.Project) ConflictImportDTO(org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 24 with TextEditor

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

the class JsJavaEditorProvider method getEditor.

@Override
public TextEditor getEditor() {
    LOG.fine("JsJavaEditor instance creation.");
    final TextEditor textEditor = super.getEditor();
    if (textEditor instanceof OrionEditorPresenter) {
        final OrionEditorPresenter editor = (OrionEditorPresenter) textEditor;
        final TextEditorConfiguration configuration = configurationFactory.create(editor);
        editor.initialize(configuration);
        editor.addEditorUpdateAction(new EditorUpdateAction() {

            @Override
            public void doRefresh() {
                final Reconciler reconciler = configuration.getReconciler();
                if (reconciler != null) {
                    final ReconcilingStrategy strategy = reconciler.getReconcilingStrategy(DEFAULT_CONTENT_TYPE);
                    if (strategy instanceof JavaReconcilerStrategy) {
                        ((JavaReconcilerStrategy) strategy).parse();
                    }
                }
            }
        });
    }
    watcher.editorOpened(textEditor);
    return textEditor;
}
Also used : ReconcilingStrategy(org.eclipse.che.ide.api.editor.reconciler.ReconcilingStrategy) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) Reconciler(org.eclipse.che.ide.api.editor.reconciler.Reconciler) EditorUpdateAction(org.eclipse.che.ide.api.editor.editorconfig.EditorUpdateAction) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration) OrionEditorPresenter(org.eclipse.che.ide.editor.orion.client.OrionEditorPresenter)

Example 25 with TextEditor

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

the class FileStructurePresenter method show.

/**
     * Shows the structure of the opened class.
     *
     * @param editorPartPresenter
     *         the active editor
     */
public void show(EditorPartPresenter editorPartPresenter) {
    loader.show();
    view.setTitle(editorPartPresenter.getEditorInput().getFile().getName());
    if (!(editorPartPresenter instanceof TextEditor)) {
        Log.error(getClass(), "Open Declaration support only TextEditor as editor");
        return;
    }
    activeEditor = ((TextEditor) editorPartPresenter);
    cursorOffset = activeEditor.getCursorOffset();
    VirtualFile file = activeEditor.getEditorInput().getFile();
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
        if (!srcFolder.isPresent()) {
            return;
        }
        final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
        javaNavigationService.getCompilationUnit(project.get().getLocation(), fqn, showInheritedMembers).then(new Operation<CompilationUnit>() {

            @Override
            public void apply(CompilationUnit unit) throws OperationException {
                view.setStructure(unit, showInheritedMembers);
                showInheritedMembers = !showInheritedMembers;
                loader.hide();
                view.show();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(FileStructurePresenter.class, arg.getMessage());
                loader.hide();
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) CompilationUnit(org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

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