Changeset 5608
- Timestamp:
- 09/12/08 12:16:56 (2 months ago)
- Location:
- trunk/SRC/org/openmicroscopy/shoola/agents/editor
- Files:
-
- 3 added
- 7 modified
-
browser/BrowserControl.java (modified) (2 diffs)
-
browser/paramUIs/BooleanEditor.java (modified) (6 diffs)
-
browser/paramUIs/editTemplate/AddParamActions.java (modified) (4 diffs)
-
browser/paramUIs/editTemplate/BooleanTemplate.java (added)
-
browser/paramUIs/editTemplate/EnumTemplate.java (modified) (3 diffs)
-
browser/paramUIs/editTemplate/FieldEditorPanel.java (modified) (3 diffs)
-
browser/paramUIs/editTemplate/NumberTemplate.java (added)
-
browser/paramUIs/editTemplate/ParamTemplateUIFactory.java (modified) (2 diffs)
-
model/undoableEdits/AddParamEdit.java (added)
-
model/undoableEdits/AttributesEdit.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java
r5594 r5608 50 50 import org.openmicroscopy.shoola.agents.editor.browser.undo.ObservableUndoManager; 51 51 import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 52 import org.openmicroscopy.shoola.agents.editor.model.IField; 53 import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AddParamEdit; 52 54 import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributeEdit; 53 55 import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributesEdit; 56 54 57 55 58 … … 226 229 227 230 /** 231 * Edits a field by creating and adding a new Parameter. 232 * 233 * @param field The field to add a new parameter to. 234 * @param paramType A string defining the type of parameter to add. 235 * @param tree The JTree to refresh with undo/redo 236 * @param node The node to highlight / refresh with undo/redo. 237 */ 238 public void addParamToField(IField field, String paramType, 239 JTree tree, TreeNode node) { 240 241 UndoableEdit edit = new AddParamEdit(field, paramType, tree, node); 242 undoSupport.postEdit(edit); 243 } 244 245 /** 228 246 * An undo/redo adpater. The adpater is notified when 229 247 * an undo edit occur(e.g. add or remove from the list) -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/BooleanEditor.java
r5588 r5608 30 30 import javax.swing.JCheckBox; 31 31 32 import org.openmicroscopy.shoola.agents.editor.model.params.IParam;33 import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam;34 35 32 //Third-party libraries 36 33 37 34 //Application-internal dependencies 38 35 36 import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 37 import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam; 39 38 40 39 /** … … 59 58 * A JCheckBox for editing the boolean value 60 59 */ 61 private JCheckBox checkBox;60 private JCheckBox checkBox; 62 61 63 62 /** … … 65 64 * value of the boolean parameter we're editing. 66 65 */ 67 private String valueAttribute = SingleParam.PARAM_VALUE;66 private String attributeName; 68 67 69 68 /** … … 79 78 checkBox.setBorderPaintedFlat(true); 80 79 81 boolean checked = getParameter().isAttributeTrue( valueAttribute);80 boolean checked = getParameter().isAttributeTrue(attributeName); 82 81 83 82 checkBox.setSelected(checked); … … 87 86 * Creates an instance. 88 87 * 89 * @param param 88 * @param param The IAttributes collection we're editing 89 * @param attributeName The name of the attribute we're editing 90 90 */ 91 public BooleanEditor(I Param param) {91 public BooleanEditor(IAttributes param, String attributeName) { 92 92 93 93 super(param); 94 94 95 this.attributeName = attributeName; 96 97 initialise(); 98 99 this.add(checkBox); 100 } 101 102 /** 103 * Creates an instance, which will edit the 104 * {@link SingleParam#PARAM_VALUE} attribute of the 105 * {@link IAttributes} parameter. 106 * 107 * @param param The IAttributes collection we're editing 108 */ 109 public BooleanEditor(IAttributes param) { 110 111 super(param); 112 113 attributeName = SingleParam.PARAM_VALUE; 95 114 initialise(); 96 115 … … 104 123 */ 105 124 public void actionPerformed(ActionEvent e) { 106 attributeEdited( valueAttribute, checkBox.isSelected() + "");125 attributeEdited(attributeName, checkBox.isSelected() + ""); 107 126 } 108 127 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/AddParamActions.java
r5588 r5608 43 43 import org.openmicroscopy.shoola.agents.editor.browser.BrowserControl; 44 44 import org.openmicroscopy.shoola.agents.editor.model.IField; 45 import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam; 45 46 import org.openmicroscopy.shoola.agents.editor.uiComponents.PopupMenuButton; 46 47 … … 188 189 { 189 190 // TODO implement this method in controller. 190 //controller.addParamToField(field, SingleParam.TEXT_LINE_PARAM,191 //tree, node);191 controller.addParamToField(field, SingleParam.TEXT_LINE_PARAM, 192 tree, node); 192 193 } 193 194 … … 222 223 public void actionPerformed(ActionEvent e) 223 224 { 224 // TODO implement this method in controller. 225 //controller.addParamToField(field, SingleParam.NUMBER_PARAM, 226 // tree, node); 225 controller.addParamToField(field, SingleParam.NUMBER_PARAM, 226 tree, node); 227 227 } 228 228 … … 256 256 public void actionPerformed(ActionEvent e) 257 257 { 258 // TODO implement this method in controller. 259 //controller.addParamToField(field, SingleParam.BOOLEAN_PARAM, 260 // tree, node); 258 controller.addParamToField(field, SingleParam.BOOLEAN_PARAM, 259 tree, node); 261 260 } 262 261 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/EnumTemplate.java
r5601 r5608 23 23 package org.openmicroscopy.shoola.agents.editor.browser.paramUIs.editTemplate; 24 24 25 import java.awt.BorderLayout; 25 26 import java.awt.event.ActionEvent; 26 27 import java.awt.event.ActionListener; … … 94 95 private void buildUI() 95 96 { 96 setLayout(new Bo xLayout(this, BoxLayout.Y_AXIS));97 add(optionsFieldEditor );98 add(new CustomLabel("Default Value: ") );99 add(defaultValueComboBox );97 setLayout(new BorderLayout()); 98 add(optionsFieldEditor, BorderLayout.NORTH); 99 add(new CustomLabel("Default Value: "), BorderLayout.WEST); 100 add(defaultValueComboBox, BorderLayout.CENTER); 100 101 101 102 } … … 123 124 if (ITreeEditComp.VALUE_CHANGED_PROPERTY.equals(evt.getPropertyName())){ 124 125 if (evt.getSource().equals(defaultValueComboBox)) { 125 String newDefault = evt.getNewValue().toString(); 126 String newDefault = null; 127 if (evt.getNewValue() != null) 128 newDefault = evt.getNewValue().toString(); 126 129 // simply change the new value of default attribute 127 130 attributeEdited(SingleParam.DEFAULT_VALUE, newDefault); 128 131 } 129 132 133 // if the drop-down options have changed, need to check that 134 // the value and default value are in the new options. 130 135 if (evt.getSource().equals(optionsFieldEditor)) { 131 String newOptions = evt.getNewValue().toString(); 136 String newOptions = null; 137 if(evt.getNewValue() != null) 138 newOptions = evt.getNewValue().toString(); 132 139 133 140 String defaultValue = getParameter().getAttribute -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/FieldEditorPanel.java
r5601 r5608 64 64 import org.openmicroscopy.shoola.agents.editor.model.params.IParam; 65 65 import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomComboBox; 66 import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomLabel; 66 67 import org.openmicroscopy.shoola.agents.editor.uiComponents.ImageBorderFactory; 67 68 … … 198 199 //JLabel paramLabel = new CustomLabel("Parameters:"); 199 200 JPanel paramHeader = new JPanel(new BorderLayout()); 200 paramHeader.setBackground(null);201 202 // Add the JComboBox for changing parameter type 203 paramHeader.add(paramTypeChooser, BorderLayout.WEST);204 205 JButton addParamsButton = new AddParamActions(field, tree,206 treeNode, controller).getButton();207 addParamsButton.addPropertyChangeListener(208 AddParamActions.PARAM_ADDED_PROPERTY, this);209 paramHeader.add( addParamsButton, BorderLayout.EAST);210 201 Border emptyB = new EmptyBorder(4, 4, 4,4); 202 Border lineB = BorderFactory.createMatteBorder( 203 1, 1, 1, 1, new Color(200,200,200)); 204 Border compoundBorder = BorderFactory.createCompoundBorder 205 (lineB, emptyB); 206 paramHeader.setBorder(compoundBorder); 207 paramHeader.setBackground(Color.white); 208 209 // Add the JComboBox for changing type of FIRST parameter 210 paramHeader.add(paramTypeChooser, BorderLayout.CENTER); 211 paramHeader.add(new CustomLabel("Parameter type: "), BorderLayout.WEST); 211 212 attributeFieldsPanel.add(paramHeader); 213 214 if (field.getParamCount() > 0) { 215 IParam param = field.getParamAt(0); 216 JComponent edit = ParamTemplateUIFactory. 217 getEditDefaultComponent(param); 218 if (edit != null) { 219 edit.addPropertyChangeListener( 220 ITreeEditComp.VALUE_CHANGED_PROPERTY, this); 221 paramHeader.add(edit, BorderLayout.SOUTH); 222 } 223 } 212 224 213 225 // For each parameter of this field, add the components for 214 226 // editing their default or template values. 215 buildParamComponents();227 addAdditionalParams(); 216 228 217 229 this.setLayout(new BorderLayout()); … … 239 251 /** 240 252 * Add additional UI components for editing the value of this field. 241 * Use a Factory to create the UI components, depending on the value type 242 */ 243 private void buildParamComponents() 253 * This deals with "Additional" parameters, not the first one, which 254 * is a special case (added earlier). 255 * Uses the {@link ParamTemplateUIFactory} to create the UI components, 256 * depending on the value type 257 */ 258 private void addAdditionalParams() 244 259 { 260 addFieldComponent(createAdditionalParamsHeader()); 261 245 262 int paramCount = field.getParamCount(); 246 247 for (int i=0; i<paramCount; i++) { 263 if (paramCount < 2) { return; } 264 265 for (int i=1; i<paramCount; i++) { 248 266 IParam param = field.getParamAt(i); 249 267 JComponent edit = ParamTemplateUIFactory. 250 268 getEditDefaultComponent(param); 251 if (edit != null) 269 if (edit != null) { 252 270 addFieldComponent(edit); 253 } 271 } 272 } 273 } 274 275 private JComponent createAdditionalParamsHeader() { 276 JPanel addParamsHeader = new JPanel(new BorderLayout()); 277 addParamsHeader.setBackground(null); 278 JButton addParamsButton = new AddParamActions(field, tree, 279 treeNode, controller).getButton(); 280 addParamsButton.addPropertyChangeListener( 281 AddParamActions.PARAM_ADDED_PROPERTY, this); 282 addParamsHeader.add(addParamsButton, BorderLayout.EAST); 283 284 addParamsHeader.add( 285 new CustomLabel("Additional Parameters:"), BorderLayout.WEST); 286 287 return addParamsHeader; 254 288 } 255 289 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/ParamTemplateUIFactory.java
r5601 r5608 68 68 } 69 69 String inputType = paramObject.getAttribute(AbstractParam.PARAM_TYPE); 70 70 71 71 if (inputType == null) { 72 72 return null; … … 80 80 if (inputType.equals(SingleParam.ENUM_PARAM)) { 81 81 return new EnumTemplate(paramObject); 82 } 83 84 if (inputType.equals(SingleParam.BOOLEAN_PARAM)) { 85 return new BooleanTemplate(paramObject); 86 } 87 88 if (inputType.equals(SingleParam.NUMBER_PARAM)) { 89 return new NumberTemplate(paramObject); 82 90 } 83 91 -
trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/undoableEdits/AttributesEdit.java
r5601 r5608 148 148 oldValues.put(key, attributes.getAttribute(key)); 149 149 attributes.setAttribute(key, newValues.get(key)); 150 System.out.println("AttributesEdit " + key + " " +151 attributes.getAttribute(key) + " " + newValues.get(key));152 150 } 153 151 // if node changed (eg template edited), need to notify
