Exemplo n.º 1
0
  @Override
  public Insets getInsets() {
    Insets insets = super.getInsets();
    if (myTabs.isEditorTabs()) {
      if (UISettings.getInstance().SHOW_CLOSE_BUTTON) {
        return new Insets(insets.top, insets.left, insets.bottom, 3);
      }
    }

    return insets;
  }
Exemplo n.º 2
0
  protected int getNonSelectedOffset() {
    if (myTabs.isEditorTabs()) {
      int offset = (TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2);
      if (myTabs.isSingleRow()) {
        return myTabs.getTabsPosition() == JBTabsPosition.bottom ? -(offset + 1) : -offset + 1;
      } else {
        return ((TableLayout) myTabs.getEffectiveLayout()).isLastRow(getInfo())
            ? -offset + 1
            : offset - 1;
      }
    }

    return 2;
  }
Exemplo n.º 3
0
  public TabLabel(JBTabsImpl tabs, final TabInfo info) {
    super(false);

    myTabs = tabs;
    myInfo = info;
    myLabel.setOpaque(false);
    myLabel.setBorder(null);
    myLabel.setIconTextGap(tabs.isEditorTabs() ? 2 : new JLabel().getIconTextGap());
    myLabel.setIconOpaque(false);
    myLabel.setIpad(new Insets(0, 0, 0, 0));
    setOpaque(false);
    setLayout(new BorderLayout());

    myLabelPlaceholder.setOpaque(false);
    add(myLabelPlaceholder, BorderLayout.CENTER);

    setAlignmentToCenter(true);

    myIcon = new LayeredIcon(2);

    addMouseListener(
        new MouseAdapter() {
          public void mousePressed(final MouseEvent e) {
            if (JBTabsImpl.isSelectionClick(e, false) && myInfo.isEnabled()) {
              final TabInfo selectedInfo = myTabs.getSelectedInfo();
              if (selectedInfo != myInfo) {
                myInfo.setPreviousSelection(selectedInfo);
              }
              Component c =
                  SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
              if (c instanceof InplaceButton) return;
              myTabs.select(info, true);
            } else {
              handlePopup(e);
            }
          }

          public void mouseClicked(final MouseEvent e) {
            handlePopup(e);
          }

          public void mouseReleased(final MouseEvent e) {
            myInfo.setPreviousSelection(null);
            handlePopup(e);
          }
        });
  }
Exemplo n.º 4
0
  @Override
  public Dimension getPreferredSize() {
    final Dimension size = super.getPreferredSize();
    if (myActionPanel != null && !myActionPanel.isVisible()) {
      final Dimension actionPanelSize = myActionPanel.getPreferredSize();
      size.width += actionPanelSize.width;
    }

    final JBTabsPosition pos = myTabs.getTabsPosition();
    switch (pos) {
      case top:
      case bottom:
        size.height +=
            myTabs.isEditorTabs() ? TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT : getSelectedOffset();
        break;
      case left:
      case right:
        size.width += getSelectedOffset();
        break;
    }

    return size;
  }
Exemplo n.º 5
0
 protected int getSelectedOffset() {
   return myTabs.isEditorTabs() ? -(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2) + 1 : 1;
 }