- Timestamp:
- 2003-06-12T18:04:22+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/custom/CustomAZList.java
r4614 r4621 66 66 /** When this the control dialog is disposed, should we go ahead a add this custom AZ list (by processing all file records and building a new hierarchy)? */ 67 67 private boolean process = false; 68 /** are we currently processing?? */ 69 private boolean is_processing = false; 68 70 /** A reference to the Gatherer for access to the Collection and MetadataSetManager. */ 69 71 private Gatherer gatherer = null; … … 111 113 public CustomAZList() {} 112 114 /** Constructor. 113 114 115 * @param gatherer A reference to the <strong>Gatherer</strong>. 116 */ 115 117 public CustomAZList(Gatherer gatherer) { 116 118 this.gatherer = gatherer; 117 119 } 118 120 /** Used to compare this classifier to another classifier for the purposes of ordering. 119 120 121 122 121 * @param object The other classifier as an <strong>Object</strong>. 122 * @see org.greenstone.gatherer.cdm.Classifier 123 * @see org.greenstone.gatherer.cdm.CustomClassifier 124 */ 123 125 public int compareTo(Object object) { 124 126 if(object instanceof Classifier) { … … 136 138 controls = null; 137 139 } 140 public void hide() { 141 controls.setVisible(false); 142 } 138 143 /** Produce a new copy of this custom classifier. Remember that what the classifier manager does is create instances of all possible classifiers, then as they are assigned creates and assigns copies of the original reserve. This way we only have to parse arguments once. 139 140 141 144 * @return A new <strong>CustomClassifier</strong> which is a copy of this one. 145 * @see org.greenstone.gatherer.Gatherer 146 */ 142 147 public CustomClassifier copy() { 143 148 return new CustomAZList(gatherer); … … 158 163 public boolean display(boolean show) { 159 164 if(controls == null) { 165 160 166 Vector elements = gatherer.c_man.getCollection().msm.getAssignedElements(); 161 167 // Creation … … 191 197 ok = new JButton(get("OK_JButton")); 192 198 cancel = new JButton(get("Cancel_JButton")); 193 199 // Connection 194 200 buttonname_label.addActionListener(new ButtonNameListener()); 195 201 cancel.addActionListener(new CancelListener()); 196 202 ok.addActionListener(new OKListener()); 197 203 sort_label.addActionListener(new SortListener()); 198 204 // The Toggle Button block. Done all at once so we don't end up with three for loops. 199 205 JPanel center_pane = new JPanel(); 200 206 center_pane.setLayout(new GridLayout(3, 9)); … … 214 220 } 215 221 separators_preview.setText(getPreview(true)); 216 222 // Layout 217 223 metadata_pane.setBorder(BorderFactory.createEmptyBorder(1,0,1,0)); 218 224 metadata_pane.setLayout(new BorderLayout()); … … 253 259 content_pane.add(center_pane, BorderLayout.CENTER); 254 260 content_pane.add(lower_pane, BorderLayout.SOUTH); 255 261 // Display 256 262 Dimension screen_size = Gatherer.config.screen_size; 257 263 controls.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); … … 269 275 return true; 270 276 } 271 277 // We do everything -except- display the control. 272 278 } 273 279 else { 280 // we already have the controls 274 281 process = false; 275 282 controls.setVisible(true); … … 289 296 CustomClassifier classifier = (CustomClassifier) object; 290 297 if(getCommand().equalsIgnoreCase(classifier.getCommand())) { 298 //if (toString().equalsIgnoreCase(classifier.toString())) { 291 299 return true; 292 300 } … … 320 328 } 321 329 /** Retrieve the custom command, a command line that overrides and replaces some other 'actual' classifier. 322 323 330 * @param index The number of the classifer this one is replacing. 331 */ 324 332 public String getCustomCommand(int index) { 325 333 StringBuffer text = new StringBuffer("customclassifier "); … … 342 350 */ 343 351 public void process(FileNode record) { 352 is_processing = true; 344 353 ElementWrapper element = (ElementWrapper) metadata.getSelectedItem(); 345 354 if(element != null) { 346 355 addMetadata(0L, record, element); 347 356 } 357 is_processing = false; 348 358 } 349 359 /** Recreate a CustomAZList given several parameters including the real classifier created during custom design. … … 401 411 } 402 412 } 403 413 // Rebuild mappings hashtable for this pattern. Add it if not present. 404 414 GValueNode node = model.addValue(key); 405 415 // If the key is simple, ie "C", then add the mapping "C"->node 406 416 if(node == null) { 407 417 // Do nothing. … … 410 420 mappings.put(key, node); 411 421 } 412 422 // If the key is more complex, say "D-L", then we add mappings for all string values so "D"->node, "E"->node, ... "L"->node. This is miles eaiser to do here, than when you are trying to match a records metadata ie matchin "D-L" to "Igloos are cool". Note that it is guarantee that the keys are all of the same length, ie "A-L", "MA-ML", "MMA-STF", "STFA-ZZZZ". 413 423 else { 414 424 String start = key.substring(0, key.indexOf("-")); … … 553 563 public void actionPerformed(ActionEvent event) { 554 564 process = false; 555 controls.dispose(); 565 566 controls.setVisible(false); 556 567 } 557 568 } … … 564 575 public void actionPerformed(ActionEvent event) { 565 576 process = true; 566 controls. dispose();577 controls.setVisible(false); 567 578 } 568 579 } … … 604 615 // 33% - Allocation of metadata to records, 33 / <number of files>. 605 616 // Hopefully the previous dialog should have already vanished (its dispose() caused by the process click). 617 is_processing = true; 606 618 pd = new ProgressDialog("Custom Classifier Creation", "Preparing for operation."); 607 619 // Step 1: Create the new dummy element and add it if necessary. 608 620 pd.setText("Creating dummy metadata element."); 621 ///ystem.out.println("Creating dummy metadata element."); 609 622 MetadataSet hidden_mds = gatherer.c_man.getCollection().msm.getSet(MetadataSetManager.HIDDEN); 610 623 Element hidden_e = hidden_mds.getElement(element.toString().replace('.','_')); … … 622 635 // Step 2: Remove any existing value tree for this element. Wastefull I know but I don't want to lag for too long, and this is the quickest way. 623 636 pd.setText("Removing any existing hierarchy."); 637 ///ystem.out.println("Removing any existing hierarchy."); 624 638 if(found) { 625 639 hidden_mds.removeValueTree(hidden_mde); … … 628 642 // Step 3: Create a value tree for this element. 629 643 pd.setText("Creating new hierary root."); 644 ///ystem.out.println("Creating new hierary root."); 630 645 GValueModel value_tree = gatherer.c_man.getCollection().msm.getValueTree(hidden_mde); 631 646 pd.increase(5, 5, 5); 632 647 // Step 4: Build the single level value hierarchy using state's value. Here a hashtable mapping string patterns to value nodes is built. 633 648 pd.setText("Creating separations."); 649 ///ystem.out.println("Creating separations."); 634 650 StringTokenizer tokenizer = new StringTokenizer(state, ","); 635 651 int separator_count = tokenizer.countTokens(); … … 650 666 } 651 667 } 652 668 // Each iteration. 653 669 pd.increase(1, separator_count, 25); 654 670 } 655 671 // Step 5: Recurse the entire tree, adding the appropriate values where necessary (overwriting any existing value for this element). 656 672 pd.setText("Allocating metadata to records."); 673 ///ystem.out.println("Allocating metadata to records."); 657 674 int count = gatherer.c_man.getCollection().getCount(); 658 675 TreeModel record_tree = gatherer.c_man.getRecordSet(); … … 670 687 } 671 688 if(!current_record.isLeaf()) { 689 ///ystem.out.println("Add all children to records at once hopefully."); 672 690 // Add all children to records at once hopefully. 673 691 FileNode children[] = new FileNode[current_record.getChildCount()]; … … 680 698 pd.increase(1, count, 50); 681 699 } 700 is_processing = false; 682 701 // Step 6: Done. 683 702 pd.dispose(); … … 685 704 } 686 705 687 public boolean valueIsAdjusting() {688 return (pd == null);706 public boolean isProcessing() { 707 return is_processing; 689 708 } 690 709 … … 709 728 setSize(dialog_size); 710 729 setTitle(t); 711 730 // Create 712 731 JPanel content_pane = (JPanel) getContentPane(); 713 732 label.setText(l); … … 715 734 bar.setMinimum(0); 716 735 bar.setValue(0); 717 718 736 // Connect 737 // Layout 719 738 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 720 739 content_pane.setLayout(new BorderLayout()); 721 740 content_pane.add(label, BorderLayout.NORTH); 722 741 content_pane.add(bar, BorderLayout.CENTER); 723 742 // Display 724 743 Dimension screen_size = Gatherer.config.screen_size; 725 744 setLocation((screen_size.width - dialog_size.width) / 2, (screen_size.height - dialog_size.height) / 2); … … 728 747 } 729 748 /** Increase the progress bar by a certain ammount. 730 731 732 733 749 * @param item An <i>int</i> indicating what item number this is. 750 * @param out_of An <i>int</i> detailing the number of items expected in total for this phase. 751 * @param total The maximum value of the progress bar as an <i>int</i>. 752 */ 734 753 public void increase(int item, int out_of, int total) { 735 754 value = value + (((double) item / (double) out_of) * (double)total); … … 741 760 } 742 761 /** Set the message shown in the progress bar. 743 744 762 * @param l The new progress bar label as a <strong>String</strong>. 763 */ 745 764 public void setText(String l) { 746 765 label.setText(l);
Note:
See TracChangeset
for help on using the changeset viewer.