public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
  public SimpleTextAttributes applyHighlighters(
      @NotNull Component rendererComponent,
      int row,
      int column,
      String text,
      boolean hasFocus,
      final boolean selected) {
    VcsLogHighlighter.VcsCommitStyle style = getStyle(row, column, text, hasFocus, selected);

    assert style.getBackground() != null
        && style.getForeground() != null
        && style.getTextStyle() != null;

    rendererComponent.setBackground(style.getBackground());
    rendererComponent.setForeground(style.getForeground());

    switch (style.getTextStyle()) {
      case BOLD:
        return SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
      case ITALIC:
        return SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES;
      default:
    }
    return SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }
 protected void focusNext(JComponent comp) {
   FocusTraversalPolicy policy = FlatWelcomeFrame.this.getFocusTraversalPolicy();
   if (policy != null) {
     Component next = policy.getComponentAfter(FlatWelcomeFrame.this, comp);
     if (next != null) {
       next.requestFocus();
     }
   }
 }
 protected void focusPrev(JComponent comp) {
   FocusTraversalPolicy policy = FlatWelcomeFrame.this.getFocusTraversalPolicy();
   if (policy != null) {
     Component prev = policy.getComponentBefore(FlatWelcomeFrame.this, comp);
     if (prev != null) {
       prev.requestFocus();
     }
   }
 }
 private static Component setLabelColors(
     final Component label, final JTable table, final boolean isSelected, final int row) {
   if (label instanceof JComponent) {
     ((JComponent) label).setOpaque(true);
   }
   label.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   label.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   return label;
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component component =
       myDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   component.setEnabled(ElementsChooser.this.isEnabled());
   if (component instanceof JComponent) {
     ((JComponent) component).setBorder(null);
   }
   return component;
 }
  private static int columnMaxWidth(@NotNull JTable table, int col) {
    TableColumn column = table.getColumnModel().getColumn(col);
    int width = 0;
    for (int row = 0; row < table.getRowCount(); row++) {
      Component component = table.prepareRenderer(column.getCellRenderer(), row, col);

      int rendererWidth = component.getPreferredSize().width;
      width = Math.max(width, rendererWidth + table.getIntercellSpacing().width);
    }
    return width;
  }
 @Override
 public void mouseMoved(MouseEvent e) {
   Component component = e.getComponent();
   if (component != null) {
     if (getRootColumnOrNull(e) != null) {
       component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     } else {
       component.setCursor(null);
     }
   }
 }
  private VcsLogHighlighter.VcsCommitStyle getStyle(
      int row, int column, String text, boolean hasFocus, final boolean selected) {
    Component dummyRendererComponent =
        myDummyRenderer.getTableCellRendererComponent(this, text, selected, hasFocus, row, column);

    VisibleGraph<Integer> visibleGraph = getVisibleGraph();
    if (row < 0 || row >= visibleGraph.getVisibleCommitCount()) {
      LOG.error(
          "Visible graph has "
              + visibleGraph.getVisibleCommitCount()
              + " commits, yet we want row "
              + row);
      return VcsCommitStyleFactory.createStyle(
          dummyRendererComponent.getForeground(),
          dummyRendererComponent.getBackground(),
          VcsLogHighlighter.TextStyle.NORMAL);
    }

    final RowInfo<Integer> rowInfo = visibleGraph.getRowInfo(row);

    VcsLogHighlighter.VcsCommitStyle defaultStyle =
        VcsCommitStyleFactory.createStyle(
            rowInfo.getRowType() == RowType.UNMATCHED
                ? JBColor.GRAY
                : dummyRendererComponent.getForeground(),
            dummyRendererComponent.getBackground(),
            VcsLogHighlighter.TextStyle.NORMAL);

    List<VcsLogHighlighter.VcsCommitStyle> styles =
        ContainerUtil.map(
            myHighlighters,
            new Function<VcsLogHighlighter, VcsLogHighlighter.VcsCommitStyle>() {
              @Override
              public VcsLogHighlighter.VcsCommitStyle fun(VcsLogHighlighter highlighter) {
                return highlighter.getStyle(rowInfo.getCommit(), selected);
              }
            });

    return VcsCommitStyleFactory.combine(ContainerUtil.append(styles, defaultStyle));
  }
Exemplo n.º 10
0
  /**
   * @param parent parent component which is used to calculate heavy weight window ancestor. <code>
   *     parent</code> cannot be <code>null</code> and must be showing.
   */
  protected DialogWrapperPeerImpl(
      @NotNull DialogWrapper wrapper, @NotNull Component parent, boolean canBeParent) {
    myWrapper = wrapper;
    if (!parent.isShowing() && parent != JOptionPane.getRootFrame()) {
      throw new IllegalArgumentException("parent must be showing: " + parent);
    }
    myWindowManager = null;
    Application application = ApplicationManager.getApplication();
    if (application != null && application.hasComponent(WindowManager.class)) {
      myWindowManager = (WindowManagerEx) WindowManager.getInstance();
    }

    Window owner =
        parent instanceof Window
            ? (Window) parent
            : (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);
    if (!(owner instanceof Dialog) && !(owner instanceof Frame)) {
      owner = JOptionPane.getRootFrame();
    }
    createDialog(owner, canBeParent);
  }
 public void showUnderneathOf(@NotNull Component aComponent) {
   show(new RelativePoint(aComponent, new Point(0, aComponent.getHeight())));
 }