Search in sources :

Example 36 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class SingleRowLayout method recomputeToLayout.

protected void recomputeToLayout(final SingleRowPassInfo data) {
    calculateRequiredLength(data);
    while (true) {
        if (data.requiredLength <= data.toFitLength - data.position)
            break;
        if (data.toLayout.size() == 0)
            break;
        final TabInfo first = data.toLayout.get(0);
        final TabInfo last = data.toLayout.get(data.toLayout.size() - 1);
        if (myRowDropPolicy == RowDropPolicy.first) {
            if (first != myTabs.getSelectedInfo()) {
                processDrop(data, first, true);
            } else if (last != myTabs.getSelectedInfo()) {
                processDrop(data, last, false);
            } else {
                break;
            }
        } else {
            if (last != myTabs.getSelectedInfo()) {
                processDrop(data, last, false);
            } else if (first != myTabs.getSelectedInfo()) {
                processDrop(data, first, true);
            } else {
                break;
            }
        }
    }
    for (int i = 1; i < data.myVisibleInfos.size() - 1; i++) {
        final TabInfo each = data.myVisibleInfos.get(i);
        final TabInfo prev = data.myVisibleInfos.get(i - 1);
        final TabInfo next = data.myVisibleInfos.get(i + 1);
        if (data.toLayout.contains(each) && data.toDrop.contains(prev)) {
            myLeftGhost.setInfo(prev);
        } else if (data.toLayout.contains(each) && data.toDrop.contains(next)) {
            myRightGhost.setInfo(next);
        }
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 37 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class SingleRowLayout method getDropIndexFor.

@Override
public int getDropIndexFor(Point point) {
    if (myLastSingRowLayout == null)
        return -1;
    int result = -1;
    Component c = myTabs.getComponentAt(point);
    if (c instanceof JBTabsImpl) {
        for (int i = 0; i < myLastSingRowLayout.myVisibleInfos.size() - 1; i++) {
            TabLabel first = myTabs.myInfo2Label.get(myLastSingRowLayout.myVisibleInfos.get(i));
            TabLabel second = myTabs.myInfo2Label.get(myLastSingRowLayout.myVisibleInfos.get(i + 1));
            Rectangle firstBounds = first.getBounds();
            Rectangle secondBounds = second.getBounds();
            final boolean between;
            boolean horizontal = getStrategy() instanceof SingleRowLayoutStrategy.Horizontal;
            if (horizontal) {
                between = firstBounds.getMaxX() < point.x && secondBounds.getX() > point.x && firstBounds.y < point.y && secondBounds.getMaxY() > point.y;
            } else {
                between = firstBounds.getMaxY() < point.y && secondBounds.getY() > point.y && firstBounds.x < point.x && secondBounds.getMaxX() > point.x;
            }
            if (between) {
                c = first;
                break;
            }
        }
    }
    if (c instanceof TabLabel) {
        TabInfo info = ((TabLabel) c).getInfo();
        int index = myLastSingRowLayout.myVisibleInfos.indexOf(info);
        boolean isDropTarget = myTabs.isDropTarget(info);
        if (!isDropTarget) {
            for (int i = 0; i <= index; i++) {
                if (myTabs.isDropTarget(myLastSingRowLayout.myVisibleInfos.get(i))) {
                    index -= 1;
                    break;
                }
            }
            result = index;
        } else if (index < myLastSingRowLayout.myVisibleInfos.size()) {
            result = index;
        }
    } else if (c instanceof GhostComponent) {
        GhostComponent ghost = (GhostComponent) c;
        TabInfo info = ghost.myInfo;
        if (info != null) {
            int index = myLastSingRowLayout.myVisibleInfos.indexOf(info);
            index += myLeftGhost == ghost ? -1 : 1;
            result = index >= 0 && index < myLastSingRowLayout.myVisibleInfos.size() ? index : -1;
        } else {
            if (myLastSingRowLayout.myVisibleInfos.size() == 0) {
                result = 0;
            } else {
                result = myLeftGhost == ghost ? 0 : myLastSingRowLayout.myVisibleInfos.size() - 1;
            }
        }
    }
    return result;
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 38 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class SingleRowLayout method calculateRequiredLength.

protected void calculateRequiredLength(SingleRowPassInfo data) {
    for (TabInfo eachInfo : data.myVisibleInfos) {
        data.requiredLength += getRequiredLength(eachInfo);
        if (myTabs.getTabsPosition() == JBTabsPosition.left || myTabs.getTabsPosition() == JBTabsPosition.right) {
            data.requiredLength -= 1;
        }
        data.toLayout.add(eachInfo);
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 39 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class TableLayout method layoutTable.

public LayoutPassInfo layoutTable(List<TabInfo> visibleInfos) {
    myTabs.resetLayout(true);
    final TablePassInfo data = computeLayoutTable(visibleInfos);
    final Insets insets = myTabs.getLayoutInsets();
    int eachY = insets.top;
    int eachX;
    int row = 0;
    final int tabUnderlineFix = myTabs.isEditorTabs() ? myTabs.getActiveTabUnderlineHeight() : 0;
    for (TableRow eachRow : data.table) {
        eachX = insets.left;
        int deltaToFit = 0;
        boolean toAjust = false;
        if (eachRow.width < data.toFitRec.width && data.table.size() > 1) {
            deltaToFit = (int) Math.floor((double) (data.toFitRec.width - eachRow.width) / (double) eachRow.myColumns.size());
            toAjust = true;
        }
        for (int i = 0; i < eachRow.myColumns.size(); i++) {
            TabInfo tabInfo = eachRow.myColumns.get(i);
            final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
            label.putClientProperty(JBTabsImpl.STRETCHED_BY_WIDTH, Boolean.valueOf(toAjust));
            int width;
            if (i < eachRow.myColumns.size() - 1 || !toAjust) {
                width = label.getPreferredSize().width + deltaToFit;
            } else {
                width = data.toFitRec.width + insets.left - eachX;
            }
            myTabs.layout(label, eachX, eachY, width, row < data.table.size() - 1 ? myTabs.myHeaderFitSize.height - tabUnderlineFix : myTabs.myHeaderFitSize.height);
            label.setAlignmentToCenter(deltaToFit > 0);
            boolean lastCell = i == eachRow.myColumns.size() - 1;
            eachX += width + (lastCell ? 0 : myTabs.getInterTabSpaceLength());
        }
        eachY += myTabs.myHeaderFitSize.height - 1 + myTabs.getInterTabSpaceLength() - (row < data.table.size() - 1 ? tabUnderlineFix : 0);
        row++;
    }
    if (myTabs.getSelectedInfo() != null) {
        final JBTabsImpl.Toolbar selectedToolbar = myTabs.myInfo2Toolbar.get(myTabs.getSelectedInfo());
        int xAddin = 0;
        if (!myTabs.myHorizontalSide && selectedToolbar != null && !selectedToolbar.isEmpty()) {
            xAddin = selectedToolbar.getPreferredSize().width + 1;
            myTabs.layout(selectedToolbar, insets.left + 1, eachY + 1, selectedToolbar.getPreferredSize().width, myTabs.getHeight() - eachY - insets.bottom - 2);
        }
        myTabs.layoutComp(xAddin, eachY + (myTabs.isEditorTabs() ? 0 : 2) - myTabs.getLayoutInsets().top, myTabs.getSelectedInfo().getComponent(), 0, 0);
    }
    myLastTableLayout = data;
    return data;
}
Also used : JBTabsImpl(com.intellij.ui.tabs.impl.JBTabsImpl) TabLabel(com.intellij.ui.tabs.impl.TabLabel) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 40 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.

the class PyDataView method show.

public void show(@NotNull PyDebugValue value) {
    ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(DATA_VIEWER_ID);
    if (window == null) {
        LOG.error("Tool window '" + DATA_VIEWER_ID + "' is not found");
        return;
    }
    window.getContentManager().getReady(this).doWhenDone(() -> {
        TabInfo selectedInfo = addTab(value.getFrameAccessor());
        PyDataViewerPanel dataViewerPanel = (PyDataViewerPanel) selectedInfo.getComponent();
        dataViewerPanel.apply(value);
    });
    window.show(null);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) TabInfo(com.intellij.ui.tabs.TabInfo)

Aggregations

TabInfo (com.intellij.ui.tabs.TabInfo)41 TabLabel (com.intellij.ui.tabs.impl.TabLabel)6 RelativePoint (com.intellij.ui.awt.RelativePoint)4 JBTabsImpl (com.intellij.ui.tabs.impl.JBTabsImpl)4 Content (com.intellij.ui.content.Content)3 JBTabs (com.intellij.ui.tabs.JBTabs)3 TabsListener (com.intellij.ui.tabs.TabsListener)3 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)2 ContentManager (com.intellij.ui.content.ContentManager)2 PyDebugProcess (com.jetbrains.python.debugger.PyDebugProcess)2 ArrayList (java.util.ArrayList)2 EmptyBorder (javax.swing.border.EmptyBorder)2 Nullable (org.jetbrains.annotations.Nullable)2 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Editor (com.intellij.openapi.editor.Editor)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1