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

Show
Ignore:
Timestamp:
08/29/08 16:29:05 (3 months ago)
Author:
will
Message:

Updating docs and adopting the code style...

Location:
trunk/SRC/org/openmicroscopy/shoola/agents/editor
Files:
12 added
1 removed
26 modified

  • actions/CloseEditorAction.java (modified) (2 diffs)
  • actions/OpenFileAction.java (modified) (2 diffs)
  • browser/Browser.java (modified) (2 diffs)
  • browser/BrowserComponent.java (modified) (5 diffs)
  • browser/BrowserControl.java (modified) (8 diffs)
  • browser/BrowserFactory.java (modified) (3 diffs)
  • browser/BrowserModel.java (modified) (4 diffs)
  • browser/BrowserUI.java (modified) (5 diffs)
  • browser/ContiguousChildSelectionModel.java (modified) (10 diffs)
  • browser/DefaultFieldEditor.java (modified) (8 diffs)
  • browser/EditableTree.java (modified) (3 diffs)
  • browser/FieldPanel.java (modified) (28 diffs)
  • browser/FieldRenderer.java (modified) (7 diffs)
  • browser/MyBasicTreeUI.java (modified) (2 diffs)
  • browser/NavTree.java (modified) (3 diffs)
  • browser/NonEditableTree.java (deleted)
  • browser/ToolBar.java (added)
  • browser/TreeOutlineCellRenderer.java (modified) (2 diffs)
  • browser/actions (added)
  • browser/actions/BrowserAction.java (added)
  • browser/actions/EditAction.java (added)
  • browser/paramUIs/editTemplate/FieldEditorPanel.java (modified) (1 diff)
  • browser/undo (added)
  • browser/undo/ObservableUndoManager.java (added)
  • browser/undo/UndoRedoListener.java (added)
  • browser/undo/UndoRedoObservable.java (added)
  • model/TreeModelFactory.java (modified) (2 diffs)
  • model/TreeModelMethods.java (added)
  • model/params/AbstractParam.java (modified) (5 diffs)
  • model/params/DateTimeParam.java (modified) (12 diffs)
  • model/params/FieldParamsFactory.java (modified) (6 diffs)
  • model/params/IParam.java (modified) (5 diffs)
  • model/params/SingleParam.java (modified) (2 diffs)
  • model/params/TimeParam.java (modified) (2 diffs)
  • model/undoableEdits (added)
  • model/undoableEdits/AttributeEdit.java (added)
  • model/undoableEdits/AttributesEdit.java (added)
  • uiComponents/ImageBorderFactory.java (modified) (2 diffs)
  • view/EditorModel.java (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/CloseEditorAction.java

    r5588 r5590  
    2828import java.awt.event.ActionEvent; 
    2929 
    30 import javax.swing.Action; 
    31  
    3230//Third-party libraries 
    3331 
    … …  
    3634import org.openmicroscopy.shoola.agents.editor.IconManager; 
    3735import org.openmicroscopy.shoola.agents.editor.view.Editor; 
    38 import org.openmicroscopy.shoola.util.ui.UIUtilities; 
    3936 
    4037/**  
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/actions/OpenFileAction.java

    r5588 r5590  
    2323package org.openmicroscopy.shoola.agents.editor.actions; 
    2424 
     25//Java imports 
     26 
    2527import java.awt.event.ActionEvent; 
    2628import java.io.File; 
    2729 
    28 import javax.swing.Action; 
    2930import javax.swing.event.ChangeEvent; 
    3031import javax.swing.event.ChangeListener; 
    31  
    32 import org.openmicroscopy.shoola.agents.editor.IconManager; 
    33 import org.openmicroscopy.shoola.agents.editor.view.Editor; 
    34 import org.openmicroscopy.shoola.util.ui.UIUtilities; 
    35  
    36 //Java imports 
    3732 
    3833//Third-party libraries 
    … …  
    4035//Application-internal dependencies 
    4136 
     37import org.openmicroscopy.shoola.agents.editor.IconManager; 
     38import org.openmicroscopy.shoola.agents.editor.view.Editor; 
     39 
    4240/**  
    43  *  
     41 * Opens a file. 
    4442 * 
    4543 * @author  William Moore      
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/Browser.java

    r5584 r5590  
    5050{ 
    5151        /** 
    52          * A String that specifies that the UI should be for tree display only, 
    53          * not for editing. Used by BrowserFactory 
     52         * A Flag to denote the <i>Display</i> state. 
     53         * Specifies that the UI should be for tree display only, 
     54         * not for editing. 
    5455         */ 
    55         public static final String TREE_DISPLAY = "treeDisplay"; 
     56        public static final int TREE_DISPLAY = 0; 
    5657         
    5758        /** 
    58          * A String that specifies that the UI should be for tree editing, not 
    59          * simply display. Used by BrowserFactory 
     59         * A Flag to denote the <i>Edit</i> state. 
     60         * This specifies that the UI should be for tree editing, not 
     61         * simply display. 
    6062         */ 
    61         public static final String TREE_EDIT = "treeEdit"; 
     63        public static final int TREE_EDIT = 1; 
    6264         
    6365    /** 
    … …  
    7577    public JComponent getUI(); 
    7678    
     79    /** 
     80     * Sets the Editable state of the Browser. 
     81     * If editable is false, no editing of the data is possible. View only. 
     82     *  
     83     * @param editable          True will allow the data to be edited.  
     84     */ 
     85    public void setEditable(boolean editable); 
     86     
     87    /** 
     88         * Queries the current state. 
     89         *  
     90         * @return One of the state flags defined by this interface. 
     91         */ 
     92        public int getState(); 
    7793} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserComponent.java

    r5584 r5590  
    3232//Application-internal dependencies 
    3333 
     34import org.openmicroscopy.shoola.agents.editor.view.Editor; 
    3435import org.openmicroscopy.shoola.util.ui.component.AbstractComponent; 
    3536 
    3637/**   
    3738 * Implements the {@link Browser} interface to provide the functionality 
    38  * required of the tree viewer component. 
     39 * required of the editor browser component. 
    3940 * This class is the component hub and embeds the component's MVC triad. 
    4041 * It delegates actual functionality to the 
    … …  
    5253public class BrowserComponent  
    5354        extends AbstractComponent 
    54         implements Browser{ 
    55          
     55        implements Browser 
     56{ 
    5657         
    5758        /** The Model sub-component. */ 
    … …  
    6465    private BrowserControl      controller; 
    6566     
    66     BrowserComponent(BrowserModel model, String viewingMode) { 
     67    /** 
     68     * Creates an instance.  
     69     * Also initialises the controller and the view.  
     70     *  
     71     * @param model                             The model of the MVC 
     72     * @param viewingMode               A string to define the view/ edit mode of the UI 
     73     */ 
     74    BrowserComponent(BrowserModel model)  
     75    { 
    6776        this.model = model; 
    6877        controller = new BrowserControl(this); 
    6978         
    70         view = new BrowserUI(viewingMode); 
     79        view = new BrowserUI(); 
    7180    } 
    7281     
    … …  
    8493        } 
    8594 
     95        /** 
     96     * Implemented as specified by the {@link Browser} interface. 
     97     * @see Browser#setTreeModel(TreeModel treeModel)  
     98     */ 
    8699        public void setTreeModel(TreeModel treeModel)  
    87100    { 
    … …  
    99112        } 
    100113 
     114        /** 
     115     * Implemented as specified by the {@link Browser} interface. 
     116     * @see Browser#getUI() 
     117     */ 
     118        public void setEditable(boolean editable)  
     119        { 
     120                model.setEditable(editable); 
     121                fireStateChange(); 
     122        } 
     123 
     124        /**  
     125         * Implemented as specified by the {@link Browser} interface. 
     126         * @see Browser#getState() 
     127         */ 
     128        public int getState() { return model.getState(); } 
     129 
    101130} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserControl.java

    r5584 r5590  
    2929 
    3030import javax.swing.Action; 
     31import javax.swing.JTree; 
    3132import javax.swing.event.ChangeEvent; 
    3233import javax.swing.event.ChangeListener; 
     34import javax.swing.event.UndoableEditEvent; 
     35import javax.swing.event.UndoableEditListener; 
     36import javax.swing.tree.TreeNode; 
     37import javax.swing.undo.UndoManager; 
     38import javax.swing.undo.UndoableEdit; 
     39import javax.swing.undo.UndoableEditSupport; 
    3340 
    3441//Third-party libraries 
    … …  
    3643//Application-internal dependencies 
    3744 
     45import org.openmicroscopy.shoola.agents.editor.browser.actions.EditAction; 
     46import org.openmicroscopy.shoola.agents.editor.browser.undo.ObservableUndoManager; 
     47import org.openmicroscopy.shoola.agents.editor.model.IAttributes; 
     48import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributeEdit; 
     49import org.openmicroscopy.shoola.agents.editor.model.undoableEdits.AttributesEdit; 
     50 
    3851/**  
    39  *      The Controller in the Browser MVC.   
     52 *      The Controller in the Browser MVC.  
     53 *      Also manages undo/redo queue.   
    4054 * 
    4155 * @author  William Moore &nbsp;&nbsp;&nbsp;&nbsp; 
    … …  
    5165{ 
    5266 
    53         /** Identifies the <code>Collapse</code> action. */ 
    54         static final Integer    COLLAPSE = new Integer(0); 
     67        /** Identifies the <code>Edit</code> action. */ 
     68        static final Integer    EDIT = new Integer(0); 
    5569         
    5670        /**  
    … …  
    5872     * is regarded as the Model. 
    5973     */ 
    60     private Browser                             model; 
    61      
    62     /** Reference to the View. */ 
    63     private BrowserUI                           view; 
     74    private Browser                                     model; 
     75     
     76    /**  
     77     * Reference to the View. 
     78     */ 
     79    private BrowserUI                                   view; 
    6480     
    6581    /** Maps actions ids onto actual <code>Action</code> object. */ 
    66     private Map<Integer, Action>        actionsMap; 
     82    private Map<Integer, Action>                actionsMap; 
     83     
     84    /** 
     85     * An undo manager to handle undo/redo queue. 
     86     */ 
     87    private UndoManager                                 undoManager; 
     88         
     89    /** 
     90     * Support for the undo/redo. 
     91     */ 
     92        private UndoableEditSupport             undoSupport; 
    6793     
    6894    /** Helper method to create all the UI actions. */ 
    6995    private void createActions() 
    7096    { 
    71        // actionsMap.put(COLLAPSE, new CollapseAction(model)); 
     97       actionsMap.put(EDIT, new EditAction(model)); 
    7298    } 
    7399     
    … …  
    88114        actionsMap = new HashMap<Integer, Action>(); 
    89115        createActions(); 
     116         
     117     // initialize the undo.redo system 
     118              undoManager = new ObservableUndoManager(); 
     119              undoSupport = new UndoableEditSupport(); 
     120              undoSupport.addUndoableEditListener(new UndoAdapter()); 
    90121    } 
    91122     
    … …  
    101132        model.addChangeListener(this); 
    102133    } 
    103      
    104      
    105134     
    106135    /** 
    … …  
    110139     * @return The specified action. 
    111140     */ 
    112     Action getAction(Integer id) { return actionsMap.get(id); } 
     141    public Action getAction(Integer id) { return actionsMap.get(id); } 
    113142         
    114143    /** 
    … …  
    119148    public void stateChanged(ChangeEvent e) 
    120149    { 
    121         /*      Not sure if I need to use states?? 
    122      
    123         int state = model.getState(); 
    124         switch (state) { 
    125                         case Browser.BROWING_DATA: 
    126                                  
    127                                 break; 
    128          
    129                         default: 
    130                                 break; 
    131                 } 
    132                 */ 
    133                 //view.onStateChanged(state == Browser.READY); 
    134     } 
     150        //int state = model.getState(); 
     151  
     152        view.onStateChanged(); 
     153    } 
     154     
     155     
     156    /** 
     157         * This method adds an attributeEdit to the undo/redo queue and then 
     158         * update the JTree UI. 
     159         * JTree update (optional) requires that JTree and TreeNode are not null. 
     160         * But they are not required for editing of the data. 
     161         * TODO   Would be better for changes to the data to notify the TreeModel 
     162         * in which the data is held (without the classes modifying the data 
     163         * having to manually call DefaultTreeModel.nodeChanged(node); 
     164         *  
     165         * @param attributes            The collection of attributes to edit 
     166         * @param name          The name of the attribute to edit 
     167         * @param value         The new value for the named attribute.  
     168         * @param tree          The JTree displaying the data. This can be null 
     169         * @param node          The node in the JTree that holds data. Can be null.  
     170         */ 
     171        public void editAttribute(IAttributes attributes, String name, String value, 
     172                        String displayName, JTree tree, TreeNode node)  
     173        {        
     174                UndoableEdit edit = new AttributeEdit(attributes, name, value,  
     175                                displayName, tree, node); 
     176                undoSupport.postEdit(edit); 
     177        } 
     178         
     179        /** 
     180         * This method adds an attributesEdit to the undo/redo queue and then 
     181         * update the JTree UI. 
     182         * JTree update (optional) requires that JTree and TreeNode are not null. 
     183         * But they are not required for editing of the data. 
     184         * TODO   Would be better for changes to the data to notify the TreeModel 
     185         * in which the data is held (without the classes modifying the data 
     186         * having to manually call DefaultTreeModel.nodeChanged(node); 
     187         *  
     188         * @param attributes            The collection of attributes to edit 
     189         * @param displayName           A name for display on undo/redo 
     190         * @param newValues             The new values in an attribute map 
     191         * @param tree          The JTree displaying the data. This can be null 
     192         * @param node          The node in the JTree that holds data. Can be null.  
     193         */ 
     194        public void editAttributes(IAttributes attributes, String displayName,  
     195                        HashMap<String,String> newValues, JTree tree, TreeNode node)  
     196        {        
     197                UndoableEdit edit = new AttributesEdit(attributes, displayName,  
     198                                newValues, tree, node); 
     199                undoSupport.postEdit(edit); 
     200        } 
     201         
     202        /** 
     203          * An undo/redo adpater. The adpater is notified when 
     204          * an undo edit occur(e.g. add or remove from the list) 
     205          * The adptor extract the edit from the event, add it 
     206          * to the UndoManager, and refresh the GUI 
     207          * http://www.javaworld.com/javaworld/jw-06-1998/jw-06-undoredo.html 
     208          */ 
     209        private class UndoAdapter implements UndoableEditListener  
     210        { 
     211             public void undoableEditHappened (UndoableEditEvent evt) { 
     212                UndoableEdit edit = evt.getEdit(); 
     213                undoManager.addEdit( edit ); 
     214             } 
     215          } 
    135216} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserFactory.java

    r5584 r5590  
    11/* 
    2  * org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserFactory 
     2 * org.openmicroscopy.shoola.agents.editor.browser.BrowserFactory 
    33 * 
    44 *------------------------------------------------------------------------------ 
    … …  
    5252     * @return          A browser component.  
    5353     */ 
    54     public static Browser createBrowser(String viewingMode) 
     54    public static Browser createBrowser(int viewingState) 
    5555    { 
    56         BrowserModel model = new BrowserModel(); 
    57         BrowserComponent component = new BrowserComponent(model, viewingMode); 
     56        BrowserModel model = new BrowserModel(viewingState); 
     57        BrowserComponent component = new BrowserComponent(model); 
    5858        model.initialize(component); 
    5959        component.initialize(); 
    … …  
    6161    } 
    6262     
     63    /** 
     64     * Creates a new {@link Browser}, with a UI either in the Display mode. 
     65     *  
     66     * @return          A browser component.  
     67     */ 
     68    public static Browser createBrowser() { 
     69        return createBrowser(Browser.TREE_DISPLAY); 
     70    } 
     71     
    6372} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserModel.java

    r5584 r5590  
    2727import javax.swing.tree.TreeModel; 
    2828 
     29import org.openmicroscopy.shoola.agents.editor.view.Editor; 
     30 
    2931//Third-party libraries 
    3032 
    … …  
    4648{ 
    4749     
     50        /** Holds one of the state flags defined by {@link Browser}. */ 
     51        private int                                     state; 
     52         
    4853    /** Reference to the component that embeds this model. */ 
    4954    protected Browser           component; 
    … …  
    5459    /** 
    5560     * Creates an instance.  
     61     *  
     62     * @param   The editing state of the browser.  
     63     *          One of the flags defined by the {@link Browser} interface. 
    5664     */ 
    57     BrowserModel() { 
     65    BrowserModel(int state)  
     66    { 
     67        this.state = state; 
    5868    } 
    5969     
    … …  
    8292        this.treeModel = model; 
    8393    } 
     94     
     95    /** 
     96         * Returns the current state. 
     97         *  
     98         * @return One of the flags defined by the {@link Browser} interface.   
     99         */ 
     100        int getState() { return state; }   
     101         
     102        /** 
     103     * Sets the Editable state of the Browser. 
     104     * If editable is false, no editing of the data is possible. View only. 
     105     *  
     106     * @param editable          True will allow the data to be edited.  
     107     */ 
     108    public void setEditable(boolean editable) { 
     109         
     110        if (editable)  
     111                state = Browser.TREE_EDIT; 
     112        else  
     113                state = Browser.TREE_DISPLAY; 
     114    } 
    84115} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/BrowserUI.java

    r5584 r5590  
    5656     
    5757    /** 
    58      * A String that defines the UI model. Either View-only, or Editing.  
    59      */ 
    60     private String                                      viewingMode; 
    61      
    62     /** 
    6358     * An outline view of the Tree, displayed on the left, used 
    6459     * to navigate 
    … …  
    8075    private void createTrees()  
    8176    { 
    82         if (viewingMode.equals(Browser.TREE_EDIT)) 
    83                 treeDisplay = new EditableTree(controller); 
    84                  
    85         else 
    86                 treeDisplay = new NonEditableTree(); 
     77        treeDisplay = new EditableTree(controller); 
     78         
     79        int state = model.getState(); 
     80        if (state == Browser.TREE_EDIT) 
     81                treeDisplay.setEditable(true); 
    8782         
    8883                treeOutline = new NavTree(treeDisplay); 
    … …  
    109104         
    110105        add(splitPane, BorderLayout.CENTER); 
     106         
     107        add(new ToolBar(controller), BorderLayout.NORTH); 
    111108    } 
    112109     
    … …  
    117114     * should be called straight after to link this View to the Controller. 
    118115     */ 
    119     BrowserUI(String viewingMode) 
     116    BrowserUI() 
    120117    { 
    121         this.viewingMode = viewingMode; 
    122118    } 
    123119     
    … …  
    149145    } 
    150146     
     147    /** 
     148     * The state has changed. 
     149     * Update the editable status of the main tree display.  
     150     */ 
     151    void onStateChanged() { 
     152        int state = model.getState(); 
     153        treeDisplay.setEditable(state == Browser.TREE_EDIT);     
     154    } 
    151155} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/editor/browser/ContiguousChildSelectionModel.java

    r5584 r5590  
    11 /* 
    2  * editorDynamicTree.ContiguousChildSelectionModel  
     2 * org.openmicroscopy.shoola.agents.editor.browser.ContiguousChildSelectionModel  
    33 * 
    44 *------------------------------------------------------------------------------ 
    … …  
    5656 */ 
    5757public class ContiguousChildSelectionModel  
    58         extends DefaultTreeSelectionModel { 
    59          
    60         public ContiguousChildSelectionModel() { 
     58        extends DefaultTreeSelectionModel  
     59{ 
     60         
     61        /** 
     62         * Creates an instance.  
     63         * Sets selectionMode to {@link DISCONTIGUOUS_TREE_SELECTION} 
     64         */ 
     65        public ContiguousChildSelectionModel()  
     66        { 
    6167                super(); 
    6268                setSelectionMode(DISCONTIGUOUS_TREE_SELECTION); 
    … …