Changeset 5863


Ignore:
Timestamp:
2003-11-18T08:35:01+13:00 (20 years ago)
Author:
jmt12
Message:

The lists for selecting PlugIns and Classifiers now show the description of the aforementioned items if you hover over the combobox. If no description is a available it defaults to the appropriate message from the dictionary.

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  
    310310    }
    311311
    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!).
    313313     * @param custom_str the custom arguments all splodged together in one String
    314314     */
     
    359359    }
    360360
    361     /** Method to set the value of desc. 
     361    /** Method to set the value of desc.
    362362     * @param desc The new value of desc as a <strong>String</strong>.
    363363     */
    364     public void setDescription(String desc) {
     364    public void setDescription(String description) {
    365365    this.description = description;
    366366    }
     
    374374    }
    375375
    376     /** Method to set the value of name. 
     376    /** Method to set the value of name.
    377377     * @param name The new value of name as a <strong>String</strong>.
    378378     */
     
    382382
    383383    /** 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.
    385385     */
    386386    public void setSuper(Classifier super_classifier) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r5593 r5863  
    108108    if(!contains(classifier)) {
    109109        Element element = classifier.getElement();
    110         // Locate where we should insert this new classifier. 
     110        // Locate where we should insert this new classifier.
    111111        Node target_node = CollectionConfiguration.findInsertionPoint(element);
    112112        add(root, classifier, target_node);
     
    151151    return null;
    152152    }
    153    
     153
    154154    /** Method to retrieve the control for this manager.
    155155     * @return the Control for editing classifiers
     
    207207        remove(classifier);
    208208        add(index, classifier);
    209         Gatherer.c_man.configurationChanged(); 
     209        Gatherer.c_man.configurationChanged();
    210210        }
    211211        else {
     
    482482    /** A class which provides controls for assigned and editing classifiers. */
    483483    private class ClassifierControl
    484     extends JPanel 
     484    extends JPanel
    485485    implements Control {
    486486    /** A combobox containing all of the known classifiers, including those that may have already been assigned. */
     
    530530        Dictionary.registerText(instructions, "CDM.ClassifierManager.Instructions");
    531531
     532        ClassifierComboboxListener ccl = new ClassifierComboboxListener();
    532533        classifier = new GComboBox(getAvailable());
    533534        classifier.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false));
     
    537538        classifier.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false));
    538539        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));
    540541
    541542        JLabel classifier_label = new JLabel();
     
    589590        // Listeners
    590591        add.addActionListener(new AddListener());
     592        classifier.addItemListener(ccl);
    591593        configure.addActionListener(new ConfigureListener());
    592594        remove.addActionListener(new RemoveListener());
    593595        classifier_list.addMouseListener(new ClickListener());
    594596        classifier_list.addListSelectionListener(new ListListener());
     597        ccl = null;
    595598
    596599        MoveListener ml = new MoveListener();
     
    720723        }
    721724    }
     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    }
    722747
    723748    /** Listens for double clicks apon the list and react as if the configure button was pushed. */
     
    759784           }
    760785           ac.destroy();
    761            ac = null; 
     786           ac = null;
    762787        }
    763788        }
     
    769794
    770795        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)
    772797            if (classifier_list.isSelectionEmpty()) {
    773798            move_top_button.setEnabled(false);
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugIn.java

    r5590 r5863  
    3737
    3838/** 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 
     39public class PlugIn
    4040    extends ArrayList
    4141    implements ArgumentContainer, Comparable, DOMProxyListEntry, Serializable {
     
    111111    }
    112112
    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).
    114114     * @param argument the Argument to add
    115115     */
     
    265265    }
    266266
    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!).
    268268     * @param custom_str the custom arguments all splodged together in one String
    269269     */
     
    314314    }
    315315
    316     /** Method to set the value of desc. 
     316    /** Method to set the value of desc.
    317317     * @param desc The new value of desc as a <strong>String</strong>.
    318318     */
    319     public void setDescription(String desc) {
     319    public void setDescription(String description) {
    320320    this.description = description;
    321321    }
     
    329329    }
    330330
    331     /** Method to set the value of name. 
     331    /** Method to set the value of name.
    332332     * @param name The new value of name as a <strong>String</strong>.
    333333     */
     
    337337
    338338    /** 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.
    340340     */
    341341    public void setSuper(PlugIn super_plugin) {
     
    371371        return name;
    372372    }
    373     }         
     373    }
    374374}
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r5804 r5863  
    380380    }
    381381    catch (Exception error) {
     382        System.err.println("Failed when trying to parse: " + plugin.getName());
    382383        error.printStackTrace();
    383384    }
     
    431432        node = node.getNextSibling()) {
    432433        node_name = node.getNodeName();
    433         if(node_name.equals("Name")) {
     434        if(node_name.equalsIgnoreCase("Name")) {
    434435        String name = MSMUtils.getValue(node);
    435436        // 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.
     
    440441        plugin.setName(name);
    441442        }
    442         else if(node_name.equals("Desc")) {
     443        else if(node_name.equalsIgnoreCase("Desc")) {
    443444        plugin.setDescription(MSMUtils.getValue(node));
    444445        }
    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));
    446448        plugin.setIsAbstract(MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));
    447449        }
    448450        // Parse the multitude of arguments.
    449         else if(node_name.equals("Arguments")) {
     451        else if(node_name.equalsIgnoreCase("Arguments")) {
    450452        for(Node arg = node.getFirstChild(); arg != null; arg = arg.getNextSibling()) {
    451453            node_name = arg.getNodeName();
    452454            // An option.
    453             if(node_name.equals("Option")) {
     455            if(node_name.equalsIgnoreCase("Option")) {
    454456            Argument argument = new Argument();
    455457            // If its an option we parse the multitude of details an options might have.
    456458            for(Node det = arg.getFirstChild(); det != null; det = det.getNextSibling()) {
    457459                node_name = det.getNodeName();
    458                 if(node_name.equals("Name")) {
     460                if(node_name.equalsIgnoreCase("Name")) {
    459461                argument.setName(MSMUtils.getValue(det));
    460462                }
    461                 else if(node_name.equals("Desc")) {
     463                else if(node_name.equalsIgnoreCase("Desc")) {
    462464                argument.setDescription(MSMUtils.getValue(det));
    463465                }
    464                 else if(node_name.equals("Type")) {
     466                else if(node_name.equalsIgnoreCase("Type")) {
    465467                argument.setType(MSMUtils.getValue(det));
    466468                }
    467                 else if(node_name.equals("Default")) {
     469                else if(node_name.equalsIgnoreCase("Default")) {
    468470                argument.setDefaultValue(MSMUtils.getValue(det));
    469471                }
    470                 else if(node_name.equals("List")) {
     472                else if(node_name.equalsIgnoreCase("List")) {
    471473                // Two final loops are required to parse lists.
    472474                for(Node value = det.getFirstChild(); value != null; value = value.getNextSibling()) {
    473                     if(value.getNodeName().equals("Value")) {
     475                    if(value.getNodeName().equalsIgnoreCase("Value")) {
    474476                    String key = null;
    475477                    String desc = "";
    476478                    for(Node subvalue = value.getFirstChild(); subvalue != null; subvalue = subvalue.getNextSibling()) {
    477479                        node_name = subvalue.getNodeName();
    478                         if(node_name.equals("Name")) {
     480                        if(node_name.equalsIgnoreCase("Name")) {
    479481                        key = MSMUtils.getValue(subvalue);
    480482                        }
    481                         else if(node_name.equals("Desc")) {
     483                        else if(node_name.equalsIgnoreCase("Desc")) {
    482484                        desc = MSMUtils.getValue(subvalue);
    483485                        }
     
    489491                }
    490492                }
    491                 else if(node_name.equals("Required")) {
     493                else if(node_name.equalsIgnoreCase("Required")) {
    492494                String v = MSMUtils.getValue(det);
    493                 if(v != null && v.equals("yes")) {
     495                if(v != null && v.equalsIgnoreCase("yes")) {
    494496                    argument.setRequired(true);
    495497                }
     
    499501            }
    500502            // A super plugin class.
    501             else if(node_name.equals("PlugInfo")) {
     503            else if(node_name.equalsIgnoreCase("PlugInfo")) {
    502504            PlugIn super_plugin = parseXML(arg);
    503505            plugin.setSuper(super_plugin);
     
    609611        movement_pane = new JPanel();
    610612
     613        PlugInComboboxListener picl = new PlugInComboboxListener();
    611614        plugin = new GComboBox(getAvailable());
    612615        plugin.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false));
    613616        plugin.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));
    614617        plugin.setEditable(true);
    615         plugin.setSelectedIndex(0);
    616618        plugin.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false));
    617619        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));
    619621
    620622        plugin_label = new JLabel();
     
    650652        move_top_button.addActionListener(ml);
    651653        move_up_button.addActionListener(ml);
     654        plugin.addItemListener(picl);
    652655        remove.addActionListener(new RemoveListener());
    653656        plugin_list.addMouseListener(new ClickListener());
    654657        plugin_list.addListSelectionListener(new ListListener());
     658        picl = null;
    655659
    656660        // Layout
     
    936940        }
    937941    }
     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
    938965    /** This class listens for actions upon the remove button in the controls, and if detected calls the <i>removePlugIn()</i> method.
    939966     */
Note: See TracChangeset for help on using the changeset viewer.