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

Show
Ignore:
Timestamp:
09/12/08 12:16:56 (2 months ago)
Author:
will
Message:

Template Editing UI components for more Parameters

Location:
trunk/SRC/org/openmicroscopy/shoola/agents/editor
Files:
3 added
7 modified

  • browser/BrowserControl.java (modified) (2 diffs)
  • browser/paramUIs/BooleanEditor.java (modified) (6 diffs)
  • browser/paramUIs/editTemplate/AddParamActions.java (modified) (4 diffs)
  • browser/paramUIs/editTemplate/BooleanTemplate.java (added)
  • browser/paramUIs/editTemplate/EnumTemplate.java (modified) (3 diffs)
  • browser/paramUIs/editTemplate/FieldEditorPanel.java (modified) (3 diffs)
  • browser/paramUIs/editTemplate/NumberTemplate.java (added)
  • browser/paramUIs/editTemplate/ParamTemplateUIFactory.java (modified) (2 diffs)
  • model/undoableEdits/AddParamEdit.java (added)
  • model/undoableEdits/AttributesEdit.java (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java

    r5594 r5608  
    5050import org.openmicroscopy.shoola.agents.editor.browser.undo.ObservableUndoManager; 
    5151import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 
     52import org.openmicroscopy.shoola.agents.editor.model.IField; 
     53import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AddParamEdit; 
    5254import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributeEdit; 
    5355import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributesEdit; 
     56 
    5457 
    5558 
    … …  
    226229         
    227230        /** 
     231         * Edits a field by creating and adding a new Parameter. 
     232         *  
     233         * @param field         The field to add a new parameter to. 
     234         * @param paramType             A string defining the type of parameter to add. 
     235         * @param tree                  The JTree to refresh with undo/redo 
     236         * @param node          The node to highlight / refresh with undo/redo.  
     237         */ 
     238        public void addParamToField(IField field, String paramType,  
     239                        JTree tree, TreeNode node) { 
     240                 
     241                UndoableEdit edit = new AddParamEdit(field, paramType, tree, node); 
     242                undoSupport.postEdit(edit); 
     243        } 
     244         
     245        /** 
    228246          * An undo/redo adpater. The adpater is notified when 
    229247          * an undo edit occur(e.g. add or remove from the list) 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/BooleanEditor.java

    r5588 r5608  
    3030import javax.swing.JCheckBox; 
    3131 
    32 import org.openmicroscopy.shoola.agents.editor.model.params.IParam; 
    33 import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam; 
    34  
    3532//Third-party libraries 
    3633 
    3734//Application-internal dependencies 
    3835 
     36import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 
     37import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam; 
    3938 
    4039/**  
    … …  
    5958         * A JCheckBox for editing the boolean value  
    6059         */ 
    61         private JCheckBox checkBox; 
     60        private JCheckBox               checkBox; 
    6261         
    6362        /** 
    … …  
    6564         * value of the boolean parameter we're editing. 
    6665         */ 
    67         private String valueAttribute = SingleParam.PARAM_VALUE; 
     66        private String                  attributeName; 
    6867         
    6968        /** 
    … …  
    7978                checkBox.setBorderPaintedFlat(true); 
    8079                 
    81                 boolean checked = getParameter().isAttributeTrue(valueAttribute); 
     80                boolean checked = getParameter().isAttributeTrue(attributeName); 
    8281                 
    8382                checkBox.setSelected(checked); 
    … …  
    8786         * Creates an instance. 
    8887         *  
    89          * @param param 
     88         * @param param                         The IAttributes collection we're editing 
     89         * @param attributeName         The name of the attribute we're editing 
    9090         */ 
    91         public BooleanEditor(IParam param) { 
     91        public BooleanEditor(IAttributes param, String attributeName) { 
    9292                 
    9393                super(param); 
    9494                 
     95                this.attributeName = attributeName; 
     96                 
     97                initialise(); 
     98                 
     99                this.add(checkBox); 
     100        } 
     101         
     102        /** 
     103         * Creates an instance, which will edit the  
     104         * {@link SingleParam#PARAM_VALUE} attribute of the  
     105         * {@link IAttributes} parameter.  
     106         *  
     107         * @param param         The IAttributes collection we're editing 
     108         */ 
     109        public BooleanEditor(IAttributes param) { 
     110                 
     111                super(param); 
     112                 
     113                attributeName = SingleParam.PARAM_VALUE; 
    95114                initialise(); 
    96115                 
    … …  
    104123         */ 
    105124        public void actionPerformed(ActionEvent e) { 
    106                 attributeEdited(valueAttribute, checkBox.isSelected() + ""); 
     125                attributeEdited(attributeName, checkBox.isSelected() + ""); 
    107126        } 
    108127         
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/AddParamActions.java

    r5588 r5608  
    4343import org.openmicroscopy.shoola.agents.editor.browser.BrowserControl; 
    4444import org.openmicroscopy.shoola.agents.editor.model.IField; 
     45import org.openmicroscopy.shoola.agents.editor.model.params.SingleParam; 
    4546import org.openmicroscopy.shoola.agents.editor.uiComponents.PopupMenuButton; 
    4647 
    … …  
    188189                { 
    189190                        // TODO         implement this method in controller. 
    190                         //controller.addParamToField(field, SingleParam.TEXT_LINE_PARAM,  
    191                         //              tree, node); 
     191                        controller.addParamToField(field, SingleParam.TEXT_LINE_PARAM,  
     192                                        tree, node); 
    192193                } 
    193194                 
    … …  
    222223                public void actionPerformed(ActionEvent e)  
    223224                { 
    224                         // TODO         implement this method in controller. 
    225                         //controller.addParamToField(field, SingleParam.NUMBER_PARAM,  
    226                         //              tree, node); 
     225                        controller.addParamToField(field, SingleParam.NUMBER_PARAM,  
     226                                        tree, node); 
    227227                } 
    228228         
    … …  
    256256                public void actionPerformed(ActionEvent e)  
    257257                { 
    258                         // TODO         implement this method in controller. 
    259                         //controller.addParamToField(field, SingleParam.BOOLEAN_PARAM,  
    260                         //              tree, node); 
     258                        controller.addParamToField(field, SingleParam.BOOLEAN_PARAM,  
     259                                        tree, node); 
    261260                } 
    262261                 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/EnumTemplate.java

    r5601 r5608  
    2323package org.openmicroscopy.shoola.agents.editor.browser.paramUIs.editTemplate; 
    2424 
     25import java.awt.BorderLayout; 
    2526import java.awt.event.ActionEvent; 
    2627import java.awt.event.ActionListener; 
    … …  
    9495        private void buildUI() 
    9596        { 
    96                 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 
    97                 add(optionsFieldEditor); 
    98                 add(new CustomLabel("Default Value: ")); 
    99                 add(defaultValueComboBox); 
     97                setLayout(new BorderLayout()); 
     98                add(optionsFieldEditor, BorderLayout.NORTH); 
     99                add(new CustomLabel("Default Value: "), BorderLayout.WEST); 
     100                add(defaultValueComboBox, BorderLayout.CENTER); 
    100101                 
    101102        } 
    … …  
    123124                if (ITreeEditComp.VALUE_CHANGED_PROPERTY.equals(evt.getPropertyName())){ 
    124125                        if (evt.getSource().equals(defaultValueComboBox)) { 
    125                                 String newDefault = evt.getNewValue().toString(); 
     126                                String newDefault = null; 
     127                                if (evt.getNewValue() != null) 
     128                                        newDefault = evt.getNewValue().toString(); 
    126129                                // simply change the new value of default attribute 
    127130                                attributeEdited(SingleParam.DEFAULT_VALUE, newDefault); 
    128131                        } 
    129132                         
     133                        // if the drop-down options have changed, need to check that 
     134                        // the value and default value are in the new options.  
    130135                        if (evt.getSource().equals(optionsFieldEditor)) { 
    131                                 String newOptions = evt.getNewValue().toString(); 
     136                                String newOptions = null; 
     137                                if(evt.getNewValue() != null)  
     138                                        newOptions = evt.getNewValue().toString(); 
    132139                                 
    133140                                String defaultValue = getParameter().getAttribute 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/FieldEditorPanel.java

    r5601 r5608  
    6464import org.openmicroscopy.shoola.agents.editor.model.params.IParam; 
    6565import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomComboBox; 
     66import org.openmicroscopy.shoola.agents.editor.uiComponents.CustomLabel; 
    6667import org.openmicroscopy.shoola.agents.editor.uiComponents.ImageBorderFactory; 
    6768 
    … …  
    198199                //JLabel paramLabel = new CustomLabel("Parameters:"); 
    199200                JPanel paramHeader = new JPanel(new BorderLayout()); 
    200                 paramHeader.setBackground(null); 
    201                  
    202                 // Add the JComboBox for changing parameter type 
    203                 paramHeader.add(paramTypeChooser, BorderLayout.WEST); 
    204                  
    205                 JButton addParamsButton = new AddParamActions(field, tree,  
    206                                 treeNode, controller).getButton(); 
    207                 addParamsButton.addPropertyChangeListener( 
    208                                 AddParamActions.PARAM_ADDED_PROPERTY, this); 
    209                 paramHeader.add(addParamsButton, BorderLayout.EAST); 
    210                  
     201                Border emptyB = new EmptyBorder(4, 4, 4,4); 
     202                Border lineB = BorderFactory.createMatteBorder( 
     203                1, 1, 1, 1, new Color(200,200,200)); 
     204                Border compoundBorder = BorderFactory.createCompoundBorder 
     205                        (lineB, emptyB); 
     206                paramHeader.setBorder(compoundBorder); 
     207                paramHeader.setBackground(Color.white); 
     208                 
     209                // Add the JComboBox for changing type of FIRST parameter 
     210                paramHeader.add(paramTypeChooser, BorderLayout.CENTER); 
     211                paramHeader.add(new CustomLabel("Parameter type: "), BorderLayout.WEST);                 
    211212                attributeFieldsPanel.add(paramHeader); 
     213                 
     214                if (field.getParamCount() > 0) { 
     215                        IParam param = field.getParamAt(0); 
     216                        JComponent edit = ParamTemplateUIFactory. 
     217                                                                getEditDefaultComponent(param); 
     218                        if (edit != null) { 
     219                                edit.addPropertyChangeListener(  
     220                                                ITreeEditComp.VALUE_CHANGED_PROPERTY, this); 
     221                                paramHeader.add(edit, BorderLayout.SOUTH); 
     222                        } 
     223                } 
    212224                 
    213225                // For each parameter of this field, add the components for 
    214226                // editing their default or template values.  
    215                 buildParamComponents(); 
     227                addAdditionalParams(); 
    216228                 
    217229                this.setLayout(new BorderLayout()); 
    … …  
    239251        /** 
    240252         * Add additional UI components for editing the value of this field. 
    241          * Use a Factory to create the UI components, depending on the value type 
    242          */ 
    243         private void buildParamComponents()  
     253         * This deals with "Additional" parameters, not the first one, which 
     254         * is a special case (added earlier).  
     255         * Uses the {@link ParamTemplateUIFactory} to create the UI components, 
     256         * depending on the value type 
     257         */ 
     258        private void addAdditionalParams()  
    244259        { 
     260                addFieldComponent(createAdditionalParamsHeader()); 
     261                 
    245262                int paramCount = field.getParamCount(); 
    246                  
    247                 for (int i=0; i<paramCount; i++) { 
     263                if (paramCount < 2) { return; } 
     264                 
     265                for (int i=1; i<paramCount; i++) { 
    248266                        IParam param = field.getParamAt(i); 
    249267                        JComponent edit = ParamTemplateUIFactory. 
    250268                                                                        getEditDefaultComponent(param); 
    251                         if (edit != null) 
     269                        if (edit != null) { 
    252270                                addFieldComponent(edit); 
    253                 } 
     271                        } 
     272                } 
     273        } 
     274         
     275        private JComponent createAdditionalParamsHeader() { 
     276                JPanel addParamsHeader = new JPanel(new BorderLayout()); 
     277                addParamsHeader.setBackground(null); 
     278                JButton addParamsButton = new AddParamActions(field, tree,  
     279                                treeNode, controller).getButton(); 
     280                addParamsButton.addPropertyChangeListener( 
     281                                AddParamActions.PARAM_ADDED_PROPERTY, this); 
     282                addParamsHeader.add(addParamsButton, BorderLayout.EAST); 
     283                 
     284                addParamsHeader.add( 
     285                                new CustomLabel("Additional Parameters:"), BorderLayout.WEST); 
     286                 
     287                return addParamsHeader; 
    254288        } 
    255289 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/paramUIs/editTemplate/ParamTemplateUIFactory.java

    r5601 r5608  
    6868                } 
    6969                String inputType = paramObject.getAttribute(AbstractParam.PARAM_TYPE); 
    70                  
     70 
    7171                if (inputType == null) { 
    7272                        return null; 
    … …  
    8080                if (inputType.equals(SingleParam.ENUM_PARAM)) { 
    8181                        return new EnumTemplate(paramObject); 
     82                } 
     83                 
     84                if (inputType.equals(SingleParam.BOOLEAN_PARAM)) { 
     85                        return new BooleanTemplate(paramObject); 
     86                } 
     87                 
     88                if (inputType.equals(SingleParam.NUMBER_PARAM)) { 
     89                        return new NumberTemplate(paramObject); 
    8290                } 
    8391                 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/model/undoableEdits/AttributesEdit.java

    r5601 r5608  
    148148                                oldValues.put(key, attributes.getAttribute(key)); 
    149149                                attributes.setAttribute(key, newValues.get(key)); 
    150                                 System.out.println("AttributesEdit " + key + " " +  
    151                                                 attributes.getAttribute(key) + " " + newValues.get(key)); 
    152150                        } 
    153151                        // if node changed (eg template edited), need to notify 

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/