Changeset 8274


Ignore:
Timestamp:
2004-10-11T15:07:57+13:00 (20 years ago)
Author:
mdewsnip
Message:

Made the GEMS start initially with the core GLI metadata sets, and removed the non-functioning "Importing Profiles" node. Fixed some craziness also.

Location:
trunk/gli/src/org/greenstone/gatherer/gems
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r8270 r8274  
    8888
    8989    static private Configuration config = null;
    90     static public MetadataSetManager msm = new MetadataSetManager();
     90    static private MetadataSetManager msm = new MetadataSetManager();
    9191
    9292    private AddElementActionListener add_element_action_listener = null;
     
    171171    }
    172172
    173     new GEMS(null, NORMAL);
     173    new GEMS();
    174174    }
    175175
     
    179179     * @param action a systematic action that should be performed
    180180     */
    181     public GEMS(MetadataSet set, int action)
     181    public GEMS()
    182182    {
    183183    this.dialog_options = new String[2];
     
    206206    upper_pane.setOpaque(false);
    207207         
     208    // Load all the core metadata sets (in the GLI "metadata" directory)
    208209    model = new GEMSModel();
     210    File metadata_directory = new File(Utility.METADATA_DIR);
     211    if (metadata_directory.exists()) {
     212        // Load just those .mds files in this directory, and return them
     213        File[] directory_files = metadata_directory.listFiles();
     214        for (int i = 0; i < directory_files.length; i++) {
     215        File child_file = directory_files[i];
     216        if (!child_file.isDirectory() && child_file.getName().endsWith(".mds")) {
     217            System.err.println("Found mds file: " + child_file);
     218            MetadataSet metadata_set = msm.loadMetadataSet(child_file);
     219            model.add(null, metadata_set, GEMSNode.SET);
     220        }
     221        }
     222    }
    209223
    210224    JPanel mds_tree_pane = new JPanel();
     
    218232    mds_tree.setSelectionColor(config.getColor("coloring.collection_selection_background", false));
    219233    mds_tree.setSelectedTextColor(config.getColor("coloring.collection_selection_foreground", false));
    220     // We may have been asked to select a cetain initial set
    221     if(set != null) {
    222         GEMSNode root = (GEMSNode) model.getRoot();
    223         for(int i = 0; i < root.getChildCount(); i++) {
    224         GEMSNode child = (GEMSNode) root.getChildAt(i);
    225         if(set.equals(child.getUserObject())) {
    226             TreePath path = new TreePath(child.getPath());
    227             mds_tree.setSelectionPath(path);
    228             mds_tree.expandPath(path);
    229             path = null;
    230         }
    231         child = null;
    232         }
    233         root = null;
    234     }
    235234
    236235    details_pane = new JPanel();
     
    545544    content_pane.add(button_pane, BorderLayout.SOUTH);
    546545
    547     // Callback - we may have been asked to perform some systematic action, but we can't do that until the dialog is visible, which in itself causes a problem as the dialog is modal and setVisible won't return until the dialog is cancelled. The solution is to spawn a task on a new thread which waits until the dialog is visible then calls doClick on the appropriate button.
    548     if(action != NORMAL) {
    549         ActionTask task = new ActionTask(action);
    550         task.start();
    551     }
    552546    // Display
    553547    setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMSNode.java

    r8270 r8274  
    191191    return text;
    192192    }
    193     private void mapChildren() {
    194     ///ystem.err.println("Mapping the children of " + this);
     193
     194
     195    private void mapChildren()
     196    {
    195197    children = new Vector();
     198
    196199    // How we build children depends on the node type
    197     switch(type) {
    198     case PROFILER: // Add the collections as children
    199         // ArrayList a = GEMS.msm.profiler.getCollections();
    200         // for(int i = 0; i < a.size(); i++) {
    201         // children.add(new GEMSNode(COLLECTION, a.get(i), this));
    202         // }
    203         // a = null;
    204         break;
    205     case ROOT:
    206         Vector v = GEMS.msm.getSets();
    207         for(int i = 0; i < v.size(); i++) {
    208         children.add(new GEMSNode(SET, v.get(i), this));
    209         }
    210         v = null;
    211         // Add the profile set.
    212         children.add(new GEMSNode(PROFILER, Dictionary.get("MEM.Profiles"), this));
    213         break;
    214     case SET: // Add the elements as children
     200    if (type == SET) {
     201        // Add the elements as children
    215202        MetadataSet set = (MetadataSet) userObject;
    216203        NodeList elements = set.getElements();
    217         set = null;
    218         for(int i = 0; i < elements.getLength(); i++) {
     204        for (int i = 0; i < elements.getLength(); i++) {
    219205        children.add(new GEMSNode(ELEMENT, new ElementWrapper((Element) elements.item(i)), this));
    220206        }
    221         elements = null;
    222         break;
    223     case COLLECTION:
    224     case ELEMENT:
    225     default:
    226207    }
    227208    }
Note: See TracChangeset for help on using the changeset viewer.