Search in sources :

Example 11 with TabInfo

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

the class JBEditorTabs method doPaintBackground.

@Override
protected void doPaintBackground(Graphics2D g2d, Rectangle clip) {
    List<TabInfo> visibleInfos = getVisibleInfos();
    final boolean vertical = getTabsPosition() == JBTabsPosition.left || getTabsPosition() == JBTabsPosition.right;
    Insets insets = getTabsBorder().getEffectiveBorder();
    int minOffset = vertical ? getHeight() : getWidth();
    int maxOffset = 0;
    int maxLength = 0;
    for (int i = visibleInfos.size() - 1; i >= 0; i--) {
        TabInfo visibleInfo = visibleInfos.get(i);
        TabLabel tabLabel = myInfo2Label.get(visibleInfo);
        Rectangle r = tabLabel.getBounds();
        if (r.width == 0 || r.height == 0)
            continue;
        minOffset = Math.min(vertical ? r.y : r.x, minOffset);
        maxOffset = Math.max(vertical ? r.y + r.height : r.x + r.width, maxOffset);
        maxLength = vertical ? r.width : r.height;
    }
    minOffset--;
    maxOffset++;
    Rectangle r2 = new Rectangle(0, 0, getWidth(), getHeight());
    Rectangle beforeTabs;
    Rectangle afterTabs;
    if (vertical) {
        beforeTabs = new Rectangle(insets.left, insets.top, getWidth(), minOffset - insets.top);
        afterTabs = new Rectangle(insets.left, maxOffset, getWidth(), r2.height - maxOffset - insets.top - insets.bottom);
    } else {
        int y = r2.y + insets.top;
        int height = maxLength - insets.top - insets.bottom;
        if (getTabsPosition() == JBTabsPosition.bottom) {
            y = r2.height - height - insets.top + getActiveTabUnderlineHeight();
        } else {
            height++;
            height -= getActiveTabUnderlineHeight();
        }
        y--;
        afterTabs = new Rectangle(maxOffset, y, r2.width - maxOffset - insets.left - insets.right, height);
        beforeTabs = new Rectangle(0, y, minOffset, height);
    }
    getPainter().doPaintBackground(g2d, clip, vertical, afterTabs);
    g2d.setPaint(getEmptySpaceColor());
    g2d.fill(beforeTabs);
    g2d.fill(afterTabs);
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 12 with TabInfo

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

the class DockableEditorTabbedContainer method processDropOver.

@Override
public Image processDropOver(@NotNull DockableContent content, RelativePoint point) {
    JBTabs current = getTabsAt(content, point);
    if (myCurrentOver != null && myCurrentOver != current) {
        resetDropOver(content);
    }
    if (myCurrentOver == null && current != null) {
        myCurrentOver = current;
        Presentation presentation = content.getPresentation();
        myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon());
        myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point);
    }
    if (myCurrentOver != null) {
        myCurrentOver.processDropOver(myCurrentOverInfo, point);
    }
    return myCurrentOverImg;
}
Also used : JBTabs(com.intellij.ui.tabs.JBTabs) TabInfo(com.intellij.ui.tabs.TabInfo) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 13 with TabInfo

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

the class JBTabsDemo method main.

