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());
}
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);
}
}
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;
}
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);
}
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);
}
Aggregations