Changeset 5207
- Timestamp:
- 2003-08-19T15:32:22+12:00 (21 years ago)
- 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 166 166 int child_count = children.getLength(); 167 167 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)); 169 169 } 170 170 return child_list; -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugIn.java
r4932 r5207 39 39 extends ArrayList 40 40 implements ArgumentContainer, Comparable, DOMProxyListEntry, Serializable { 41 private boolean is_abstract = false; // Only for Base 41 42 /** The DOM Element this assigned PlugIn is modelled on. */ 42 43 private Element element; 43 44 /** 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. 49 50 */ 50 51 public PlugIn() { … … 55 56 this.element = element; 56 57 this.name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE); 57 // /atherer.println("Establishing Plugin: " + name);58 //Gatherer.println("Establishing Plugin: " + name); 58 59 // Parse in any argument options for this plugin, keeping a list of the ones found 59 60 HashMap known_arguments = new HashMap(); … … 63 64 Element option_element = (Element) option_elements.item(i); 64 65 Argument argument = new Argument(option_element); 65 // /atherer.println("Rebuilding existing argument: " + argument.getName());66 //Gatherer.println("Rebuilding existing argument: " + argument.getName()); 66 67 argument.setOwner(name); 67 68 add(argument); … … 70 71 // If a base plugin was given 71 72 if(base_plugin != null) { 73 //Gatherer.println("Based on previous plugin."); 72 74 // Copy the details, and add a reference to whatever base_plugins super plugin is. 73 75 description = base_plugin.getDescription(); … … 78 80 Argument base_argument = (Argument) all_arguments.get(j); 79 81 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); 81 83 Argument existing_argument = (Argument) known_arguments.get(base_argument_name); 82 84 // Found an existing argument. Complete its details 83 85 if(existing_argument != null) { 84 // /atherer.println("Found existing argument. Filling out details.");86 //Gatherer.println("Found existing argument. Filling out details."); 85 87 existing_argument.setCustomArgument(false); 86 88 existing_argument.setDefaultValue(base_argument.getDefaultValue()); … … 92 94 // 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. 93 95 else { 94 // /atherer.println("No such argument. Adding new, unassigned, argument.");96 //Gatherer.println("No such argument. Adding new, unassigned, argument."); 95 97 // The trick thing is that we have to create a new element in the DOM as well. 96 98 Argument new_argument = base_argument.copy(); … … 106 108 } 107 109 } 108 }109 110 /** This constructor is only used for library level Plugins.111 * @param name112 * @param description113 * @param super_plugin114 */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;120 110 } 121 111 … … 254 244 } 255 245 return name; 246 } 247 248 public boolean isAbstract() { 249 return is_abstract; 256 250 } 257 251 … … 330 324 } 331 325 326 public void setIsAbstract(boolean is_abstract) { 327 this.is_abstract = is_abstract; 328 } 329 332 330 /** Method to set the value of name. 333 331 * @param name The new value of name as a <strong>String</strong>. -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r5090 r5207 140 140 // Can't ever move RecPlug or ArcPlug. 141 141 if(getSize() < 3) { 142 Gatherer.println("Not enough plugins to allow moving.");142 //Gatherer.println("Not enough plugins to allow moving."); 143 143 return; 144 144 } … … 307 307 private Object[] getAvailable() { 308 308 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 } 310 317 // Now go through the assigned plugins, and remove any that match. 311 318 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."); 312 322 return available.toArray(); 313 323 } … … 386 396 else { 387 397 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); 389 399 JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_XML_Parse_Failed", plugin_name), get("General.Error"), JOptionPane.ERROR_MESSAGE); 390 400 } … … 454 464 plugin.setDescription(MSMUtils.getValue(node)); 455 465 } 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. 457 470 else if(node_name.equals("Arguments")) { 458 471 for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) { … … 566 579 */ 567 580 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);574 581 // Create 575 582 add = new JButton(get("Add")); … … 670 677 plugin_list_label.setBorder(BorderFactory.createEmptyBorder(0,2,0,2)); 671 678 679 movement_pane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0)); 672 680 movement_pane.setLayout(new GridLayout(4,1)); 673 681 movement_pane.add(move_top); … … 704 712 central_pane.add(temp, BorderLayout.SOUTH); 705 713 706 button_pane.setLayout(new GridLayout( 3,1));714 button_pane.setLayout(new GridLayout(1,3)); 707 715 button_pane.add(add); 708 716 button_pane.add(configure); … … 741 749 public void actionPerformed(ActionEvent event) { 742 750 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 }747 751 if(selected_object != null) { 752 // Retrieve the base plugin if any 753 PlugIn base_plugin = getBasePlugIn(selected_object.toString()); 754 748 755 // Create a new element in the DOM 749 756 Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.PLUGIN_ELEMENT); 750 757 // Remember that the plugin supplied might be a custom string rather than a base plugin 751 758 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"); 754 761 element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_plugin.getName()); 755 762 new_plugin = new PlugIn(element, base_plugin); 756 base_plugin = null;757 763 } 758 764 else { 765 //Gatherer.println("New Custom PlugIn"); 759 766 element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString()); 760 767 new_plugin = new PlugIn(element, null); … … 766 773 assignPlugIn(new_plugin); 767 774 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 } 768 779 } 769 780 ac = null; … … 774 785 JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_Exists"), get("General.Error"), JOptionPane.ERROR_MESSAGE); 775 786 } 787 base_plugin = null; 776 788 } 777 789 } … … 900 912 private class RemoveListener 901 913 implements ActionListener { 902 903 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 */ 905 917 public void actionPerformed(ActionEvent event) { 906 918 if(!plugin_list.isSelectionEmpty()) { … … 911 923 } 912 924 } 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); 918 929 } 919 930 }
Note:
See TracChangeset
for help on using the changeset viewer.