Changeset 5546 for branches/OmeroEditor/src/fields/Field.java
- Timestamp:
- 07/23/08 15:32:07 (4 months ago)
- Files:
-
- 1 modified
-
branches/OmeroEditor/src/fields/Field.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }
