Changeset 12631
- Timestamp:
- 2006-08-31T15:05:02+12:00 (18 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Classifier.java
r12247 r12631 27 27 package org.greenstone.gatherer.cdm; 28 28 29 /**************************************************************************************30 * Written: 01/05/0231 * Revised: 16/08/02 Optimized and Commented.32 * 11/07/03 DOM support33 **************************************************************************************/34 29 import java.io.*; 35 30 import java.util.*; … … 38 33 import org.w3c.dom.*; 39 34 35 40 36 /** This class is responsible for storing information from a parsed classinfo.pl call in such a way that it allows easy access to parsed details for the purposes of user design and specification of classifiers. 41 37 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 43 39 */ 44 40 public class Classifier 45 extends ArgumentContainer { 46 41 extends ArgumentContainer 42 { 43 static final public String CLASSIFIER_PREFIX = "CL"; 47 44 48 static final public String CLASSIFIER_PREFIX = "CL";49 45 50 46 /** Constructor used only in DOMProxyListModel initializations. … … 52 48 public Classifier() { 53 49 } 50 54 51 55 52 public Classifier(Element element, Classifier base_classifier) { 56 53 super(element, base_classifier); 57 54 } 55 58 56 59 57 /** The assigned classifier constructor. … … 63 61 String classifier_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE); 64 62 // Determine the base classifier from the classifier name 65 Classifier base_classifier = CollectionDesignManager.classifier_manager.get BaseClassifier(classifier_name);63 Classifier base_classifier = CollectionDesignManager.classifier_manager.getClassifier(classifier_name, true); 66 64 Classifier classifier = new Classifier(element, base_classifier); 67 65 if (base_classifier == null) { … … 73 71 return classifier; 74 72 } 73 75 74 76 75 /** Generate the string showing this classifiers position. */ … … 86 85 return position_string; 87 86 } 88 89 87 } -
trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java
r12620 r12631 57 57 */ 58 58 public class ClassifierManager 59 extends DOMProxyListModel { 60 61 /** A list of known, but currently unassigned, classifiers. */ 62 private ArrayList library = null; 59 extends DOMProxyListModel 60 { 61 // A list of all the classifiers in the core Greenstone "perllib/classify" folder (arguments may not be loaded) 62 private ArrayList core_greenstone_classifiers_list = null; 63 63 64 /** The controls for editing the contents of this manager. */ 64 65 private Control controls = null; … … 74 75 this.model = this; 75 76 DebugStream.println("ClassifierManager: " + getSize() + " classifiers parsed."); 76 // Reload/Create the library 77 loadClassifiers(); 78 saveClassifiers(); 79 } 80 81 /** Method to add a new classifier to library. 82 * @param classifier The new <strong>Classifier</strong>. 83 * @see org.greenstone.gatherer.cdm.DynamicListModel 84 */ 85 private void addClassifier(Classifier classifier) { 86 if(!library.contains(classifier)) { 87 library.add(classifier); 88 } 89 } 77 78 core_greenstone_classifiers_list = loadClassifiersList(); 79 } 80 81 82 // -------------------------------------------------------------------------------------------------------- 83 84 85 /** Retrieve a list of the classifiers that are available to be added to the collection. */ 86 private Object[] getAvailableClassifiers() 87 { 88 ArrayList available = new ArrayList(); 89 90 // Add all the non-abstract core Greenstone classifiers 91 for (int i = 0; i < core_greenstone_classifiers_list.size(); i++) { 92 Classifier classifier = (Classifier) core_greenstone_classifiers_list.get(i); 93 if (!classifier.isAbstract()) { 94 available.add(classifier); 95 } 96 } 97 98 // Sort the available classifiers into alphabetical order 99 Collections.sort(available); 100 101 return available.toArray(); 102 } 103 104 105 public Classifier getClassifier(String classifier_name, boolean arguments_required) 106 { 107 for (int i = 0; i < core_greenstone_classifiers_list.size(); i++) { 108 Classifier classifier = (Classifier) core_greenstone_classifiers_list.get(i); 109 if (classifier.getName().equals(classifier_name)) { 110 if (arguments_required) { 111 if (classifier.getArguments().size() == 0) { 112 loadClassifierInfo(classifier); 113 } 114 else { 115 System.err.println("Already loaded arguments for " + classifier_name + "!"); 116 } 117 } 118 return classifier; 119 } 120 } 121 122 return null; 123 } 124 125 126 private void loadClassifierInfo(Classifier classifier) 127 { 128 System.err.println("Loading arguments for " + classifier.getName() + "..."); 129 130 // Run classifierfo.pl to get the list of classifiers 131 try { 132 StringBuffer xml = null; 133 if (Gatherer.isGsdlRemote) { 134 // !! TO DO 135 } 136 else { 137 ArrayList args = new ArrayList(); 138 if (Utility.isWindows()) { 139 args.add(Configuration.perl_path); 140 args.add("-S"); 141 } 142 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "classinfo.pl"); 143 args.add("-xml"); 144 args.add("-language"); 145 args.add(Configuration.getLanguage()); 146 args.add(classifier.getName()); 147 148 // Run the classinfo.pl process 149 Runtime runtime = Runtime.getRuntime(); 150 Process process = runtime.exec((String[]) args.toArray(new String[] { })); 151 InputStream input_stream = process.getErrorStream(); 152 xml = XMLTools.readXMLStream(input_stream); 153 } 154 155 if (xml.length() > 0) { 156 parseClassifierInfoXML(classifier, xml.toString()); 157 } 158 else { 159 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.ClassifierManager.Classifier_XML_Parse_Failed", classifier.getName()), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 160 } 161 } 162 catch (Exception exception) { 163 DebugStream.printStackTrace(exception); 164 } 165 } 166 167 168 private ArrayList loadClassifiersList() 169 { 170 System.err.println("In loadClassifiersList()..."); 171 172 // Run classifierfo.pl to get the list of classifiers 173 try { 174 StringBuffer xml = null; 175 if (Gatherer.isGsdlRemote) { 176 // !! TO DO 177 } 178 else { 179 ArrayList args = new ArrayList(); 180 if (Utility.isWindows()) { 181 args.add(Configuration.perl_path); 182 args.add("-S"); 183 } 184 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "classinfo.pl"); 185 args.add("-listall"); 186 args.add("-xml"); 187 188 // Run the classinfo.pl process 189 Runtime runtime = Runtime.getRuntime(); 190 Process process = runtime.exec((String[]) args.toArray(new String[] { })); 191 InputStream input_stream = process.getErrorStream(); 192 xml = XMLTools.readXMLStream(input_stream); 193 } 194 195 if (xml.length() > 0) { 196 return parseClassifiersListXML(xml.toString()); 197 } 198 else { 199 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.ClassifierManager.Classifier_List_XML_Parse_Failed"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 200 } 201 } 202 catch (Exception exception) { 203 DebugStream.printStackTrace(exception); 204 } 205 206 return null; 207 } 208 209 210 private void parseClassifierInfoXML(Classifier classifier, String xml) 211 { 212 Document document = XMLTools.parseXML(new StringReader(xml)); 213 parseClassifierInfoXMLNode(classifier, document.getDocumentElement()); 214 } 215 216 217 private void parseClassifierInfoXMLNode(Classifier classifier, Node root_node) 218 { 219 for (Node node = root_node.getFirstChild(); node != null; node = node.getNextSibling()) { 220 String node_name = node.getNodeName(); 221 222 if (node_name.equalsIgnoreCase("Name")) { 223 classifier.setName(XMLTools.getValue(node)); 224 } 225 else if (node_name.equals("Desc")) { 226 classifier.setDescription(XMLTools.getValue(node)); 227 } 228 else if (node_name.equals("Abstract")) { 229 classifier.setIsAbstract(XMLTools.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR)); 230 } 231 // Parse the classifier arguments 232 else if (node_name.equalsIgnoreCase("Arguments")) { 233 for (Node argument_node = node.getFirstChild(); argument_node != null; argument_node = argument_node.getNextSibling()) { 234 // An option 235 if (argument_node.getNodeName().equalsIgnoreCase("Option")) { 236 Argument argument = new Argument(); 237 argument.parseXML((Element) argument_node); 238 classifier.addArgument(argument); 239 } 240 } 241 } 242 // A super classifier class 243 else if (node_name.equalsIgnoreCase("ClassInfo")) { 244 Classifier super_classifier = new Classifier(); 245 parseClassifierInfoXMLNode(super_classifier, node); 246 classifier.setSuper(super_classifier); 247 } 248 } 249 } 250 251 252 private ArrayList parseClassifiersListXML(String xml) 253 { 254 ArrayList classifiers_list = new ArrayList(); 255 256 Document document = XMLTools.parseXML(new StringReader(xml)); 257 Node root = document.getDocumentElement(); 258 for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) { 259 String node_name = node.getNodeName(); 260 261 if (node_name.equals("ClassInfo")) { 262 Classifier classifier = new Classifier(); 263 parseClassifierInfoXMLNode(classifier, node); 264 classifiers_list.add(classifier); 265 } 266 } 267 268 return classifiers_list; 269 } 270 271 272 // -------------------------------------------------------------------------------------------------------- 273 90 274 91 275 /** Method to assign a classifier. … … 112 296 return true; 113 297 } 114 /** Destructor. 115 * @see org.greenstone.gatherer.Gatherer 116 * @see org.greenstone.gatherer.cdm.CollectionDesignManager 117 * @see org.greenstone.gatherer.cdm.DynamicListModel 118 */ 119 public void destroy() { 120 if(controls != null) { 298 299 300 /** Destructor. */ 301 public void destroy() 302 { 303 if (controls != null) { 121 304 controls.destroy(); 122 305 controls = null; 123 306 } 124 library.clear(); 125 library = null; 126 } 127 128 public Classifier getBaseClassifier(String name) { 129 int library_size = library.size(); 130 for(int i = 0; i < library_size; i++) { 131 Classifier classifier = (Classifier) library.get(i); 132 if(classifier.getName().equals(name)) { 133 return classifier; 134 } 135 } 136 // No success. 137 return null; 138 } 307 } 308 139 309 140 310 /** Method to retrieve the classifier with the given index. … … 255 425 } 256 426 257 /** Method to cache the current contents of library (known classifiers) to file.258 * @see org.greenstone.gatherer.util.Utility259 */260 private void saveClassifiers() {261 try {262 File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");263 FileOutputStream file = new FileOutputStream(classifiers_dat_file);264 ObjectOutputStream out = new ObjectOutputStream(file);265 out.writeObject(library);266 out.close();267 }268 catch (Exception error) {269 }270 }271 272 private Object[] getAvailable() {273 ArrayList available = new ArrayList();274 int library_size = library.size();275 for(int i = 0; i < library_size; i++) {276 Classifier classifier = (Classifier) library.get(i);277 if(!classifier.isAbstract()) {278 available.add(classifier);279 }280 classifier = null;281 }282 return available.toArray();283 }284 285 /** Method to extract just the classifiers name from a file object.286 * @param classifier The <strong>File</strong> which references a certain classifier.287 * @return A <strong>String</strong> containing just the classifiers name, without extension.288 */289 private String getClassifierName(String filename) {290 String name = filename;291 if(name.indexOf(".") != -1) {292 name = name.substring(0, name.indexOf("."));293 }294 return name;295 }296 297 /** Method to load the details of a single plug-in.298 * @param classifier The classifier <strong>File</strong> you wish to load.299 */300 private void loadClassifier(String classifier, String lang, String collection) {301 ///ystem.err.println("Attempting to parse " + classifier + " for collection "+collection);302 Document document = null;303 InputStream input_stream = null;304 305 long start;306 long end;307 // Run classinfo on this classifier, and then send the results for parsing.308 try {309 StringBuffer xml = null;310 if (Gatherer.isGsdlRemote) {311 String classinfo_output = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", "&classifier=" + classifier);312 xml = new StringBuffer(classinfo_output);313 }314 else {315 ArrayList args = new ArrayList();316 if (Utility.isWindows()) {317 args.add(Configuration.perl_path);318 args.add("-S");319 }320 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "classinfo.pl");321 args.add("-xml");322 args.add("-language");323 args.add(lang);324 args.add("-collect");325 args.add(collection);326 args.add(getClassifierName(classifier));327 328 // Create the process.329 Runtime runtime = Runtime.getRuntime();330 Process process = runtime.exec((String[])args.toArray(new String [0]));331 332 input_stream = process.getErrorStream();333 xml = XMLTools.readXMLStream(input_stream);334 }335 336 if (xml.length() > 0) {337 document = XMLTools.parseXML(new StringReader(xml.toString()));338 }339 else {340 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.ClassifierManager.Classifier_XML_Parse_Failed", classifier), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);341 }342 }343 catch (Exception exception) {344 DebugStream.println("Failed when trying to parse: " + classifier);345 DebugStream.printStackTrace(exception);346 }347 348 if (document != null) {349 parseXML(document.getDocumentElement());350 }351 }352 353 /** Method to initially load information from the standard classifiers within the gsdl Perl library.354 * @see org.greenstone.gatherer.util.Utility355 */356 private void loadClassifiers() {357 // Attempt to restore the cached file.358 File classifiers_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "classifiers.dat");359 try {360 FileInputStream file = new FileInputStream(classifiers_dat_file);361 ObjectInputStream input = new ObjectInputStream(file);362 library = (ArrayList) input.readObject();363 }364 catch (Exception error) {365 DebugStream.println("Unable to open " + classifiers_dat_file);366 }367 368 if(library == null) {369 library = new ArrayList();370 371 if (Gatherer.isGsdlRemote) {372 String classinfo_output = RemoteGreenstoneServer.getScriptOptions("classinfo.pl", "&listall=");373 loadClassifiers(new StringBuffer(classinfo_output));374 }375 376 else {377 // Retrieve the gsdl home directory...378 String directory = LocalGreenstone.getDirectoryPath();379 directory = directory + "perllib" + File.separator + "classify" + File.separator;380 381 String current_lang = Configuration.getLanguage();382 String collection_name = Gatherer.c_man.getCollection().getName();383 File files[] = (new File(directory)).listFiles();384 File coll_files[] = (new File(Gatherer.c_man.getCollectionClassifiersDirectoryPath())).listFiles();385 int num_files =0;386 if (files != null) {387 num_files += files.length;388 }389 if (coll_files != null) {390 num_files += coll_files.length;391 }392 if(num_files > 0) {393 // Create a progress indicator.394 ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.ClassifierManager.Parsing.Title"), Dictionary.get("CDM.ClassifierManager.Parsing.Message"), num_files);395 if (coll_files != null) {396 for (int i=0; i<coll_files.length; i++) {397 398 if(coll_files[i].getName().endsWith(".pm")) {399 loadClassifier(coll_files[i].getName(), current_lang, collection_name);400 }401 progress.inc();402 }403 }404 if (files != null) {405 for(int i = 0; i < files.length; i++) {406 // We only want to check Perl Modules.407 if(files[i].getName().endsWith(".pm")) {408 loadClassifier(files[i].getName(), current_lang, collection_name);409 }410 progress.inc();411 }412 }413 progress.dispose();414 progress.destroy();415 progress = null;416 }417 }418 }419 }420 421 422 423 /** Method to load classifier information from a specified input stream (could be local or through URL). Of course no classifiers may be found at this location.424 * @param input_stream An <strong>InputStream</strong> indicating the where list of classifiers -- encoded in XML -- can be read from425 */426 private void loadClassifiers(StringBuffer xml)427 {428 Document document = XMLTools.parseXML(new StringReader(xml.toString()));429 430 // Parse XML to build up list of classifier names431 Element root = document.getDocumentElement();432 433 String num_classifiers_str = root.getAttribute("length");434 int num_classifiers = Integer.parseInt(num_classifiers_str);435 String class_list[] = new String[num_classifiers];436 437 Node node = root.getFirstChild();438 int i = 0;439 while (node != null) {440 if (node.getNodeName().equalsIgnoreCase("ClassifyName")) {441 class_list[i] = XMLTools.getValue(node);442 i++;443 }444 445 node = node.getNextSibling();446 }447 448 String current_lang = Configuration.getLanguage();449 String collection_name = Gatherer.c_man.getCollection().getName();450 if (num_classifiers>0) {451 // Create a progress indicator.452 ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.ClassifierManager.Parsing.Title"), Dictionary.get("CDM.ClassifierManager.Parsing.Message"), num_classifiers);453 454 for (i=0; i<num_classifiers; i++) {455 String classifier = class_list[i];456 loadClassifier(classifier, current_lang, collection_name);457 progress.inc();458 }459 progress.dispose();460 progress.destroy();461 progress = null;462 }463 }464 465 466 /** Parses a DOM tree model turning it into a Classifier and its associated arguments.467 * @param root The <strong>Node</strong> at the root of the DOM model.468 * @return A newly created <strong>Classifier</strong> based on the information parsed from the DOM model.469 * @see org.greenstone.gatherer.cdm.Argument470 */471 private Classifier parseXML(Node root) {472 Classifier classifier = new Classifier();473 String node_name = null;474 for(Node node = root.getFirstChild(); node != null;475 node = node.getNextSibling()) {476 node_name = node.getNodeName();477 if(node_name.equals("Name")) {478 String name = XMLTools.getValue(node);479 // We can save ourselves some processing time if a classifier with this name already exists in our manager. If so retrieve it and return it.480 Classifier existing = getBaseClassifier(name);481 if(existing != null) {482 return existing;483 }484 classifier.setName(name);485 }486 else if(node_name.equals("Desc")) {487 classifier.setDescription(XMLTools.getValue(node));488 }489 else if(node_name.equals("Abstract")) {490 classifier.setIsAbstract(XMLTools.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));491 }492 // Parse the multitude of arguments.493 else if(node_name.equals("Arguments")) {494 for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) {495 node_name = arg.getNodeName();496 // An option.497 if(node_name.equals("Option")) {498 Argument argument = new Argument();499 argument.parseXML((Element)arg);500 classifier.addArgument(argument);501 }502 }503 }504 // A super classifier class.505 else if(node_name.equals("ClassInfo")) {506 Classifier super_classifier = parseXML(node);507 classifier.setSuper(super_classifier);508 }509 510 }511 if(classifier.getName() != null) {512 addClassifier(classifier);513 return classifier;514 }515 return null;516 }517 427 518 428 /** A class which provides controls for assigned and editing classifiers. */ … … 540 450 * @see org.greenstone.gatherer.cdm.ClassifierManager.ClassifierControl.RemoveListener 541 451 */ 542 public ClassifierControl() {543 Collections.sort(library);452 public ClassifierControl() 453 { 544 454 // Create 545 455 add = new GLIButton(Dictionary.get("CDM.ClassifierManager.Add"), Dictionary.get("CDM.ClassifierManager.Add_Tooltip")); … … 554 464 555 465 ClassifierComboboxListener ccl = new ClassifierComboboxListener(); 556 classifier_combobox = new JComboBox(getAvailable ());466 classifier_combobox = new JComboBox(getAvailableClassifiers()); 557 467 classifier_combobox.setEditable(false); 558 468 if(classifier_combobox.getItemCount() > 0) { … … 674 584 if(selected_object != null) { 675 585 // Retrieve the base classifier 676 Classifier base_classifier = get BaseClassifier(selected_object.toString());586 Classifier base_classifier = getClassifier(selected_object.toString(), true); 677 587 678 588 // Create a new element in the DOM … … 702 612 private class ClassifierComboboxListener 703 613 implements ItemListener { 704 /** When a user selects a certain plugin, update the tooltip to show the plugindescription. */614 /** When a user selects a certain classifier, update the tooltip to show the classifier description. */ 705 615 public void itemStateChanged(ItemEvent event) { 706 616 if(event.getStateChange() == ItemEvent.SELECTED) { 707 // Retrieve the selected plugin617 // Retrieve the selected classifier 708 618 Classifier current_selection = (Classifier) classifier_combobox.getSelectedItem(); 709 619 // And reset the tooltip. -
trunk/gli/src/org/greenstone/gatherer/cdm/Plugin.java
r12247 r12631 33 33 import org.w3c.dom.*; 34 34 35 35 36 /** This class is responsible for storing information from a parsed pluginfo call in such a way that it allows easy access to parsed details for the purposes of user design and specification of plugins. */ 36 37 public class Plugin 37 extends ArgumentContainer { 38 extends ArgumentContainer 39 { 40 private String default_block_expression = ""; 41 private String default_process_expression = ""; 38 42 private boolean does_explode_metadata_databases = false; 43 39 44 40 45 /** Constructor used in DOMProxyListModel initializations, and Library Level. Used for Base plugins (those in the list of available plugins, not ones that are in the DOMProxyList) … … 42 47 public Plugin() { 43 48 } 49 44 50 45 51 public Plugin(Element element, Plugin base_plugin) { 46 52 super(element, base_plugin); 47 53 } 54 48 55 49 56 /** Method to compare two plugins for ordering. … … 56 63 return -1; 57 64 } 65 58 66 59 67 /** The assigned plugin constructor. … … 63 71 String plugin_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE); 64 72 // Determine the base plugin from the plugin name 65 Plugin base_plugin = CollectionDesignManager.plugin_manager.get BasePlugin(plugin_name);73 Plugin base_plugin = CollectionDesignManager.plugin_manager.getPlugin(plugin_name, true); 66 74 Plugin plugin = new Plugin(element, base_plugin); 67 75 if (base_plugin == null) { … … 77 85 public boolean doesExplodeMetadataDatabases() 78 86 { 79 Plugin base_plugin = CollectionDesignManager.plugin_manager.get BasePlugin(getName());87 Plugin base_plugin = CollectionDesignManager.plugin_manager.getPlugin(getName(), false); 80 88 if (base_plugin == null) { 81 89 return false; … … 89 97 { 90 98 // Check the filename against the plugin's block_exp value 91 //ArrayList arguments = getArguments(true, true);92 99 ArrayList arguments = getArguments(); 93 100 for (int i = 0; i < arguments.size(); i++) { … … 104 111 } 105 112 106 // The $ at the end doesn't seem to work in Java, so need to add ".*" at the start 107 if (regular_expression.startsWith("(?i)")) { 108 // Don't mess up case-insensitive matching though 109 regular_expression = "(?i)" + ".*" + regular_expression.substring("(?i)".length()); 110 } 111 else { 112 regular_expression = ".*" + regular_expression; 113 } 114 115 // If the filename matches the regular expression, this plugin will deal with the file in some way 116 if (file.getName().matches(regular_expression)) { 113 if (doesFileMatchRegularExpression(file, regular_expression)) { 117 114 return true; 118 115 } 119 116 } 117 } 118 119 // Try the plugin's default block expression 120 if (!default_block_expression.equals("") && doesFileMatchRegularExpression(file, default_block_expression)) { 121 return true; 120 122 } 121 123 … … 129 131 { 130 132 // Check the filename against the plugin's process_exp value 131 //ArrayList arguments = getArguments(true, true);132 133 ArrayList arguments = getArguments(); 133 134 for (int i = 0; i < arguments.size(); i++) { … … 144 145 } 145 146 146 // The $ at the end doesn't seem to work in Java, so need to add ".*" at the start 147 if (regular_expression.startsWith("(?i)")) { 148 // Don't mess up case-insensitive matching though 149 regular_expression = "(?i)" + ".*" + regular_expression.substring("(?i)".length()); 150 } 151 else { 152 regular_expression = ".*" + regular_expression; 153 } 154 155 // If the filename matches the regular expression, this plugin will deal with the file in some way 156 if (file.getName().matches(regular_expression)) { 147 if (doesFileMatchRegularExpression(file, regular_expression)) { 157 148 return true; 158 149 } 159 150 } 151 } 152 153 // Try the plugin's default process expression 154 if (!default_process_expression.equals("") && doesFileMatchRegularExpression(file, default_process_expression)) { 155 return true; 160 156 } 161 157 … … 164 160 } 165 161 162 163 private boolean doesFileMatchRegularExpression(File file, String regular_expression) 164 { 165 // The $ at the end doesn't seem to work in Java, so need to add ".*" at the start 166 if (regular_expression.startsWith("(?i)")) { 167 // Don't mess up case-insensitive matching though 168 regular_expression = "(?i)" + ".*" + regular_expression.substring("(?i)".length()); 169 } 170 else { 171 regular_expression = ".*" + regular_expression; 172 } 173 174 // If the filename matches the regular expression, this plugin will deal with the file in some way 175 if (file.getName().matches(regular_expression)) { 176 return true; 177 } 178 179 return false; 180 } 181 182 166 183 public boolean isSeparator() { 167 184 return (element != null && element.getAttribute(StaticStrings.SEPARATOR_ATTRIBUTE).equals(StaticStrings.TRUE_STR)); 168 185 } 169 186 170 public void setDoesExplodeMetadataDatabases(boolean does_explode_metadata_databases) { 187 188 public void setDefaultBlockExpression(String default_block_expression) 189 { 190 this.default_block_expression = default_block_expression; 191 } 192 193 194 public void setDefaultProcessExpression(String default_process_expression) 195 { 196 this.default_process_expression = default_process_expression; 197 } 198 199 200 public void setDoesExplodeMetadataDatabases(boolean does_explode_metadata_databases) 201 { 171 202 this.does_explode_metadata_databases = does_explode_metadata_databases; 172 203 } 173 174 204 } -
trunk/gli/src/org/greenstone/gatherer/cdm/PluginManager.java
r12620 r12631 62 62 implements CollectionContentsChangedListener 63 63 { 64 /** The library 'reserve' of base plugins. */ 65 private ArrayList library = null; 64 // A list of all the plugins in the core Greenstone "perllib/plugins" folder (arguments may not be loaded) 65 private ArrayList core_greenstone_plugins_list = null; 66 66 67 /** When asking how many rows are in the model, and if this variables value is true, then this modifier alters the number returned. This funtionality is used to hide the last three rows of the list in low detail modes. */ 67 68 private boolean modify_row_count = false; … … 77 78 DebugStream.println("PluginManager: " + super.getSize() + " plugins parsed."); 78 79 model = this; 79 // Reload/Create the library 80 loadPlugins(); // adds all the plugins to the library81 savePlugins(); 80 81 core_greenstone_plugins_list = loadPluginsList(); 82 82 83 // Create the separator, cause we can reuse it. 83 84 separator = getSeparator(); … … 87 88 } 88 89 89 /** Method to add a new plugin to the library 90 * @param plugin the new base Plugin 91 */ 92 private void addPlugin(Plugin plugin) { 93 if(!library.contains(plugin)) { 94 library.add(plugin); 95 } 96 } 90 91 // -------------------------------------------------------------------------------------------------------- 92 93 94 /** Retrieve a list of the plugins that are available to be added to the collection. */ 95 private Object[] getAvailablePlugins() 96 { 97 ArrayList available = new ArrayList(); 98 99 // Add all the non-abstract core Greenstone plugins, except for ArcPlug and RecPlug 100 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 101 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 102 if (!plugin.isAbstract()) { 103 String plugin_name = plugin.getName(); 104 if (!plugin_name.equals(StaticStrings.ARCPLUG_STR) && !plugin_name.equals(StaticStrings.RECPLUG_STR)) { 105 available.add(plugin); 106 } 107 } 108 } 109 110 // Now remove any assigned plugins 111 if (Configuration.getMode() <= Configuration.SYSTEMS_MODE) { 112 available.removeAll(children()); 113 } 114 115 // Sort the available plugins into alphabetical order 116 Collections.sort(available); 117 118 return available.toArray(); 119 } 120 121 122 public ArrayList getExploderPlugins(File file) 123 { 124 ArrayList exploder_plugins = new ArrayList(); 125 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 126 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 127 if (plugin.doesExplodeMetadataDatabases() == true && plugin.doesProcessFile(file)) { 128 exploder_plugins.add(plugin); 129 } 130 } 131 132 return exploder_plugins; 133 } 134 135 136 public Plugin getPlugin(String plugin_name, boolean arguments_required) 137 { 138 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 139 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 140 if (plugin.getName().equals(plugin_name)) { 141 if (arguments_required) { 142 if (plugin.getArguments().size() == 0) { 143 loadPluginInfo(plugin); 144 } 145 else { 146 System.err.println("Already loaded arguments for " + plugin_name + "!"); 147 } 148 } 149 return plugin; 150 } 151 } 152 153 return null; 154 } 155 156 157 public boolean isFileExplodable(File file) 158 { 159 for (int i = 0; i < core_greenstone_plugins_list.size(); i++) { 160 Plugin plugin = (Plugin) core_greenstone_plugins_list.get(i); 161 if (plugin.doesExplodeMetadataDatabases() == true && plugin.doesProcessFile(file) == true) { 162 return true; 163 } 164 } 165 166 return false; 167 } 168 169 170 private void loadPluginInfo(Plugin plugin) 171 { 172 System.err.println("Loading arguments for " + plugin.getName() + "..."); 173 174 // Run pluginfo.pl to get the list of plugins 175 try { 176 StringBuffer xml = null; 177 if (Gatherer.isGsdlRemote) { 178 // !! TO DO 179 } 180 else { 181 ArrayList args = new ArrayList(); 182 if (Utility.isWindows()) { 183 args.add(Configuration.perl_path); 184 args.add("-S"); 185 } 186 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl"); 187 args.add("-xml"); 188 args.add("-language"); 189 args.add(Configuration.getLanguage()); 190 args.add(plugin.getName()); 191 192 // Run the pluginfo.pl process 193 Runtime runtime = Runtime.getRuntime(); 194 Process process = runtime.exec((String[]) args.toArray(new String[] { })); 195 InputStream input_stream = process.getErrorStream(); 196 xml = XMLTools.readXMLStream(input_stream); 197 } 198 199 if (xml.length() > 0) { 200 parsePluginInfoXML(plugin, xml.toString()); 201 } 202 else { 203 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", plugin.getName()), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 204 } 205 } 206 catch (Exception exception) { 207 DebugStream.printStackTrace(exception); 208 } 209 } 210 211 212 private ArrayList loadPluginsList() 213 { 214 System.err.println("In loadPluginsList()..."); 215 216 // Run pluginfo.pl to get the list of plugins 217 try { 218 StringBuffer xml = null; 219 if (Gatherer.isGsdlRemote) { 220 // !! TO DO 221 } 222 else { 223 ArrayList args = new ArrayList(); 224 if (Utility.isWindows()) { 225 args.add(Configuration.perl_path); 226 args.add("-S"); 227 } 228 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl"); 229 args.add("-listall"); 230 args.add("-xml"); 231 232 // Run the pluginfo.pl process 233 Runtime runtime = Runtime.getRuntime(); 234 Process process = runtime.exec((String[]) args.toArray(new String[] { })); 235 InputStream input_stream = process.getErrorStream(); 236 xml = XMLTools.readXMLStream(input_stream); 237 } 238 239 if (xml.length() > 0) { 240 return parsePluginsListXML(xml.toString()); 241 } 242 else { 243 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PluginManager.Plugin_List_XML_Parse_Failed"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 244 } 245 } 246 catch (Exception exception) { 247 DebugStream.println("Failed when trying to list plugins."); 248 DebugStream.printStackTrace(exception); 249 } 250 251 return null; 252 } 253 254 255 private void parsePluginInfoXML(Plugin plugin, String xml) 256 { 257 Document document = XMLTools.parseXML(new StringReader(xml)); 258 parsePluginInfoXMLNode(plugin, document.getDocumentElement()); 259 } 260 261 262 private void parsePluginInfoXMLNode(Plugin plugin, Node root_node) 263 { 264 for (Node node = root_node.getFirstChild(); node != null; node = node.getNextSibling()) { 265 String node_name = node.getNodeName(); 266 267 if (node_name.equalsIgnoreCase("Name")) { 268 plugin.setName(XMLTools.getValue(node)); 269 } 270 else if (node_name.equals("Desc")) { 271 plugin.setDescription(XMLTools.getValue(node)); 272 } 273 else if (node_name.equals("Abstract")) { 274 plugin.setIsAbstract(XMLTools.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR)); 275 } 276 else if (node_name.equalsIgnoreCase("Explodes")) { 277 plugin.setDoesExplodeMetadataDatabases(XMLTools.getValue(node).equalsIgnoreCase(StaticStrings.YES_STR)); 278 } 279 else if (node_name.equalsIgnoreCase("Processes")) { 280 plugin.setDefaultProcessExpression(XMLTools.getValue(node)); 281 } 282 else if (node_name.equalsIgnoreCase("Blocks")) { 283 plugin.setDefaultBlockExpression(XMLTools.getValue(node)); 284 } 285 // Parse the plugin arguments 286 else if (node_name.equalsIgnoreCase("Arguments")) { 287 for (Node argument_node = node.getFirstChild(); argument_node != null; argument_node = argument_node.getNextSibling()) { 288 // An option 289 if (argument_node.getNodeName().equalsIgnoreCase("Option")) { 290 Argument argument = new Argument(); 291 argument.parseXML((Element) argument_node); 292 plugin.addArgument(argument); 293 } 294 } 295 } 296 // A super plugin class 297 else if (node_name.equalsIgnoreCase("PlugInfo")) { 298 Plugin super_plugin = new Plugin(); 299 parsePluginInfoXMLNode(super_plugin, node); 300 plugin.setSuper(super_plugin); 301 } 302 } 303 } 304 305 306 private ArrayList parsePluginsListXML(String xml) 307 { 308 ArrayList plugins_list = new ArrayList(); 309 310 Document document = XMLTools.parseXML(new StringReader(xml)); 311 Node root = document.getDocumentElement(); 312 for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) { 313 String node_name = node.getNodeName(); 314 315 if (node_name.equals("PlugInfo")) { 316 Plugin plugin = new Plugin(); 317 parsePluginInfoXMLNode(plugin, node); 318 plugins_list.add(plugin); 319 } 320 } 321 322 return plugins_list; 323 } 324 325 326 // -------------------------------------------------------------------------------------------------------- 327 97 328 98 329 /** Method to assign a plugin … … 128 359 controls = null; 129 360 } 130 131 library.clear();132 library = null;133 361 } 134 362 … … 149 377 // Next try the plugins NOT already assigned in the collection 150 378 ArrayList suitable_plugins = new ArrayList(); 151 Object[] unassigned_plugins = getAvailable ();379 Object[] unassigned_plugins = getAvailablePlugins(); 152 380 for (int i = 0; i < unassigned_plugins.length; i++) { 153 381 Plugin unassigned_plugin = (Plugin) unassigned_plugins[i]; … … 173 401 174 402 175 public boolean isFileExplodable(File file)176 {177 178 for (int i = 0; i < library.size(); i++) {179 Plugin plugin = (Plugin) library.get(i);180 if (plugin.doesExplodeMetadataDatabases() == true && plugin.doesProcessFile(file) == true) {181 return true;182 }183 }184 185 return false;186 }187 188 public ArrayList getExploderPlugins(File file)189 {190 ArrayList exp_plugins = new ArrayList();191 for (int i = 0; i < library.size(); i++) {192 Plugin plugin = (Plugin) library.get(i);193 if (plugin.doesProcessFile(file) == true && plugin.doesExplodeMetadataDatabases() == true) {194 exp_plugins.add(plugin);195 }196 }197 return exp_plugins;198 }199 200 403 /** Method to retrieve the control for this manager. 201 404 * @return the Control … … 209 412 } 210 413 211 /** Retrieve the base plugin of the given name, or null if no such plugin.212 * @param name the name of the base plugin to retrieve as a String213 * @return the Plugin requested or null if no such plugin214 */215 public Plugin getBasePlugin(String name) {216 int library_size = library.size();217 for(int i = 0; i < library_size; i++) {218 Plugin plugin = (Plugin) library.get(i);219 if(plugin.getName().equals(name)) {220 return plugin;221 }222 }223 // No success.224 return null;225 }226 414 227 415 /** Overrides getSize in DOMProxyListModel to take into account the row count modifier used to hide the last three rows in lower detail modes … … 359 547 } 360 548 361 /** Method to cache the current contents of library (known plugins) to file.362 */363 private void savePlugins() {364 try {365 File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");366 FileOutputStream file = new FileOutputStream(plugins_dat_file);367 ObjectOutputStream out = new ObjectOutputStream(file);368 out.writeObject(library);369 out.close();370 }371 catch (Exception error) {372 DebugStream.printStackTrace(error);373 }374 }375 549 376 550 /** Inform the model to hide/show the last three lines on the list. … … 401 575 } 402 576 403 404 /** Retrieve a list of those plugins that are in library but not in the assigned plugins. */405 private Object[] getAvailable() {406 ArrayList available = new ArrayList();407 int library_size = library.size();408 for(int i = 0; i < library_size; i++) {409 Plugin plugin = (Plugin) library.get(i);410 String plugin_name = plugin.getName();411 if(!plugin.isAbstract() && !plugin_name.equals(StaticStrings.ARCPLUG_STR) && !plugin_name.equals(StaticStrings.RECPLUG_STR)) {412 available.add(plugin);413 }414 plugin = null;415 }416 // Now go through the assigned plugins, and remove any that match.417 // only for < lib sys specialist mode418 if (Configuration.getMode()<=Configuration.SYSTEMS_MODE) {419 available.removeAll(children());420 }421 //DebugStream.println("There are a total of " + library.size() + " plugins in the library.");422 //DebugStream.println("However " + children().size() + " are in use,");423 //DebugStream.println("So only " + available.size() + " remain.");424 Collections.sort(available);425 return available.toArray();426 }427 428 /** Method to extract just the plugins name from a file object.429 * @param plugin The <strong>File</strong> which references a certain plugin.430 * @return A <strong>String</strong> containing just the plugins name, without extension.431 */432 private String getPluginName(String filename) {433 String name = filename;434 if(name.indexOf(".") != -1) {435 name = name.substring(0, name.indexOf("."));436 }437 return name;438 }439 440 441 /** Method to load the details of a single plug-in.442 * @param plugin The plugin <strong>File</strong> you wish to load.443 */444 private void loadPlugin(String plugin, String lang, String collection_name) {445 Document document = null;446 InputStream input_stream = null;447 448 // Run pluginfo on this plugin, and then send the results for parsing.449 try {450 StringBuffer xml = null;451 if (Gatherer.isGsdlRemote) {452 String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", "&plugin=" + plugin);453 xml = new StringBuffer(pluginfo_output);454 }455 else {456 ArrayList args = new ArrayList();457 if (Utility.isWindows()) {458 args.add(Configuration.perl_path);459 args.add("-S");460 }461 args.add(LocalGreenstone.getBinScriptDirectoryPath() + "pluginfo.pl");462 args.add("-xml");463 args.add("-language");464 args.add(lang);465 args.add("-collect");466 args.add(collection_name);467 args.add(getPluginName(plugin));468 469 // Create the process.470 Runtime runtime = Runtime.getRuntime();471 Process process = runtime.exec((String[])args.toArray(new String [0]));472 input_stream = process.getErrorStream();473 xml = XMLTools.readXMLStream(input_stream);474 }475 476 if (xml.length() > 0) {477 document = XMLTools.parseXML(new StringReader(xml.toString()));478 }479 else {480 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.PlugInManager.PlugIn_XML_Parse_Failed", plugin), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);481 }482 }483 catch (Exception exception) {484 DebugStream.println("Failed when trying to parse: " + plugin);485 DebugStream.printStackTrace(exception);486 }487 488 if (document != null) {489 parseXML(document.getDocumentElement());490 }491 }492 493 /** Method to initially load information from the standard plug-ins within the gsdl Perl library.494 */495 private void loadPlugins() {496 // Attempt to restore the cached file.497 File plugins_dat_file = new File(Gatherer.getGLIUserDirectoryPath() + "plugins.dat");498 try {499 FileInputStream file = new FileInputStream(plugins_dat_file);500 ObjectInputStream input = new ObjectInputStream(file);501 library = (ArrayList) input.readObject();502 }503 catch (Exception error) {504 DebugStream.println("Unable to open " + plugins_dat_file);505 }506 507 if(library == null) {508 library = new ArrayList();509 510 if (Gatherer.isGsdlRemote) {511 String pluginfo_output = RemoteGreenstoneServer.getScriptOptions("pluginfo.pl", "&listall=");512 loadPlugins(new StringBuffer(pluginfo_output));513 }514 515 else {516 // Retrieve the gsdl home directory...517 String directory = LocalGreenstone.getDirectoryPath();518 directory = directory + "perllib" + File.separator + "plugins" + File.separator;519 String current_lang = Configuration.getLanguage();520 String collection_name = Gatherer.c_man.getCollection().getName();521 522 boolean is_windows = Utility.isWindows();523 boolean is_mac = Utility.isMac();524 525 File files[] = (new File(directory)).listFiles();526 File coll_files[] = (new File(Gatherer.c_man.getCollectionPluginsDirectoryPath())).listFiles();527 int num_files = 0;528 if (files != null) {529 num_files += files.length;530 }531 if (coll_files != null) {532 num_files += coll_files.length;533 }534 if(num_files > 0) {535 536 // Create a progress indicator.537 ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.PlugInManager.Parsing.Title"), Dictionary.get("CDM.PlugInManager.Parsing.Message"), num_files);538 if (coll_files != null) {539 for (int i=0; i<coll_files.length; i++) {540 if(coll_files[i].getName().endsWith(".pm")) {541 loadPlugin(coll_files[i].getName(), current_lang, collection_name);542 }543 progress.inc();544 }545 }546 547 if (files != null) {548 for(int i = 0; i < files.length; i++) {549 // We only want to check Perl Modules.550 if(files[i].getName().endsWith(".pm")) {551 if (files[i].getName().equals("GMLPlug.pm") || ((is_windows || is_mac) && files[i].getName().equals("DBPlug.pm"))) {552 // don't load GMLPlug or DBPlug for windows553 } else {554 loadPlugin(files[i].getName(), current_lang, collection_name);555 }556 }557 progress.inc();558 }559 }560 progress.dispose();561 progress.destroy();562 progress = null;563 }564 }565 }566 }567 568 569 /** Method to load plug-in information from a specified input stream (could be local or through URL). Of course no plug-ins may be found at this location.570 * @param input_stream An <strong>InputStream</strong> indicating the where list of plugins -- encoded in XML -- can be read from571 */572 private void loadPlugins(StringBuffer xml)573 {574 Document document = XMLTools.parseXML(new StringReader(xml.toString()));575 576 // Parse XML to build up list of plugin names577 Node root = document.getDocumentElement();578 579 NamedNodeMap attributes = root.getAttributes();580 Node length_node = attributes.getNamedItem("length");581 String num_plugins_str = length_node.getNodeValue();582 int num_plugins = Integer.parseInt(num_plugins_str);583 String plugin_list[] = new String[num_plugins];584 585 Node node = root.getFirstChild();586 int i = 0;587 while (node != null) {588 String node_name = node.getNodeName();589 if (node_name.equalsIgnoreCase("PluginName")) {590 String name = XMLTools.getValue(node);591 plugin_list[i] = name;592 i++;593 }594 595 node = node.getNextSibling();596 }597 598 599 boolean is_windows = Utility.isWindows();600 boolean is_mac = Utility.isMac();601 602 String current_lang = Configuration.getLanguage();603 String collection_name = Gatherer.c_man.getCollection().getName();604 if (num_plugins>0) {605 // Create a progress indicator.606 ParsingProgress progress = new ParsingProgress(Dictionary.get("CDM.PlugInManager.Parsing.Title"), Dictionary.get("CDM.PlugInManager.Parsing.Message"), num_plugins);607 608 for (i=0; i<num_plugins; i++) {609 String plugin = plugin_list[i];610 if (plugin.equals("GMLPlug.pm") || ((is_windows || is_mac) && plugin.equals("DBPlug.pm"))) {611 // don't load GMLPlug or DBPlug for windows612 } else {613 loadPlugin(plugin, current_lang, collection_name);614 }615 616 progress.inc();617 }618 progress.dispose();619 progress.destroy();620 progress = null;621 }622 }623 624 625 private Plugin parseXML(Node root) {626 Plugin plugin = new Plugin();627 String node_name = null;628 for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) {629 node_name = node.getNodeName();630 if(node_name.equalsIgnoreCase("Name")) {631 String name = XMLTools.getValue(node);632 // We can save ourselves some processing time if a plugin with this name already exists in our manager. If so retrieve it and return it.633 Plugin existing = getBasePlugin(name);634 if(existing != null) {635 return existing;636 }637 plugin.setName(name);638 }639 else if (node_name.equalsIgnoreCase("Desc")) {640 plugin.setDescription(XMLTools.getValue(node));641 }642 else if (node_name.equalsIgnoreCase("Abstract")) {643 plugin.setIsAbstract(XMLTools.getValue(node).equalsIgnoreCase(StaticStrings.YES_STR));644 }645 else if (node_name.equalsIgnoreCase("Explodes")) {646 plugin.setDoesExplodeMetadataDatabases(XMLTools.getValue(node).equalsIgnoreCase(StaticStrings.YES_STR));647 //System.err.println("Plugin " + plugin.getName() + " explodes metadata databases: " + plugin.doesExplodeMetadataDatabases());648 }649 // Parse the multitude of arguments650 else if(node_name.equalsIgnoreCase("Arguments")) {651 for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) {652 node_name = arg.getNodeName();653 // An option.654 if(node_name.equalsIgnoreCase("Option")) {655 Argument argument = new Argument();656 argument.parseXML((Element)arg);657 plugin.addArgument(argument);658 }659 }660 }661 // A super plugin class.662 else if(node_name.equalsIgnoreCase("PlugInfo")) {663 Plugin super_plugin = parseXML(node);664 plugin.setSuper(super_plugin);665 }666 667 }668 if(plugin.getName() != null) {669 addPlugin(plugin);670 return plugin;671 }672 return null;673 }674 577 675 578 /** A class which provodes controls for assigned and editing plugins. */ … … 708 611 /** Constructor. 709 612 */ 710 public PluginControl() { 613 public PluginControl() 614 { 711 615 // Create 712 616 add = new GLIButton(Dictionary.get("CDM.PlugInManager.Add"), Dictionary.get("CDM.PlugInManager.Add_Tooltip")); … … 728 632 729 633 PluginComboboxListener picl = new PluginComboboxListener(); 730 plugin_combobox = new JComboBox(getAvailable ());634 plugin_combobox = new JComboBox(getAvailablePlugins()); 731 635 plugin_combobox.setEditable(false); 732 636 picl.itemStateChanged(new ItemEvent(plugin_combobox, 0, null, ItemEvent.SELECTED)); … … 849 753 if(selected_object != null) { 850 754 // Retrieve the base plugin 851 Plugin base_plugin = get BasePlugin(selected_object.toString());755 Plugin base_plugin = getPlugin(selected_object.toString(), true); 852 756 if (base_plugin == null) { 853 757 // shouldn't happen … … 1114 1018 } 1115 1019 // Refresh the available plugins 1116 plugin_combobox.setModel(new DefaultComboBoxModel(getAvailable ()));1020 plugin_combobox.setModel(new DefaultComboBoxModel(getAvailablePlugins())); 1117 1021 } 1118 1022 else { … … 1199 1103 // add the selected plugin to the list 1200 1104 Object selected_object = suitable_plugins_combobox.getSelectedItem(); 1201 Plugin base_plugin = get BasePlugin(selected_object.toString());1105 Plugin base_plugin = getPlugin(selected_object.toString(), true); 1202 1106 if (base_plugin == null) { 1203 1107 // shouldn't happen - we are not allowed custom plugins anymore
Note:
See TracChangeset
for help on using the changeset viewer.