Changeset 5207


Ignore:
Timestamp:
2003-08-19T15:32:22+12:00 (21 years ago)
Author:
jmt12
Message:

Fix 203B120, 145 and 146

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
3 edited

Legend:

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

    r5080 r5207  
    166166    int child_count = children.getLength();
    167167    for(int i = 0; i < child_count; i++) {
    168         child_list.add(class_type.create((Element)children.item(i)));
     168        child_list.add(getElementAt(i));
    169169    }
    170170    return child_list;
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugIn.java

    r4932 r5207  
    3939    extends ArrayList
    4040    implements ArgumentContainer, Comparable, DOMProxyListEntry, Serializable {
     41    private boolean is_abstract = false; // Only for Base
    4142    /** The DOM Element this assigned PlugIn is modelled on. */
    4243    private Element element;
    4344    /** The parent PlugIn this one inherits from, if any. */
    44     private PlugIn super_plugin;
    45     private String description;
    46     private String name;
    47 
    48     /** Constructor used only in DOMProxyListModel initializations.
     45    private PlugIn super_plugin; // Only for Base
     46    private String description; // Only for Base
     47    private String name; // Only for Base
     48
     49    /** Constructor used in DOMProxyListModel initializations, and Library Level.
    4950     */
    5051    public PlugIn() {
     
    5556    this.element = element;
    5657    this.name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
    57     ///atherer.println("Establishing Plugin: " + name);
     58    //Gatherer.println("Establishing Plugin: " + name);
    5859    // Parse in any argument options for this plugin, keeping a list of the ones found
    5960    HashMap known_arguments = new HashMap();
     
    6364        Element option_element = (Element) option_elements.item(i);
    6465        Argument argument = new Argument(option_element);
    65         ///atherer.println("Rebuilding existing argument: " + argument.getName());
     66        //Gatherer.println("Rebuilding existing argument: " + argument.getName());
    6667        argument.setOwner(name);
    6768        add(argument);
     
    7071    // If a base plugin was given
    7172    if(base_plugin != null) {
     73        //Gatherer.println("Based on previous plugin.");
    7274        // Copy the details, and add a reference to whatever base_plugins super plugin is.
    7375        description = base_plugin.getDescription();
     
    7880        Argument base_argument = (Argument) all_arguments.get(j);
    7981        String base_argument_name = base_argument.getName();
    80         ///atherer.println("Library indicates this plugin should have an argument: " + base_argument_name);
     82        //Gatherer.println("Library indicates this plugin should have an argument: " + base_argument_name);
    8183        Argument existing_argument = (Argument) known_arguments.get(base_argument_name);
    8284        // Found an existing argument. Complete its details
    8385        if(existing_argument != null) {
    84             ///atherer.println("Found existing argument. Filling out details.");
     86            //Gatherer.println("Found existing argument. Filling out details.");
    8587            existing_argument.setCustomArgument(false);
    8688            existing_argument.setDefaultValue(base_argument.getDefaultValue());
     
    9294        // No existing argument. Copy base_argument and add it, but do not set its assigned flag. That should be set the first time its changed by the user.
    9395        else {
    94             ///atherer.println("No such argument. Adding new, unassigned, argument.");
     96            //Gatherer.println("No such argument. Adding new, unassigned, argument.");
    9597            // The trick thing is that we have to create a new element in the DOM as well.
    9698            Argument new_argument = base_argument.copy();
     
    106108        }
    107109    }
    108     }
    109 
    110     /** This constructor is only used for library level Plugins.
    111      * @param name
    112      * @param description
    113      * @param super_plugin
    114      */
    115     public PlugIn(String name, String description, PlugIn super_plugin) {
    116     super();
    117     this.description = description;
    118     this.name = name;
    119     this.super_plugin = super_plugin;
    120110    }
    121111
     
    254244    }
    255245    return name;
     246    }
     247
     248    public boolean isAbstract() {
     249    return is_abstract;
    256250    }
    257251
     
    330324    }
    331325
     326    public void setIsAbstract(boolean is_abstract) {
     327    this.is_abstract = is_abstract;
     328    }
     329
    332330    /** Method to set the value of name.
    333331     * @param name The new value of name as a <strong>String</strong>.
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r5090 r5207  
    140140    // Can't ever move RecPlug or ArcPlug.
    141141    if(getSize() < 3) {
    142         Gatherer.println("Not enough plugins to allow moving.");
     142        //Gatherer.println("Not enough plugins to allow moving.");
    143143        return;
    144144    }
     
    307307    private Object[] getAvailable() {
    308308    ArrayList available = new ArrayList();
    309     available.addAll(library);
     309    int library_size = library.size();
     310    for(int i = 0; i < library_size; i++) {
     311        PlugIn plugin = (PlugIn) library.get(i);
     312        if(!plugin.isAbstract()) {
     313        available.add(plugin);
     314        }
     315        plugin = null;
     316    }
    310317    // Now go through the assigned plugins, and remove any that match.
    311318    available.removeAll(children());
     319    //Gatherer.println("There are a total of " + library.size() + " plugins in the library.");
     320    //Gatherer.println("However " + children().size() + " are in use,");
     321    //Gatherer.println("So only " + available.size() + " remain.");
    312322    return available.toArray();
    313323    }
     
    386396        else {
    387397        String plugin_name = getPlugInName(plugin);
    388         Gatherer.println("Zero length argument xml detected for: " + plugin_name);
     398        //Gatherer.println("Zero length argument xml detected for: " + plugin_name);
    389399        JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_XML_Parse_Failed", plugin_name), get("General.Error"), JOptionPane.ERROR_MESSAGE);
    390400        }
     
    454464        plugin.setDescription(MSMUtils.getValue(node));
    455465        }
    456                 // Parse the multitude of arguments.
     466        else if(node_name.equals(CollectionConfiguration.ABSTRACT_ELEMENT)) {
     467        plugin.setIsAbstract(MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));
     468        }
     469        // Parse the multitude of arguments.
    457470        else if(node_name.equals("Arguments")) {
    458471        for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) {
     
    566579     */
    567580    public PlugInControl() {
    568         Object plugins[] = library.toArray();
    569         Vector plugin_model = new Vector();
    570         for(int i = 0; i < plugins.length; i++) {
    571         plugin_model.add(((PlugIn)plugins[i]).getName());
    572         }
    573         Collections.sort(plugin_model);
    574581        // Create
    575582        add = new JButton(get("Add"));
     
    670677        plugin_list_label.setBorder(BorderFactory.createEmptyBorder(0,2,0,2));
    671678
     679        movement_pane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0));
    672680        movement_pane.setLayout(new GridLayout(4,1));
    673681        movement_pane.add(move_top);
     
    704712        central_pane.add(temp, BorderLayout.SOUTH);
    705713
    706         button_pane.setLayout(new GridLayout(3,1));
     714        button_pane.setLayout(new GridLayout(1,3));
    707715        button_pane.add(add);
    708716        button_pane.add(configure);
     
    741749        public void actionPerformed(ActionEvent event) {
    742750        Object selected_object = plugin.getSelectedItem();
    743         // If there is something in the combobox, but we haven't registered a selection, then add the object and select it!
    744         if(selected_object != null && plugin.getSelectedIndex() == -1) {
    745             plugin.insertItemAt(selected_object, plugin.getItemCount());
    746         }
    747751        if(selected_object != null) {
     752            // Retrieve the base plugin if any
     753            PlugIn base_plugin = getBasePlugIn(selected_object.toString());
     754
    748755            // Create a new element in the DOM
    749756            Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.PLUGIN_ELEMENT);
    750757            // Remember that the plugin supplied might be a custom string rather than a base plugin
    751758            PlugIn new_plugin = null;
    752             if(selected_object instanceof PlugIn) {
    753             PlugIn base_plugin = (PlugIn) selected_object;
     759            if(base_plugin != null) {
     760            //Gatherer.println("New PlugIn based on existing PlugIn");
    754761            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_plugin.getName());
    755762            new_plugin = new PlugIn(element, base_plugin);
    756             base_plugin = null;
    757763            }
    758764            else {
     765            //Gatherer.println("New Custom PlugIn");
    759766            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString());
    760767            new_plugin = new PlugIn(element, null);
     
    766773                assignPlugIn(new_plugin);
    767774                plugin_list.setSelectedValue(new_plugin, true);
     775                // Since we weren't cancelled, and if there was a base plugin, ensure it no longer is shown as available
     776                if(base_plugin != null) {
     777                plugin.removeItem(base_plugin);
     778                }
    768779            }
    769780            ac = null;
     
    774785            JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_Exists"), get("General.Error"), JOptionPane.ERROR_MESSAGE);
    775786            }
     787            base_plugin = null;
    776788        }
    777789        }
     
    900912    private class RemoveListener
    901913        implements ActionListener {
    902                 /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed when an action has occured on one of our target controls.
    903                 * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
    904                 */
     914        /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed when an action has occured on one of our target controls.
     915        * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
     916        */
    905917        public void actionPerformed(ActionEvent event) {
    906918        if(!plugin_list.isSelectionEmpty()) {
     
    911923            }
    912924            }
    913             //Object object = plugin_list.getSelectedValue();
    914             //if(object instanceof PlugIn) {
    915             //removePlugIn((PlugIn)object);
    916             //}
    917         }
     925            // Refresh the available plugins
     926            plugin.setModel(new DefaultComboBoxModel(getAvailable()));
     927        }
     928        remove.setEnabled(false);
    918929        }
    919930    }
Note: See TracChangeset for help on using the changeset viewer.