use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class EditorAgentImpl method doSave.
private void doSave(final AsyncCallback callback) {
final EditorPartPresenter partPresenter = dirtyEditors.get(0);
partPresenter.doSave(new AsyncCallback<EditorInput>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(EditorInput result) {
dirtyEditors.remove(partPresenter);
if (dirtyEditors.isEmpty()) {
callback.onSuccess("Success");
} else {
doSave(callback);
}
}
});
}
use of org.eclipse.che.ide.api.editor.EditorInput in project che by eclipse.
the class SaveAllAction method save.
private void save(final List<EditorPartPresenter> editors) {
if (editors.isEmpty()) {
return;
}
final EditorPartPresenter editorPartPresenter = editors.get(0);
if (editorPartPresenter.isDirty()) {
editorPartPresenter.doSave(new AsyncCallback<EditorInput>() {
@Override
public void onFailure(Throwable caught) {
Log.error(SaveAllAction.class, caught);
//try to save other files
editors.remove(editorPartPresenter);
save(editors);
}
@Override
public void onSuccess(EditorInput result) {
editors.remove(editorPartPresenter);
save(editors);
}
});
} else {
editors.remove(editorPartPresenter);
save(editors);
}
}
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());
}
Aggregations