Changeset 5547
- Timestamp:
- 07/24/08 11:43:53 (4 months ago)
- Location:
- branches/OmeroEditor/src
- Files:
-
- 4 added
- 1 removed
- 14 modified
-
fields/AbstractParam.java (modified) (4 diffs)
-
fields/DateTimeParam.java (modified) (2 diffs)
-
fields/Field.java (modified) (7 diffs)
-
fields/FieldPanel.java (modified) (2 diffs)
-
fields/FieldParamsFactory.java (modified) (2 diffs)
-
fields/IAttributes.java (modified) (1 diff)
-
fields/IField.java (modified) (1 diff)
-
fields/NoParam.java (deleted)
-
treeModel/TreeEditorControl.java (modified) (3 diffs)
-
treeModel/TreeEditorUI.java (modified) (3 diffs)
-
treeModel/editActions/AddFieldAction.java (added)
-
treeModel/editActions/DeleteFieldsAction.java (modified) (2 diffs)
-
treeModel/editActions/DuplicateFieldsAction.java (added)
-
treeModel/editActions/RedoEditAction.java (modified) (2 diffs)
-
treeModel/editActions/UndoEditAction.java (modified) (2 diffs)
-
treeModel/undoableTreeEdits/AddFieldEdit.java (added)
-
treeModel/undoableTreeEdits/DeleteFieldsEdit.java (modified) (2 diffs)
-
treeModel/undoableTreeEdits/DuplicateFieldsEdit.java (added)
-
treeModel/undoableTreeEdits/TreeModelMethods.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/OmeroEditor/src/fields/AbstractParam.java
r5546 r5547 35 35 36 36 /** 37 * An abstract example 37 * An Abstract superclass of the Parameter object used to model an 38 * experimental variable (or parameter) within a Field (or tree node). 39 * All Parameter objects store their data in an attribute Map<String, String>. 40 * 41 * Subclasses must implement the getValueAttributes() method to provide an 42 * Array of the attribute names that they use to store the "value" of the 43 * parameter (as opposed to name etc). 44 * Subclasses may want to implement getDefaultAttributes(), if they 45 * have attributes for storing default values. 46 * Subclasses must also implement isParamFilled(), depending on how many 47 * attributes must be not null in order that the field is 'valid' 38 48 * 39 49 * @author William Moore … … 49 59 IParam { 50 60 61 /** 62 * A property of a Parameter object that indicates what type of data 63 * the parameter is. Eg. {link# SingleParam.TEXT_LINE_PARAM} 64 */ 51 65 public static final String PARAM_TYPE = "paramType"; 52 66 67 /** 68 * A property to give a name to this Parameter object. 69 * Users will set this and it can be displayed in UI. 70 * eg "Temperature" 71 */ 53 72 public static final String PARAM_NAME = "paramName"; 54 73 … … 60 79 valueAttributesMap = new HashMap<String, String>(); 61 80 valueAttributesMap.put(PARAM_TYPE, fieldType); 81 } 82 83 /** 84 * Convenience method for getting all the attributes of this class, 85 * eg for duplicating an instance. 86 * 87 * @return A map of all the attributes for this Parameter 88 */ 89 public HashMap<String, String> getAllAttributes() { 90 return valueAttributesMap; 91 } 92 93 /** 94 * Convenience method for setting all the attributes of this class, 95 * eg for cloning an instance. 96 * 97 * @newAttributes A map of all the new attributes for this Parameter 98 */ 99 public void setAllAttributes(HashMap<String, String> newAttributes) { 100 valueAttributesMap = newAttributes; 62 101 } 63 102 … … 83 122 } 84 123 124 /** 125 * Should return true if the parameter is filled. 126 */ 85 127 public abstract boolean isParamFilled(); 86 87 128 88 129 /** 130 * Returns a string to identify the type of field. 131 * @return 132 */ 89 133 public String getFieldType() { 90 134 return getAttribute(PARAM_TYPE); 91 135 } 92 136 137 /** 138 * @see IAttributes.getAttribute(String name) 139 */ 93 140 public String getAttribute(String name) { 94 141 return valueAttributesMap.get(name); 95 142 } 96 143 144 /** 145 * @see IAttributes.isAttributeTrue(String attributeName) 146 */ 97 147 public boolean isAttributeTrue(String attributeName) { 98 148 return (DataFieldConstants.TRUE.equals(getAttribute(attributeName))); 99 149 } 100 150 151 /** 152 * @see IAttributes.setAttribute(String name, String value) 153 */ 101 154 public void setAttribute(String name, String value) { 102 155 System.out.println("ValueObject setAttribute() " + name + " = " + value); -
branches/OmeroEditor/src/fields/DateTimeParam.java
r5546 r5547 46 46 public class DateTimeParam extends AbstractParam { 47 47 48 /** 49 * A property of this parameter. 50 * This stores a Date (not time) in UTC milliseconds. 51 * Used by the Date-Picker 52 * If the number of millisecs is equivalent to a small number of days (<10) 53 * then this is a "relative" date, a number of days after a previous date. 54 */ 48 55 public static final String DATE_ATTRIBUTE = DataFieldConstants.UTC_MILLISECS; 49 56 57 /** 58 * A property of this parameter. 59 * This stores a Time of Day in Seconds. Optional. 60 */ 50 61 public static final String TIME_ATTRIBUTE = DataFieldConstants.SECONDS; 51 62 63 /** 64 * A property of this parameter. 65 * This stores an alarm time in seconds, relative to the Date-Time 66 * specified by the other attributes of this parameter. 67 * This will be a negative number if the alarm is before the event. 68 * Eg 1 hour before = "-3600" 69 */ 52 70 public static final String ALARM_SECONDS = DataFieldConstants.ALARM_SECONDS; 53 71 … … 63 81 64 82 /** 65 * Th e value attribute is a single value83 * This parameter stores its value in 3 attributes. 66 84 */ 67 85 public String[] getValueAttributes() { -
branches/OmeroEditor/src/fields/Field.java
r5546 r5547 27 27 import java.util.HashMap; 28 28 import java.util.List; 29 import java.util.Map; 29 30 30 31 import tree.DataFieldConstants; 31 32 32 33 /** 33 * 34 * This is the data object that occupies a node of the tree hierarchy. 35 * It has name, description, url, stored in an AttributeMap, and may 36 * have 0, 1 or more Parameter objects {link# IParam} to store 37 * experimental variables, or parameters. 34 38 * 35 39 * @author William Moore … … 44 48 implements IField { 45 49 50 /** 51 * A property of this field. The attribute for an (optional) Name. 52 */ 46 53 public static final String FIELD_NAME = "fieldName"; 47 54 55 /** 56 * A property of this field. The attribute for an optional Description. 57 */ 48 58 public static final String FIELD_DESCRIPTION = "fieldDescription"; 49 59 60 /** 61 * A property of this field. The attribute for an optional Url. 62 */ 50 63 public static final String FIELD_URL = "fieldUrl"; 51 64 52 65 /** 66 * The list of Parameters, representing experimental variables for this 67 * field. 68 */ 53 69 private List<IParam> fieldParams; 54 70 71 /** 72 * A map of attributes for this Field. eg Name, Description etc. 73 */ 55 74 HashMap<String, String> allAttributesMap; 56 75 57 76 /** 58 * The "Value" of the field. 59 * This could be a simple string, or a mixture of dates, times etc. 60 * It represents the experimental parameters that are stored by this 61 * field. 62 */ 63 //private IFieldValue fieldValue; 64 77 * Default constructor. Sets the name of the field to "untitled" 78 */ 65 79 public Field() { 66 80 this("untitled"); 67 81 } 68 82 83 /** 84 * Duplicates a field by making a copy of the given field. 85 * 86 * @param cloneField The field to be copied. 87 */ 88 public Field(Field cloneField) { 89 this(); 90 91 /* 92 * Clone all attributes 93 */ 94 allAttributesMap = new HashMap<String,String> 95 (cloneField.getAllAttributes()); 96 97 /* 98 * Clone the parameter objects... 99 */ 100 for (int i=0; i<cloneField.getParamCount(); i++) { 101 IParam param = cloneField.getParamAt(i); 102 IParam newP = FieldParamsFactory.cloneParam(param); 103 addParam(newP); 104 } 105 } 106 107 /** 108 * A constructor used to set the name of the field. 109 * This constructor is called by the others, in order to initialise 110 * the attributesMap and parameters list. 111 * 112 * @param name A name given to this field. 113 */ 69 114 public Field(String name) { 70 115 … … 76 121 } 77 122 123 /** 124 * gets an attribute in the attributesMap 125 */ 78 126 public String getAttribute(String name) { 79 127 //System.out.println("Field getAttribute()"); … … 82 130 } 83 131 132 /** 133 * gets all attributes in the attributesMap 134 */ 135 public Map getAllAttributes() { 136 return allAttributesMap; 137 } 138 139 /** 140 * sets an attribute in the attributesMap 141 */ 84 142 public void setAttribute(String name, String value) { 85 143 … … 87 145 } 88 146 147 /** 148 * For display etc. Simply returns the name... 149 */ 89 150 public String toString() { 90 151 return getAttribute(DataFieldConstants.ELEMENT_NAME); 91 152 } 92 153 93 154 /** 155 * Convenience method for querying the attributes map for 156 * boolean attributes. 157 */ 94 158 public boolean isAttributeTrue(String attributeName) { 95 159 String value = getAttribute(attributeName); … … 102 166 * This method tests to see whether the field has been filled out. 103 167 * ie, Has the user entered a "valid" value into the Form. 104 * For fields that have a single 'value', this method will return true if 105 * that value is filled (not null). 106 * For fields with several attributes, it depends on what is considered 'filled'. 107 * This method can be used to check that 'Obligatory Fields' have been completed 108 * when a file is saved. 109 * Subclasses should override this method. 168 * This will return false if any of the parameters for this field are 169 * not filled. 110 170 * 111 * @return True if the field has been filled out by user. Required values are not null.171 * @return True if the all the parameters have been filled out by user. 112 172 */ 113 173 public boolean isFieldFilled() { … … 121 181 } 122 182 183 /** 184 * Returns the number of IParam parameters for this field. 185 */ 123 186 public int getParamCount() { 124 187 return fieldParams.size(); 125 188 } 126 189 190 /** 191 * Returns the parameter of this field at the given index. 192 */ 127 193 public IParam getParamAt(int index) { 128 194 return fieldParams.get(index); 129 195 } 130 196 197 /** 198 * Adds a parameter to the list for this field 199 */ 131 200 public void addParam(IParam param) { 132 201 fieldParams.add(param); 133 202 } 134 203 204 /** 205 * Removes the specified parameter from the list. 206 */ 135 207 public boolean removeParam(IParam param) { 136 208 return fieldParams.remove(param); -
branches/OmeroEditor/src/fields/FieldPanel.java
r5546 r5547 54 54 55 55 import tree.DataFieldConstants; 56 import treeEditingComponents.DateTimeField;57 56 import treeEditingComponents.EditingComponentFactory; 58 57 import ui.XMLView; … … 66 65 * Displays a name, description etc. and holds other UI 67 66 * components that are specific to the types of data being edited. 67 * These components display and edit the Parameters of this field. 68 68 * 69 69 * @author William Moore -
branches/OmeroEditor/src/fields/FieldParamsFactory.java
r5546 r5547 29 29 //Application-internal dependencies 30 30 31 import java.util.HashMap; 32 31 33 import tree.DataFieldConstants; 32 34 33 35 /** 34 * 36 * This factory is used to create new Parameter objects (subclasses of 37 * AbstractParam), according to the String that describes their data type. 35 38 * 36 39 * @author William Moore … … 44 47 public class FieldParamsFactory { 45 48 49 public static IParam cloneParam(IParam cloneThis) { 50 51 String paramType = cloneThis.getAttribute(AbstractParam.PARAM_TYPE); 52 53 AbstractParam newParam = (AbstractParam)getFieldParam(paramType); 54 HashMap<String, String> attr = new HashMap<String, String>( 55 ((AbstractParam)cloneThis).getAllAttributes()); 56 57 if(newParam != null) // just in case... 58 newParam.setAllAttributes(attr); 59 60 return newParam; 61 } 62 63 /** 64 * This create new Parameter objects (subclasses of 65 * AbstractParam), according to the String that describes their data type. 66 * 67 * @param paramType A string to describe the data type 68 * @return A new parameter object 69 */ 46 70 public static IParam getFieldParam(String paramType) { 47 71 48 72 IParam fieldValue = null; 49 73 50 if (paramType == null) {51 fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP);74 if (paramType.equals(SingleParam.TEXT_LINE_PARAM)) { 75 fieldValue = new SingleParam(SingleParam.TEXT_LINE_PARAM); 52 76 } 53 else if (paramType.equals(DataFieldConstants.TEXT_ENTRY_STEP)) { 54 fieldValue = new SingleParam(DataFieldConstants.TEXT_ENTRY_STEP); 55 } 56 else if (paramType.equals(DataFieldConstants.FIXED_PROTOCOL_STEP)) { 57 fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP); 77 else if (paramType.equals(SingleParam.TEXT_BOX_PARAM)) { 78 fieldValue = new SingleParam(SingleParam.TEXT_BOX_PARAM); 58 79 } 59 80 else if (paramType.equals(DataFieldConstants.DATE_TIME_FIELD)) { -
branches/OmeroEditor/src/fields/IAttributes.java
r5546 r5547 30 30 31 31 /** 32 * 32 * Methods for editing a collection of attributes. 33 * The attributes are identified by name (String) and the values are Strings. 33 34 * 34 35 * @author William Moore -
branches/OmeroEditor/src/fields/IField.java
r5546 r5547 49 49 extends IAttributes { 50 50 51 51 /** 52 * Returns the number of parameters for this field 53 * 54 * @return the number of parameters for this field 55 */ 52 56 public int getParamCount(); 53 57 58 /** 59 * Returns a parameter object at the specified index 60 * 61 * @param index 62 * @return 63 */ 54 64 public IParam getParamAt(int index); 55 65 66 /** 67 * Adds a parameter object to the field 68 * 69 * @param param 70 */ 56 71 public void addParam(IParam param); 57 72 73 /** 74 * Removes a parameter object from the field 75 * 76 * @param param The object to remove 77 * @return True if the object was found and removed. 78 */ 58 79 public boolean removeParam(IParam param); 59 80 81 /** 82 * Indicates whether all parameters have been filled out. 83 * 84 * @return True if all the parameters have been filled. 85 */ 60 86 public boolean isFieldFilled(); 61 87 -
branches/OmeroEditor/src/treeModel/TreeEditorControl.java
r5546 r5547 33 33 import javax.swing.undo.UndoableEditSupport; 34 34 35 import treeModel.editActions.AddFieldAction; 35 36 import treeModel.editActions.DeleteFieldsAction; 37 import treeModel.editActions.DuplicateFieldsAction; 36 38 import treeModel.editActions.RedoEditAction; 37 39 import treeModel.editActions.UndoEditAction; … … 73 75 public static final Integer REDO_ACTION = new Integer(3); 74 76 77 public static final Integer ADD_FIELD_ACTION = new Integer(4); 78 79 public static final Integer DUPLICATE_FIELDS_ACTION = new Integer(5); 80 81 75 82 public void initialise(ITreeEditor model, TreeEditorUI view) { 76 83 … … 91 98 actions = new HashMap<Integer, Action>(); 92 99 100 actions.put(ADD_FIELD_ACTION, new AddFieldAction(undoSupport)); 93 101 actions.put(DELETE_FIELD_ACTION, new DeleteFieldsAction(undoSupport)); 94 102 actions.put(UNDO_ACTION, new UndoEditAction(undoManager, undoSupport)); 95 103 actions.put(REDO_ACTION, new RedoEditAction(undoManager, undoSupport)); 104 actions.put(DUPLICATE_FIELDS_ACTION, new DuplicateFieldsAction(undoSupport)); 96 105 97 106 } -
branches/OmeroEditor/src/treeModel/TreeEditorUI.java
r5546 r5547 26 26 27 27 import javax.swing.Action; 28 import javax.swing.BorderFactory; 28 29 import javax.swing.Box; 29 30 import javax.swing.JButton; 30 31 import javax.swing.JComponent; 31 32 import javax.swing.JPanel; 33 import javax.swing.border.Border; 32 34 33 35 import treeModel.editActions.AbstractEditorAction; … … 79 81 Box toolBarBox = Box.createHorizontalBox(); 80 82 83 addActionButton(toolBarBox, TreeEditorControl.ADD_FIELD_ACTION); 84 addActionButton(toolBarBox, TreeEditorControl.DUPLICATE_FIELDS_ACTION); 81 85 addActionButton(toolBarBox, TreeEditorControl.DELETE_FIELD_ACTION); 82 86 addActionButton(toolBarBox, TreeEditorControl.UNDO_ACTION); … … 92 96 ((AbstractEditorAction)newAction).setTree(treeUI.getJTree()); 93 97 } 94 comp.add(new JButton(newAction)); 98 JButton newButton = new JButton(newAction); 99 Border emptyBorder = BorderFactory.createEmptyBorder(4,4,4,4); 100 newButton.setText(null); 101 newButton.setBorder(emptyBorder); 102 newButton.setBackground(null); 103 comp.add(newButton); 95 104 } 96 105 -
branches/OmeroEditor/src/treeModel/editActions/DeleteFieldsAction.java
r5546 r5547 36 36 import treeModel.undoableTreeEdits.DeleteFieldsEdit; 37 37 import treeModel.undoableTreeEdits.UndoableTreeEdit; 38 import util.ImageFactory; 38 39 39 40 … … 77 78 putValue(Action.NAME, "Delete Fields"); 78 79 putValue(Action.SHORT_DESCRIPTION, "Delete the currently selected fields"); 79 //putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.ADD_ICON));80 putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.DELETE_ICON)); 80 81 } 81 82 -
branches/OmeroEditor/src/treeModel/editActions/RedoEditAction.java
r5546 r5547 33 33 import javax.swing.undo.UndoManager; 34 34 import javax.swing.undo.UndoableEditSupport; 35 36 import util.ImageFactory; 35 37 36 38 //Third-party libraries … … 78 80 79 81 putValue(Action.NAME, "Redo"); 80 //putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.ADD_ICON));82 putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.REDO_ICON)); 81 83 82 84 refreshStatus(); // sets description, enabled etc. -
branches/OmeroEditor/src/treeModel/editActions/UndoEditAction.java
r5546 r5547 33 33 import javax.swing.undo.UndoManager; 34 34 import javax.swing.undo.UndoableEditSupport; 35 36 import util.ImageFactory; 35 37 36 38 //Third-party libraries … … 78 80 79 81 putValue(Action.NAME, "Undo"); 80 //putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.ADD_ICON));
