Changeset 8853


Ignore:
Timestamp:
2004-12-17T16:50:46+13:00 (19 years ago)
Author:
mdewsnip
Message:

Initial work on allowing metadata databases to be exploded from within the GLI. These are marked with a different icon in the collection tree and a new item is added to the right-click menu for these files. Clicking this will eventually run the explode_metadata_databases.pl script to explode these files.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r8841 r8853  
    136136        // This file will be processed by an assigned plugin, so no suggestion is necessary
    137137        System.err.println("Processed by assigned plugin: " + assigned_plugin);
    138         System.err.println("Explodes metadata databases: " + assigned_plugin.doesExplodeMetadataDatabases());
     138        // System.err.println("Explodes metadata databases: " + assigned_plugin.doesExplodeMetadataDatabases());
    139139        return;
    140140        }
     
    164164    // Generate a dialog
    165165    new PluginSuggestionPrompt(file.getName(), suitable_plugins);
     166    }
     167
     168
     169    public boolean isFileExplodable(File file)
     170    {
     171    // Temporary hack to test the rest of this, the correct code is below
     172    if (file.isFile() && file.getName().endsWith(".mst")) {
     173        return true;
     174    }
     175
     176//  for (int i = 0; i < library.getSize(); i++) {
     177//      Plugin plugin = (Plugin) library.get(i);
     178//      if (plugin.doesProcessFile(file) == true && plugin.doesExplodeMetadataDatabases() == true) {
     179//      return true;
     180//      }
     181//  }
     182
     183    return false;
    166184    }
    167185
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionTree.java

    r8846 r8853  
    2727package org.greenstone.gatherer.collection;
    2828
     29import java.awt.*;
     30import javax.swing.*;
    2931import org.greenstone.gatherer.gui.tree.DragTree;
     32import org.greenstone.gatherer.gui.tree.DragTreeCellRenderer;
    3033
    3134
     
    3639    {
    3740    super(name, collection_tree_model, mixed_selection);
     41    setCellRenderer(new CollectionTreeCellRenderer());
     42    }
     43
     44
     45    private class CollectionTreeCellRenderer
     46    extends DragTreeCellRenderer
     47    {
     48    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
     49    {
     50        JLabel tree_cell = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
     51
     52        // Mark explodable files with a different icon
     53        if (value instanceof CollectionTreeNode && ((CollectionTreeNode) value).isExplodable()) {
     54        tree_cell.setIcon(CollectionTreeNode.GREEN_FILE);
     55        }
     56
     57        return tree_cell;
     58    }
    3859    }
    3960}
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionTreeNode.java

    r8783 r8853  
    2929
    3030import java.io.*;
     31import javax.swing.*;
     32import org.greenstone.gatherer.cdm.CollectionDesignManager;
    3133import org.greenstone.gatherer.file.FileNode;
     34import org.greenstone.gatherer.util.Utility;
    3235
    3336
     
    3639    extends FileNode
    3740{
     41    static final public ImageIcon GREEN_FILE = Utility.getImage("greenfile.gif", true);
     42
     43    /** Is this file a metadata database that is explodable with the explode_metadata_databases.pl script? */
     44    private boolean is_explodable = false;
     45
     46
    3847    public CollectionTreeNode(File file)
    3948    {
    4049    super(file);
     50
     51    this.is_explodable = CollectionDesignManager.plugin_manager.isFileExplodable(file);
    4152    }
    4253
     
    4960    return child_node;
    5061    }
     62
     63
     64    public boolean isExplodable()
     65    {
     66    return is_explodable;
     67    }
    5168}
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r8846 r8853  
    476476    private JMenuItem collapse_folder = null;
    477477    private JMenuItem expand_folder = null;
     478    private JMenuItem explode_metadata_database = null;
    478479    private JMenuItem delete = null;
    479480    private JMenuItem metaaudit = null;
     
    539540        // ---- Options for file nodes ----
    540541        if (node.isLeaf()) {
     542        // Explode metadata databases, for collection tree only, and for explodable files only
     543        if (tree == collection_tree && ((CollectionTreeNode) node).isExplodable()) {
     544            explode_metadata_database = new JMenuItem(Dictionary.get("Menu.Explode_Metadata_Database"), KeyEvent.VK_E);
     545            explode_metadata_database.addActionListener(this);
     546            add(explode_metadata_database);
     547        }
     548
    541549        // Open the file in an external program
    542550        open_externally = new JMenuItem(Dictionary.get("Menu.Open_Externally"), KeyEvent.VK_O);
     
    616624        else if (source == expand_folder) {
    617625        tree.expandPath(selection_paths[0]);
     626        }
     627
     628        // Explode metadata database
     629        else if (source == explode_metadata_database) {
     630        // !! TO DO: Open dialog with options to explode_metadata_databases.pl, then run it
    618631        }
    619632
Note: See TracChangeset for help on using the changeset viewer.