Changeset 5546
- Timestamp:
- 07/23/08 15:32:07 (5 weeks ago)
- Location:
- branches/OmeroEditor/src
- Files:
-
- 16 added
- 4 removed
- 15 modified
- 7 moved
-
fields/AbstractParam.java (moved) (moved from branches/OmeroEditor/src/fields/AbstractValueObject.java) (3 diffs)
-
fields/DateTimeParam.java (moved) (moved from branches/OmeroEditor/src/fields/DateTimeValueObject.java) (4 diffs)
-
fields/Field.java (modified) (5 diffs)
-
fields/FieldPanel.java (modified) (9 diffs)
-
fields/FieldParamsFactory.java (moved) (moved from branches/OmeroEditor/src/fields/FieldValueFactory.java) (3 diffs)
-
fields/IAttributes.java (added)
-
fields/IField.java (modified) (2 diffs)
-
fields/IFieldValue.java (deleted)
-
fields/IParam.java (added)
-
fields/NoParam.java (moved) (moved from branches/OmeroEditor/src/fields/NoValue.java) (2 diffs)
-
fields/SingleParam.java (added)
-
fields/TextValueObject.java (deleted)
-
tree/DataField.java (modified) (1 diff)
-
treeEditingComponents/DateTimeField.java (modified) (6 diffs)
-
treeEditingComponents/EditingComponentFactory.java (modified) (4 diffs)
-
treeEditingComponents/TextBoxEditor.java (added)
-
treeEditingComponents/TextFieldEditor.java (modified) (2 diffs)
-
treeIO (added)
-
treeIO/TreeModelFactory.java (added)
-
treeModel/DefaultFieldEditor.java (moved) (moved from branches/OmeroEditor/src/fields/DefaultFieldEditor.java) (1 diff)
-
treeModel/ITreeEditor.java (modified) (2 diffs)
-
treeModel/TreeEditor.java (deleted)
-
treeModel/TreeEditorComponent.java (modified) (4 diffs)
-
treeModel/TreeEditorControl.java (modified) (3 diffs)
-
treeModel/TreeEditorFactory.java (modified) (4 diffs)
-
treeModel/TreeEditorModel.java (moved) (moved from branches/OmeroEditor/src/treeModel/TreeModel.java) (2 diffs)
-
treeModel/TreeEditorUI.java (modified) (4 diffs)
-
treeModel/TreeUI.java (modified) (4 diffs)
-
treeModel/editActions/AbstractEditorAction.java (added)
-
treeModel/editActions/DeleteFields.java (deleted)
-
treeModel/editActions/DeleteFieldsAction.java (added)
-
treeModel/editActions/RedoEditAction.java (added)
-
treeModel/editActions/UndoEditAction.java (added)
-
treeModel/editActions/UndoRedoListener.java (added)
-
treeModel/editActions/UndoRedoObservable.java (added)
-
treeModel/undoableTreeEdits (added)
-
treeModel/undoableTreeEdits/DeleteFieldsEdit.java (added)
-
treeModel/undoableTreeEdits/ObservableUndoManager.java (added)
-
treeModel/undoableTreeEdits/TreeModelMethods.java (moved) (moved from branches/OmeroEditor/src/treeModel/editActions/TreeModelMethods.java) (6 diffs)
-
treeModel/undoableTreeEdits/UndoableTreeEdit.java (added)
-
ui/components/AttributeEditorListeners.java (modified) (3 diffs)
-
ui/components/AttributeTextAreaEditor.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/OmeroEditor/src/fields/AbstractParam.java
r5543 r5546 23 23 package fields; 24 24 25 import java.util.HashMap;26 27 import tree.DataFieldConstants;28 25 29 26 //Java imports 27 import java.util.HashMap; 30 28 31 29 //Third-party libraries … … 33 31 //Application-internal dependencies 34 32 33 import tree.DataFieldConstants; 34 35 35 36 /** 36 * 37 * An abstract example 37 38 * 38 39 * @author William Moore … … 44 45 * @since OME3.0 45 46 */ 46 public abstract class Abstract ValueObject47 public abstract class AbstractParam 47 48 implements 48 I FieldValue{49 IParam { 49 50 50 private String fieldType; 51 public static final String PARAM_TYPE = "paramType"; 52 53 public static final String PARAM_NAME = "paramName"; 54 51 55 52 56 private HashMap<String, String> valueAttributesMap; 53 57 54 58 55 public AbstractValueObject(String fieldType) { 56 this.fieldType = fieldType; 59 public AbstractParam(String fieldType) { 57 60 valueAttributesMap = new HashMap<String, String>(); 61 valueAttributesMap.put(PARAM_TYPE, fieldType); 58 62 } 59 63 64 /** 65 * This method returns a list of the names of attributes. 66 * These attributes represent the experimental "value" of this 67 * parameter (rather than other attributes such as name or default 68 * values that represent the "template" part of the parameter. 69 * This method is used for eg. clearing the value of a parameter by 70 * setting all value attributes to null. 71 */ 60 72 public abstract String[] getValueAttributes(); 61 73 62 public abstract boolean isFieldFilled();63 64 74 /** 65 * A convenience method to test whether the attribute is included in 66 * the list of value attributes. 75 * Unless specified by subclasses, parameter has no default values. 76 * If a list of default values is given, these should be given in the 77 * same order as the value attributes to which they apply 67 78 * 68 * @param attributeName The name of the attribute to test. 69 * @return True if the attribute is a value attribute. 79 * @see getValueAttributes(); 70 80 */ 71 public boolean isValueAttribute(String attributeName) { 72 73 if (attributeName == null) return false; 74 75 String[] attributes = getValueAttributes(); 76 for (int i=0; i<attributes.length; i++) { 77 if (attributeName.equals(attributes[i])) 78 return true; 79 } 80 return false; 81 public String[] getDefaultAttributes() { 82 return new String[] {}; 81 83 } 82 84 85 public abstract boolean isParamFilled(); 86 87 88 83 89 public String getFieldType() { 84 return fieldType;90 return getAttribute(PARAM_TYPE); 85 91 } 86 92 -
branches/OmeroEditor/src/fields/DateTimeParam.java
r5543 r5546 32 32 33 33 /** 34 * 34 * An experimental parameter that represents a Date (with optional Time). 35 * Also an optional Alarm time can be set (in seconds before 36 * (negative value) or after the Date/Time). 35 37 * 36 38 * @author William Moore … … 42 44 * @since OME3.0 43 45 */ 44 public class DateTime ValueObject extends AbstractValueObject{46 public class DateTimeParam extends AbstractParam { 45 47 46 48 public static final String DATE_ATTRIBUTE = DataFieldConstants.UTC_MILLISECS; 47 49 48 50 public static final String TIME_ATTRIBUTE = DataFieldConstants.SECONDS; 51 52 public static final String ALARM_SECONDS = DataFieldConstants.ALARM_SECONDS; 49 53 50 54 /** … … 53 57 * @param fieldType The String defining the field type 54 58 */ 55 public DateTime ValueObject(String fieldType) {59 public DateTimeParam(String fieldType) { 56 60 super(fieldType); 57 61 } … … 64 68 65 69 return new String[] {DATE_ATTRIBUTE, 66 TIME_ATTRIBUTE };70 TIME_ATTRIBUTE, ALARM_SECONDS}; 67 71 } 68 72 69 73 /** 70 * This field is filled if the value isn't null, and74 * This field is filled if the DATE value isn't null, and 71 75 * is not an empty string. 72 76 */ 73 public boolean is FieldFilled() {74 String timeValue = getAttribute(getValueAttributes()[0]);77 public boolean isParamFilled() { 78 String dateValue = getAttribute(DATE_ATTRIBUTE); 75 79 76 return ( timeValue != null && timeValue.length() > 0);80 return (dateValue != null && dateValue.length() > 0); 77 81 } 78 82 -
branches/OmeroEditor/src/fields/Field.java
r5543 r5546 24 24 package fields; 25 25 26 import java.util.ArrayList; 26 27 import java.util.HashMap; 28 import java.util.List; 27 29 28 30 import tree.DataFieldConstants; 29 31 30 32 /** 33 * 34 * 35 * @author William Moore 36 * <a href="mailto:will@lifesci.dundee.ac.uk">will@lifesci.dundee.ac.uk</a> 37 * @version 3.0 38 * <small> 39 * (<b>Internal version:</b> $Revision: $Date: $) 40 * </small> 41 * @since OME3.0 42 */ 31 43 public class Field 32 44 implements IField { 45 46 public static final String FIELD_NAME = "fieldName"; 47 48 public static final String FIELD_DESCRIPTION = "fieldDescription"; 49 50 public static final String FIELD_URL = "fieldUrl"; 51 52 53 private List<IParam> fieldParams; 33 54 34 55 HashMap<String, String> allAttributesMap; … … 40 61 * field. 41 62 */ 42 private IFieldValue fieldValue;63 //private IFieldValue fieldValue; 43 64 44 65 public Field() { 45 this("untitled" , null, DataFieldConstants.FIXED_PROTOCOL_STEP);66 this("untitled"); 46 67 } 47 68 48 public Field(String name , String value, String fieldType) {69 public Field(String name) { 49 70 50 71 allAttributesMap = new HashMap<String, String>(); 72 fieldParams = new ArrayList<IParam>(); 51 73 52 fieldValue = FieldValueFactory.getFieldValue(fieldType);74 setAttribute(FIELD_NAME, name); 53 75 54 setAttribute(DataFieldConstants.ELEMENT_NAME, name);55 setAttribute(DataFieldConstants.VALUE, value);56 76 } 57 77 58 78 public String getAttribute(String name) { 59 79 //System.out.println("Field getAttribute()"); 60 if (fieldValue.isValueAttribute(name)) {61 return fieldValue.getAttribute(name);62 }63 80 64 81 return allAttributesMap.get(name); … … 66 83 67 84 public void setAttribute(String name, String value) { 68 System.out.println("Field setAttribute() " + name + " = " + value); 69 if (fieldValue.isValueAttribute(name)) { 70 fieldValue.setAttribute(name, value); 71 } 85 72 86 allAttributesMap.put(name, value); 73 87 } 74 88 75 89 public String toString() { 76 return getAttribute(DataFieldConstants.ELEMENT_NAME) + ": " + 77 getAttribute(DataFieldConstants.VALUE); 90 return getAttribute(DataFieldConstants.ELEMENT_NAME); 78 91 } 79 92 93 80 94 public boolean isAttributeTrue(String attributeName) { 81 95 String value = getAttribute(attributeName); … … 83 97 } 84 98 85 public IFieldValue getValueObject() { 86 return fieldValue; 87 } 88 89 /** 90 * Gets the names of the attributes where this field stores its "value"s. 91 * This is used eg. (if a single value is returned) 92 * as the destination to copy the default value when defaults are loaded. 93 * Also used by EditClearFields to set all values back to null. 94 * This method delegates to the Value object for this field. 95 * 96 * @return the names of the attributes that holds the "value" of this field 97 */ 98 public String[] getValueAttributes() { 99 return fieldValue.getValueAttributes(); 100 } 99 101 100 102 101 /** … … 113 112 */ 114 113 public boolean isFieldFilled() { 115 return fieldValue.isFieldFilled(); 114 115 for (IParam param : fieldParams) { 116 if (! param.isParamFilled()) { 117 return false; 118 } 119 } 120 return true; 121 } 122 123 public int getParamCount() { 124 return fieldParams.size(); 125 } 126 127 public IParam getParamAt(int index) { 128 return fieldParams.get(index); 129 } 130 131 public void addParam(IParam param) { 132 fieldParams.add(param); 133 } 134 135 public boolean removeParam(IParam param) { 136 return fieldParams.remove(param); 116 137 } 117 138 } -
branches/OmeroEditor/src/fields/FieldPanel.java
r5543 r5546 204 204 Border imageBorderHighlight; 205 205 206 /**207 * A flag used to toggle the display of the description.208 */209 boolean showDescription = false;210 211 206 212 207 /** … … 259 254 descriptionButton.addActionListener(new ActionListener(){ 260 255 public void actionPerformed(ActionEvent event) { 261 showDescription = !showDescription; 262 descriptionLabel.setVisible(showDescription); 256 // TODO 257 // Need to set an attribute in the dataField such as 258 // descriptionVisible = true / false 263 259 } 264 260 }); … … 326 322 horizontalBox.add(defaultButton); 327 323 horizontalBox.add(requiredFieldButton); 324 horizontalBox.add(descriptionLabel); 328 325 horizontalBox.add(Box.createHorizontalStrut(10)); 329 326 … … 337 334 contentsPanel.add(nameLabel, BorderLayout.WEST); 338 335 contentsPanel.add(horizontalBox, BorderLayout.CENTER); 339 contentsPanel.add(descriptionLabel, BorderLayout.SOUTH);336 //contentsPanel.add(descriptionLabel, BorderLayout.SOUTH); 340 337 341 338 contentsPanel.setBorder(imageBorder); … … 349 346 */ 350 347 setNameText(addHtmlTagsForNameLabel( 351 dataField.getAttribute( DataFieldConstants.ELEMENT_NAME)));348 dataField.getAttribute(Field.FIELD_NAME))); 352 349 setDescriptionText( 353 dataField.getAttribute( DataFieldConstants.DESCRIPTION));354 setURL(dataField.getAttribute( DataFieldConstants.URL));350 dataField.getAttribute(Field.FIELD_DESCRIPTION)); 351 setURL(dataField.getAttribute(Field.FIELD_URL)); 355 352 356 353 refreshBackgroundColour(); … … 358 355 refreshDefaultValue(); 359 356 360 /* 361 * Add additional UI components for editing the value of this field. 362 * Use a Factory to create the UI components, depending on the value type 363 */ 364 IFieldValue valueObject = ((Field)field).getValueObject(); 365 JComponent edit = EditingComponentFactory.getEditingComponent(valueObject); 366 addFieldComponent(edit); 357 buildParamComponents(); 358 } 359 360 /** 361 * Add additional UI components for editing the value of this field. 362 * Use a Factory to create the UI components, depending on the value type 363 */ 364 public void buildParamComponents() { 365 366 int paramCount = dataField.getParamCount(); 367 368 for (int i=0; i<paramCount; i++) { 369 IParam param = dataField.getParamAt(i); 370 JComponent edit = EditingComponentFactory.getEditingComponent(param); 371 if (edit != null) 372 addFieldComponent(edit); 373 } 374 367 375 } 368 376 … … 440 448 } 441 449 450 451 442 452 public void setDescriptionText(String description) { 443 453 if ((description != null) && (description.trim().length() > 0)) { … … 445 455 descriptionButton.setToolTipText(htmlDescription); 446 456 descriptionButton.setVisible(true); 447 descriptionLabel.setVisible(showDescription); 457 // TODO setVisibility of label based on dataField attribute 458 //descriptionLabel.setVisible(showDescription); 448 459 descriptionLabel.setFont(XMLView.FONT_TINY); 449 460 descriptionLabel.setText(htmlDescription); … … 552 563 553 564 565 /** 566 * If the size of a sub-component of this panel changes, 567 * the JTree in which it is contained must be required to 568 * re-draw the panel. 569 */ 554 570 public void propertyChange(PropertyChangeEvent evt) { 555 571 556 572 if (SIZE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { 557 573 558 if ((tree != null) && (treeNode !=null)) { 559 560 TreePath path = new TreePath(treeNode.getPath()); 561 562 tree.getUI().startEditingAtPath(tree, path); 563 } 564 } 565 } 566 574 refreshSizeOfPanel(); 575 } 576 } 577 578 579 /** 580 * This method is used to refresh the size of this panel in the JTree. 581 * It must also remain in the editing mode, otherwise the user who 582 * is currently editing it will be required to click again to 583 * continue editing. 584 * This can be achieved by calling startEditingAtPath(tree, path) 585 */ 586 public void refreshSizeOfPanel() { 587 if ((tree != null) && (treeNode !=null)) { 588 589 TreePath path = new TreePath(treeNode.getPath()); 590 591 tree.getUI().startEditingAtPath(tree, path); 592 } 593 } 567 594 568 595 -
branches/OmeroEditor/src/fields/FieldParamsFactory.java
r5543 r5546 23 23 package fields; 24 24 25 import tree.DataFieldConstants;26 import ui.fieldEditors.FieldEditorCheckBox;27 import ui.fieldEditors.FieldEditorCustom;28 import ui.fieldEditors.FieldEditorDate;29 import ui.fieldEditors.FieldEditorDateTime;30 import ui.fieldEditors.FieldEditorDropDown;31 import ui.fieldEditors.FieldEditorFixed;32 import ui.fieldEditors.FieldEditorMemo;33 import ui.fieldEditors.FieldEditorNumber;34 import ui.fieldEditors.FieldEditorOLS;35 import ui.fieldEditors.FieldEditorObservation;36 import ui.fieldEditors.FieldEditorProtocol;37 import ui.fieldEditors.FieldEditorTable;38 import ui.fieldEditors.FieldEditorText;39 import ui.fieldEditors.FieldEditorTime;40 41 25 //Java imports 42 26 … … 44 28 45 29 //Application-internal dependencies 30 31 import tree.DataFieldConstants; 46 32 47 33 /** … … 56 42 * @since OME3.0 57 43 */ 58 public class Field ValueFactory {44 public class FieldParamsFactory { 59 45 60 public static I FieldValue getFieldValue(String inputType) {46 public static IParam getFieldParam(String paramType) { 61 47 62 I FieldValuefieldValue = null;48 IParam fieldValue = null; 63 49 64 if ( inputType == null) {65 fieldValue = new No Value(DataFieldConstants.FIXED_PROTOCOL_STEP);50 if (paramType == null) { 51 fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP); 66 52 } 67 else if ( inputType.equals(DataFieldConstants.TEXT_ENTRY_STEP)) {68 fieldValue = new TextValueObject(DataFieldConstants.TEXT_ENTRY_STEP);53 else if (paramType.equals(DataFieldConstants.TEXT_ENTRY_STEP)) { 54 fieldValue = new SingleParam(DataFieldConstants.TEXT_ENTRY_STEP); 69 55 } 70 else if ( inputType.equals(DataFieldConstants.FIXED_PROTOCOL_STEP)) {71 fieldValue = new No Value(DataFieldConstants.FIXED_PROTOCOL_STEP);56 else if (paramType.equals(DataFieldConstants.FIXED_PROTOCOL_STEP)) { 57 fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP); 72 58 } 73 else if ( inputType.equals(DataFieldConstants.DATE_TIME_FIELD)) {74 fieldValue = new DateTime ValueObject(DataFieldConstants.DATE_TIME_FIELD);59 else if (paramType.equals(DataFieldConstants.DATE_TIME_FIELD)) { 60 fieldValue = new DateTimeParam(DataFieldConstants.DATE_TIME_FIELD); 75 61 } 76 62 -
branches/OmeroEditor/src/fields/IField.java
r5543 r5546 30 30 31 31 /** 32 * This interface specifies the minimum methods needed to save and 33 * retrieve data. 34 * It also has a convenience method for querying boolean attributes. 32 * This interface specifies methods of a Field, which corresponds to a node
