• 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 5546

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

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

Location:
branches/OmeroEditor/src
Files:
16 added
4 removed
15 modified
7 moved

  • fields/AbstractParam.java (moved) (moved from branches/OmeroEditor/src/fields/AbstractValueObject.java) (3 diffs)
  • fields/DateTimeParam.java (moved) (moved from branches/OmeroEditor/src/fields/DateTimeValueObject.java) (4 diffs)
  • fields/Field.java (modified) (5 diffs)
  • fields/FieldPanel.java (modified) (9 diffs)
  • fields/FieldParamsFactory.java (moved) (moved from branches/OmeroEditor/src/fields/FieldValueFactory.java) (3 diffs)
  • fields/IAttributes.java (added)
  • fields/IField.java (modified) (2 diffs)
  • fields/IFieldValue.java (deleted)
  • fields/IParam.java (added)
  • fields/NoParam.java (moved) (moved from branches/OmeroEditor/src/fields/NoValue.java) (2 diffs)
  • fields/SingleParam.java (added)
  • fields/TextValueObject.java (deleted)
  • tree/DataField.java (modified) (1 diff)
  • treeEditingComponents/DateTimeField.java (modified) (6 diffs)
  • treeEditingComponents/EditingComponentFactory.java (modified) (4 diffs)
  • treeEditingComponents/TextBoxEditor.java (added)
  • treeEditingComponents/TextFieldEditor.java (modified) (2 diffs)
  • treeIO (added)
  • treeIO/TreeModelFactory.java (added)
  • treeModel/DefaultFieldEditor.java (moved) (moved from branches/OmeroEditor/src/fields/DefaultFieldEditor.java) (1 diff)
  • treeModel/ITreeEditor.java (modified) (2 diffs)
  • treeModel/TreeEditor.java (deleted)
  • treeModel/TreeEditorComponent.java (modified) (4 diffs)
  • treeModel/TreeEditorControl.java (modified) (3 diffs)
  • treeModel/TreeEditorFactory.java (modified) (4 diffs)
  • treeModel/TreeEditorModel.java (moved) (moved from branches/OmeroEditor/src/treeModel/TreeModel.java) (2 diffs)
  • treeModel/TreeEditorUI.java (modified) (4 diffs)
  • treeModel/TreeUI.java (modified) (4 diffs)
  • treeModel/editActions/AbstractEditorAction.java (added)
  • treeModel/editActions/DeleteFields.java (deleted)
  • treeModel/editActions/DeleteFieldsAction.java (added)
  • treeModel/editActions/RedoEditAction.java (added)
  • treeModel/editActions/UndoEditAction.java (added)
  • treeModel/editActions/UndoRedoListener.java (added)
  • treeModel/editActions/UndoRedoObservable.java (added)
  • treeModel/undoableTreeEdits (added)
  • treeModel/undoableTreeEdits/DeleteFieldsEdit.java (added)
  • treeModel/undoableTreeEdits/ObservableUndoManager.java (added)
  • treeModel/undoableTreeEdits/TreeModelMethods.java (moved) (moved from branches/OmeroEditor/src/treeModel/editActions/TreeModelMethods.java) (6 diffs)
  • treeModel/undoableTreeEdits/UndoableTreeEdit.java (added)
  • ui/components/AttributeEditorListeners.java (modified) (3 diffs)
  • ui/components/AttributeTextAreaEditor.java (modified) (5 diffs)

