Changeset 4626 for trunk


Ignore:
Timestamp:
2003-06-12T18:08:42+12:00 (21 years ago)
Author:
kjdon
Message:

indented some comments, changed it so that custom classifiers are hidden rather than destroyed after they are used, fixed a couple of other bugs

File:
1 edited

Legend:

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

    r4597 r4626  
    228228    public int indexOf(Classifier classifier) {
    229229    for(int i = 0; i < assigned.size(); i++) {
    230         Classifier sibling = (Classifier) assigned.get(i);
    231         if(sibling.equals(classifier)) {
    232         return i;
     230        Object elem = assigned.get(i);
     231        if (elem instanceof Classifier) {
     232        Classifier sibling = (Classifier)elem;
     233        if(sibling.equals(classifier)) {
     234            return i;
     235        }
     236        }
     237    }
     238    return -1;
     239    }
     240    // these two methods assume that a custome classifier can never be the same as a classifier
     241    public int indexOf(CustomClassifier classifier) {
     242    for(int i = 0; i < assigned.size(); i++) {
     243        Object elem = assigned.get(i);
     244        if (elem instanceof CustomClassifier) {
     245        CustomClassifier sibling = (CustomClassifier) assigned.get(i);
     246        if(sibling.equals(classifier)) {
     247            return i;
     248        }
    233249        }
    234250    }
     
    327343        if(object instanceof CustomClassifier) {
    328344            CustomClassifier classifier = (CustomClassifier) object;
    329             if(!classifier.valueIsAdjusting()) {
     345            if(!classifier.isProcessing()) { // are we already in the middle of processing??
    330346            classifier.process(record);
    331             }
     347            } 
    332348        }
    333349        }
     
    438454        CommandTokenizer tokenizer = new CommandTokenizer(command);
    439455        if(tokenizer.countTokens() >= 6) {
    440         tokenizer.nextToken();// Loose customclassifier
     456        tokenizer.nextToken();// Lose customclassifier
    441457        // Get class name.
    442458        String class_name = tokenizer.nextToken();
     
    449465            replaces = tokenizer.nextToken();
    450466            }
    451             else {
     467            else if (arg_name.equalsIgnoreCase("-separations")){
    452468            separations = tokenizer.nextToken();
    453469            }
     
    462478            custom_classifier.setGatherer(gatherer);
    463479            custom_classifier.recreate(original, separations);
    464             assigned.add(indexOf(original), custom_classifier);
     480            assigned.add(index, custom_classifier);
    465481            assigned.removeElement(original);
    466482            }
     
    856872    private class AddListener
    857873        implements ActionListener {
    858                 /** Any implementation of ActionListener must include this method so that we can be informed when an action has occured on one of our target controls, so that we can add the selected Classifier.
    859                 * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
    860                 * @see org.greenstone.gatherer.Gatherer
    861                 * @see org.greenstone.gatherer.cdm.ArgumentConfiguration
    862                 * @see org.greenstone.gatherer.cdm.Classifier
    863                 * @see org.greenstone.gatherer.cdm.CustomClassifier
    864                 */
     874        /** Any implementation of ActionListener must include this method so that we can be informed when an action has occured on one of our target controls, so that we can add the selected Classifier.
     875        * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
     876        * @see org.greenstone.gatherer.Gatherer
     877        * @see org.greenstone.gatherer.cdm.ArgumentConfiguration
     878        * @see org.greenstone.gatherer.cdm.Classifier
     879        * @see org.greenstone.gatherer.cdm.CustomClassifier
     880        */
    865881        public void actionPerformed(ActionEvent event) {
    866882        String name = (String)classifier.getSelectedItem();
     
    928944                assigned.refresh();
    929945                }
    930                 cc.destroy(); // Remove gui prompt or else.
     946                cc.hide(); // Remove gui prompt or else.
    931947                cc = null;
    932948            }
     
    939955    private class ConfigureListener
    940956        implements ActionListener {
    941                 /** 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.
    942                 * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
    943                 * @see org.greenstone.gatherer.cdm.ArgumentConfiguration
    944                 * @see org.greenstone.gatherer.cdm.Classifier
    945                 * @see org.greenstone.gatherer.cdm.CustomClassifier
    946                 */
     957        /** 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.
     958        * @param event An <strong>ActionEvent</strong> containing information garnered from the control action.
     959        * @see org.greenstone.gatherer.cdm.ArgumentConfiguration
     960        * @see org.greenstone.gatherer.cdm.Classifier
     961        * @see org.greenstone.gatherer.cdm.CustomClassifier
     962        */
    947963        public void actionPerformed(ActionEvent event) {
    948964        if(!classifier_list.isSelectionEmpty()) {
     
    961977                assigned.refresh();
    962978            }
    963             cc.destroy(); // Remove gui prompt or else.
     979            cc.hide(); // Remove gui prompt or else.
    964980            cc = null;
    965981            }
     
    981997            assignClassifier(custom_classifier);
    982998        }
    983         custom_classifier.destroy(); // Remove gui prompt or else.
     999        custom_classifier.hide(); // Remove gui prompt or else.
    9841000        custom_classifier = null;
    9851001        }
Note: See TracChangeset for help on using the changeset viewer.