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

Show
Ignore:
Timestamp:
09/19/08 15:18:05 (2 months ago)
Author:
jburel
Message:

Modified code so that the containers hosting an edited node are only loaded when the user
expands Related To. Will speed the metadata retrieval

Location:
trunk/SRC/org/openmicroscopy/shoola/agents/metadata
Files:
15 modified

  • ContainersLoader.java (modified) (3 diffs)
  • browser/Browser.java (modified) (1 diff)
  • browser/BrowserComponent.java (modified) (4 diffs)
  • browser/BrowserControl.java (modified) (4 diffs)
  • browser/BrowserFactory.java (modified) (1 diff)
  • browser/BrowserModel.java (modified) (5 diffs)
  • browser/BrowserUI.java (modified) (1 diff)
  • editor/Editor.java (modified) (2 diffs)
  • editor/EditorComponent.java (modified) (2 diffs)
  • editor/EditorControl.java (modified) (1 diff)
  • editor/EditorModel.java (modified) (14 diffs)
  • editor/EditorUI.java (modified) (2 diffs)
  • view/MetadataViewer.java (modified) (2 diffs)
  • view/MetadataViewerComponent.java (modified) (3 diffs)
  • view/MetadataViewerModel.java (modified) (3 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/ContainersLoader.java

    r5564 r5620  
    5858 
    5959        /** Either <code>DatasetData</code> or <code>ProjectData</code>. */ 
    60         private Class           type; 
     60        private Class                                   type; 
    6161         
    6262        /** The ID of the parent of the {@link #refNode}. */ 
    63         private long            id; 
    64          
    65         private StructuredDataResults data; 
     63        private long                                    id; 
     64 
    6665         
    6766        /** Handle to the async call so that we can cancel it. */ 
    … …  
    9089         * @param viewer The viewer this data loader is for. 
    9190         *                               Mustn't be <code>null</code>. 
    92          * @param data   
     91         * @param type   The data type of the edited object. 
     92         * @param id     The id of the currently edited object.  
    9393         */ 
    94         public ContainersLoader(MetadataViewer viewer, StructuredDataResults data) 
     94        public ContainersLoader(MetadataViewer viewer, Class type, long id) 
    9595        { 
    9696                super(viewer, null); 
    97                 if (data == null) 
    98                         throw new IllegalArgumentException("No element to handle."); 
    99                 this.data = data; 
    100                 type = data.getRelatedObject().getClass(); 
    101                 id = ((DataObject) data.getRelatedObject()).getId(); 
     97                this.type = type; 
     98                this.id = id; 
     99                //type = data.getRelatedObject().getClass(); 
     100                //id = ((DataObject) data.getRelatedObject()).getId(); 
    102101        } 
    103102         
    … …  
    124123    { 
    125124        if (viewer.getState() == MetadataViewer.DISCARDED) return;  //Async cancel. 
    126         if (data == null)  
    127                 viewer.setContainers(refNode, result); 
    128         else { 
    129                 data.setParents((Collection) result); 
    130         } 
     125        viewer.setContainers(refNode, result); 
    131126    } 
    132127     
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/Browser.java

    r5564 r5620  
    125125         */ 
    126126        public void setParents(TreeBrowserDisplay node, Collection parents); 
    127  
    128         /** 
    129          * Converts the results into the corresponding UI components. 
    130          * and adds them to the display. 
    131          *  
    132          * @param node          The node to handle. Mustn't be <code>null</code>. 
    133          * @param results       The results to handle. 
    134          */ 
    135         public void setStructuredDataResults(TreeBrowserDisplay node, 
    136                                                                                 StructuredDataResults results); 
    137127         
    138128} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/BrowserComponent.java

    r5564 r5620  
    3434 
    3535//Application-internal dependencies 
    36 import org.openmicroscopy.shoola.env.data.util.StructuredDataResults; 
    3736import org.openmicroscopy.shoola.util.ui.component.AbstractComponent; 
    38  
     37import org.openmicroscopy.shoola.util.ui.component.ObservableComponent; 
    3938import pojos.ProjectData; 
    4039import pojos.ScreenData; 
    … …  
    8786        } 
    8887         
    89         /** Links up the MVC triad. */ 
    90         void initialize() 
     88        /**  
     89         * Links up the MVC triad.  
     90         *  
     91         * @param comp The component to register. 
     92         */ 
     93        void initialize(ObservableComponent comp) 
    9194        { 
    9295                controller.initialize(this, view); 
     96                comp.addPropertyChangeListener(controller); 
    9397                view.initialize(model, controller); 
    9498        } 
    … …  
    171175        public void setParents(TreeBrowserDisplay node, Collection parents) 
    172176        { 
    173                 if (node == null)  
    174                         throw new IllegalArgumentException("No node to handle."); 
     177                if (node == null) node = model.getRoot(); 
     178                //      throw new IllegalArgumentException("No node to handle."); 
    175179                if (parents == null || parents.size() == 0) { 
    176180                        view.addDefaultNode(node, BrowserUI.NO_PARENTS_MSG); 
    … …  
    190194                view.setNodes(node, nodes); 
    191195        } 
    192  
    193         /**  
    194          * Implemented as specified by the {@link Browser} interface. 
    195          * @see Browser#setStructuredDataResults(TreeBrowserDisplay,  
    196          *                                                                              StructuredDataResults) 
    197          */ 
    198         public void setStructuredDataResults(TreeBrowserDisplay node,  
    199                                 StructuredDataResults results) 
    200         { 
    201                 if (node == null)  
    202                         throw new IllegalArgumentException("No node to handle."); 
    203                 Object userObject = node.getUserObject(); 
    204                 if (userObject != results.getRelatedObject()) return; 
    205                 if (results == null) { 
    206                         return; 
    207                 } 
    208                 //parents 
    209                 setParents(node, results.getParents()); 
    210         } 
    211196         
    212197} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/BrowserControl.java

    r5299 r5620  
    2525 
    2626//Java imports 
     27import java.beans.PropertyChangeEvent; 
     28import java.beans.PropertyChangeListener; 
    2729import java.util.ArrayList; 
    2830import java.util.HashMap; 
    … …  
    4446import org.openmicroscopy.shoola.agents.metadata.actions.BrowserAction; 
    4547import org.openmicroscopy.shoola.agents.metadata.actions.CollapseAction; 
     48import org.openmicroscopy.shoola.agents.metadata.view.MetadataViewer; 
    4649import org.openmicroscopy.shoola.env.event.EventBus; 
    4750import org.openmicroscopy.shoola.env.ui.UserNotifier; 
    … …  
    6467 */ 
    6568class BrowserControl 
     69        implements PropertyChangeListener 
    6670{ 
    6771         
    … …  
    230234                bus.post(evt); 
    231235        } 
     236 
     237        /** 
     238         * Adds a dummy node to the view when the parents are loaded. 
     239         * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) 
     240         */ 
     241        public void propertyChange(PropertyChangeEvent evt) 
     242        { 
     243                String name = evt.getPropertyName(); 
     244                if (MetadataViewer.LOADING_PARENTS_PROPERTY.equals(name)) { 
     245                        view.addDefaultNode(BrowserUI.LOADING_MSG); 
     246                } 
     247        } 
    232248         
    233249} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/BrowserFactory.java

    r5247 r5620  
    6060        BrowserComponent component = new BrowserComponent(model); 
    6161        model.initialize(component); 
    62         component.initialize(); 
     62        component.initialize(parent); 
    6363        return component; 
    6464    } 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/BrowserModel.java

    r5298 r5620  
    2727import java.awt.Point; 
    2828import java.util.ArrayList; 
     29import java.util.Collection; 
    2930import java.util.Iterator; 
    3031import java.util.List; 
    … …  
    3435//Application-internal dependencies 
    3536import org.openmicroscopy.shoola.agents.metadata.view.MetadataViewer; 
     37import org.openmicroscopy.shoola.env.data.util.StructuredDataResults; 
    3638 
    3739 
    … …  
    6163        /** The parent of this browser. */ 
    6264        private  MetadataViewer                         parent; 
     65         
     66        /** The UI object hosting the edited root object. */ 
     67        private TreeBrowserSet                          root; 
    6368         
    6469        /** Reference to the component that embeds this model. */ 
    … …  
    138143        { 
    139144                selectedNodes.clear(); 
    140                 TreeBrowserSet node = new TreeBrowserSet(refObject); 
    141                 selectedNodes.add(node); 
    142                 parent.loadMetadata(node); 
     145                root = new TreeBrowserSet(refObject); 
     146                selectedNodes.add(root); 
     147                parent.loadMetadata(root); 
    143148        } 
    144149 
    … …  
    159164                parent.loadContainers(node); 
    160165        } 
    161          
     166 
     167        /** 
     168         * Returns the UI object hosting the edited object. 
     169         *  
     170         * @return See above. 
     171         */ 
     172        TreeBrowserSet getRoot() { return root; } 
     173 
    162174} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/browser/BrowserUI.java

    r5486 r5620  
    348348        } 
    349349         
    350     /** 
    351      * Creates a dummy loading node whose parent is the specified node. 
     350        /** 
     351         * Creates a dummy loading node whose parent is the specified node. 
     352         *  
     353         * @param message       The value of the default node. 
     354         */ 
     355    void addDefaultNode(String message) 
     356    { 
     357        addDefaultNode(model.getRoot(), message); 
     358    } 
     359     
     360    /** 
     361     * Creates a dummy loading node to the specified node. 
    352362     *  
    353363     * @param node              The parent of the default node. 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/editor/Editor.java

    r5450 r5620  
    6161        public static final int GRID_LAYOUT = MetadataViewer.GRID_LAYOUT;; 
    6262         
    63         /** 
    64          * Feeds the metadata back to the editor. 
    65          *  
    66          * @param result        The result to feed back. 
    67          */ 
    68         public void setStructuredDataResults(StructuredDataResults result); 
     63        /** Feeds the metadata back to the editor. */ 
     64        public void setStructuredDataResults(); 
    6965         
    7066        /** 
    … …  
    181177         */ 
    182178        public void setSelectionMode(boolean single); 
     179 
     180        /** Loads the container hosting the currently edited object. */ 
     181        public void loadParents(); 
    183182         
    184183} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/editor/EditorComponent.java

    r5603 r5620  
    111111        /**  
    112112         * Implemented as specified by the {@link Browser} interface. 
    113          * @see Editor#setStructuredDataResults(StructuredDataResults) 
    114          */ 
    115         public void setStructuredDataResults(StructuredDataResults result) 
    116         { 
    117                 if (result == null) return; 
    118                 model.setStructuredDataResults(result); 
     113         * @see Editor#setStructuredDataResults() 
     114         */ 
     115        public void setStructuredDataResults() 
     116        { 
    119117                view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 
    120118                view.layoutUI(); 
    … …  
    305303                view.setSelectionMode(single); 
    306304        } 
     305 
     306        /**  
     307         * Implemented as specified by the {@link Browser} interface. 
     308         * @see Editor#loadParents() 
     309         */ 
     310        public void loadParents() 
     311        { 
     312                model.loadParents(); 
     313        } 
    307314         
    308315} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/editor/EditorControl.java

    r5394 r5620  
    8181        void showImageInfo() { model.showImageInfo(); } 
    8282         
     83        /**  
     84         * Loads the container hosting the currently edited object, 
     85         * forwards call to the model.  
     86         */ 
     87        void loadParents() { model.loadParents(); } 
     88         
    8389        /** 
    8490         * Reacts to property change. 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/editor/EditorModel.java

    r5577 r5620  
    4343import org.openmicroscopy.shoola.agents.metadata.AttachmentsLoader; 
    4444import org.openmicroscopy.shoola.agents.metadata.ChannelDataLoader; 
     45import org.openmicroscopy.shoola.agents.metadata.ContainersLoader; 
    4546import org.openmicroscopy.shoola.agents.metadata.DiskSpaceLoader; 
    4647import org.openmicroscopy.shoola.agents.metadata.EditorLoader; 
    … …  
    99100        /** Reference to the component that embeds this model. */ 
    100101        private Editor                                  component; 
    101  
    102         /** The object hosting the various annotations linked to an object. */ 
    103         private StructuredDataResults   data; 
    104102         
    105103        /** The object this editor later. */ 
    … …  
    427425        Collection getUrls() 
    428426        {  
     427                StructuredDataResults data = parent.getStructuredData(); 
    429428                if (data == null) return null; 
    430429                return data.getUrls();  
    … …  
    450449        Collection getTags() 
    451450        {  
     451                StructuredDataResults data = parent.getStructuredData(); 
    452452                if (data == null) return null; 
    453453                Collection tags = data.getTags(); 
    … …  
    475475        Collection getAttachments() 
    476476        {  
     477                StructuredDataResults data = parent.getStructuredData(); 
    477478                if (data == null) return null; 
    478479                return data.getAttachments();  
    … …  
    498499        Collection getViewedBy() 
    499500        {  
     501                StructuredDataResults data = parent.getStructuredData(); 
    500502                if (data == null) return null; 
    501503                Collection l = data.getViewedBy();  
    … …  
    520522        int getRatingCount() 
    521523        { 
     524                StructuredDataResults data = parent.getStructuredData(); 
    522525                Collection ratings = data.getRatings(); 
    523526                if (ratings == null) return 0; 
    … …  
    532535        int getUserRating() 
    533536        { 
     537                StructuredDataResults data = parent.getStructuredData(); 
    534538                if (data == null) return 0; 
    535539                Collection ratings = data.getRatings(); 
    … …  
    553557        int getRatingAverage()  
    554558        { 
     559                StructuredDataResults data = parent.getStructuredData(); 
    555560                if (data == null) return 0; 
    556561                Collection ratings = data.getRatings(); 
    … …  
    585590        Collection getTextualAnnotations() 
    586591        { 
     592                StructuredDataResults data = parent.getStructuredData(); 
    587593                if (data == null) return null; 
    588594                return data.getTextualAnnotations(); 
    … …  
    663669        return textualAnnotationsByUsers; 
    664670        } 
    665          
    666         /** 
    667          * Sets the structured data. 
    668          *  
    669          * @param data The value to set. 
    670          */ 
    671         void setStructuredDataResults(StructuredDataResults data) 
    672         { 
    673                 this.data = data; 
    674         } 
    675671 
    676672        /**  
    … …  
    686682                textualAnnotationsByUsers = null; 
    687683                textualAnnotationsByDate = null; 
    688                 data = null; 
    689684            existingAttachments = null; 
    690685            existingURLs = null; 
    … …  
    10451040        boolean isArchived() 
    10461041        {  
     1042                StructuredDataResults data = parent.getStructuredData(); 
    10471043                if (data == null) return false; 
    10481044                return data.isArchived();  
    … …  
    11271123        } 
    11281124 
    1129         void loadParents() 
    1130         { 
    1131                 if (data == null) return; 
    1132                 if (data.getParents() != null) return; 
    1133                 parent.loadParents(data); 
    1134         } 
     1125        /** 
     1126         * Fires an asynchronous retrieval of containers hosting the currently 
     1127         * edited object.  
     1128         */ 
     1129        void loadParents() { parent.loadParents(); } 
     1130         
     1131        /** Cancels any ongoing parents retrieval. */ 
     1132        void cancelParentsLoading() {  } 
    11351133         
    11361134} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/editor/EditorUI.java

    r5564 r5620  
    218218                viewedByUI.buildUI(); 
    219219        } 
     220 
     221        /** 
     222         * Loads or cancels any on-going loading of containers hosting 
     223         * the edited object. 
     224         *  
     225         * @param b Pass <code>true</code> to load, <code>false</code> to cancel. 
     226         */ 
     227        private void loadParents(boolean b) 
     228        { 
     229                if (b) controller.loadParents(); 
     230                else model.cancelParentsLoading(); 
     231        } 
    220232         
    221233        /** Initializes the UI components. */ 
    … …  
    232244                                public void propertyChange(PropertyChangeEvent evt) { 
    233245                                        String name = evt.getPropertyName(); 
    234                                         if (TreeComponent.EXPANDED_PROPERTY.equals(name)) { 
    235                                                 model.loadParents(); 
    236                                         } 
     246                                        if (TreeComponent.EXPANDED_PROPERTY.equals(name))  
     247                                                loadParents((Boolean) evt.getNewValue()); 
    237248                                } 
    238249                         
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/view/MetadataViewer.java

    r5564 r5620  
    7575                                                                "experimenterUpdated"; 
    7676         
    77         /** Inidicates to layout all the components vertically. */ 
     77        /** 
     78         * Bound property indicating that parents of the currently edited objects 
     79         * are loaded. 
     80         */ 
     81        public static final String      LOADING_PARENTS_PROPERTY = "loadingParents"; 
     82         
     83        /** Indicates to layout all the components vertically. */ 
    7884        public static final int         VERTICAL_LAYOUT = 0; 
    7985         
    80         /** Inidicates to layout all the components vertically. */ 
     86        /** Indicates to layout all the components vertically. */ 
    8187        public static final int         GRID_LAYOUT = 1; 
    8288         
    … …  
    265271        public void onExperimenterUpdated(ExperimenterData data); 
    266272 
    267         public void loadParents(StructuredDataResults data); 
    268          
    269         public void setParents(StructuredDataResults data); 
     273        /** 
     274         * Loads the containers hosting the currently edited object. 
     275         */ 
     276        public void loadParents(); 
     277         
     278        /** 
     279         * Returns the metadata linked to the currently edited object 
     280         * or <code>null</code> if not loaded. 
     281         *  
     282         * @return See above. 
     283         */ 
     284        public StructuredDataResults getStructuredData(); 
    270285         
    271286} 
  • trunk/SRC/org/openmicroscopy/shoola/agents/metadata/view/MetadataViewerComponent.java

    r5603 r5620  
    184184                        Browser browser = model.getBrowser(); 
    185185                        if (result instanceof StructuredDataResults) { 
    186                                 browser.setStructuredDataResults(node,  
    187                                                                                                 (StructuredDataResults) result); 
    188                                 model.getEditor().setStructuredDataResults(  
    189                                                                         (StructuredDataResults) result); 
    190186                                model.setStructuredDataResults((StructuredDataResults) result);