Changeset 8813
- Timestamp:
- 2004-12-15T13:41:43+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8811 r8813 95 95 static public ActionRecorderDialog feedback_dialog = null; 96 96 97 // Refresh reasons 98 static public final int COLLECTION_OPENED = 0; 99 static public final int COLLECTION_CLOSED = 1; 100 static public final int COLLECTION_REBUILT = 2; 101 static public final int PREFERENCES_CHANGED = 3; 102 97 103 98 104 /** Magic to allow Enter to fire the default button. */ … … 326 332 327 333 328 329 334 public void run(Dimension size, Splash splash, GUIManager g_man) 330 335 { … … 448 453 } 449 454 455 456 static public void refresh(int refresh_reason) 457 { 458 if (g_man != null) { 459 g_man.refresh(refresh_reason, c_man.ready()); 460 } 461 462 // Now is a good time to force a garbage collect 463 System.gc(); 464 } 465 466 450 467 // used to send reload coll messages to the tomcat server 451 468 static public void configGS3Server(String site, String command) { … … 471 488 } 472 489 473 /** Retrieve the metadata directory, as required by any MSMCaller implementation.474 * @return The currently active collection metadata directory as a <strong>String</strong>.475 * @see org.greenstone.gatherer.collection.CollectionManager476 */477 public String getCollectionMetadata() {478 if (c_man != null && c_man.ready()) {479 return c_man.getCollectionMetadata();480 }481 return "";482 }483 490 484 491 /** Used to 'spawn' a new child application when a file is double clicked. -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r8783 r8813 101 101 static final public String LOCK_FILE = "gli.lck"; 102 102 103 static public final int COLLECTION_OPENED = 10;104 static public final int COLLECTION_CLOSED = 11;105 static public final int COLLECTION_REBUILT = 12;106 107 103 /** Used to indicate the source of the message is the file collection methods. */ 108 104 static final public int COLLECT = 3; … … 226 222 // workspace_model = null; 227 223 Configuration.setCollectionConfiguration(null); 224 Gatherer.refresh(Gatherer.COLLECTION_CLOSED); 228 225 if (Gatherer.g_man != null) { 229 Gatherer.g_man.updateUI(); 230 Gatherer.g_man.refresh(COLLECTION_CLOSED, false); 226 Gatherer.g_man.updateUI(); // !!! Necessary? 231 227 } 232 228 } … … 482 478 Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED); 483 479 484 Gatherer. g_man.refresh(COLLECTION_OPENED, ready());480 Gatherer.refresh(Gatherer.COLLECTION_OPENED); 485 481 } 486 482 } … … 959 955 960 956 // We're done. Let everyone know. 961 if (Gatherer.g_man != null) { 962 Gatherer.g_man.refresh(COLLECTION_OPENED, ready()); 963 } 957 Gatherer.refresh(Gatherer.COLLECTION_OPENED); 964 958 result = true; 965 959 } … … 1133 1127 1134 1128 // Fire a collection changed first to update the preview etc buttons 1135 Gatherer. g_man.refresh(COLLECTION_REBUILT, ready());1129 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1136 1130 1137 1131 // Now display a message dialog saying its all built … … 1144 1138 else { 1145 1139 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1146 Gatherer. g_man.refresh(COLLECTION_REBUILT, ready());1140 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1147 1141 } 1148 1142 } … … 1153 1147 } else { 1154 1148 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1155 Gatherer. g_man.refresh(COLLECTION_REBUILT, ready());1149 Gatherer.refresh(Gatherer.COLLECTION_REBUILT); 1156 1150 } 1157 1151 -
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r8802 r8813 100 100 101 101 /** Used to dynamically filter the collection tree at user request. Note that this is synchronized with the collection tree filter in the Gather view. */ 102 private Filter filter = null;102 private Filter collection_filter = null; 103 103 /** The currently reported selection. */ 104 104 private CollectionTreeNode[] file_nodes = null; … … 125 125 private DragTree collection_tree; 126 126 /** Provide synchronization between the collection trees in this view and the collection pane view. */ 127 private TreeSynchronizer tree_sync = null;127 private TreeSynchronizer collection_tree_sync = null; 128 128 private boolean metadata_edit_event = false; 129 129 … … 132 132 * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree 133 133 */ 134 public EnrichPane(TreeSynchronizer tree_sync)134 public EnrichPane(TreeSynchronizer collection_tree_sync) 135 135 { 136 this. tree_sync =tree_sync;136 this.collection_tree_sync = collection_tree_sync; 137 137 138 138 add = new GLIButton(); … … 267 267 collection_tree.addTreeSelectionListener(this); 268 268 collection_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener); 269 collection_tree.setLargeModel(true); 269 collection_tree.setBackgroundNonSelectionColor(Configuration.getColor("coloring.collection_tree_background", false)); 270 collection_tree.setTextNonSelectionColor(Configuration.getColor("coloring.collection_tree_foreground", false)); 271 collection_tree.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false)); 272 collection_tree.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false)); 270 273 collection_tree.setRootVisible(false); 271 274 … … 274 277 JScrollPane collection_scroll = new JScrollPane(collection_tree); 275 278 276 filter = Gatherer.g_man.getFilter(collection_tree);277 filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));278 filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE);279 Dictionary.registerTooltip( filter.getComboBox(), "Collection.Filter_Tooltip");279 collection_filter = Gatherer.g_man.getFilter(collection_tree); 280 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 281 collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE); 282 Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip"); 280 283 281 284 // Layout … … 287 290 collection_pane.add(collection_label, BorderLayout.NORTH); 288 291 collection_pane.add(collection_scroll, BorderLayout.CENTER); 289 collection_pane.add( filter, BorderLayout.SOUTH);292 collection_pane.add(collection_filter, BorderLayout.SOUTH); 290 293 291 294 JSplitPane main_split_pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); … … 438 441 public void modeChanged(int mode) 439 442 { 440 filter.setEditable(mode > Configuration.LIBRARIAN_MODE);443 collection_filter.setEditable(mode > Configuration.LIBRARIAN_MODE); 441 444 } 442 445 443 446 444 public void refresh(int refresh_reason, boolean ready) 447 /** Refresh this pane, depending on what has just happened (refresh_reason). */ 448 public void refresh(int refresh_reason, boolean collection_loaded) 445 449 { 446 if ( ready) {447 // Update label450 if (collection_loaded) { 451 // Update collection label 448 452 Dictionary.registerText(collection_label, "Collection.Collection"); 449 453 collection_label.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 450 454 collection_label.setForeground(Configuration.getColor("coloring.collection_heading_foreground", false)); 451 455 452 // Update tree 453 collection_tree.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); 454 collection_tree.setForeground(Configuration.getColor("coloring.collection_tree_foreground", false)); 455 if (refresh_reason != CollectionManager.COLLECTION_REBUILT) { 456 // Update collection tree 457 if (refresh_reason == Gatherer.COLLECTION_OPENED) { 456 458 collection_tree.setModel(Gatherer.c_man.getRecordSet()); 457 459 } 460 461 // Update collection filter 462 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 458 463 } 459 464 else { 460 // Update label465 // Update collection label 461 466 Dictionary.registerText(collection_label, "Collection.No_Collection"); 462 467 collection_label.setBackground(Color.lightGray); 463 468 collection_label.setForeground(Color.black); 464 469 465 // Update tree 466 collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(Dictionary.get("Collection.No_Collection")))); 467 } 468 469 filter.setEnabled(ready); 470 // Ensure that this collection tree view is synchronized with any others. 471 tree_sync.add(collection_tree); 470 // Update collection tree 471 collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error"))); 472 473 // Update collection filter 474 collection_filter.setBackground(Color.lightGray); 475 } 476 477 // Enable or disable the controls 478 collection_tree.setEnabled(collection_loaded); 479 collection_filter.setEnabled(collection_loaded); 480 481 // Ensure that this collection tree view is synchronized with all others 482 collection_tree_sync.add(collection_tree); 483 484 // Force the metadata table to be rebuilt (for switching extracted metadata on or off) 485 if (refresh_reason == Gatherer.PREFERENCES_CHANGED) { 486 valueChanged(null); 487 } 472 488 } 473 489 -
trunk/gli/src/org/greenstone/gatherer/gui/Filter.java
r7233 r8813 132 132 public void setEnabled(boolean state) { 133 133 ignore = true; 134 combobox.setEditable(state);135 134 combobox.setEnabled(state); 136 135 ignore = false; -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r8783 r8813 103 103 /** Ensures that expansion events between like collection trees are synchronized. */ 104 104 private TreeSynchronizer collection_tree_sync = null; 105 /** Ensures that expansion events between like workspace trees are synchronized. */106 private TreeSynchronizer workspace_tree_sync = null;107 108 static public final int GUI_REFRESHED = 0;109 static public final int PREFERENCES_CHANGED = 1;110 105 111 106 … … 120 115 this.collection_tree_sync = new TreeSynchronizer(); 121 116 this.meta_audit = new MetaAuditFrame(collection_tree_sync, null); 122 this.workspace_tree_sync = new TreeSynchronizer();123 117 124 118 this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); … … 342 336 } 343 337 344 gather_pane = new GatherPane( workspace_tree_sync,collection_tree_sync);338 gather_pane = new GatherPane(collection_tree_sync); 345 339 gather_pane.display(); 346 340 if(Configuration.get("workflow.gather", true)) { … … 494 488 495 489 496 public void refresh(int refresh_reason, boolean ready)490 public void refresh(int refresh_reason, boolean collection_loaded) 497 491 { 492 // Set the collection information in the title bar 493 if (collection_loaded) { 494 Collection collection = Gatherer.c_man.getCollection(); 495 setTitle(collection.getTitle(), collection.getName()); 496 } 497 else { 498 setTitle(null, null); 499 } 500 498 501 // Update the menu bar 499 menu_bar.refresh(refresh_reason, ready);502 menu_bar.refresh(refresh_reason, collection_loaded); 500 503 501 504 // Update the loaded panes 502 505 if (mirror_pane != null) { 503 mirror_pane.refresh(refresh_reason, ready);506 mirror_pane.refresh(refresh_reason, collection_loaded); 504 507 } 505 508 if (gather_pane != null) { 506 gather_pane.refresh(refresh_reason, ready);509 gather_pane.refresh(refresh_reason, collection_loaded); 507 510 } 508 511 if (enrich_pane != null) { 509 enrich_pane.refresh(refresh_reason, ready);512 enrich_pane.refresh(refresh_reason, collection_loaded); 510 513 } 511 514 if (design_pane != null) { 512 design_pane.refresh(refresh_reason, ready);515 design_pane.refresh(refresh_reason, collection_loaded); 513 516 } 514 517 if (create_pane != null) { 515 create_pane.refresh(refresh_reason, ready); 516 } 517 518 if (refresh_reason == PREFERENCES_CHANGED) { 519 // Force both workspace and collection trees to redraw 520 Gatherer.g_man.refreshWorkspaceTree(DragTree.TREE_DISPLAY_CHANGED); 521 Gatherer.g_man.refreshCollectionTree(DragTree.TREE_DISPLAY_CHANGED); 522 } 523 518 create_pane.refresh(refresh_reason, collection_loaded); 519 } 520 521 // Now enable tabs as necessary. Do this on event queue to prevent crazy NPEs 524 522 if (!locked) { 525 // Now enable tabs as necessary. Do this on event queue to prevent crazy NPEs 526 if(tab_updater == null) { 527 tab_updater = new TabUpdater(tab_pane, ready); 523 if (tab_updater == null) { 524 tab_updater = new TabUpdater(tab_pane, collection_loaded); 528 525 } 529 526 else { 530 tab_updater.setReady( ready);527 tab_updater.setReady(collection_loaded); 531 528 } 532 529 SwingUtilities.invokeLater(tab_updater); 533 530 } 534 535 // Set the title536 String collection_title = null;537 String collection_name = null;538 if (ready) {539 Collection collection = Gatherer.c_man.getCollection();540 collection_title = collection.getTitle();541 collection_name = collection.getName();542 collection = null;543 }544 setTitle(collection_title, collection_name);545 collection_title = null;546 collection_name = null;547 548 // Now is a good time to force a garbage collect549 System.gc();550 531 } 551 532 -
trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java
r8788 r8813 130 130 * @see org.greenstone.gatherer.file.FileQueue 131 131 */ 132 public GatherPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizercollection_tree_sync) {132 public GatherPane(TreeSynchronizer collection_tree_sync) { 133 133 this.group = new DragGroup(); 134 134 this.file_queue = Gatherer.f_man.getQueue(); 135 135 this.collection_tree_sync = collection_tree_sync; 136 136 137 137 // Create components. 138 138 stop_action = new GLIButton(); … … 284 284 285 285 collection_filter = Gatherer.g_man.getFilter(collection_tree); 286 if (collection != null) { 287 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 288 } 289 else { 290 collection_filter.setBackground(Color.lightGray); 291 } 292 // Add a tool tip 286 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 287 collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE); 293 288 Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip"); 294 289 … … 419 414 420 415 421 /** Called whenever a significant change occurs in the current collections state, such as a new collection being loaded or the current one being closed. Several actions must occur in the GUI to indicate this change to the user, such as en/disabling the collection tree. 422 * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise. 423 * @see org.greenstone.gatherer.Configuration 424 * @see org.greenstone.gatherer.Gatherer 425 * @see org.greenstone.gatherer.collection.CollectionManager 426 * @see org.greenstone.gatherer.gui.Coloring 427 * @see org.greenstone.gatherer.gui.Filter 428 * @see org.greenstone.gatherer.util.TreeSynchronizer 429 */ 430 public void refresh(int refresh_reason, boolean ready) 416 /** Refresh this pane, depending on what has just happened (refresh_reason). */ 417 public void refresh(int refresh_reason, boolean collection_loaded) 431 418 { 432 if ( ready) {433 // Update label419 if (collection_loaded) { 420 // Update collection label 434 421 Dictionary.registerText(collection_label, "Collection.Collection"); 435 436 // Update tree 437 if (refresh_reason != CollectionManager.COLLECTION_REBUILT) { 422 collection_label.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 423 collection_label.setForeground(Configuration.getColor("coloring.collection_heading_foreground", false)); 424 425 // Update collection tree 426 if (refresh_reason == Gatherer.COLLECTION_OPENED) { 438 427 collection_tree.setModel(Gatherer.c_man.getRecordSet()); 439 collection_tree.repaint(); 440 } 441 442 // Update filter 428 } 429 430 // Update collection filter 443 431 collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false)); 444 432 } 445 433 else { 446 // Update label447 String args[]= new String[1];434 // Update collection label 435 String[] args = new String[1]; 448 436 args[0] = Dictionary.get("Collection.No_Collection"); 449 437 Dictionary.registerText(collection_label, "Collection.Collection", args); 450 args = null; 451 452 // Update tree 438 collection_label.setBackground(Color.lightGray); 439 collection_label.setForeground(Color.black); 440 441 // Update collection tree 453 442 collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error"))); 454 443 455 // Update filter444 // Update collection filter 456 445 collection_filter.setBackground(Color.lightGray); 457 446 } 458 collection_tree.setEnabled(ready); 459 collection_filter.setEnabled(ready); 460 collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE); 461 Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip"); 462 463 // Change the label at the top of collection tree. 464 setEnabled(collection_label, ready, Configuration.getColor("coloring.collection_heading_foreground", false), Configuration.getColor("coloring.collection_heading_background", false)); 465 // Ensure that this tree view of the collection record set is synchronized with any others. 447 448 // Enable or disable the controls 449 workspace_tree.setEnabled(true); 450 collection_tree.setEnabled(collection_loaded); 451 collection_filter.setEnabled(collection_loaded); 452 bin_button.setEnabled(collection_loaded); 453 new_folder.setEnabled(collection_loaded); 454 455 // Ensure that this collection tree view is synchronized with all others 466 456 collection_tree_sync.add(collection_tree); 467 468 // Refresh the collection tree (the workspace tree stays the same)469 refreshCollectionTree(DragTree.LOADED_COLLECTION_CHANGED);470 471 // Enable or disable the control buttons472 bin_button.setEnabled(ready);473 new_folder.setEnabled(ready);474 457 } 475 458 … … 484 467 } 485 468 486 487 /** Used to set the enabled state, and hence the colouring, of the two tree labels.488 * @param label The <strong>JLabel</strong> to be affected.489 * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise.490 * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled.491 * @param background The <strong>Color</strong> to make the background of the label when enabled.492 */493 private void setEnabled(JLabel label, boolean state, Color foreground, Color background) {494 ///ystem.err.println("Setting the label color to state " + state);495 if(state) {496 label.setBackground(background);497 label.setForeground(foreground);498 }499 else {500 label.setBackground(Color.lightGray);501 label.setForeground(Color.black);502 }503 label.repaint();504 ///ystem.err.println("Color is now " + label.getBackground());505 }506 507 469 508 470 /** When a user right-clicks within the workspace and collection trees they are presented with a small popup menu of context based options. This class provides such functionality. -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r8688 r8813 711 711 712 712 // Refresh the GLI to account for the configuration changes 713 Gatherer. g_man.refresh(GUIManager.PREFERENCES_CHANGED, Gatherer.c_man.ready());713 Gatherer.refresh(Gatherer.PREFERENCES_CHANGED); 714 714 715 715 // Hide dialog -
trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java
r8784 r8813 508 508 public void setEnabled(boolean state) { 509 509 super.setEnabled(state); 510 clearSelection(); 510 511 511 // Change some colors 512 512 if(state) {
Note:
See TracChangeset
for help on using the changeset viewer.