• 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 Changeset
  • Next Changeset →

Changeset 5547

Show
Ignore:
Timestamp:
07/24/08 11:43:53 (4 months ago)
Author:
will
Message:

Duplicate fields Action and Edit.
More docs

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  
    3535 
    3636/**  
    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' 
    3848 * 
    3949 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
    … …  
    4959        IParam { 
    5060         
     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         */ 
    5165        public static final String PARAM_TYPE = "paramType"; 
    5266         
     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         */ 
    5372        public static final String PARAM_NAME = "paramName"; 
    5473         
    … …  
    6079                valueAttributesMap = new HashMap<String, String>(); 
    6180                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; 
    62101        } 
    63102         
    … …  
    83122        } 
    84123         
     124        /** 
     125         * Should return true if the parameter is filled.  
     126         */ 
    85127        public abstract boolean isParamFilled(); 
    86  
    87128         
    88          
     129        /** 
     130         * Returns a string to identify the type of field.  
     131         * @return 
     132         */ 
    89133        public String getFieldType() { 
    90134                return getAttribute(PARAM_TYPE); 
    91135        } 
    92136         
     137        /** 
     138         * @see         IAttributes.getAttribute(String name) 
     139         */ 
    93140        public String getAttribute(String name) { 
    94141                return valueAttributesMap.get(name); 
    95142        } 
    96143 
     144        /** 
     145         * @see         IAttributes.isAttributeTrue(String attributeName) 
     146         */ 
    97147        public boolean isAttributeTrue(String attributeName) { 
    98148                return (DataFieldConstants.TRUE.equals(getAttribute(attributeName))); 
    99149        } 
    100150 
     151        /** 
     152         * @see         IAttributes.setAttribute(String name, String value) 
     153         */ 
    101154        public void setAttribute(String name, String value) { 
    102155                System.out.println("ValueObject setAttribute() " + name + " = " + value); 
  • branches/OmeroEditor/src/fields/DateTimeParam.java

    r5546 r5547  
    4646public class DateTimeParam extends AbstractParam { 
    4747 
     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         */ 
    4855        public static final String DATE_ATTRIBUTE = DataFieldConstants.UTC_MILLISECS; 
    4956         
     57        /** 
     58         * A property of this parameter.  
     59         * This stores a Time of Day in Seconds. Optional.  
     60         */ 
    5061        public static final String TIME_ATTRIBUTE = DataFieldConstants.SECONDS; 
    5162         
     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         */ 
    5270        public static final String ALARM_SECONDS = DataFieldConstants.ALARM_SECONDS; 
    5371         
    … …  
    6381         
    6482        /** 
    65          * The value attribute is a single value 
     83         * This parameter stores its value in 3 attributes.  
    6684         */ 
    6785        public String[] getValueAttributes() { 
  • branches/OmeroEditor/src/fields/Field.java

    r5546 r5547  
    2727import java.util.HashMap; 
    2828import java.util.List; 
     29import java.util.Map; 
    2930 
    3031import tree.DataFieldConstants; 
    3132 
    3233/** 
    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.  
    3438 *  
    3539 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
    … …  
    4448        implements IField { 
    4549         
     50        /** 
     51         * A property of this field. The attribute for an (optional) Name. 
     52         */ 
    4653        public static final String FIELD_NAME = "fieldName"; 
    4754         
     55        /** 
     56         * A property of this field. The attribute for an optional Description. 
     57         */ 
    4858        public static final String FIELD_DESCRIPTION = "fieldDescription"; 
    4959         
     60        /** 
     61         * A property of this field. The attribute for an optional Url. 
     62         */ 
    5063        public static final String FIELD_URL = "fieldUrl"; 
    5164         
    52          
     65        /** 
     66         * The list of Parameters, representing experimental variables for this  
     67         * field. 
     68         */ 
    5369        private List<IParam> fieldParams; 
    5470 
     71        /** 
     72         * A map of attributes for this Field. eg Name, Description etc.  
     73         */ 
    5574        HashMap<String, String> allAttributesMap; 
    5675         
    5776        /** 
    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         */ 
    6579        public Field() { 
    6680                this("untitled"); 
    6781        } 
    6882         
     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         */ 
    69114        public Field(String name) { 
    70115                 
    … …  
    76121        } 
    77122         
     123        /** 
     124         * gets an attribute in the attributesMap 
     125         */ 
    78126        public String getAttribute(String name) { 
    79127                //System.out.println("Field getAttribute()"); 
    … …  
    82130        } 
    83131         
     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         */ 
    84142        public void setAttribute(String name, String value) { 
    85143                 
    … …  
    87145        } 
    88146         
     147        /** 
     148         * For display etc. Simply returns the name... 
     149         */ 
    89150        public String toString() { 
    90151                return getAttribute(DataFieldConstants.ELEMENT_NAME); 
    91152        } 
    92153 
    93          
     154        /** 
     155         * Convenience method for querying the attributes map for  
     156         * boolean attributes. 
     157         */ 
    94158        public boolean isAttributeTrue(String attributeName) { 
    95159                String value = getAttribute(attributeName); 
    … …  
    102166         * This method tests to see whether the field has been filled out.  
    103167         * 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.  
    110170         *  
    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.  
    112172         */ 
    113173        public boolean isFieldFilled() { 
    … …  
    121181        } 
    122182 
     183        /** 
     184         * Returns the number of IParam parameters for this field. 
     185         */ 
    123186        public int getParamCount() { 
    124187                return fieldParams.size(); 
    125188        } 
    126189 
     190        /** 
     191         * Returns the parameter of this field at the given index. 
     192         */ 
    127193        public IParam getParamAt(int index) { 
    128194                return fieldParams.get(index); 
    129195        } 
    130196 
     197        /** 
     198         * Adds a parameter to the list for this field 
     199         */ 
    131200        public void addParam(IParam param) { 
    132201                fieldParams.add(param); 
    133202        } 
    134203 
     204        /** 
     205         * Removes the specified parameter from the list.  
     206         */ 
    135207        public boolean removeParam(IParam param) { 
    136208                return fieldParams.remove(param); 
  • branches/OmeroEditor/src/fields/FieldPanel.java

    r5546 r5547  
    5454 
    5555import tree.DataFieldConstants; 
    56 import treeEditingComponents.DateTimeField; 
    5756import treeEditingComponents.EditingComponentFactory; 
    5857import ui.XMLView; 
    … …  
    6665 * Displays a name, description etc. and holds other UI  
    6766 * components that are specific to the types of data being edited.  
     67 * These components display and edit the Parameters of this field. 
    6868 *  
    6969* @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
  • branches/OmeroEditor/src/fields/FieldParamsFactory.java

    r5546 r5547  
    2929//Application-internal dependencies 
    3030 
     31import java.util.HashMap; 
     32 
    3133import tree.DataFieldConstants; 
    3234 
    3335/**  
    34  *  
     36 * This factory is used to create new Parameter objects (subclasses of 
     37 * AbstractParam), according to the String that describes their data type. 
    3538 * 
    3639 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
    … …  
    4447public class FieldParamsFactory { 
    4548         
     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         */ 
    4670        public static IParam getFieldParam(String paramType) { 
    4771                 
    4872                IParam fieldValue = null; 
    4973                 
    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); 
    5276                } 
    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); 
    5879                } 
    5980                else if (paramType.equals(DataFieldConstants.DATE_TIME_FIELD)) { 
  • branches/OmeroEditor/src/fields/IAttributes.java

    r5546 r5547  
    3030 
    3131/**  
    32  *  
     32 * Methods for editing a collection of attributes. 
     33 * The attributes are identified by name (String) and the values are Strings. 
    3334 * 
    3435 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
  • branches/OmeroEditor/src/fields/IField.java

    r5546 r5547  
    4949        extends IAttributes { 
    5050         
    51  
     51        /** 
     52         * Returns the number of parameters for this field 
     53         *  
     54         * @return      the number of parameters for this field 
     55         */ 
    5256        public int getParamCount(); 
    5357         
     58        /** 
     59         * Returns a parameter object at the specified index 
     60         *  
     61         * @param index          
     62         * @return 
     63         */ 
    5464        public IParam getParamAt(int index); 
    5565         
     66        /** 
     67         * Adds a parameter object to the field 
     68         *  
     69         * @param param 
     70         */ 
    5671        public void addParam(IParam param); 
    5772         
     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         */ 
    5879        public boolean removeParam(IParam param); 
    5980         
     81        /** 
     82         * Indicates whether all parameters have been filled out.  
     83         *  
     84         * @return              True if all the parameters have been filled.  
     85         */ 
    6086        public boolean isFieldFilled(); 
    6187 
  • branches/OmeroEditor/src/treeModel/TreeEditorControl.java

    r5546 r5547  
    3333import javax.swing.undo.UndoableEditSupport; 
    3434 
     35import treeModel.editActions.AddFieldAction; 
    3536import treeModel.editActions.DeleteFieldsAction; 
     37import treeModel.editActions.DuplicateFieldsAction; 
    3638import treeModel.editActions.RedoEditAction; 
    3739import treeModel.editActions.UndoEditAction; 
    … …  
    7375        public static final Integer REDO_ACTION = new Integer(3); 
    7476         
     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         
    7582        public void initialise(ITreeEditor model, TreeEditorUI view) { 
    7683                 
    … …  
    9198                actions = new HashMap<Integer, Action>(); 
    9299                 
     100                actions.put(ADD_FIELD_ACTION, new AddFieldAction(undoSupport)); 
    93101                actions.put(DELETE_FIELD_ACTION, new DeleteFieldsAction(undoSupport)); 
    94102                actions.put(UNDO_ACTION, new UndoEditAction(undoManager, undoSupport)); 
    95103                actions.put(REDO_ACTION, new RedoEditAction(undoManager, undoSupport)); 
     104                actions.put(DUPLICATE_FIELDS_ACTION, new DuplicateFieldsAction(undoSupport)); 
    96105                 
    97106        } 
  • branches/OmeroEditor/src/treeModel/TreeEditorUI.java

    r5546 r5547  
    2626 
    2727import javax.swing.Action; 
     28import javax.swing.BorderFactory; 
    2829import javax.swing.Box; 
    2930import javax.swing.JButton; 
    3031import javax.swing.JComponent; 
    3132import javax.swing.JPanel; 
     33import javax.swing.border.Border; 
    3234 
    3335import treeModel.editActions.AbstractEditorAction; 
    … …  
    7981                Box toolBarBox = Box.createHorizontalBox(); 
    8082                 
     83                addActionButton(toolBarBox, TreeEditorControl.ADD_FIELD_ACTION); 
     84                addActionButton(toolBarBox, TreeEditorControl.DUPLICATE_FIELDS_ACTION); 
    8185                addActionButton(toolBarBox, TreeEditorControl.DELETE_FIELD_ACTION); 
    8286                addActionButton(toolBarBox, TreeEditorControl.UNDO_ACTION); 
    … …  
    9296                        ((AbstractEditorAction)newAction).setTree(treeUI.getJTree()); 
    9397                } 
    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); 
    95104        } 
    96105 
  • branches/OmeroEditor/src/treeModel/editActions/DeleteFieldsAction.java

    r5546 r5547  
    3636import treeModel.undoableTreeEdits.DeleteFieldsEdit; 
    3737import treeModel.undoableTreeEdits.UndoableTreeEdit; 
     38import util.ImageFactory; 
    3839 
    3940 
    … …  
    7778                putValue(Action.NAME, "Delete Fields"); 
    7879                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));  
    8081        } 
    8182 
  • branches/OmeroEditor/src/treeModel/editActions/RedoEditAction.java

    r5546 r5547  
    3333import javax.swing.undo.UndoManager; 
    3434import javax.swing.undo.UndoableEditSupport; 
     35 
     36import util.ImageFactory; 
    3537 
    3638//Third-party libraries 
    … …  
    7880                 
    7981                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));  
    8183                 
    8284                refreshStatus();        // sets description, enabled etc. 
  • branches/OmeroEditor/src/treeModel/editActions/UndoEditAction.java

    r5546 r5547  
    3333import javax.swing.undo.UndoManager; 
    3434import javax.swing.undo.UndoableEditSupport; 
     35 
     36import util.ImageFactory; 
    3537 
    3638//Third-party libraries 
    … …  
    7880                 
    7981                putValue(Action.NAME, "Undo"); 
    80                 //putValue(Action.SMALL_ICON, ImageFactory.getInstance().getIcon(ImageFactory.ADD_ICON));