Legend:

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

    r5543 r5546  
    2323package fields; 
    2424 
    25 import java.util.HashMap; 
    26  
    27 import tree.DataFieldConstants; 
    2825 
    2926//Java imports 
     27import java.util.HashMap; 
    3028 
    3129//Third-party libraries 
    … …  
    3331//Application-internal dependencies 
    3432 
     33import tree.DataFieldConstants; 
     34 
     35 
    3536/**  
    36  *  
     37 * An abstract example 
    3738 * 
    3839 * @author  William Moore      
    … …  
    4445 * @since OME3.0 
    4546 */ 
    46 public abstract class AbstractValueObject  
     47public abstract class AbstractParam  
    4748        implements 
    48         IFieldValue { 
     49        IParam { 
    4950         
    50         private String fieldType; 
     51        public static final String PARAM_TYPE = "paramType"; 
     52         
     53        public static final String PARAM_NAME = "paramName"; 
     54         
    5155         
    5256        private HashMap<String, String> valueAttributesMap; 
    5357 
    5458         
    55         public AbstractValueObject(String fieldType) { 
    56                 this.fieldType = fieldType; 
     59        public AbstractParam(String fieldType) { 
    5760                valueAttributesMap = new HashMap<String, String>(); 
     61                valueAttributesMap.put(PARAM_TYPE, fieldType); 
    5862        } 
    5963         
     64        /** 
     65         * This method returns a list of the names of attributes.  
     66         * These attributes represent the experimental "value" of this 
     67         * parameter (rather than other attributes such as name or default 
     68         * values that represent the "template" part of the parameter.  
     69         * This method is used for eg. clearing the value of a parameter by  
     70         * setting all value attributes to null.  
     71         */ 
    6072        public abstract String[] getValueAttributes(); 
    6173 
    62         public abstract boolean isFieldFilled(); 
    63  
    6474        /** 
    65          * A convenience method to test whether the attribute is included in 
    66          * the list of value attributes.  
     75         * Unless specified by subclasses, parameter has no default values. 
     76         * If a list of default values is given, these should be given in the  
     77         * same order as the value attributes to which they apply  
    6778         *  
    68          * @param attributeName         The name of the attribute to test.  
    69          * @return              True if the attribute is a value attribute.  
     79         * @see getValueAttributes(); 
    7080         */ 
    71         public boolean isValueAttribute(String attributeName) { 
    72                  
    73                 if (attributeName == null) return false; 
    74                  
    75                 String[] attributes = getValueAttributes(); 
    76                 for (int i=0; i<attributes.length; i++) { 
    77                         if (attributeName.equals(attributes[i])) 
    78                                 return true; 
    79                 } 
    80                 return false; 
     81        public String[] getDefaultAttributes() { 
     82                return new String[] {}; 
    8183        } 
    8284         
     85        public abstract boolean isParamFilled(); 
     86 
     87         
     88         
    8389        public String getFieldType() { 
    84                 return fieldType; 
     90                return getAttribute(PARAM_TYPE); 
    8591        } 
    8692         
  • branches/OmeroEditor/src/fields/DateTimeParam.java

    r5543 r5546  
    3232 
    3333/**  
    34  *  
     34 * An experimental parameter that represents a Date (with optional Time). 
     35 * Also an optional Alarm time can be set (in seconds before  
     36 * (negative value) or after the Date/Time). 
    3537 * 
    3638 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
    … …  
    4244 * @since OME3.0 
    4345 */ 
    44 public class DateTimeValueObject extends AbstractValueObject { 
     46public class DateTimeParam extends AbstractParam { 
    4547 
    4648        public static final String DATE_ATTRIBUTE = DataFieldConstants.UTC_MILLISECS; 
    4749         
    4850        public static final String TIME_ATTRIBUTE = DataFieldConstants.SECONDS; 
     51         
     52        public static final String ALARM_SECONDS = DataFieldConstants.ALARM_SECONDS; 
    4953         
    5054        /** 
    … …  
    5357         * @param fieldType             The String defining the field type 
    5458         */ 
    55         public DateTimeValueObject(String fieldType) { 
     59        public DateTimeParam(String fieldType) { 
    5660                super(fieldType); 
    5761        } 
    … …  
    6468                 
    6569                return new String[] {DATE_ATTRIBUTE,  
    66                                 TIME_ATTRIBUTE}; 
     70                                TIME_ATTRIBUTE, ALARM_SECONDS}; 
    6771        } 
    6872 
    6973        /** 
    70          * This field is filled if the value isn't null, and  
     74         * This field is filled if the DATE value isn't null, and  
    7175         * is not an empty string.  
    7276         */ 
    73         public boolean isFieldFilled() { 
    74                 String timeValue = getAttribute(getValueAttributes()[0]); 
     77        public boolean isParamFilled() { 
     78                String dateValue = getAttribute(DATE_ATTRIBUTE); 
    7579                 
    76                 return (timeValue != null && timeValue.length() > 0); 
     80                return (dateValue != null && dateValue.length() > 0); 
    7781        } 
    7882 
  • 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 &nbsp;&nbsp;&nbsp;&nbsp; 
     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} 
  • branches/OmeroEditor/src/fields/FieldPanel.java

    r5543 r5546  
    204204        Border imageBorderHighlight; 
    205205         
    206         /** 
    207          * A flag used to toggle the display of the description.  
    208          */ 
    209         boolean showDescription = false; 
    210          
    211206         
    212207        /** 
    … …  
    259254                descriptionButton.addActionListener(new ActionListener(){ 
    260255                        public void actionPerformed(ActionEvent event) { 
    261                                 showDescription = !showDescription; 
    262                                 descriptionLabel.setVisible(showDescription); 
     256                                // TODO 
     257                                // Need to set an attribute in the dataField such as  
     258                                // descriptionVisible = true / false 
    263259                        } 
    264260                }); 
    … …  
    326322                horizontalBox.add(defaultButton); 
    327323                horizontalBox.add(requiredFieldButton); 
     324                horizontalBox.add(descriptionLabel); 
    328325                horizontalBox.add(Box.createHorizontalStrut(10)); 
    329326                 
    … …  
    337334                contentsPanel.add(nameLabel, BorderLayout.WEST); 
    338335                contentsPanel.add(horizontalBox, BorderLayout.CENTER); 
    339                 contentsPanel.add(descriptionLabel, BorderLayout.SOUTH); 
     336                //contentsPanel.add(descriptionLabel, BorderLayout.SOUTH); 
    340337                 
    341338                contentsPanel.setBorder(imageBorder); 
    … …  
    349346                 */ 
    350347                setNameText(addHtmlTagsForNameLabel( 
    351                                 dataField.getAttribute(DataFieldConstants.ELEMENT_NAME))); 
     348                                dataField.getAttribute(Field.FIELD_NAME))); 
    352349                setDescriptionText( 
    353                                 dataField.getAttribute(DataFieldConstants.DESCRIPTION)); 
    354                 setURL(dataField.getAttribute(DataFieldConstants.URL)); 
     350                                dataField.getAttribute(Field.FIELD_DESCRIPTION)); 
     351                setURL(dataField.getAttribute(Field.FIELD_URL)); 
    355352                 
    356353                refreshBackgroundColour(); 
    … …  
    358355                refreshDefaultValue(); 
    359356                 
    360                 /* 
    361                  * Add additional UI components for editing the value of this field. 
    362                  * Use a Factory to create the UI components, depending on the value type 
    363                  */ 
    364                 IFieldValue valueObject = ((Field)field).getValueObject(); 
    365                 JComponent edit = EditingComponentFactory.getEditingComponent(valueObject); 
    366                 addFieldComponent(edit); 
     357                buildParamComponents(); 
     358        } 
     359         
     360        /** 
     361         * Add additional UI components for editing the value of this field. 
     362         * Use a Factory to create the UI components, depending on the value type 
     363         */ 
     364        public void buildParamComponents() { 
     365 
     366                int paramCount = dataField.getParamCount(); 
     367                 
     368                for (int i=0; i<paramCount; i++) { 
     369                        IParam param = dataField.getParamAt(i); 
     370                        JComponent edit = EditingComponentFactory.getEditingComponent(param); 
     371                        if (edit != null) 
     372                                addFieldComponent(edit); 
     373                } 
     374                 
    367375        } 
    368376         
    … …  
    440448        } 
    441449         
     450 
     451         
    442452        public void setDescriptionText(String description) { 
    443453                if ((description != null) && (description.trim().length() > 0)) { 
    … …  
    445455                        descriptionButton.setToolTipText(htmlDescription); 
    446456                        descriptionButton.setVisible(true); 
    447                         descriptionLabel.setVisible(showDescription); 
     457                        // TODO setVisibility of label based on dataField attribute  
     458                        //descriptionLabel.setVisible(showDescription); 
    448459                        descriptionLabel.setFont(XMLView.FONT_TINY); 
    449460                        descriptionLabel.setText(htmlDescription); 
    … …  
    552563 
    553564 
     565        /** 
     566         * If the size of a sub-component of this panel changes,  
     567         * the JTree in which it is contained must be required to  
     568         * re-draw the panel.  
     569         */ 
    554570        public void propertyChange(PropertyChangeEvent evt) { 
    555571                 
    556572                if (SIZE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { 
    557573                 
    558                         if ((tree != null) && (treeNode !=null)) { 
    559                                  
    560                                 TreePath path = new TreePath(treeNode.getPath()); 
    561                                  
    562                                 tree.getUI().startEditingAtPath(tree, path); 
    563                         } 
    564                 } 
    565         } 
    566  
     574                        refreshSizeOfPanel(); 
     575                } 
     576        } 
     577 
     578         
     579        /** 
     580         * This method is used to refresh the size of this panel in the JTree. 
     581         * It must also remain in the editing mode, otherwise the user who 
     582         * is currently editing it will be required to click again to  
     583         * continue editing. 
     584         * This can be achieved by calling startEditingAtPath(tree, path) 
     585         */ 
     586        public void refreshSizeOfPanel() { 
     587                if ((tree != null) && (treeNode !=null)) { 
     588                         
     589                        TreePath path = new TreePath(treeNode.getPath()); 
     590                         
     591                        tree.getUI().startEditingAtPath(tree, path); 
     592                } 
     593        } 
    567594         
    568595 
  • branches/OmeroEditor/src/fields/FieldParamsFactory.java

    r5543 r5546  
    2323package fields; 
    2424 
    25 import tree.DataFieldConstants; 
    26 import ui.fieldEditors.FieldEditorCheckBox; 
    27 import ui.fieldEditors.FieldEditorCustom; 
    28 import ui.fieldEditors.FieldEditorDate; 
    29 import ui.fieldEditors.FieldEditorDateTime; 
    30 import ui.fieldEditors.FieldEditorDropDown; 
    31 import ui.fieldEditors.FieldEditorFixed; 
    32 import ui.fieldEditors.FieldEditorMemo; 
    33 import ui.fieldEditors.FieldEditorNumber; 
    34 import ui.fieldEditors.FieldEditorOLS; 
    35 import ui.fieldEditors.FieldEditorObservation; 
    36 import ui.fieldEditors.FieldEditorProtocol; 
    37 import ui.fieldEditors.FieldEditorTable; 
    38 import ui.fieldEditors.FieldEditorText; 
    39 import ui.fieldEditors.FieldEditorTime; 
    40  
    4125//Java imports 
    4226 
    … …  
    4428 
    4529//Application-internal dependencies 
     30 
     31import tree.DataFieldConstants; 
    4632 
    4733/**  
    … …  
    5642 * @since OME3.0 
    5743 */ 
    58 public class FieldValueFactory { 
     44public class FieldParamsFactory { 
    5945         
    60         public static IFieldValue getFieldValue(String inputType) { 
     46        public static IParam getFieldParam(String paramType) { 
    6147                 
    62                 IFieldValue fieldValue = null; 
     48                IParam fieldValue = null; 
    6349                 
    64                 if (inputType == null) { 
    65                         fieldValue = new NoValue(DataFieldConstants.FIXED_PROTOCOL_STEP); 
     50                if (paramType == null) { 
     51                        fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP); 
    6652                } 
    67                 else if (inputType.equals(DataFieldConstants.TEXT_ENTRY_STEP)) { 
    68                         fieldValue = new TextValueObject(DataFieldConstants.TEXT_ENTRY_STEP); 
     53                else if (paramType.equals(DataFieldConstants.TEXT_ENTRY_STEP)) { 
     54                        fieldValue = new SingleParam(DataFieldConstants.TEXT_ENTRY_STEP); 
    6955                } 
    70                 else if (inputType.equals(DataFieldConstants.FIXED_PROTOCOL_STEP)) { 
    71                         fieldValue = new NoValue(DataFieldConstants.FIXED_PROTOCOL_STEP); 
     56                else if (paramType.equals(DataFieldConstants.FIXED_PROTOCOL_STEP)) { 
     57                        fieldValue = new NoParam(DataFieldConstants.FIXED_PROTOCOL_STEP); 
    7258                } 
    73                 else if (inputType.equals(DataFieldConstants.DATE_TIME_FIELD)) { 
    74                         fieldValue = new DateTimeValueObject(DataFieldConstants.DATE_TIME_FIELD); 
     59                else if (paramType.equals(DataFieldConstants.DATE_TIME_FIELD)) { 
     60                        fieldValue = new DateTimeParam(DataFieldConstants.DATE_TIME_FIELD); 
    7561                } 
    7662                 
  • branches/OmeroEditor/src/fields/IField.java

    r5543 r5546  
    3030 
    3131/**  
    32  * This interface specifies the minimum methods needed to save and  
    33  * retrieve data.  
    34  * It also has a convenience method for querying boolean attributes.  
     32 * This interface specifies methods of a Field, which corresponds to a node