Changeset 5209
- Timestamp:
- 2003-08-19T15:38:01+12:00 (21 years ago)
- 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 33 33 import java.io.*; 34 34 import java.util.*; 35 import org.greenstone.gatherer.Gatherer; 35 36 import org.greenstone.gatherer.cdm.Argument; 36 37 import org.greenstone.gatherer.cdm.ArgumentContainer; … … 50 51 51 52 static final public String CLASSIFIER_PREFIX = "CL"; 53 54 private boolean is_abstract = false; 52 55 53 56 /** A reference to the classifier that this one inherits from. */ … … 111 114 // The trick thing is that we have to create a new element in the DOM as well. 112 115 Argument new_argument = base_argument.copy(); 116 new_argument.setOwner(name); 113 117 Element argument_element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.OPTION_ELEMENT); 114 118 argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, base_argument_name); … … 288 292 } 289 293 return position_string; 294 } 295 296 public boolean isAbstract() { 297 return is_abstract; 290 298 } 291 299 … … 360 368 } 361 369 370 public void setIsAbstract(boolean is_abstract) { 371 this.is_abstract = is_abstract; 372 } 373 362 374 /** Method to set the value of name. 363 375 * @param name The new value of name as a <strong>String</strong>. -
trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java
r5090 r5209 274 274 } 275 275 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 276 289 /** Method to extract just the classifiers name from a file object. 277 290 * @param classifier The <strong>File</strong> which references a certain classifier. … … 420 433 else if(node_name.equals("Desc")) { 421 434 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)); 422 438 } 423 439 // Parse the multitude of arguments. … … 476 492 } 477 493 // A super classifier class. 478 else if(node_name.equals("Clas Info")) {494 else if(node_name.equals("ClassInfo")) { 479 495 Classifier super_classifier = parseXML(arg); 480 496 classifier.setSuper(super_classifier); … … 535 551 instructions.setWrapStyleWord(true); 536 552 537 classifier = new GComboBox( library.toArray());553 classifier = new GComboBox(getAvailable()); 538 554 classifier.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false)); 539 555 classifier.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false)); … … 641 657 642 658 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)); 644 660 classifier_pane.add(classifier_label); 645 661 classifier_pane.add(classifier); 646 662 647 button_pane.setLayout(new GridLayout( 3,1));663 button_pane.setLayout(new GridLayout(1, 3)); 648 664 button_pane.add(add); 649 665 button_pane.add(configure); … … 698 714 Object selected_object = classifier.getSelectedItem(); 699 715 // 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 }703 716 if(selected_object != null) { 717 // Retrieve the base classifier 718 Classifier base_classifier = getBaseClassifier(selected_object.toString()); 719 704 720 // Create a new element in the DOM 705 721 Element element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.CLASSIFY_ELEMENT); 706 722 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."); 709 725 element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, base_classifier.getName()); 710 726 new_classifier = new Classifier(element, base_classifier); 711 base_classifier = null;712 727 } 713 728 else { 729 Gatherer.println("Creating new custom Classifier."); 714 730 element.setAttribute(CollectionConfiguration.TYPE_ATTRIBUTE, selected_object.toString()); 715 731 new_classifier = new Classifier(element, null); 732 // Also we add the custom classifier name to the combobox for convienence. 733 classifier.addItem(selected_object); 716 734 } 717 735 element = null; … … 729 747 ac = null; 730 748 new_classifier = null; 731 classifier.setSelectedIndex(0);732 749 } 733 750 }
Note:
See TracChangeset
for help on using the changeset viewer.