use of org.eclipse.che.ide.api.editor.EditorWithErrors.EditorState 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);
}
Aggregations