Changeset 12292


Ignore:
Timestamp:
2006-07-24T17:00:16+12:00 (18 years ago)
Author:
kjdon
Message:

there may be multiple plugins that can explode a particular file extension (eg Refer and BibTex bith use .bib) so we add a new argument to exploding, a drop down list of potential plugins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/ExplodeMetadataPrompt.java

    r12119 r12292  
    6767    /** the file we wil be exploding */
    6868    private File metadata_file = null;
    69     /** the name of the plugin to be used */
    70     private String plugin_name = null;
     69    /** the list of potential plugins to be used */
     70    private Argument plugin_arg = null;
    7171    /** holds all the available options for the exploding script */
    7272    private ScriptOptions options = null;
     
    8585
    8686    // check that we actually have an explodable file
    87     Plugin plugin = CollectionDesignManager.plugin_manager.getExploderPlugin(source_file);
    88     if (plugin==null) {
     87    ArrayList exp_plugins = CollectionDesignManager.plugin_manager.getExploderPlugins(source_file);
     88    if (exp_plugins.size() == 0) {
    8989        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("ExplodeMetadataPrompt.NotExplodable"), Dictionary.get("ExplodeMetadataPrompt.Title"), JOptionPane.ERROR_MESSAGE);
    9090        return;
    9191    }
    92     plugin_name = plugin.getName();
     92    plugin_arg = createPluginArgument(exp_plugins);
    9393    setJMenuBar(new SimpleMenuBar("explodingmetadata"));
    9494    setSize(SIZE);
     
    176176    }
    177177
     178    private Argument createPluginArgument(ArrayList plugin_list) {
     179    Argument arg = new Argument();
     180    arg.setName("plugin");
     181    arg.setDescription(Dictionary.get("ExplodeMetadataPrompt.Plugin"));
     182    arg.setRequired(true);
     183    arg.setType(Argument.ENUM);
     184    for (int i=0; i<plugin_list.size(); i++) {
     185        Plugin p = (Plugin)plugin_list.get(i);
     186        arg.addOption(p.getName(), p.getName());
     187    }
     188    return arg;
     189    }
    178190    private void addScriptOptions(JPanel options_pane) {
    179191
     
    185197    int total_argument_count = options.getArgumentCount();
    186198       
     199    // first we add the plugin arg
     200    ArgumentControl argument_control = new ArgumentControl(plugin_arg,true, null);
     201    argument_control.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
     202    options_pane.add((JComponent)argument_control);
    187203    for(int i = 0; i < total_argument_count; i++) {
    188204        // Retrieve the argument so we know how to format the control.
     
    193209        }
    194210        // by default, all args are disabled, and no value
    195         ArgumentControl argument_control = new ArgumentControl(argument,false, null);
     211        argument_control = new ArgumentControl(argument,false, null);
    196212        // make sure they are coloured the way we want - this is not the standard arg control coloring
    197213        argument_control.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
     
    239255    }
    240256    command_parts_list.add(LocalGreenstone.getBinScriptDirectoryPath() + "explode_metadata_database.pl");
    241     command_parts_list.add("-plugin");
    242     command_parts_list.add(plugin_name);
    243 
     257   
    244258    // Add in all the options from the user
    245259    String[] explode_options = options.getValues();
     
    250264    // Add in the filename
    251265    command_parts_list.add(metadata_file.getPath());
    252 
    253266    // Run the explode_metadata_database.pl command
    254267    String[] command_parts = (String[]) command_parts_list.toArray(new String[0]);
Note: See TracChangeset for help on using the changeset viewer.