Search in sources :

Example 21 with TabInfo

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

the class TableLayout method computeLayoutTable.

private TablePassInfo computeLayoutTable(List<TabInfo> visibleInfos) {
    final TablePassInfo data = new TablePassInfo(myTabs, visibleInfos);
    final Insets insets = myTabs.getLayoutInsets();
    data.toFitRec = new Rectangle(insets.left, insets.top, myTabs.getWidth() - insets.left - insets.right, myTabs.getHeight() - insets.top - insets.bottom);
    int eachRow = 0, eachX = data.toFitRec.x;
    TableRow eachTableRow = new TableRow(data);
    data.table.add(eachTableRow);
    data.requiredRows = 1;
    for (TabInfo eachInfo : data.myVisibleInfos) {
        final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
        final Dimension size = eachLabel.getPreferredSize();
        if (eachX + size.width >= data.toFitRec.getMaxX()) {
            data.requiredRows++;
            eachX = data.toFitRec.x;
        }
        myTabs.layout(eachLabel, eachX, 0, size.width, 1);
        eachX += size.width + myTabs.getInterTabSpaceLength();
        data.requiredWidth += size.width + myTabs.getInterTabSpaceLength();
    }
    int selectedRow = -1;
    eachX = data.toFitRec.x;
    data.rowToFitMaxX = (int) data.toFitRec.getMaxX();
    if (data.requiredRows > 1) {
        final int rowFit = insets.left + data.requiredWidth / data.requiredRows;
        for (TabInfo eachInfo : data.myVisibleInfos) {
            final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
            final Rectangle eachBounds = eachLabel.getBounds();
            if (eachBounds.contains(rowFit, 0)) {
                data.rowToFitMaxX = (int) eachLabel.getBounds().getMaxX();
                break;
            }
        }
    }
    for (TabInfo eachInfo : data.myVisibleInfos) {
        final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
        final Dimension size = eachLabel.getPreferredSize();
        if (eachX + size.width <= data.rowToFitMaxX) {
            eachTableRow.add(eachInfo);
            if (myTabs.getSelectedInfo() == eachInfo) {
                selectedRow = eachRow;
            }
            eachX += size.width + myTabs.getInterTabSpaceLength();
        } else {
            eachTableRow = new TableRow(data);
            data.table.add(eachTableRow);
            eachRow++;
            eachX = insets.left + size.width;
            eachTableRow.add(eachInfo);
            if (myTabs.getSelectedInfo() == eachInfo) {
                selectedRow = eachRow;
            }
        }
    }
    List<TableRow> toMove = new ArrayList<>();
    for (int i = selectedRow + 1; i < data.table.size(); i++) {
        toMove.add(data.table.get(i));
    }
    return data;
}
Also used : ArrayList(java.util.ArrayList) TabLabel(com.intellij.ui.tabs.impl.TabLabel) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 22 with TabInfo

use of com.intellij.ui.tabs.TabInfo in project buck by facebook.

the class BuckToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setIcon(BuckIcons.BUCK_TOOL_WINDOW_ICON);
    RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project);
    BuckSettingsProvider.State state = BuckSettingsProvider.getInstance().getState();
    JBTabs myTabs = new JBTabsImpl(project);
    // Debug Console
    if (state.showDebug) {
        Content consoleContent = createConsoleContent(runnerLayoutUi, project);
        myTabs.addTab(new TabInfo(consoleContent.getComponent())).setText("Debug");
    }
    // Build Tree Events
    Content treeViewContent = runnerLayoutUi.createContent(BUILD_OUTPUT_PANEL, createBuildInfoPanel(project), "Build Output", null, null);
    myTabs.addTab(new TabInfo(treeViewContent.getComponent()).setText("Build"));
    Content tabsContent = runnerLayoutUi.createContent(TABS_CONTENT_ID, myTabs.getComponent(), "Buck Tool Tabs", null, null);
    runnerLayoutUi.addContent(tabsContent, 0, PlaceInGrid.center, false);
    runnerLayoutUi.getOptions().setLeftToolbar(getLeftToolbarActions(project), ActionPlaces.UNKNOWN);
    runnerLayoutUi.updateActionsNow();
    final ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(runnerLayoutUi.getComponent(), "", true);
    contentManager.addContent(content);
    updateBuckToolWindowTitle(project);
}
Also used : RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) JBTabs(com.intellij.ui.tabs.JBTabs) JBTabsImpl(com.intellij.ui.tabs.impl.JBTabsImpl) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) BuckSettingsProvider(com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 23 with TabInfo

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

the class GridCellImpl method remove.

void remove(Content content) {
    if (!myContents.containsKey(content))
        return;
    final TabInfo info = getTabFor(content);
    myContents.remove(content);
    revalidateCell(() -> myTabs.removeTab(info));
    updateSelection(myTabs.getComponent().getRootPane() != null);
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 24 with TabInfo

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

the class GridCellImpl method updateSelection.

public void updateSelection(final boolean isShowing) {
    ContentManager contentManager = myContext.getContentManager();
    if (contentManager.isDisposed())
        return;
    for (Content each : myContents.getKeys()) {
        final TabInfo eachTab = getTabFor(each);
        boolean isSelected = eachTab != null && myTabs.getSelectedInfo() == eachTab;
        if (isSelected && isShowing) {
            contentManager.addSelectedContent(each);
        } else {
            contentManager.removeFromSelection(each);
        }
    }
    for (Content each : myMinimizedContents) {
        contentManager.removeFromSelection(each);
    }
}
Also used : Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) TabInfo(com.intellij.ui.tabs.TabInfo)

Example 25 with TabInfo

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

the class RunnerContentUi method doSaveUiState.

private void doSaveUiState() {
    if (isStateBeingRestored())
        return;
    for (TabInfo each : myTabs.getTabs()) {
        GridImpl eachGrid = getGridFor(each);
        eachGrid.saveUiState();
    }
    for (RunnerContentUi child : myChildren) {
        child.doSaveUiState();
    }
}
Also used : 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