2 package fr.orsay.lri.varna.components;
6 import java.awt.Component;
8 import javax.swing.AbstractCellEditor;
9 import javax.swing.JButton;
10 import javax.swing.JColorChooser;
11 import javax.swing.JDialog;
12 import javax.swing.JTable;
13 import javax.swing.table.TableCellEditor;
15 import fr.orsay.lri.varna.controlers.ControleurBaseSpecialColorEditor;
16 import fr.orsay.lri.varna.views.VueBases;
18 public class BaseSpecialColorEditor extends AbstractCellEditor implements
23 private static final long serialVersionUID = 1L;
24 private Color currentColor;
25 private JButton button;
26 private JColorChooser colorChooser;
27 private JDialog dialog;
28 protected static final String EDIT = "edit";
29 private VueBases _vueBases;
30 private ControleurBaseSpecialColorEditor _controleurSpecialColorEditor;
32 public BaseSpecialColorEditor(VueBases vueBases) {
33 // Set up the editor (from the table's point of view),
35 // This button brings up the color chooser dialog,
36 // which is the editor from the user's point of view.
37 button = new JButton();
38 button.setActionCommand(EDIT);
39 _controleurSpecialColorEditor = new ControleurBaseSpecialColorEditor(this);
40 button.addActionListener(_controleurSpecialColorEditor);
41 button.setBorderPainted(false);
45 // Set up the dialog that the button brings up.
46 colorChooser = new JColorChooser();
47 dialog = JColorChooser.createDialog(button, "Pick a Color", true, // modal
48 colorChooser, _controleurSpecialColorEditor, // OK button
50 null); // no CANCEL button handler
53 // Implement the one CellEditor method that AbstractCellEditor doesn't.
54 public Object getCellEditorValue() {
58 // Implement the one method defined by TableCellEditor.
59 public Component getTableCellEditorComponent(JTable table, Object value,
60 boolean isSelected, int row, int column) {
61 currentColor = (Color) value;
65 public static long getSerialVersionUID() {
66 return serialVersionUID;
69 public Color getCurrentColor() {
73 public JButton getButton() {
77 public JColorChooser getColorChooser() {
81 public JDialog getDialog() {
85 public static String getEDIT() {
89 public VueBases get_vueBases() {
93 public ControleurBaseSpecialColorEditor get_controleurSpecialColorEditor() {
94 return _controleurSpecialColorEditor;
97 public void setCurrentColor(Color currentColor) {
98 this.currentColor = currentColor;
101 public void callFireEditingStopped() {
102 fireEditingStopped();