@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;
  }
 public void updateUI() {
   super.updateUI();
   TreeCellRenderer tcr = super.getCellRenderer();
   if (tcr instanceof DefaultTreeCellRenderer) {
     DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tcr;
     dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground());
     dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground());
   }
 }
Exemplo n.º 3
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);
   }
 }