01: /*
02: * @(#)DefaultCellEditor.java 1.0 03-JUL-04
03: *
04: * Copyright (c) 2001-2004 Gaudenz Alder
05: *
06: */
07: package org.jgraph.graph;
08:
09: import java.awt.Component;
10:
11: import javax.swing.DefaultCellEditor;
12: import javax.swing.JCheckBox;
13: import javax.swing.JComboBox;
14: import javax.swing.JTextField;
15:
16: import org.jgraph.JGraph;
17:
18: /**
19: * The default editor for graph cells.
20: *
21: * @version 1.0 1/1/02
22: * @author Gaudenz Alder
23: */
24: public class DefaultRealEditor extends DefaultCellEditor implements
25: GraphCellEditor {
26:
27: //
28: // Constructors
29: //
30: /**
31: * Constructs a DefaultCellEditor that uses a text field.
32: *
33: * @param textField
34: * a JTextField object used as the editor
35: */
36: public DefaultRealEditor(final JTextField textField) {
37: super (textField);
38: setClickCountToStart(1);
39: }
40:
41: /**
42: * Constructs a DefaultCellEditor object that uses a check box.
43: *
44: * @param checkBox
45: * a JCheckBox object
46: */
47: public DefaultRealEditor(final JCheckBox checkBox) {
48: super (checkBox);
49: }
50:
51: /**
52: * Constructs a DefaultCellEditor object that uses a combo box.
53: *
54: * @param comboBox
55: * a JComboBox object
56: */
57: public DefaultRealEditor(final JComboBox comboBox) {
58: super (comboBox);
59: }
60:
61: //
62: // GraphCellEditor Interface
63: //
64: public Component getGraphCellEditorComponent(JGraph graph,
65: Object value, boolean isSelected) {
66: String stringValue = graph.convertValueToString(value);
67: delegate.setValue(stringValue);
68: if (editorComponent instanceof JTextField)
69: ((JTextField) editorComponent).selectAll();
70: return editorComponent;
71: }
72: } // End of class JCellEditor
|