- Timestamp:
- 07/17/08 16:32:21 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/OmeroEditor/src/ui/components/AttributeEditorListeners.java
r5526 r5543 31 31 import javax.swing.text.JTextComponent; 32 32 33 import fields.IField; 34 33 35 //Third-party libraries 34 36 … … 43 45 * Then when focus is lost, the focusListener updates the dataField 44 46 * attribute (if textChanged), by calling 45 * setDataFieldAttribute. 47 * setDataFieldAttribute. TextChanged is reset to false. 46 48 * 47 49 * @author William Moore … … 60 62 boolean textChanged; 61 63 62 I AttributeSaverdataField;64 IField dataField; 63 65 64 66 String attributeName; 65 67 66 public AttributeEditorListeners(I AttributeSaverdataField,68 public AttributeEditorListeners(IField dataField, 67 69 String attributeName) { 68 70 … … 91 93 // called to update dataField with attribute 92 94 protected void setDataFieldAttribute(String value, boolean notifyUndoRedo) { 93 dataField.setAttribute(attributeName, value , notifyUndoRedo);95 dataField.setAttribute(attributeName, value); 94 96 textChanged = false; 97 } 98 99 /** 100 * Convenience method for adding listeners to a text component, such that 101 * the text component will then update the IField, using its 102 * setAttribute(attributeName, value) method. 103 * 104 * @param textComp The text component to add the listeners to 105 * @param field The IField that will be updated with new text value 106 * @param attributeName The name of the attribute to set to the new value 107 */ 108 public static void addListeners(JTextComponent textComp, IField field, 109 String attributeName) { 110 AttributeEditorListeners listeners = new AttributeEditorListeners(field, 111 attributeName); 112 textComp.addFocusListener(listeners); 113 textComp.addKeyListener(listeners); 95 114 } 96 115
