Search in sources :

Example 1 with VirtualFile

use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.

the class BreakpointManagerImpl method reAddBreakpointMark.

private void reAddBreakpointMark(BreakpointRenderer breakpointRenderer, Breakpoint breakpoint) {
    int lineNumber = breakpoint.getLineNumber();
    breakpointRenderer.addBreakpointMark(lineNumber, new LineChangeAction() {

        @Override
        public void onLineChange(VirtualFile file, int firstLine, int linesAdded, int linesRemoved) {
            BreakpointManagerImpl.this.onLineChange(file, firstLine, linesAdded, linesRemoved);
        }
    });
    breakpointRenderer.setBreakpointActive(lineNumber, breakpoint.isActive());
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) LineChangeAction(org.eclipse.che.ide.api.debug.BreakpointRenderer.LineChangeAction) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint)

Example 2 with VirtualFile

use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.

the class BreakpointManagerImpl method changeBreakpointState.

@Override
public void changeBreakpointState(final int lineNumber) {
    EditorPartPresenter editor = editorAgent.getActiveEditor();
    if (editor == null) {
        return;
    }
    final VirtualFile activeFile = editor.getEditorInput().getFile();
    List<Breakpoint> pathBreakpoints = breakpoints.get(activeFile.getLocation().toString());
    if (pathBreakpoints != null) {
        for (final Breakpoint breakpoint : pathBreakpoints) {
            if (breakpoint.getLineNumber() == lineNumber) {
                // breakpoint already exists at given line
                deleteBreakpoint(activeFile, breakpoint);
                return;
            }
        }
    }
    if (isLineNotEmpty(activeFile, lineNumber)) {
        Breakpoint breakpoint = new Breakpoint(BREAKPOINT, lineNumber, activeFile.getLocation().toString(), activeFile, false);
        addBreakpoint(breakpoint);
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 3 with VirtualFile

use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.

the class LanguageServerEditorProvider method createEditor.

@Override
public Promise<EditorPartPresenter> createEditor(VirtualFile file) {
    if (file instanceof File) {
        File resource = (File) file;
        Promise<InitializeResult> promise = registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
        final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
        loader.show();
        return promise.thenPromise(new Function<InitializeResult, Promise<EditorPartPresenter>>() {

            @Override
            public Promise<EditorPartPresenter> apply(InitializeResult arg) throws FunctionException {
                loader.hide();
                return Promises.<EditorPartPresenter>resolve(createEditor(editorConfigurationFactory.build(arg.getCapabilities())));
            }
        });
    }
    return null;
}
Also used : Promise(org.eclipse.che.api.promises.client.Promise) InitializeResult(io.typefox.lsapi.InitializeResult) MessageLoader(org.eclipse.che.ide.ui.loaders.request.MessageLoader) FunctionException(org.eclipse.che.api.promises.client.FunctionException) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Example 4 with VirtualFile

use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.

the class EditorPartStackPresenter method addPart.

/** {@inheritDoc} */
@Override
public void addPart(@NotNull PartPresenter part) {
    checkArgument(part instanceof AbstractEditorPresenter, "Can not add part " + part.getTitle() + " to editor part stack");
    EditorPartPresenter editorPart = (AbstractEditorPresenter) part;
    if (containsPart(editorPart)) {
        setActivePart(editorPart);
        return;
    }
    VirtualFile file = editorPart.getEditorInput().getFile();
    checkArgument(file != null, "File doesn't provided");
    addHandlers();
    updateListClosedParts(file);
    editorPart.addPropertyListener(propertyListener);
    final EditorTab editorTab = tabItemFactory.createEditorPartButton(editorPart, this);
    editorPart.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            if (propId == EditorPartPresenter.PROP_INPUT && source instanceof EditorPartPresenter) {
                editorTab.setReadOnlyMark(((EditorPartPresenter) source).getEditorInput().getFile().isReadOnly());
            }
        }
    });
    editorTab.setDelegate(this);
    parts.put(editorTab, editorPart);
    partsOrder.add(editorPart);
    view.addTab(editorTab, editorPart);
    TabItem tabItem = getTabByPart(editorPart);
    if (tabItem != null) {
        final EditorPaneMenuItem<TabItem> item = editorPaneMenuItemFactory.createMenuItem(tabItem);
        item.setDelegate(paneMenuTabItemHandler);
        editorPaneMenu.addItem(item);
        items.put(item, tabItem);
    }
    if (editorPart instanceof EditorWithErrors) {
        final EditorWithErrors presenter = ((EditorWithErrors) editorPart);
        editorPart.addPropertyListener(new PropertyListener() {

            @Override
            public void propertyChanged(PartPresenter source, int propId) {
                EditorState editorState = presenter.getErrorState();
                editorTab.setErrorMark(ERROR.equals(editorState));
                editorTab.setWarningMark(WARNING.equals(editorState));
            }
        });
    }
    view.selectTab(editorPart);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorTab(org.eclipse.che.ide.api.parts.EditorTab) TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) EditorWithErrors(org.eclipse.che.ide.api.editor.EditorWithErrors) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) EditorState(org.eclipse.che.ide.api.editor.EditorWithErrors.EditorState) AbstractEditorPresenter(org.eclipse.che.ide.api.editor.AbstractEditorPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 5 with VirtualFile

use of org.eclipse.che.ide.api.resources.VirtualFile in project che by eclipse.

the class PreviewPresenterTest method acceptButtonActionShouldBeNotPerformedIfStatusIsNotOK.

@Test
public void acceptButtonActionShouldBeNotPerformedIfStatusIsNotOK() throws Exception {
    VirtualFile virtualFile = Mockito.mock(VirtualFile.class);
    EditorInput editorInput = Mockito.mock(EditorInput.class);
    when(refactoringStatus.getSeverity()).thenReturn(2);
    when(editor.getEditorInput()).thenReturn(editorInput);
    when(editorInput.getFile()).thenReturn(virtualFile);
    presenter.onAcceptButtonClicked();
    verify(refactoringStatusPromise).then(refactoringStatusOperation.capture());
    refactoringStatusOperation.getValue().apply(refactoringStatus);
    verify(view, never()).hide();
    verify(editor, never()).getEditorInput();
    verify(editorInput, never()).getFile();
    verify(virtualFile, never()).getLocation();
    verify(view).showErrorMessage(refactoringStatus);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorInput(org.eclipse.che.ide.api.editor.EditorInput) Test(org.junit.Test)

Aggregations

VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)48 Project (org.eclipse.che.ide.api.resources.Project)21 Resource (org.eclipse.che.ide.api.resources.Resource)19 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)18 OperationException (org.eclipse.che.api.promises.client.OperationException)15 Operation (org.eclipse.che.api.promises.client.Operation)14 PromiseError (org.eclipse.che.api.promises.client.PromiseError)9 File (org.eclipse.che.ide.api.resources.File)8 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)6 Test (org.junit.Test)6 Optional (com.google.common.base.Optional)5 Scheduler (com.google.gwt.core.client.Scheduler)4 HashMap (java.util.HashMap)4 EditorInput (org.eclipse.che.ide.api.editor.EditorInput)4 OpenEditorCallbackImpl (org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl)4 JarEntry (org.eclipse.che.ide.ext.java.shared.JarEntry)4 ClassContent (org.eclipse.che.ide.ext.java.shared.dto.ClassContent)4 Path (org.eclipse.che.ide.resource.Path)4 Breakpoint (org.eclipse.che.ide.api.debug.Breakpoint)3 JarFileNode (org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode)3