Changeset 5863
- Timestamp:
- 2003-11-18T08:35:01+13:00 (20 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
r5785 r5863 310 310 } 311 311 312 /** Set the custom arguments. This turns out to be quite tricky. We must parse in the string, searching for arguments (for that we use a handy method in CollectionConfiguration). Next, for each argument, we check if we already know about it. If so we update its value, otherwise we create a new argument and assign it (must assign!). 312 /** Set the custom arguments. This turns out to be quite tricky. We must parse in the string, searching for arguments (for that we use a handy method in CollectionConfiguration). Next, for each argument, we check if we already know about it. If so we update its value, otherwise we create a new argument and assign it (must assign!). 313 313 * @param custom_str the custom arguments all splodged together in one String 314 314 */ … … 359 359 } 360 360 361 /** Method to set the value of desc. 361 /** Method to set the value of desc. 362 362 * @param desc The new value of desc as a <strong>String</strong>. 363 363 */ 364 public void setDescription(String desc ) {364 public void setDescription(String description) { 365 365 this.description = description; 366 366 } … … 374 374 } 375 375 376 /** Method to set the value of name. 376 /** Method to set the value of name. 377 377 * @param name The new value of name as a <strong>String</strong>. 378 378 */ … … 382 382 383 383 /** Method to set the value of the super_classifier. 384 * @param super_classifier The new value of super_classifier as a <strong>Classifier</strong>, or <i>null</i> if this class has no inheritance. 384 * @param super_classifier The new value of super_classifier as a <strong>Classifier</strong>, or <i>null</i> if this class has no inheritance. 385 385 */ 386 386 public void setSuper(Classifier super_classifier) { -
trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java
r5593 r5863 108 108 if(!contains(classifier)) { 109 109 Element element = classifier.getElement(); 110 // Locate where we should insert this new classifier. 110 // Locate where we should insert this new classifier. 111 111 Node target_node = CollectionConfiguration.findInsertionPoint(element); 112 112 add(root, classifier, target_node); … … 151 151 return null; 152 152 } 153 153 154 154 /** Method to retrieve the control for this manager. 155 155 * @return the Control for editing classifiers … … 207 207 remove(classifier); 208 208 add(index, classifier); 209 Gatherer.c_man.configurationChanged(); 209 Gatherer.c_man.configurationChanged(); 210 210 } 211 211 else { … … 482 482 /** A class which provides controls for assigned and editing classifiers. */ 483 483 private class ClassifierControl 484 extends JPanel 484 extends JPanel 485 485 implements Control { 486 486 /** A combobox containing all of the known classifiers, including those that may have already been assigned. */ … … 530 530 Dictionary.registerText(instructions, "CDM.ClassifierManager.Instructions"); 531 531 532 ClassifierComboboxListener ccl = new ClassifierComboboxListener(); 532 533 classifier = new GComboBox(getAvailable()); 533 534 classifier.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false)); … … 537 538 classifier.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false)); 538 539 classifier.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false)); 539 Dictionary.registerTooltip(classifier, "CDM.ClassifierManager.Classifier_Tooltip");540 ccl.itemStateChanged(new ItemEvent(classifier, 0, null, ItemEvent.SELECTED)); 540 541 541 542 JLabel classifier_label = new JLabel(); … … 589 590 // Listeners 590 591 add.addActionListener(new AddListener()); 592 classifier.addItemListener(ccl); 591 593 configure.addActionListener(new ConfigureListener()); 592 594 remove.addActionListener(new RemoveListener()); 593 595 classifier_list.addMouseListener(new ClickListener()); 594 596 classifier_list.addListSelectionListener(new ListListener()); 597 ccl = null; 595 598 596 599 MoveListener ml = new MoveListener(); … … 720 723 } 721 724 } 725 726 /** This listener reacts to changes in the current selection of the classifier combobox. */ 727 private class ClassifierComboboxListener 728 implements ItemListener { 729 /** When a user selects a certain plugin, update the tooltip to show the plugin description. */ 730 public void itemStateChanged(ItemEvent event) { 731 if(event.getStateChange() == ItemEvent.SELECTED) { 732 // Retrieve the selected plugin 733 Object current_selection = classifier.getSelectedItem(); 734 // And reset the tooltip. If the plugin is null or is a string, then go back to the default message 735 if(current_selection == null || current_selection instanceof String) { 736 Dictionary.registerTooltip(classifier, "CDM.ClassifierManager.Classifier_Tooltip"); 737 } 738 else { 739 Classifier current_classifier = (Classifier) current_selection; 740 Dictionary.registerTooltip(classifier, Utility.formatHTMLWidth(current_classifier.getDescription(), 40), false); 741 current_classifier = null; 742 } 743 current_selection = null; 744 } 745 } 746 } 722 747 723 748 /** Listens for double clicks apon the list and react as if the configure button was pushed. */ … … 759 784 } 760 785 ac.destroy(); 761 ac = null; 786 ac = null; 762 787 } 763 788 } … … 769 794 770 795 public void valueChanged(ListSelectionEvent e) { 771 if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one) 796 if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one) 772 797 if (classifier_list.isSelectionEmpty()) { 773 798 move_top_button.setEnabled(false); -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugIn.java
r5590 r5863 37 37 38 38 /** 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. */ 39 public class PlugIn 39 public class PlugIn 40 40 extends ArrayList 41 41 implements ArgumentContainer, Comparable, DOMProxyListEntry, Serializable { … … 111 111 } 112 112 113 /** Method to add an argument to this base plugin. Only adds the argument if it isn't already present, and only if this is a base plugin (ie not based on DOM). 113 /** Method to add an argument to this base plugin. Only adds the argument if it isn't already present, and only if this is a base plugin (ie not based on DOM). 114 114 * @param argument the Argument to add 115 115 */ … … 265 265 } 266 266 267 /** Set the custom arguments. This turns out to be quite tricky. We must parse in the string, searching for arguments (for that we use a handy method in CollectionConfiguration). Next, for each argument, we check if we already know about it. If so we update its value, otherwise we create a new argument and assign it (must assign!). 267 /** Set the custom arguments. This turns out to be quite tricky. We must parse in the string, searching for arguments (for that we use a handy method in CollectionConfiguration). Next, for each argument, we check if we already know about it. If so we update its value, otherwise we create a new argument and assign it (must assign!). 268 268 * @param custom_str the custom arguments all splodged together in one String 269 269 */ … … 314 314 } 315 315 316 /** Method to set the value of desc. 316 /** Method to set the value of desc. 317 317 * @param desc The new value of desc as a <strong>String</strong>. 318 318 */ 319 public void setDescription(String desc ) {319 public void setDescription(String description) { 320 320 this.description = description; 321 321 } … … 329 329 } 330 330 331 /** Method to set the value of name. 331 /** Method to set the value of name. 332 332 * @param name The new value of name as a <strong>String</strong>. 333 333 */ … … 337 337 338 338 /** Method to set the value of the super_plugin. 339 * @param super_plugin The new value of super_plugin as a <strong>PlugIn</strong>, or <i>null</i> if this class has no inheritance. 339 * @param super_plugin The new value of super_plugin as a <strong>PlugIn</strong>, or <i>null</i> if this class has no inheritance. 340 340 */ 341 341 public void setSuper(PlugIn super_plugin) { … … 371 371 return name; 372 372 } 373 } 373 } 374 374 } -
trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
r5804 r5863 380 380 } 381 381 catch (Exception error) { 382 System.err.println("Failed when trying to parse: " + plugin.getName()); 382 383 error.printStackTrace(); 383 384 } … … 431 432 node = node.getNextSibling()) { 432 433 node_name = node.getNodeName(); 433 if(node_name.equals ("Name")) {434 if(node_name.equalsIgnoreCase("Name")) { 434 435 String name = MSMUtils.getValue(node); 435 436 // 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. … … 440 441 plugin.setName(name); 441 442 } 442 else if(node_name.equals ("Desc")) {443 else if(node_name.equalsIgnoreCase("Desc")) { 443 444 plugin.setDescription(MSMUtils.getValue(node)); 444 445 } 445 else if(node_name.equals(CollectionConfiguration.ABSTRACT_ELEMENT)) { 446 else if(node_name.equalsIgnoreCase(CollectionConfiguration.ABSTRACT_ELEMENT)) { 447 System.err.println("Is " + plugin.getName() + " abstract? " + MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR)); 446 448 plugin.setIsAbstract(MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR)); 447 449 } 448 450 // Parse the multitude of arguments. 449 else if(node_name.equals ("Arguments")) {451 else if(node_name.equalsIgnoreCase("Arguments")) { 450 452 for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) { 451 453 node_name = arg.getNodeName(); 452 454 // An option. 453 if(node_name.equals ("Option")) {455 if(node_name.equalsIgnoreCase("Option")) { 454 456 Argument argument = new Argument(); 455 457 // If its an option we parse the multitude of details an options might have. 456 458 for(Node det = arg.getFirstChild(); det != null; det = det.getNextSibling()) { 457 459 node_name = det.getNodeName(); 458 if(node_name.equals ("Name")) {460 if(node_name.equalsIgnoreCase("Name")) { 459 461 argument.setName(MSMUtils.getValue(det)); 460 462 } 461 else if(node_name.equals ("Desc")) {463 else if(node_name.equalsIgnoreCase("Desc")) { 462 464 argument.setDescription(MSMUtils.getValue(det)); 463 465 } 464 else if(node_name.equals ("Type")) {466 else if(node_name.equalsIgnoreCase("Type")) { 465 467 argument.setType(MSMUtils.getValue(det)); 466 468 } 467 else if(node_name.equals ("Default")) {469 else if(node_name.equalsIgnoreCase("Default")) { 468 470 argument.setDefaultValue(MSMUtils.getValue(det)); 469 471 } 470 else if(node_name.equals ("List")) {472 else if(node_name.equalsIgnoreCase("List")) { 471 473 // Two final loops are required to parse lists. 472 474 for(Node value = det.getFirstChild(); value != null; value = value.getNextSibling()) { 473 if(value.getNodeName().equals ("Value")) {475 if(value.getNodeName().equalsIgnoreCase("Value")) { 474 476 String key = null; 475 477 String desc = ""; 476 478 for(Node subvalue = value.getFirstChild(); subvalue != null; subvalue = subvalue.getNextSibling()) { 477 479 node_name = subvalue.getNodeName(); 478 if(node_name.equals ("Name")) {480 if(node_name.equalsIgnoreCase("Name")) { 479 481 key = MSMUtils.getValue(subvalue); 480 482 } 481 else if(node_name.equals ("Desc")) {483 else if(node_name.equalsIgnoreCase("Desc")) { 482 484 desc = MSMUtils.getValue(subvalue); 483 485 } … … 489 491 } 490 492 } 491 else if(node_name.equals ("Required")) {493 else if(node_name.equalsIgnoreCase("Required")) { 492 494 String v = MSMUtils.getValue(det); 493 if(v != null && v.equals ("yes")) {495 if(v != null && v.equalsIgnoreCase("yes")) { 494 496 argument.setRequired(true); 495 497 } … … 499 501 } 500 502 // A super plugin class. 501 else if(node_name.equals ("PlugInfo")) {503 else if(node_name.equalsIgnoreCase("PlugInfo")) { 502 504 PlugIn super_plugin = parseXML(arg); 503 505 plugin.setSuper(super_plugin); … … 609 611 movement_pane = new JPanel(); 610 612 613 PlugInComboboxListener picl = new PlugInComboboxListener(); 611 614 plugin = new GComboBox(getAvailable()); 612 615 plugin.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false)); 613 616 plugin.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false)); 614 617 plugin.setEditable(true); 615 plugin.setSelectedIndex(0);616 618 plugin.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false)); 617 619 plugin.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false)); 618 Dictionary.registerTooltip(plugin, "CDM.PlugInManager.PlugIn_Tooltip");620 picl.itemStateChanged(new ItemEvent(plugin, 0, null, ItemEvent.SELECTED)); 619 621 620 622 plugin_label = new JLabel(); … … 650 652 move_top_button.addActionListener(ml); 651 653 move_up_button.addActionListener(ml); 654 plugin.addItemListener(picl); 652 655 remove.addActionListener(new RemoveListener()); 653 656 plugin_list.addMouseListener(new ClickListener()); 654 657 plugin_list.addListSelectionListener(new ListListener()); 658 picl = null; 655 659 656 660 // Layout … … 936 940 } 937 941 } 942 943 /** This listener reacts to changes in the current selection of the plugin combobox. */ 944 private class PlugInComboboxListener 945 implements ItemListener { 946 /** When a user selects a certain plugin, update the tooltip to show the plugin description. */ 947 public void itemStateChanged(ItemEvent event) { 948 if(event.getStateChange() == ItemEvent.SELECTED) { 949 // Retrieve the selected plugin 950 Object current_selection = plugin.getSelectedItem(); 951 // And reset the tooltip. If the plugin is null or is a string, then go back to the default message 952 if(current_selection == null || current_selection instanceof String) { 953 Dictionary.registerTooltip(plugin, "CDM.PlugInManager.PlugIn_Tooltip"); 954 } 955 else { 956 PlugIn current_plugin = (PlugIn) current_selection; 957 Dictionary.registerTooltip(plugin, Utility.formatHTMLWidth(current_plugin.getDescription(), 40), false); 958 current_plugin = null; 959 } 960 current_selection = null; 961 } 962 } 963 } 964 938 965 /** This class listens for actions upon the remove button in the controls, and if detected calls the <i>removePlugIn()</i> method. 939 966 */
Note:
See TracChangeset
for help on using the changeset viewer.