Search in sources :

Example 6 with EditorInput

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);
            }
        }
    });
}
Also used : EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorInput(org.eclipse.che.ide.api.editor.EditorInput)

Example 7 with EditorInput

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);
    }
}
Also used : EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EditorInput(org.eclipse.che.ide.api.editor.EditorInput)

Example 8 with EditorInput

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);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) FileType(org.eclipse.che.ide.api.filetypes.FileType) EditorInput(org.eclipse.che.ide.api.editor.EditorInput) Test(org.junit.Test)

Example 9 with EditorInput

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());
}
Also used : FileType(org.eclipse.che.ide.api.filetypes.FileType) EditorInput(org.eclipse.che.ide.api.editor.EditorInput) Test(org.junit.Test)

Aggregations

EditorInput (org.eclipse.che.ide.api.editor.EditorInput)9 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)4 Test (org.junit.Test)4 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)3 FileType (org.eclipse.che.ide.api.filetypes.FileType)2 Optional (com.google.common.base.Optional)1 ArrayList (java.util.ArrayList)1 Document (org.eclipse.che.ide.api.editor.document.Document)1 Container (org.eclipse.che.ide.api.resources.Container)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ChangeInfo (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeInfo)1 RevealResourceEvent (org.eclipse.che.ide.resources.reveal.RevealResourceEvent)1 Before (org.junit.Before)1