use of org.eclipse.che.ide.api.editor.EditorPartPresenter 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.editor.EditorPartPresenter in project che by eclipse.
the class EditorContentSynchronizerImplTest method shouldUpdatePathForGroupWhenFolderLocationIsChanged.
@Test
public void shouldUpdatePathForGroupWhenFolderLocationIsChanged() {
Resource resource = mock(Resource.class);
ResourceDelta delta = mock(ResourceDelta.class);
ResourceChangedEvent resourceChangedEvent = new ResourceChangedEvent(delta);
Path fromPath = new Path(FOLDER_PATH);
Path toPath = new Path("testProject/src/main/java/org/eclipse/che/samples/");
Path oldFilePath = new Path(FILE_PATH);
Path newFilePath = new Path("testProject/src/main/java/org/eclipse/che/samples/" + FILE_NAME);
EditorPartPresenter openedEditor1 = mock(EditorPartPresenter.class);
when(openedEditor1.getEditorInput()).thenReturn(editorInput);
when(delta.getKind()).thenReturn(ResourceDelta.ADDED);
when(delta.getFlags()).thenReturn(5632);
when(delta.getFromPath()).thenReturn(fromPath);
when(delta.getToPath()).thenReturn(toPath);
when(delta.getResource()).thenReturn(resource);
when(resource.isFile()).thenReturn(false);
editorContentSynchronizer.trackEditor(openedEditor1);
editorContentSynchronizer.onResourceChanged(resourceChangedEvent);
final EditorGroupSynchronization oldGroup = editorContentSynchronizer.editorGroups.get(oldFilePath);
final EditorGroupSynchronization newGroup = editorContentSynchronizer.editorGroups.get(newFilePath);
assertNull(oldGroup);
assertNotNull(newGroup);
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorContentSynchronizerImplTest method shouldRemoveGroup.
@Test
public void shouldRemoveGroup() {
EditorPartPresenter openedEditor1 = mock(EditorPartPresenter.class);
when(openedEditor1.getEditorInput()).thenReturn(editorInput);
editorContentSynchronizer.trackEditor(openedEditor1);
editorContentSynchronizer.trackEditor(activeEditor);
editorContentSynchronizer.unTrackEditor(activeEditor);
verify(editorGroupSynchronization).removeEditor(activeEditor);
verify(editorGroupSynchronization).unInstall();
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorContentSynchronizerImplTest method shouldRemoveEditorFromGroup.
@Test
public void shouldRemoveEditorFromGroup() {
EditorPartPresenter openedEditor1 = mock(EditorPartPresenter.class);
EditorPartPresenter openedEditor2 = mock(EditorPartPresenter.class);
when(openedEditor1.getEditorInput()).thenReturn(editorInput);
when(openedEditor2.getEditorInput()).thenReturn(editorInput);
editorContentSynchronizer.trackEditor(openedEditor1);
editorContentSynchronizer.trackEditor(openedEditor2);
editorContentSynchronizer.trackEditor(activeEditor);
editorContentSynchronizer.unTrackEditor(activeEditor);
verify(editorGroupSynchronization).removeEditor(activeEditor);
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorPartStackPresenterTest method shouldReturnFirstPart.
@Test
public void shouldReturnFirstPart() {
presenter.addPart(partPresenter1);
presenter.addPart(partPresenter2);
presenter.addPart(partPresenter3);
EditorPartPresenter result = presenter.getNextFor(partPresenter3);
assertNotNull(result);
assertEquals(partPresenter1, result);
}
Aggregations