Java 类com.intellij.ui.tabs.impl.TabLabel 实例源码

项目:intellij-ce-playground    文件:ScrollableSingleRowLayout.java   
@Override
protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
  if (data.requiredLength > data.toFitLength) {
    length = getStrategy().getLengthIncrement(label.getPreferredSize());
    final int moreRectSize = getStrategy().getMoreRectAxisSize();
    if (data.position + length > data.toFitLength - moreRectSize) {
      final int clippedLength = getStrategy().drawPartialOverflowTabs() ? data.toFitLength - data.position - moreRectSize - 4 : 0;
      super.applyTabLayout(data, label, clippedLength, deltaToFit);
      label.setAlignmentToCenter(false);
      label.setActionPanelVisible(false);
      return false;
    }
  }
  label.setActionPanelVisible(true);
  return super.applyTabLayout(data, label, length, deltaToFit);
}
项目:tools-idea    文件:ScrollableSingleRowLayout.java   
@Override
protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
  if (data.requiredLength > data.toFitLength) {
    length = getStrategy().getLengthIncrement(label.getPreferredSize());
    final int moreRectSize = getStrategy().getMoreRectAxisSize();
    if (data.position + length > data.toFitLength - moreRectSize) {
      final int clippedLength = getStrategy().drawPartialOverflowTabs() ? data.toFitLength - data.position - moreRectSize - 4 : 0;
      super.applyTabLayout(data, label, clippedLength, deltaToFit);
      label.setAlignmentToCenter(false);
      label.setActionPanelVisible(false);
      return false;
    }
  }
  label.setActionPanelVisible(true);
  return super.applyTabLayout(data, label, length, deltaToFit);
}
项目:tools-idea    文件:JBRunnerTabs.java   
@Override
protected void doPaintInactive(Graphics2D g2d,
                               boolean leftGhostExists,
                               TabLabel label,
                               Rectangle effectiveBounds,
                               boolean rightGhostExists, int row, int column) {
  Insets insets = getTabsBorder().getEffectiveBorder();
  final boolean dark = UIUtil.isUnderDarcula();
  int _x = effectiveBounds.x + insets.left;
  int _y = effectiveBounds.y + insets.top + 3;
  int _width = effectiveBounds.width - insets.left - insets.right;
  int _height = effectiveBounds.height - insets.top - insets.bottom - 3;
  _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
  if (dark) {
    g2d.setPaint(UIUtil.getGradientPaint(_x, _y, ColorUtil.shift(UIUtil.getListBackground(), 1.3), _x, _y + effectiveBounds.height, UIUtil.getPanelBackground()));
    g2d.fillRect(_x, _y, _width, _height);

    g2d.setColor(Gray._0.withAlpha(50));
  } else {
    g2d.setPaint(UIUtil.getGradientPaint(_x, _y, new Color(255, 255, 255, 180), _x, _y + effectiveBounds.height, new Color(255, 255, 255, 100)));
    g2d.fillRect(_x, _y, _width, _height);

    g2d.setColor(new Color(255, 255, 255, 100));
    g2d.drawRect(_x, _y, _width - 1, _height - 1);
  }
}
项目:consulo    文件:ScrollableSingleRowLayout.java   
@Override
protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
  if (data.requiredLength > data.toFitLength) {
    length = getStrategy().getLengthIncrement(label.getPreferredSize());
    final int moreRectSize = getStrategy().getMoreRectAxisSize();
    if (data.position + length > data.toFitLength - moreRectSize) {
      final int clippedLength = getStrategy().drawPartialOverflowTabs() ? data.toFitLength - data.position - moreRectSize - 4 : 0;
      super.applyTabLayout(data, label, clippedLength, deltaToFit);
      label.setAlignmentToCenter(false);
      label.setActionPanelVisible(false);
      return false;
    }
  }
  label.setActionPanelVisible(true);
  return super.applyTabLayout(data, label, length, deltaToFit);
}
项目:ApiDebugger    文件:JBDebuggerTab.java   
@Override
public Component add(Component comp) {
    //set tab cursor
    if (comp instanceof TabLabel) {
        comp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
    return super.add(comp);
}
项目:intellij-ce-playground    文件:ScrollableSingleRowLayout.java   
@Nullable
@Override
protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) {
  int i = data.toLayout.size()-1;
  while(i > 0) {
    final TabInfo info = data.toLayout.get(i);
    final TabLabel label = myTabs.myInfo2Label.get(info);
    if (!label.getBounds().isEmpty()) {
      return label;
    }
    i--;
  }
  return null;
}
项目:intellij-ce-playground    文件:TableLayout.java   
@Override
public boolean isDragOut(@NotNull TabLabel tabLabel, int deltaX, int deltaY) {
  if (myLastTableLayout == null) {
    return super.isDragOut(tabLabel, deltaX, deltaY);
  }

  Rectangle area = new Rectangle(myLastTableLayout.toFitRec.width, tabLabel.getBounds().height);
  for (int i = 0; i < myLastTableLayout.myVisibleInfos.size(); i++) {
    area = area.union(myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i)).getBounds());
  }
  return Math.abs(deltaY) > area.height * getDragOutMultiplier();
}
项目:intellij-ce-playground    文件:JBRunnerTabs.java   
public boolean shouldAddToGlobal(Point point) {
  final TabLabel label = getSelectedLabel();
  if (label == null || point == null) {
    return true;
  }
  final Rectangle bounds = label.getBounds();
  return point.y <= bounds.y + bounds.height;
}
项目:intellij-ce-playground    文件:JBRunnerTabs.java   
@Override
public void processDropOver(TabInfo over, RelativePoint relativePoint) {
  final Point point = relativePoint.getPoint(getComponent());
  myShowDropLocation = shouldAddToGlobal(point);
  super.processDropOver(over, relativePoint);
  for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) {
    final TabLabel label = entry.getValue();
    if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) {
      select(entry.getKey(), false);
      break;
    }
  }
}
项目:intellij-ce-playground    文件:DeferredIconImpl.java   
private static Component getTarget(Component c) {
  final Component target;

  final Container list = SwingUtilities.getAncestorOfClass(JList.class, c);
  if (list != null) {
    target = list;
  }
  else {
    final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c);
    if (tree != null) {
      target = tree;
    }
    else {
      final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c);
      if (table != null) {
        target = table;
      }
      else {
        final Container box = SwingUtilities.getAncestorOfClass(JComboBox.class, c);
        if (box != null) {
          target = box;
        }
        else {
          final Container tabLabel = SwingUtilities.getAncestorOfClass(TabLabel.class, c);
          target = tabLabel == null ? c : tabLabel;
        }
      }
    }
  }
  return target;
}
项目:intellij-ce-playground    文件:AndroidToolWindowFixture.java   
private void selectTab(@NotNull final String tabName) {
  JBRunnerTabs tabs = myRobot.finder().findByType(getContentPanel(), JBRunnerTabs.class);
  TabLabel tabLabel = myRobot.finder().find(tabs, new GenericTypeMatcher<TabLabel>(TabLabel.class) {
    @Override
    protected boolean isMatching(@NotNull TabLabel component) {
      return tabName.equals(component.toString());
    }
  });
  myRobot.click(tabLabel);
}
项目:tools-idea    文件:ScrollableSingleRowLayout.java   
@Nullable
@Override
protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) {
  int i = data.toLayout.size()-1;
  while(i > 0) {
    final TabInfo info = data.toLayout.get(i);
    final TabLabel label = myTabs.myInfo2Label.get(info);
    if (!label.getBounds().isEmpty()) {
      return label;
    }
    i--;
  }
  return null;
}
项目:tools-idea    文件:JBRunnerTabs.java   
public boolean shouldAddToGlobal(Point point) {
  final TabLabel label = getSelectedLabel();
  if (label == null || point == null) {
    return true;
  }
  final Rectangle bounds = label.getBounds();
  return point.y <= bounds.y + bounds.height;
}
项目:tools-idea    文件:JBRunnerTabs.java   
@Override
public void processDropOver(TabInfo over, RelativePoint relativePoint) {
  final Point point = relativePoint.getPoint(getComponent());
  myShowDropLocation = shouldAddToGlobal(point);
  super.processDropOver(over, relativePoint);
  for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) {
    final TabLabel label = entry.getValue();
    if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) {
      select(entry.getKey(), false);
      break;
    }
  }
}
项目:tools-idea    文件:DeferredIconImpl.java   
private static Component getTarget(Component c) {
  final Component target;

  final Container list = SwingUtilities.getAncestorOfClass(JList.class, c);
  if (list != null) {
    target = list;
  }
  else {
    final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c);
    if (tree != null) {
      target = tree;
    }
    else {
      final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c);
      if (table != null) {
        target = table;
      }
      else {
        final Container box = SwingUtilities.getAncestorOfClass(JComboBox.class, c);
        if (box != null) {
          target = box;
        }
        else {
          final Container tabLabel = SwingUtilities.getAncestorOfClass(TabLabel.class, c);
          target = tabLabel == null ? c : tabLabel;
        }
      }
    }
  }
  return target;
}
项目:jediterm    文件:ScrollableSingleRowLayout.java   
@Override
protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
  if (data.requiredLength > data.toFitLength) {
    length = getStrategy().getLengthIncrement(label.getPreferredSize());
    final int moreRectSize = getStrategy().getMoreRectAxisSize();
    if (data.position + length > data.toFitLength - moreRectSize && label.getInfo() != myTabs.getSelectedInfo()) {
      final int clippedLength = getStrategy().drawPartialOverflowTabs()
                                ? data.toFitLength - data.position - moreRectSize - 4 : 0;
      super.applyTabLayout(data, label, clippedLength, deltaToFit);
      label.setAlignmentToCenter(false);
      return false;
    }
  }
  return super.applyTabLayout(data, label, length, deltaToFit);
}
项目:jediterm    文件:ScrollableSingleRowLayout.java   
@Nullable
@Override
protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) {
  int i = data.toLayout.size()-1;
  while(i > 0) {
    final TabInfo info = data.toLayout.get(i);
    final TabLabel label = myTabs.myInfo2Label.get(info);
    if (!label.getBounds().isEmpty()) {
      return label;
    }
    i--;
  }
  return null;
}
项目:jediterm    文件:TableLayout.java   
@Override
public boolean isDragOut(@NotNull TabLabel tabLabel, int deltaX, int deltaY) {
  if (myLastTableLayout == null) {
    return super.isDragOut(tabLabel, deltaX, deltaY);
  }

  Rectangle area = new Rectangle(myLastTableLayout.toFitRec.width, tabLabel.getBounds().height);
  for (int i = 0; i < myLastTableLayout.myVisibleInfos.size(); i++) {
    area = area.union(myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i)).getBounds());
  }
  return Math.abs(deltaY) > area.height * getDragOutMultiplier();
}
项目:consulo    文件:ScrollableSingleRowLayout.java   
@Nullable
@Override
protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) {
  int i = data.toLayout.size()-1;
  while(i > 0) {
    final TabInfo info = data.toLayout.get(i);
    final TabLabel label = myTabs.myInfo2Label.get(info);
    if (!label.getBounds().isEmpty()) {
      return label;
    }
    i--;
  }
  return null;
}
项目:consulo    文件:IntelliJEditorTabsUI.java   
protected Dimension computeHeaderPreferredSize(JBTabsImpl tabs, int tabsCount) {
  final Iterator<TabInfo> infos = tabs.myInfo2Label.keySet().iterator();
  Dimension size = new Dimension();
  int currentTab = 0;

  final boolean horizontal = tabs.getTabsPosition() == JBTabsPosition.top || tabs.getTabsPosition() == JBTabsPosition.bottom;

  while (infos.hasNext()) {
    final boolean canGrow = currentTab < tabsCount;

    TabInfo eachInfo = infos.next();
    final TabLabel eachLabel = tabs.myInfo2Label.get(eachInfo);
    final Dimension eachPrefSize = eachLabel.getPreferredSize();
    if (horizontal) {
      if (canGrow) {
        size.width += eachPrefSize.width;
      }
      size.height = Math.max(size.height, eachPrefSize.height);
    }
    else {
      size.width = Math.max(size.width, eachPrefSize.width);
      if (canGrow) {
        size.height += eachPrefSize.height;
      }
    }

    currentTab++;
  }


  if (horizontal) {
    size.height += tabs.getTabsBorder().getTabBorderSize();
  }
  else {
    size.width += tabs.getTabsBorder().getTabBorderSize();
  }

  return size;
}
项目:consulo    文件:IntelliJEditorTabsUI.java   
protected void doPaintInactive(JBTabsImpl t,
                               Graphics2D g2d,
                               boolean leftGhostExists,
                               TabLabel label,
                               Rectangle effectiveBounds,
                               boolean rightGhostExists,
                               int row,
                               int column) {
  Insets insets = t.getTabsBorder().getEffectiveBorder();

  int _x = effectiveBounds.x + insets.left;
  int _y = effectiveBounds.y + insets.top;
  int _width = effectiveBounds.width - insets.left - insets.right + (t.getTabsPosition() == JBTabsPosition.right ? 1 : 0);
  int _height = effectiveBounds.height - insets.top - insets.bottom;


  if ((!t.isSingleRow() /* for multiline */) || (t.isSingleRow() && t.isHorizontalTabs())) {
    if (t.isSingleRow() && t.getPosition() == JBTabsPosition.bottom) {
      _y += t.getActiveTabUnderlineHeight();
    }
    else {
      if (t.isSingleRow()) {
        _height -= t.getActiveTabUnderlineHeight();
      }
      else {
        TabInfo info = label.getInfo();
        if (((TableLayout)t.getEffectiveLayout()).isLastRow(info)) {
          _height -= t.getActiveTabUnderlineHeight();
        }
      }
    }
  }

  final boolean vertical = t.getTabsPosition() == JBTabsPosition.left || t.getTabsPosition() == JBTabsPosition.right;
  final Color tabColor = label.getInfo().getTabColor();
  doPaintInactive(g2d, effectiveBounds, _x, _y, _width, _height, tabColor, row, column, vertical);
}
项目:consulo    文件:IntelliJEditorTabsUI.java   
protected void doPaintAdditionalBackgroundIfFirstOffsetSet(JBTabsImpl tabs, Graphics2D g2d, Rectangle clip) {
  if (tabs.getTabsPosition() == JBTabsPosition.top && tabs.isSingleRow() && tabs.getFirstTabOffset() > 0) {
    int maxOffset = 0;
    int maxLength = 0;

    for (int i = tabs.getVisibleInfos().size() - 1; i >= 0; i--) {
      TabInfo visibleInfo = tabs.getVisibleInfos().get(i);
      TabLabel tabLabel = tabs.myInfo2Label.get(visibleInfo);
      Rectangle r = tabLabel.getBounds();
      if (r.width == 0 || r.height == 0) continue;
      maxOffset = r.x + r.width;
      maxLength = r.height;
      break;
    }

    maxOffset++;
    g2d.setPaint(UIUtil.getPanelBackground());
    if (tabs.getFirstTabOffset() > 0) {
      g2d.fillRect(clip.x, clip.y, clip.x + JBUI.scale(tabs.getFirstTabOffset() - 1), clip.y + maxLength - tabs.getActiveTabUnderlineHeight());
    }
    g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - tabs.getActiveTabUnderlineHeight());
    g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground()));
    g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - tabs.getActiveTabUnderlineHeight(), clip.x + clip.width,
                 clip.y + maxLength - tabs.getActiveTabUnderlineHeight());
    g2d.setPaint(UIUtil.getPanelBackground());
    g2d.drawLine(clip.x, clip.y + maxLength, clip.width, clip.y + maxLength);
  }
}
项目:consulo    文件:IntelliJEditorTabsUI.java   
public void paintChildren(JBTabsImpl tabs, Graphics g) {
  final GraphicsConfig config = new GraphicsConfig(g);
  config.setAntialiasing(true);
  paintSelectionAndBorder(tabs, (Graphics2D)g);
  config.restore();

  final TabLabel selected = tabs.getSelectedLabel();
  if (selected != null) {
    selected.paintImage(g);
  }

  tabs.getSingleRowLayoutInternal().myMoreIcon.paintIcon(tabs, g);
}
项目:consulo    文件:JBRunnerTabs.java   
public boolean shouldAddToGlobal(Point point) {
  final TabLabel label = getSelectedLabel();
  if (label == null || point == null) {
    return true;
  }
  final Rectangle bounds = label.getBounds();
  return point.y <= bounds.y + bounds.height;
}
项目:consulo    文件:JBRunnerTabs.java   
@Override
public void processDropOver(TabInfo over, RelativePoint relativePoint) {
  final Point point = relativePoint.getPoint(getComponent());
  myShowDropLocation = shouldAddToGlobal(point);
  super.processDropOver(over, relativePoint);
  for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) {
    final TabLabel label = entry.getValue();
    if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) {
      select(entry.getKey(), false);
      break;
    }
  }
}
项目:consulo    文件:DeferredIconImpl.java   
private static Component getTarget(Component c) {
  final Component target;

  final Container list = SwingUtilities.getAncestorOfClass(JList.class, c);
  if (list != null) {
    target = list;
  }
  else {
    final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c);
    if (tree != null) {
      target = tree;
    }
    else {
      final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c);
      if (table != null) {
        target = table;
      }
      else {
        final Container box = SwingUtilities.getAncestorOfClass(JComboBox.class, c);
        if (box != null) {
          target = box;
        }
        else {
          final Container tabLabel = SwingUtilities.getAncestorOfClass(TabLabel.class, c);
          target = tabLabel == null ? c : tabLabel;
        }
      }
    }
  }
  return target;
}
项目:ApiDebugger    文件:JBDebuggerTab.java   
@Override
protected void doPaintInactive(Graphics2D g2d, boolean leftGhostExists, TabLabel label, Rectangle effectiveBounds, boolean rightGhostExists, int row, int column) {
    //Empty
}
项目:intellij-ce-playground    文件:CompressibleSingleRowLayout.java   
@Override
protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
  boolean result = super.applyTabLayout(data, label, length, deltaToFit);
  label.setAlignmentToCenter(false);
  return result;
}
项目:intellij-ce-playground    文件:ScrollableSingleRowLayout.java   
@Override
public boolean isTabHidden(TabInfo tabInfo) {
  final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
  final Rectangle bounds = label.getBounds();
  return getStrategy().getMinPosition(bounds) < -10 || bounds.isEmpty();
}
项目:intellij-ce-playground    文件:SingleRowLayoutStrategy.java   
@Override
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
  return Math.abs(deltaY) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
}
项目:intellij-ce-playground    文件:SingleRowLayoutStrategy.java   
@Override
public int getScrollUnitIncrement(TabLabel label) {
  return 10;
}
项目:intellij-ce-playground    文件:SingleRowLayoutStrategy.java   
@Override
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
  return Math.abs(deltaX) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
}
项目:intellij-ce-playground    文件:SingleRowLayoutStrategy.java   
@Override
public int getScrollUnitIncrement(TabLabel label) {
  return label.getPreferredSize().height;
}
项目:intellij-ce-playground    文件:TableLayout.java   
@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;
}
项目:intellij-ce-playground    文件:JBRunnerTabs.java   
@Override
protected TabLabel createTabLabel(TabInfo info) {
  return new MyTabLabel(this, info);
}
项目:tools-idea    文件:ScrollableSingleRowLayout.java   
@Override
public boolean isTabHidden(TabInfo tabInfo) {
  final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
  final Rectangle bounds = label.getBounds();
  return getStrategy().getMinPosition(bounds) < -10 || bounds.isEmpty();
}
项目:tools-idea    文件:SingleRowLayoutStrategy.java   
@Override
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
  return Math.abs(deltaY) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
}
项目:tools-idea    文件:SingleRowLayoutStrategy.java   
@Override
public int getScrollUnitIncrement(TabLabel label) {
  return 10;
}
项目:tools-idea    文件:SingleRowLayoutStrategy.java   
@Override
public boolean isDragOut(TabLabel tabLabel, int deltaX, int deltaY) {
  return Math.abs(deltaX) > tabLabel.getHeight() * TabLayout.getDragOutMultiplier();
}
项目:tools-idea    文件:SingleRowLayoutStrategy.java   
@Override
public int getScrollUnitIncrement(TabLabel label) {
  return label.getPreferredSize().height;
}