public static void main(String[] args) {
    System.out.println("JBTabs.main");
    IconLoader.activate();
    final JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout(0, 0));
    final int[] count = new int[1];
    final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
    tabs.setTestMode(true);
    //final JPanel flow = new JPanel(new FlowLayout(FlowLayout.CENTER));
    //frame.getContentPane().add(flow);
    //flow.add(tabs.getComponent());
    frame.getContentPane().add(tabs.getComponent(), BorderLayout.CENTER);
    JPanel south = new JPanel(new FlowLayout());
    south.setOpaque(true);
    south.setBackground(Color.white);
    final JComboBox pos = new JComboBox(new Object[] { JBTabsPosition.top, JBTabsPosition.left, JBTabsPosition.right, JBTabsPosition.bottom });
    pos.setSelectedIndex(0);
    south.add(pos);
    pos.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            final JBTabsPosition p = (JBTabsPosition) pos.getSelectedItem();
            if (p != null) {
                tabs.getPresentation().setTabsPosition(p);
            }
        }
    });
    final JCheckBox bb = new JCheckBox("Buffered", true);
    bb.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setUseBufferedPaint(bb.isSelected());
        }
    });
    south.add(bb);
    final JCheckBox f = new JCheckBox("Focused");
    f.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setFocused(f.isSelected());
        }
    });
    south.add(f);
    final JCheckBox v = new JCheckBox("Vertical");
    v.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setSideComponentVertical(v.isSelected());
        }
    });
    south.add(v);
    final JCheckBox row = new JCheckBox("Single row", true);
    row.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setSingleRow(row.isSelected());
        }
    });
    south.add(row);
    final JCheckBox ghosts = new JCheckBox("Ghosts always visible", false);
    ghosts.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setGhostsAlwaysVisible(ghosts.isSelected());
        }
    });
    south.add(ghosts);
    final JCheckBox stealth = new JCheckBox("Stealth tab", tabs.isStealthTabMode());
    stealth.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setStealthTabMode(stealth.isSelected());
        }
    });
    south.add(stealth);
    final JCheckBox hide = new JCheckBox("Hide tabs", tabs.isHideTabs());
    hide.addItemListener(new ItemListener() {

        public void itemStateChanged(final ItemEvent e) {
            tabs.setHideTabs(hide.isSelected());
        }
    });
    south.add(hide);
    frame.getContentPane().add(south, BorderLayout.SOUTH);
    tabs.addListener(new TabsListener.Adapter() {

        public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
            System.out.println("TabsWithActions.selectionChanged old=" + oldSelection + " new=" + newSelection);
        }
    });
    final JTree someTree = new Tree() {

        public void addNotify() {
            //To change body of overridden methods use File | Settings | File Templates.
            super.addNotify();
            System.out.println("JBTabs.addNotify");
        }

        public void removeNotify() {
            System.out.println("JBTabs.removeNotify");
            //To change body of overridden methods use File | Settings | File Templates.
            super.removeNotify();
        }
    };
    //someTree.setBorder(new LineBorder(Color.cyan));
    tabs.addTab(new TabInfo(someTree)).setText("Tree1").setActions(new DefaultActionGroup(), null).setIcon(AllIcons.Debugger.Frame);
    final JTree component = new Tree();
    final TabInfo toAnimate1 = new TabInfo(component);
    //toAnimate1.setIcon(IconLoader.getIcon("/debugger/console.png"));
    final JCheckBox attract1 = new JCheckBox("Attract 1");
    attract1.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            if (attract1.isSelected()) {
                toAnimate1.fireAlert();
            } else {
                toAnimate1.stopAlerting();
            }
        }
    });
    south.add(attract1);
    final JCheckBox hide1 = new JCheckBox("Hide 1", toAnimate1.isHidden());
    hide1.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            toAnimate1.setHidden(!toAnimate1.isHidden());
        }
    });
    south.add(hide1);
    final JCheckBox block = new JCheckBox("Block", false);
    block.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            tabs.setPaintBlocked(!block.isSelected(), true);
        }
    });
    south.add(block);
    final JCheckBox fill = new JCheckBox("Tab fill in", true);
    fill.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            tabs.getPresentation().setActiveTabFillIn(fill.isSelected() ? Color.white : null);
        }
    });
    south.add(fill);
    final JButton refire = new JButton("Re-fire attraction");
    refire.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            toAnimate1.fireAlert();
        }
    });
    south.add(refire);
    final JEditorPane text = new JEditorPane();
    text.setEditorKit(new HTMLEditorKit());
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < 50; i++) {
        buffer.append("1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv1234567890abcdefghijklmnopqrstv<br>");
    }
    text.setText(buffer.toString());
    final JLabel tb = new JLabel("Side comp");
    tb.setBorder(new LineBorder(Color.red));
    tabs.addTab(new TabInfo(ScrollPaneFactory.createScrollPane(text)).setSideComponent(tb)).setText("Text text text");
    tabs.addTab(toAnimate1).append("Tree2", new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, Color.black, Color.red));
    tabs.addTab(new TabInfo(new JTable())).setText("Table 1").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 2").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 3").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 4").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 5").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 6").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 7").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 8").setActions(new DefaultActionGroup(), null);
    tabs.addTab(new TabInfo(new JTable())).setText("Table 9").setActions(new DefaultActionGroup(), null);
    //tabs.getComponent().setBorder(new EmptyBorder(5, 5, 5, 5));
    tabs.setTabSidePaintBorder(5);
    tabs.setPaintBorder(1, 1, 1, 1);
    tabs.getPresentation().setActiveTabFillIn(Color.white);
    tabs.setGhostsAlwaysVisible(true);
    //tabs.setBorder(new LineBorder(Color.blue, 5));
    tabs.setBorder(new EmptyBorder(30, 30, 30, 30));
    tabs.setUiDecorator(new UiDecorator() {

        public UiDecoration getDecoration() {
            return new UiDecoration(null, new Insets(0, -1, 0, -1));
        }
    });
    tabs.setStealthTabMode(true);
    frame.setBounds(1400, 200, 1000, 800);
    frame.show();
}
Also used : JBTabsPosition(com.intellij.ui.tabs.JBTabsPosition) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) LineBorder(javax.swing.border.LineBorder) TabsListener(com.intellij.ui.tabs.TabsListener) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) Tree(com.intellij.ui.treeStructure.Tree) TabInfo(com.intellij.ui.tabs.TabInfo) EmptyBorder(javax.swing.border.EmptyBorder) UiDecorator(com.intellij.ui.tabs.UiDecorator) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 14 with TabInfo

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

the class TableLayout method getDropIndexFor.

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

Example 15 with TabInfo

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

the class TabsSideSplitter method setSideTabsLimit.

void setSideTabsLimit(int sideTabsLimit) {
    if (mySideTabsLimit != sideTabsLimit) {
        mySideTabsLimit = sideTabsLimit;
        UIUtil.putClientProperty(myTabs, JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY, mySideTabsLimit);
        myTabs.resetLayout(true);
        myTabs.doLayout();
        myTabs.repaint();
        TabInfo info = myTabs.getSelectedInfo();
        JComponent page = info != null ? info.getComponent() : null;
        if (page != null) {
            page.revalidate();
            page.repaint();
        }
    }
}
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