Java Code Examples for com.intellij.ui.SimpleColoredComponent#setIpad()

The following examples show how to use com.intellij.ui.SimpleColoredComponent#setIpad() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowUsagesTableCellRenderer.java    From dagger-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode) node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon(false));
    SimpleTextAttributes attributes =
        deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0, 0, 0, 0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example 2
Source File: ShowUsagesTableCellRenderer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode)node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon());
    SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0,0,0,0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example 3
Source File: AbstractFindUsagesDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  JPanel panel = new JPanel(new GridBagLayout());
  GridBagConstraints gbConstraints = new GridBagConstraints();

  gbConstraints.insets = new Insets(0, 0, UIUtil.DEFAULT_VGAP, 0);
  gbConstraints.fill = GridBagConstraints.NONE;
  gbConstraints.weightx = 1;
  gbConstraints.weighty = 1;
  gbConstraints.anchor = GridBagConstraints.WEST;
  final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
  coloredComponent.setIpad(new Insets(0,0,0,0));
  coloredComponent.setMyBorder(null);
  configureLabelComponent(coloredComponent);
  panel.add(coloredComponent, gbConstraints);

  return panel;
}
 
Example 4
Source File: ShowUsagesTableCellRenderer.java    From otto-intellij-plugin with Apache License 2.0 6 votes vote down vote up
private void appendGroupText(final GroupNode node, JPanel panel, Color fileBgColor) {
  UsageGroup group = node == null ? null : node.getGroup();
  if (group == null) return;
  GroupNode parentGroup = (GroupNode)node.getParent();
  appendGroupText(parentGroup, panel, fileBgColor);
  if (node.canNavigateToSource()) {
    SimpleColoredComponent renderer = new SimpleColoredComponent();

    renderer.setIcon(group.getIcon(false));
    SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
    renderer.append(group.getText(myUsageView), attributes);
    renderer.append(" ", attributes);
    renderer.setIpad(new Insets(0,0,0,0));
    renderer.setBorder(null);
    panel.add(renderer);
  }
}
 
Example 5
Source File: ShowUsagesTableCellRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Component textComponentSpanningWholeRow(@Nonnull SimpleColoredComponent chunks,
                                                       Color panelBackground,
                                                       Color panelForeground,
                                                       final int column,
                                                       @Nonnull final JTable table, int row) {
  final SimpleColoredComponent component = new SimpleColoredComponent() {
    @Override
    protected void doPaint(Graphics2D g) {
      int offset = 0;
      int i = 0;
      final TableColumnModel columnModel = table.getColumnModel();
      while (i < column) {
        offset += columnModel.getColumn(i).getWidth();
        i++;
      }
      g.translate(-offset, 0);

      //if (column == columnModel.getColumnCount()-1) {
      //}
      setSize(getWidth()+offset, getHeight()); // should increase the column width so that selection background will be visible even after offset translation

      super.doPaint(g);

      g.translate(+offset, 0);
    }

    @Nonnull
    @Override
    public Dimension getPreferredSize() {
      //return super.getPreferredSize();
      return column == table.getColumnModel().getColumnCount()-1 ? super.getPreferredSize() : new Dimension(0,0);
      // it should span the whole row, so we can't return any specific value here,
      // because otherwise it would be used in the "max width" calculation in com.intellij.find.actions.ShowUsagesAction.calcMaxWidth
    }
  };

  component.setIpad(new Insets(0,0,0,0));
  component.setBorder(null);
  component.setBackground(panelBackground);
  component.setForeground(panelForeground);

  for (SimpleColoredComponent.ColoredIterator iterator = chunks.iterator(); iterator.hasNext(); ) {
    iterator.next();
    String fragment = iterator.getFragment();
    SimpleTextAttributes attributes = iterator.getTextAttributes();
    attributes = attributes.derive(attributes.getStyle(), panelForeground, panelBackground, attributes.getWaveColor());
    component.append(fragment, attributes);
  }

  return component;
}
 
Example 6
Source File: RunAnythingItemBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setupIcon(@Nonnull SimpleColoredComponent component, @Nullable Image icon) {
  component.setIcon(ObjectUtils.notNull(icon, Image.empty(16)));
  component.setIpad(JBUI.insets(0, 10, 0, 0));
}