• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.clients
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 5546 for branches/OmeroEditor/src/fields/Field.java

Show
Ignore:
Timestamp:
07/23/08 15:32:07 (4 months ago)
Author:
will
Message:

Actions and UndoableEdit? framework setup.
Can open Beta 3.0 XML files (not all fields rendered yet)

Files:
1 modified

  • branches/OmeroEditor/src/fields/Field.java (modified) (5 diffs)

Legend:

Unmodified
Added
Removed
  • branches/OmeroEditor/src/fields/Field.java

    r5543 r5546  
    2424package fields; 
    2525 
     26import java.util.ArrayList; 
    2627import java.util.HashMap; 
     28import java.util.List; 
    2729 
    2830import tree.DataFieldConstants; 
    2931 
    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 */ 
    3143public class Field  
    3244        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; 
    3354 
    3455        HashMap<String, String> allAttributesMap; 
    … …  
    4061         * field.  
    4162         */ 
    42         private IFieldValue fieldValue; 
     63        //private IFieldValue fieldValue; 
    4364         
    4465        public Field() { 
    45                 this("untitled", null, DataFieldConstants.FIXED_PROTOCOL_STEP); 
     66                this("untitled"); 
    4667        } 
    4768         
    48         public Field(String name, String value, String fieldType) { 
     69        public Field(String name) { 
    4970                 
    5071                allAttributesMap = new HashMap<String, String>(); 
     72                fieldParams = new ArrayList<IParam>(); 
    5173                 
    52                 fieldValue = FieldValueFactory.getFieldValue(fieldType); 
     74                setAttribute(FIELD_NAME, name); 
    5375                 
    54                 setAttribute(DataFieldConstants.ELEMENT_NAME, name); 
    55                 setAttribute(DataFieldConstants.VALUE, value); 
    5676        } 
    5777         
    5878        public String getAttribute(String name) { 
    5979                //System.out.println("Field getAttribute()"); 
    60                 if (fieldValue.isValueAttribute(name)) { 
    61                         return fieldValue.getAttribute(name); 
    62                 } 
    6380                 
    6481                return allAttributesMap.get(name); 
    … …  
    6683         
    6784        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                 
    7286                allAttributesMap.put(name, value); 
    7387        } 
    7488         
    7589        public String toString() { 
    76                 return getAttribute(DataFieldConstants.ELEMENT_NAME) + ": " +  
    77                 getAttribute(DataFieldConstants.VALUE); 
     90                return getAttribute(DataFieldConstants.ELEMENT_NAME); 
    7891        } 
    7992 
     93         
    8094        public boolean isAttributeTrue(String attributeName) { 
    8195                String value = getAttribute(attributeName); 
    … …  
    8397        } 
    8498         
    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 
    101100         
    102101        /** 
    … …  
    113112         */ 
    114113        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); 
    116137        } 
    117138} 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/