Search in sources :

Example 1 with EditorInput

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

Example 2 with EditorInput

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

Example 3 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 4 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)

Example 5 with EditorInput

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

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