use of org.eclipse.che.ide.api.editor.EditorInput 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);
}
use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class LinkWithEditorAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final String linkWithEditorValue = preferencesManager.getValue(LINK_WITH_EDITOR);
boolean value = !parseBoolean(linkWithEditorValue);
preferencesManager.setValue(LINK_WITH_EDITOR, Boolean.toString(value));
if (!value) {
return;
}
final EditorPartPresenter activeEditor = editorAgentProvider.get().getActiveEditor();
if (activeEditor == null) {
return;
}
final EditorInput editorInput = activeEditor.getEditorInput();
if (editorInput == null) {
return;
}
eventBus.fireEvent(new RevealResourceEvent(editorInput.getFile().getLocation()));
}
use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class EditorTabWidgetTest method virtualFileShouldBeUpdated.
@Test
public void virtualFileShouldBeUpdated() throws Exception {
EditorInput editorInput = mock(EditorInput.class);
FileType fileType = mock(FileType.class);
VirtualFile newFile = mock(VirtualFile.class);
when(editorPartPresenter.getEditorInput()).thenReturn(editorInput);
when(fileTypeRegistry.getFileTypeByFile(newFile)).thenReturn(fileType);
when(fileType.getImage()).thenReturn(icon);
when(editorInput.getFile()).thenReturn(newFile);
assertNotEquals(tab.getFile(), newFile);
tab.update(editorPartPresenter);
assertEquals(tab.getFile(), newFile);
}
use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class EditorTabWidgetTest method tabIconShouldBeUpdatedWhenMediaTypeChanged.
@Test
public void tabIconShouldBeUpdatedWhenMediaTypeChanged() {
EditorInput editorInput = mock(EditorInput.class);
FileType fileType = mock(FileType.class);
when(editorPartPresenter.getEditorInput()).thenReturn(editorInput);
when(fileTypeRegistry.getFileTypeByFile(file)).thenReturn(fileType);
when(fileType.getImage()).thenReturn(icon);
when(editorInput.getFile()).thenReturn(file);
tab.update(editorPartPresenter);
verify(editorPartPresenter, times(2)).getEditorInput();
verify(fileTypeRegistry).getFileTypeByFile(file);
verify(tab.iconPanel).setWidget(Matchers.<SVGImage>anyObject());
}
use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class JavaEditorAction method updateProjectAction.
@Override
protected void updateProjectAction(ActionEvent e) {
if (editorAgent.getActiveEditor() != null) {
EditorInput input = editorAgent.getActiveEditor().getEditorInput();
VirtualFile file = input.getFile();
final String fileExtension = fileTypeRegistry.getFileTypeByFile(file).getExtension();
if ("java".equals(fileExtension) || "class".equals(fileExtension)) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
}
e.getPresentation().setEnabledAndVisible(false);
}
Aggregations