1 package org.columba.core.gui.plugin; 17 18 import java.awt.Component ; 19 20 import javax.swing.AbstractCellEditor ; 21 import javax.swing.JCheckBox ; 22 import javax.swing.JTable ; 23 import javax.swing.SwingConstants ; 24 import javax.swing.table.TableCellEditor ; 25 26 27 33 34 public class EnabledEditor extends AbstractCellEditor implements TableCellEditor { 35 protected JCheckBox component = new JCheckBox (); 36 protected PluginNode currentNode; 37 38 41 public EnabledEditor() { 42 component.setHorizontalAlignment(SwingConstants.CENTER); 43 } 44 45 public int getClickCountToStart() { 46 return 1; 47 } 48 49 public Component getTableCellEditorComponent(JTable table, Object value, 51 boolean isSelected, int rowIndex, int vColIndex) { 52 currentNode = (PluginNode) value; 53 54 ((JCheckBox ) component).setSelected(currentNode.isEnabled()); 56 57 if (isSelected) { 58 ((JCheckBox ) component).setBackground(table.getSelectionBackground()); 59 } else { 60 ((JCheckBox ) component).setBackground(table.getBackground()); 61 } 62 63 return component; 65 } 66 67 public Object getCellEditorValue() { 70 Boolean b = Boolean.valueOf(((JCheckBox ) component).isSelected()); 71 72 currentNode.setEnabled(b.booleanValue()); 74 75 81 return b; 82 } 83 84 public Component getComponent() { 85 return component; 86 } 87 } 88 | Popular Tags |