コード例 #1
0
 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;
 }
コード例 #2
0
 @NotNull
 public List<T> getMarkedElements() {
   final int count = myTableModel.getRowCount();
   List<T> elements = new ArrayList<T>();
   for (int idx = 0; idx < count; idx++) {
     final T element = myTableModel.getElementAt(idx);
     if (myTableModel.isElementMarked(idx)) {
       elements.add(element);
     }
   }
   return elements;
 }
コード例 #3
0
 /**
  * Check if element is marked
  *
  * @param element an element to test
  * @return true if element is marked
  */
 public boolean isElementMarked(T element) {
   final int elementRow = myTableModel.getElementRow(element);
   return myTableModel.isElementMarked(elementRow);
 }