예제 #1
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (value instanceof VirtualFile) {
     myColor = myUi.getColorManager().getRootColor((VirtualFile) value);
   } else {
     myColor = UIUtil.getTableBackground(isSelected);
   }
   return this;
 }
예제 #2
0
 private void prepareComponent(final ColorDescriptor value, final boolean selected) {
   myColorDescriptor = value;
   clear();
   setIcon(myEmptyIcon);
   setBackground(selected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground());
   if (myColorDescriptor != null) {
     append(
         myColorDescriptor.toString(),
         selected
             ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES
             : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
   }
 }
  @Override
  protected JComponent getRowPresentation(
      ParameterTableModelItemBase<ParameterInfoImpl> item,
      boolean selected,
      final boolean focused) {
    final JPanel panel = new JPanel(new BorderLayout());
    final String typeText = item.typeCodeFragment.getText();
    final String separator =
        StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1);
    String text = typeText + separator + item.parameter.getName();
    final String defaultValue = item.defaultValueCodeFragment.getText();
    String tail = "";
    if (StringUtil.isNotEmpty(defaultValue)) {
      tail += " default value = " + defaultValue;
    }
    if (item.parameter.isUseAnySingleVariable()) {
      if (StringUtil.isNotEmpty(defaultValue)) {
        tail += ";";
      }
      tail += " Use any var.";
    }
    if (!StringUtil.isEmpty(tail)) {
      text += " //" + tail;
    }
    final EditorTextField field =
        new EditorTextField(" " + text, getProject(), getFileType()) {
          @Override
          protected boolean shouldHaveBorder() {
            return false;
          }
        };

    Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
    font = new Font(font.getFontName(), font.getStyle(), 12);
    field.setFont(font);

    if (selected && focused) {
      panel.setBackground(UIUtil.getTableSelectionBackground());
      field.setAsRendererWithSelection(
          UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground());
    } else {
      panel.setBackground(UIUtil.getTableBackground());
      if (selected && !focused) {
        panel.setBorder(new DottedBorder(UIUtil.getTableForeground()));
      }
    }
    panel.add(field, BorderLayout.WEST);
    return panel;
  }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      String text;
      Color color;

      if (value instanceof VirtualFile) {
        VirtualFile root = (VirtualFile) value;
        int readableRow =
            ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
        if (row < readableRow) {
          text = "";
        } else if (row == 0
            || !value.equals(table.getModel().getValueAt(row - 1, column))
            || readableRow == row) {
          text = root.getName();
        } else {
          text = "";
        }
        color = getRootBackgroundColor(root, myUi.getColorManager());
      } else {
        text = null;
        color = UIUtil.getTableBackground(isSelected);
      }

      myColor = color;
      Color background =
          ((VcsLogGraphTable) table)
              .getStyle(row, column, text, hasFocus, isSelected)
              .getBackground();
      assert background != null;
      myBorderColor = background;
      setForeground(UIUtil.getTableForeground(false));

      if (myUi.isShowRootNames()) {
        setText(text);
        isNarrow = false;
      } else {
        setText("");
        isNarrow = true;
      }

      return this;
    }
예제 #5
0
  private static class RootCellRenderer extends JPanel implements TableCellRenderer {

    @NotNull private final VcsLogUiImpl myUi;

    @NotNull private Color myColor = UIUtil.getTableBackground();

    RootCellRenderer(@NotNull VcsLogUiImpl ui, boolean multiRoot) {
      myUi = ui;
      int rootWidth = multiRoot ? ROOT_INDICATOR_WIDTH : 0;
      setPreferredSize(new Dimension(rootWidth, -1));
    }

    @Override
    protected void paintComponent(Graphics g) {
      g.setColor(myColor);
      g.fillRect(0, 0, ROOT_INDICATOR_WIDTH - 1, HEIGHT_CELL);
      UIUtil.drawLine(
          (Graphics2D) g,
          ROOT_INDICATOR_WIDTH - 1,
          0,
          ROOT_INDICATOR_WIDTH - 1,
          HEIGHT_CELL,
          null,
          myUi.getColorManager().getRootIndicatorBorder());
    }

    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (value instanceof VirtualFile) {
        myColor = myUi.getColorManager().getRootColor((VirtualFile) value);
      } else {
        myColor = UIUtil.getTableBackground(isSelected);
      }
      return this;
    }
  }
 private static Color getDetailsBackground() {
   return UIUtil.getTableBackground();
 }
  private static class RootCellRenderer extends JBLabel implements TableCellRenderer {
    @NotNull private final VcsLogUiImpl myUi;
    @NotNull private Color myColor = UIUtil.getTableBackground();
    @NotNull private Color myBorderColor = UIUtil.getTableBackground();
    private boolean isNarrow = true;

    RootCellRenderer(@NotNull VcsLogUiImpl ui) {
      super("", CENTER);
      myUi = ui;
    }

    @Override
    protected void paintComponent(Graphics g) {
      setFont(UIManager.getFont("Table.font"));
      g.setColor(myColor);

      int width = getWidth();

      if (isNarrow) {
        g.fillRect(0, 0, width - ROOT_INDICATOR_WHITE_WIDTH, myUi.getTable().getRowHeight());
        g.setColor(myBorderColor);
        g.fillRect(
            width - ROOT_INDICATOR_WHITE_WIDTH,
            0,
            ROOT_INDICATOR_WHITE_WIDTH,
            myUi.getTable().getRowHeight());
      } else {
        g.fillRect(0, 0, width, myUi.getTable().getRowHeight());
      }

      super.paintComponent(g);
    }

    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      String text;
      Color color;

      if (value instanceof VirtualFile) {
        VirtualFile root = (VirtualFile) value;
        int readableRow =
            ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
        if (row < readableRow) {
          text = "";
        } else if (row == 0
            || !value.equals(table.getModel().getValueAt(row - 1, column))
            || readableRow == row) {
          text = root.getName();
        } else {
          text = "";
        }
        color = getRootBackgroundColor(root, myUi.getColorManager());
      } else {
        text = null;
        color = UIUtil.getTableBackground(isSelected);
      }

      myColor = color;
      Color background =
          ((VcsLogGraphTable) table)
              .getStyle(row, column, text, hasFocus, isSelected)
              .getBackground();
      assert background != null;
      myBorderColor = background;
      setForeground(UIUtil.getTableForeground(false));

      if (myUi.isShowRootNames()) {
        setText(text);
        isNarrow = false;
      } else {
        setText("");
        isNarrow = true;
      }

      return this;
    }

    @Override
    public void setBackground(Color bg) {
      myBorderColor = bg;
    }
  }