Changeset 5209


Ignore:
Timestamp:
2003-08-19T15:38:01+12:00 (21 years ago)
Author:
jmt12
Message:

Fix 203B120 and 147

Location:
trunk/gli/src/org/greenstone/gatherer/cdm
Files:
2 edited

Legend:

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

    r4960 r5209  
    3333import java.io.*;
    3434import java.util.*;
     35import org.greenstone.gatherer.Gatherer;
    3536import org.greenstone.gatherer.cdm.Argument;
    3637import org.greenstone.gatherer.cdm.ArgumentContainer;
     
    5051
    5152    static final public String CLASSIFIER_PREFIX = "CL";
     53
     54    private boolean is_abstract = false;
    5255
    5356    /** A reference to the classifier that this one inherits from. */
     
    111114            // The trick thing is that we have to create a new element in the DOM as well.
    112115            Argument new_argument = base_argument.copy();
     116            new_argument.setOwner(name);
    113117            Element argument_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.OPTION_ELEMENT);
    114118            argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, base_argument_name);
     
    288292    }
    289293    return position_string;
     294    }
     295
     296    public boolean isAbstract() {
     297    return is_abstract;
    290298    }
    291299
     
    360368    }
    361369
     370    public void setIsAbstract(boolean is_abstract) {
     371    this.is_abstract = is_abstract;
     372    }
     373
    362374    /** Method to set the value of name.
    363375     * @param name The new value of name as a <strong>String</strong>.
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r5090 r5209  
    274274    }
    275275
     276    private Object[] getAvailable() {
     277    ArrayList available = new ArrayList();
     278    int library_size = library.size();
     279    for(int i = 0; i < library_size; i++) {
     280        Classifier classifier = (Classifier) library.get(i);
     281        if(!classifier.isAbstract()) {
     282        available.add(classifier);
     283        }
     284        classifier = null;
     285    }
     286    return available.toArray();
     287    }
     288
    276289    /** Method to extract just the classifiers name from a file object.
    277290     * @param classifier The <strong>File</strong> which references a certain classifier.
     
    420433        else if(node_name.equals("Desc")) {
    421434        classifier.setDescription(MSMUtils.getValue(node));
     435        }
     436        else if(node_name.equals(CollectionConfiguration.ABSTRACT_ELEMENT)) {
     437        classifier.setIsAbstract(MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));
    422438        }
    423439        // Parse the multitude of arguments.
     
    476492            }
    477493            // A super classifier class.
    478             else if(node_name.equals("ClasInfo")) {
     494            else if(node_name.equals("ClassInfo")) {
    479495            Classifier super_classifier = parseXML(arg);
    480496            classifier.setSuper(super_classifier);
     
    535551        instructions.setWrapStyleWord(true);
    536552
    537         classifier = new GComboBox(library.toArray());
     553        classifier = new GComboBox(getAvailable());
    538554        classifier.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false));
    539555        classifier.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));
     
    641657
    642658        classifier_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
    643         classifier_pane.setLayout(new GridLayout(1,2));
     659        classifier_pane.setLayout(new GridLayout(1, 2));
    644660        classifier_pane.add(classifier_label);
    645661        classifier_pane.add(classifier);
    646662
    647         button_pane.setLayout(new GridLayout(3,1));
     663        button_pane.setLayout(new GridLayout(1, 3));
    648664        button_pane.add(add);
    649665        button_pane.add(configure);
     
    698714        Object selected_object = classifier.getSelectedItem();
    699715        // If there is something in the combobox, but we haven't registered a selection, then add the object and select it!
    700         if(selected_object != null && classifier.getSelectedIndex() == -1) {
    701             classifier.insertItemAt(selected_object, classifier.getItemCount());
    702         }
    703716        if(selected_object != null) {
     717            // Retrieve the base classifier
     718            Classifier base_classifier = getBaseClassifier(selected_object.toString());
     719
    704720            // Create a new element in the DOM
    705721            Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.CLASSIFY_ELEMENT);
    706722            Classifier new_classifier = null;
    707             if(selected_object instanceof Classifier) {
    708             Classifier base_classifier = (Classifier) selected_object;
     723            if(base_classifier != null) {
     724            Gatherer.println("Creating Classifier based on existing Classifer.");
    709725            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_classifier.getName());
    710726            new_classifier = new Classifier(element, base_classifier);
    711             base_classifier = null;
    712727            }
    713728            else {
     729            Gatherer.println("Creating new custom Classifier.");
    714730            element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString());
    715731            new_classifier = new Classifier(element, null);
     732            // Also we add the custom classifier name to the combobox for convienence.
     733            classifier.addItem(selected_object);
    716734            }
    717735            element = null;
     
    729747            ac = null;
    730748            new_classifier = null;
    731             classifier.setSelectedIndex(0);
    732749        }
    733750        }
Note: See TracChangeset for help on using the changeset viewer.