Changeset 5526
- Timestamp:
- 07/04/08 11:49:37 (3 months ago)
- Location:
- branches/OmeroEditor/src/ui
- Files:
-
- 3 added
- 6 modified
-
components/AttributeEditorListeners.java (added)
-
components/AttributeTextAreaEditor.java (added)
-
components/AttributeTextEditor.java (added)
-
formFields/FormField.java (modified) (7 diffs)
-
formFields/FormFieldCustom.java (modified) (3 diffs)
-
formFields/FormFieldDate.java (modified) (3 diffs)
-
formFields/FormFieldMemo.java (modified) (3 diffs)
-
formFields/FormFieldNumber.java (modified) (4 diffs)
-
formFields/FormFieldText.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/OmeroEditor/src/ui/formFields/FormField.java
r5483 r5526 69 69 // Subclasses have eg TextFields etc 70 70 71 public abstract class FormField extends JPanel implements DataFieldObserver{ 71 public abstract class FormField 72 extends JPanel 73 implements DataFieldObserver{ 72 74 73 75 IDataFieldObservable dataFieldObs; … … 84 86 public static final String HAS_FOCUS = "hasFocus"; 85 87 86 boolean textChanged = false; 87 TextChangedListener textChangedListener = new TextChangedListener(); 88 FocusListener focusChangedListener = new FocusChangedListener(); 88 /** 89 * Add this listener to various buttons etc, so that if they are clicked. 90 * this field will become selected. 91 */ 89 92 FocusListener componentFocusListener = new FormFieldComponentFocusListener(); 90 93 … … 128 131 Icon spacerIcon; // A blank icon to replace collapsedIcon if there are no children. 129 132 130 // used in Diff (comparing two trees), to get a ref to all components, to colour red if different!131 ArrayList<JComponent> visibleAttributes = new ArrayList<JComponent>();132 133 133 134 boolean showDescription = false; // not saved, just used to toggle … … 205 206 descriptionLabel = new JLabel(); 206 207 descriptionLabel.setBackground(null); 207 visibleAttributes.add(descriptionLabel);208 208 209 infoIcon = ImageFactory.getInstance().getIcon(ImageFactory.INFO_ICON); 209 210 descriptionButton = new JButton(infoIcon); … … 559 560 if(evt.getPropertyName().equals(FormField.HAS_FOCUS)) { 560 561 panelClicked(true); 562 System.out.println("FormField. FocusGainedPropertyChangedListener"); 561 563 } 562 564 } … … 761 763 } 762 764 763 public ArrayList<JComponent> getVisibleAttributes() {764 return visibleAttributes;765 }766 765 767 766 private String addHtmlTagsForNameLabel(String text) { … … 770 769 } 771 770 772 773 public class TextChangedListener implements KeyListener {774 775 public void keyTyped(KeyEvent event) {776 textChanged = true; // some character was typed, so set this flag777 }778 public void keyPressed(KeyEvent event) {}779 public void keyReleased(KeyEvent event) {}780 781 }782 783 public class FocusChangedListener implements FocusListener {784 785 public void focusLost(FocusEvent event) {786 if (textChanged) {787 JTextComponent source = (JTextComponent)event.getSource();788 789 setDataFieldAttribute(source.getName(), source.getText(), true);790 791 textChanged = false;792 }793 }794 public void focusGained(FocusEvent event) {}795 }796 797 798 771 // called to update dataField with attribute 799 772 protected void setDataFieldAttribute(String attributeName, String value, boolean notifyUndoRedo) { -
branches/OmeroEditor/src/ui/formFields/FormFieldCustom.java
r5344 r5526 34 34 import tree.IDataFieldObservable; 35 35 import ui.XMLView; 36 import ui.components.AttributeTextEditor; 36 37 import ui.components.AttributesDialog; 37 38 import util.ImageFactory; … … 57 58 } 58 59 59 textInput = new JTextField(); 60 textInput = new AttributeTextEditor(dataField, 61 DataFieldConstants.TEXT_NODE_VALUE); 60 62 textInput.addMouseListener(new FormPanelMouseListener()); 61 textInput.setName(DataFieldConstants.TEXT_NODE_VALUE); 62 textInput.addFocusListener(focusChangedListener); 63 textInput.addKeyListener(textChangedListener); 63 64 textInput.setVisible(false); // not visible unless text node 65 66 horizontalBox.add(textInput); 67 64 68 checkForTextNodeValue(); 65 69 … … 68 72 public void checkForTextNodeValue() { 69 73 String textNodeValue = dataField.getAttribute(DataFieldConstants.TEXT_NODE_VALUE); 70 //System.out.println("FormFieldCustom constructor: textNodeValue = " + textNodeValue); 71 if (textNodeValue != null) { 72 textInput.setText(textNodeValue); 73 horizontalBox.add(textInput); 74 } 74 75 textInput.setVisible(textNodeValue != null); 76 75 77 } 76 78 -
branches/OmeroEditor/src/ui/formFields/FormFieldDate.java
r5355 r5526 29 29 import tree.DataFieldConstants; 30 30 import tree.IDataFieldObservable; 31 import ui.components.AttributeTextEditor; 31 32 32 33 public class FormFieldDate extends FormField { … … 40 41 String date = dataField.getAttribute(DataFieldConstants.VALUE); 41 42 42 textInput = new JTextField(date); 43 visibleAttributes.add(textInput); 43 textInput = new AttributeTextEditor(dataField, 44 DataFieldConstants.VALUE); 45 44 46 textInput.addFocusListener(componentFocusListener); 45 textInput.setName(DataFieldConstants.VALUE); 46 textInput.addFocusListener(focusChangedListener); 47 textInput.addKeyListener(textChangedListener); 47 48 48 horizontalBox.add(textInput); 49 49 … … 91 91 } 92 92 93 // overridden by subclasses if they have other attributes to retrieve from dataField94 public void dataFieldUpdated() {95 super.dataFieldUpdated();96 textInput.setText(dataField.getAttribute(DataFieldConstants.VALUE));97 }98 99 93 100 94 public void setHighlighted(boolean highlight) { -
branches/OmeroEditor/src/ui/formFields/FormFieldMemo.java
r5355 r5526 29 29 import tree.DataFieldConstants; 30 30 import tree.IDataFieldObservable; 31 import ui.components.AttributeTextAreaEditor; 31 32 32 33 public class FormFieldMemo extends FormField { … … 39 40 super(dataFieldObs); 40 41 41 /* 42 inputEditor = new AttributeMemoFormatEditor(dataField, 43 "", DataFieldConstants.VALUE, dataField.getAttribute(DataFieldConstants.VALUE)); 44 inputEditor.getTextArea().addFocusListener(componentFocusListener); 45 horizontalBox.add(inputEditor); 46 */ 42 textInput = new AttributeTextAreaEditor(dataField, 43 DataFieldConstants.VALUE); 47 44 45 textInput.addMouseListener(new FormPanelMouseListener()); 48 46 49 String value = dataField.getAttribute(DataFieldConstants.VALUE);50 51 textInput = new JTextArea(value);52 visibleAttributes.add(textInput);53 textInput.setRows(2);54 textInput.setLineWrap(true);55 textInput.setWrapStyleWord(true);56 //JScrollPane textScroller = new JScrollPane(textInput);57 Border bevelBorder = BorderFactory.createLoweredBevelBorder();58 Border emptyBorder = BorderFactory.createEmptyBorder(3, 3, 3, 3);59 Border compoundBorder = BorderFactory.createCompoundBorder(bevelBorder, emptyBorder);60 textInput.setBorder(compoundBorder);61 //textInput.setMaximumSize(new Dimension(500, 500));62 textInput.addMouseListener(new FormPanelMouseListener());63 textInput.setName(DataFieldConstants.VALUE);64 textInput.addFocusListener(focusChangedListener);65 textInput.addKeyListener(textChangedListener);66 47 horizontalBox.add(textInput); 67 48 … … 84 65 } 85 66 86 87 // overridden by subclasses if they have other attributes to retrieve from dataField88 public void dataFieldUpdated() {89 super.dataFieldUpdated();90 textInput.setText(dataField.getAttribute(DataFieldConstants.VALUE));91 }92 67 93 68 public void setHighlighted(boolean highlight) { -
branches/OmeroEditor/src/ui/formFields/FormFieldNumber.java
r5355 r5526 34 34 import tree.DataFieldConstants; 35 35 import tree.IDataFieldObservable; 36 import ui.components.AttributeTextEditor; 36 37 37 38 public class FormFieldNumber extends FormField { … … 44 45 super(dataFieldObs); 45 46 46 String valueString = dataField.getAttribute(DataFieldConstants.VALUE);47 47 48 48 String units = dataField.getAttribute(DataFieldConstants.UNITS); 49 49 50 numberTextBox = new JTextField(valueString); 51 visibleAttributes.add(numberTextBox); 50 numberTextBox = new AttributeTextEditor(dataField, 51 DataFieldConstants.VALUE); 52 52 53 numberTextBox.addFocusListener(componentFocusListener); 53 54 numberTextBox.addFocusListener(new NumberCheckerListener()); 54 numberTextBox.setName(DataFieldConstants.VALUE);55 55 numberTextBox.setMaximumSize(new Dimension(100, 30)); 56 numberTextBox.addFocusListener(focusChangedListener);57 numberTextBox.addKeyListener(textChangedListener);58 56 numberTextBox.setToolTipText("Must enter a number"); 59 57 60 58 unitsLabel = new JLabel(units); 61 visibleAttributes.add(unitsLabel);59 62 60 63 61 horizontalBox.add(numberTextBox); … … 125 123 126 124 private void checkForNumber() { 127 String number = numberTextBox.getText();125 String number = dataField.getAttribute(DataFieldConstants.VALUE); 128 126 float value; 129 127 try { … … 141 139 public void dataFieldUpdated() { 142 140 super.dataFieldUpdated(); 143 numberTextBox.setText(dataField.getAttribute(DataFieldConstants.VALUE));144 141 checkForNumber(); 145 142 setUnits(dataField.getAttribute(DataFieldConstants.UNITS)); -
branches/OmeroEditor/src/ui/formFields/FormFieldText.java
r5355 r5526 29 29 import tree.DataFieldConstants; 30 30 import tree.IDataFieldObservable; 31 import ui.components.AttributeTextEditor; 31 32 32 33 public class FormFieldText extends FormField { … … 39 40 String value = dataField.getAttribute(DataFieldConstants.VALUE); 40 41 41 textInput = new JTextField(value);42 visibleAttributes.add(textInput);42 textInput = new AttributeTextEditor(dataField, 43 DataFieldConstants.VALUE); 43 44 textInput.addFocusListener(componentFocusListener); // to highlight field when textBox gets focus 44 textInput.setName(DataFieldConstants.VALUE); 45 textInput.addFocusListener(focusChangedListener); 46 textInput.addKeyListener(textChangedListener); 45 47 46 horizontalBox.add(textInput); 48 47 … … 88 87 return ((value != null) && (value.length() > 0)); 89 88 } 90 91 // overridden by subclasses if they have other attributes to retrieve from dataField92 public void dataFieldUpdated() {93 super.dataFieldUpdated();94 textInput.setText(dataField.getAttribute(DataFieldConstants.VALUE));95 }96 89 97 90
