Search in sources :

Example 1 with EditorTab

use of org.eclipse.che.ide.api.parts.EditorTab 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);
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) EditorTab(org.eclipse.che.ide.api.parts.EditorTab) TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) EditorWithErrors(org.eclipse.che.ide.api.editor.EditorWithErrors) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) EditorState(org.eclipse.che.ide.api.editor.EditorWithErrors.EditorState) AbstractEditorPresenter(org.eclipse.che.ide.api.editor.AbstractEditorPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 2 with EditorTab

use of org.eclipse.che.ide.api.parts.EditorTab in project che by eclipse.

the class EditorPartStackPresenter method getPartByPath.

@Nullable
public PartPresenter getPartByPath(Path path) {
    for (TabItem tab : parts.keySet()) {
        EditorTab editorTab = (EditorTab) tab;
        Path currentPath = editorTab.getFile().getLocation();
        if (currentPath.equals(path)) {
            return parts.get(tab);
        }
    }
    return null;
}
Also used : Path(org.eclipse.che.ide.resource.Path) TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) EditorTab(org.eclipse.che.ide.api.parts.EditorTab) Nullable(org.eclipse.che.commons.annotation.Nullable)

Example 3 with EditorTab

use of org.eclipse.che.ide.api.parts.EditorTab in project che by eclipse.

the class EditorPartStackPresenter method getTabByPath.

@Nullable
@Override
public EditorTab getTabByPath(@NotNull Path path) {
    for (TabItem tab : parts.keySet()) {
        EditorTab editorTab = (EditorTab) tab;
        Path currentPath = editorTab.getFile().getLocation();
        if (currentPath.equals(path)) {
            return editorTab;
        }
    }
    return null;
}
Also used : Path(org.eclipse.che.ide.resource.Path) TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) EditorTab(org.eclipse.che.ide.api.parts.EditorTab) Nullable(org.eclipse.che.commons.annotation.Nullable)

Example 4 with EditorTab

use of org.eclipse.che.ide.api.parts.EditorTab in project che by eclipse.

the class OrionEditorPresenter method updateTabReference.

private void updateTabReference(File file, Path oldPath) {
    final PartPresenter activePart = editorMultiPartStackPresenter.getActivePart();
    final EditorPartStack activePartStack = editorMultiPartStackPresenter.getPartStackByPart(activePart);
    if (activePartStack == null) {
        return;
    }
    final EditorTab editorTab = activePartStack.getTabByPath(oldPath);
    if (editorTab != null) {
        editorTab.setFile(file);
    }
}
Also used : EditorTab(org.eclipse.che.ide.api.parts.EditorTab) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartStack(org.eclipse.che.ide.api.parts.EditorPartStack)

Example 5 with EditorTab

use of org.eclipse.che.ide.api.parts.EditorTab in project che by eclipse.

the class EditorAgentImpl method closeEditor.

@Override
public void closeEditor(EditorPartPresenter editor) {
    if (editor == null) {
        return;
    }
    EditorPartStack editorPartStack = editorMultiPartStack.getPartStackByPart(editor);
    if (editorPartStack == null) {
        return;
    }
    EditorTab editorTab = editorPartStack.getTabByPart(editor);
    //we have the handlers for the closing file event in different places of the project
    //so we need to notify them about it (we can't just pass doClose() method)
    eventBus.fireEvent(FileEvent.createCloseFileEvent(editorTab));
}
Also used : EditorTab(org.eclipse.che.ide.api.parts.EditorTab) EditorPartStack(org.eclipse.che.ide.api.parts.EditorPartStack)

Aggregations

EditorTab (org.eclipse.che.ide.api.parts.EditorTab)9 TabItem (org.eclipse.che.ide.api.parts.PartStackView.TabItem)4 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)3 Nullable (org.eclipse.che.commons.annotation.Nullable)2 EditorPartStack (org.eclipse.che.ide.api.parts.EditorPartStack)2 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)2 Path (org.eclipse.che.ide.resource.Path)2 Scheduler (com.google.gwt.core.client.Scheduler)1 AbstractEditorPresenter (org.eclipse.che.ide.api.editor.AbstractEditorPresenter)1 EditorWithErrors (org.eclipse.che.ide.api.editor.EditorWithErrors)1 EditorState (org.eclipse.che.ide.api.editor.EditorWithErrors.EditorState)1 PropertyListener (org.eclipse.che.ide.api.parts.PropertyListener)1 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)1 EditorPaneMenuItem (org.eclipse.che.ide.part.widgets.panemenu.EditorPaneMenuItem)1