Search in sources :

Example 1 with TabItem

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

the class PartStackPresenter method setActivePart.

/** {@inheritDoc} */
@Override
public void setActivePart(@NotNull PartPresenter part) {
    TabItem tab = getTabByPart(part);
    if (tab == null) {
        return;
    }
    activePart = part;
    activeTab = tab;
    if (state == State.MINIMIZED) {
        state = State.NORMAL;
        if (currentSize < MIN_PART_SIZE) {
            currentSize = DEFAULT_PART_SIZE;
        }
        workBenchPartController.setSize(currentSize);
        workBenchPartController.setMinSize(MIN_PART_SIZE);
        workBenchPartController.setHidden(false);
    } else if (state == State.COLLAPSED) {
        // Ask the delegate to restore part stacks.
        if (delegate != null) {
            delegate.onRestore(this);
        }
    } else if (state == State.NORMAL) {
        if (workBenchPartController.getSize() < MIN_PART_SIZE) {
            workBenchPartController.setMinSize(MIN_PART_SIZE);
            workBenchPartController.setSize(DEFAULT_PART_SIZE);
        }
        workBenchPartController.setHidden(false);
    }
    // Notify the part stack state has been changed.
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
            eventBus.fireEvent(new PartStackStateChangedEvent(PartStackPresenter.this));
        }
    });
    selectActiveTab(tab);
}
Also used : TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) Scheduler(com.google.gwt.core.client.Scheduler) PartStackStateChangedEvent(org.eclipse.che.ide.api.parts.PartStackStateChangedEvent)

Example 2 with TabItem

use of org.eclipse.che.ide.api.parts.PartStackView.TabItem 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 3 with TabItem

use of org.eclipse.che.ide.api.parts.PartStackView.TabItem 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 4 with TabItem

use of org.eclipse.che.ide.api.parts.PartStackView.TabItem 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 5 with TabItem

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

the class PartStackPresenter method addPart.

/** {@inheritDoc} */
@Override
public void addPart(@NotNull PartPresenter part, @Nullable Constraints constraint) {
    if (containsPart(part)) {
        TabItem tab = getTabByPart(part);
        onTabClicked(tab);
        return;
    }
    if (part instanceof BasePresenter) {
        ((BasePresenter) part).setPartStack(this);
    }
    part.addPropertyListener(propertyListener);
    PartButton partButton = tabItemFactory.createPartButton(part.getTitle()).setTooltip(part.getTitleToolTip()).setIcon(part.getTitleImage());
    partButton.setDelegate(this);
    parts.put(partButton, part);
    constraints.put(part, constraint);
    view.addTab(partButton, part);
    sortPartsOnView();
    onRequestFocus();
}
Also used : TabItem(org.eclipse.che.ide.api.parts.PartStackView.TabItem) PartButton(org.eclipse.che.ide.part.widgets.partbutton.PartButton) BasePresenter(org.eclipse.che.ide.api.parts.base.BasePresenter)

Aggregations

TabItem (org.eclipse.che.ide.api.parts.PartStackView.TabItem)7 EditorTab (org.eclipse.che.ide.api.parts.EditorTab)4 Scheduler (com.google.gwt.core.client.Scheduler)2 Nullable (org.eclipse.che.commons.annotation.Nullable)2 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)2 Path (org.eclipse.che.ide.resource.Path)2 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 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)1 PartStackStateChangedEvent (org.eclipse.che.ide.api.parts.PartStackStateChangedEvent)1 PropertyListener (org.eclipse.che.ide.api.parts.PropertyListener)1 BasePresenter (org.eclipse.che.ide.api.parts.base.BasePresenter)1 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)1 PartButton (org.eclipse.che.ide.part.widgets.partbutton.PartButton)1 Test (org.junit.Test)1