• 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 5543 for branches/OmeroEditor/src/fields/Field.java

Show
Ignore:
Timestamp:
07/17/08 16:32:21 (4 months ago)
Author:
will
Message:

Basically working JTree, with custom Rendering, Editing and Selection behavior

Files:
1 modified

  • branches/OmeroEditor/src/fields/Field.java (modified) (1 diff)

Legend:

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

    r5536 r5543  
    2626import java.util.HashMap; 
    2727 
     28import tree.DataFieldConstants; 
    2829 
    29 public class Field { 
     30 
     31public class Field  
     32        implements IField { 
    3033 
    3134        HashMap<String, String> allAttributesMap; 
    3235         
     36        /** 
     37         * The "Value" of the field.  
     38         * This could be a simple string, or a mixture of dates, times etc.  
     39         * It represents the experimental parameters that are stored by this 
     40         * field.  
     41         */ 
     42        private IFieldValue fieldValue; 
     43         
    3344        public Field() { 
    34                 this("untitled", "no value"); 
     45                this("untitled", null, DataFieldConstants.FIXED_PROTOCOL_STEP); 
    3546        } 
    3647         
    37         public Field(String name, String value) { 
     48        public Field(String name, String value, String fieldType) { 
    3849                 
    3950                allAttributesMap = new HashMap<String, String>(); 
    4051                 
    41                 setAttribute("name", name); 
    42                 setAttribute("value", value); 
     52                fieldValue = FieldValueFactory.getFieldValue(fieldType); 
     53                 
     54                setAttribute(DataFieldConstants.ELEMENT_NAME, name); 
     55                setAttribute(DataFieldConstants.VALUE, value); 
    4356        } 
    4457         
    4558        public String getAttribute(String name) { 
     59                //System.out.println("Field getAttribute()"); 
     60                if (fieldValue.isValueAttribute(name)) { 
     61                        return fieldValue.getAttribute(name); 
     62                } 
     63                 
    4664                return allAttributesMap.get(name); 
    4765        } 
    4866         
    4967        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                } 
    5072                allAttributesMap.put(name, value); 
    5173        } 
    5274         
    5375        public String toString() { 
    54                 return getAttribute("name") + ": " + getAttribute("value"); 
     76                return getAttribute(DataFieldConstants.ELEMENT_NAME) + ": " +  
     77                getAttribute(DataFieldConstants.VALUE); 
     78        } 
     79 
     80        public boolean isAttributeTrue(String attributeName) { 
     81                String value = getAttribute(attributeName); 
     82                return DataFieldConstants.TRUE.equals(value); 
     83        } 
     84         
     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        } 
     101         
     102        /** 
     103         * This method tests to see whether the field has been filled out.  
     104         * ie, Has the user entered a "valid" value into the Form.  
     105         * For fields that have a single 'value', this method will return true if  
     106         * that value is filled (not null).  
     107         * For fields with several attributes, it depends on what is considered 'filled'. 
     108         * This method can be used to check that 'Obligatory Fields' have been completed  
     109         * when a file is saved.  
     110         * Subclasses should override this method. 
     111         *  
     112         * @return      True if the field has been filled out by user. Required values are not null.  
     113         */ 
     114        public boolean isFieldFilled() { 
     115                return fieldValue.isFieldFilled(); 
    55116        } 
    56117} 

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/