Changeset 6051 for trunk/gli/src/org/greenstone/gatherer/gui
- Timestamp:
- 2003-11-30T21:43:23+13:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/gui
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java
r5854 r6051 65 65 */ 66 66 public class CollectionPane 67 68 69 70 private DragGroup group= null;71 72 private DragTree collection_tree= null;73 74 private WorkspaceTree workspace_tree= null;75 76 private FileQueue file_queue= null;77 78 79 80 81 82 private TreeModel collection= null;83 84 private TreeModel workspace= null;85 86 private JButton stop_action= null;87 88 private JButton new_folder= null;89 90 private JLabel collection_label= null;91 92 private JLabel filename_label= null;93 94 private JLabel status_label= null;95 96 private JLabel workspace_label= null;97 98 private JPanel collection_pane= null;99 100 private JPanel control_pane= null;101 102 private JPanel workspace_pane= null;103 104 105 106 107 108 private JSplitPane tree_pane= null;109 110 private String args[]= null;111 112 113 114 115 116 private UndoManager bin_button= null;117 118 119 120 121 122 static private Dimension MIN_SIZE= new Dimension( 90, 90);123 124 125 126 127 128 129 130 131 132 133 67 extends JPanel 68 implements ActionListener, FocusListener { 69 /** The group encompassing all of the components available as drop targets for drag and drop actions. Required so that only one component renders the ghost and higlights itself as a target, which the other members are restored to their original, pristine, condition. */ 70 private DragGroup group = null; 71 /** The tree showing the files within the collection. */ 72 private DragTree collection_tree = null; 73 /** The tree showing the available source workspace. */ 74 private WorkspaceTree workspace_tree = null; 75 /** The threaded queue that handles the actually movement of files, so that the gui remains responsive. */ 76 private FileQueue file_queue = null; 77 /** The filter currently applied to the collection tree. */ 78 private Filter collection_filter = null; 79 /** The filter currently applied to the workspace tree. */ 80 private Filter workspace_filter = null; 81 /** The collection model which is used to build, and hold the data of, the collection tree. */ 82 private TreeModel collection = null; 83 /** The GTree model used as the data source for the workspace tree. */ 84 private TreeModel workspace = null; 85 /** The button used to cancel all pending file queue jobs. */ 86 private JButton stop_action = null; 87 /** The button used to create a new folder in the collection tree. */ 88 private JButton new_folder = null; 89 /** The label shown at the top of the collection tree. */ 90 private JLabel collection_label = null; 91 /** The label shown in the status area explaining the file apon which action is taking place. */ 92 private JLabel filename_label = null; 93 /** The label shown explaining the current state of the file queue thread. */ 94 private JLabel status_label = null; 95 /** The label at the top of the workspace tree. */ 96 private JLabel workspace_label = null; 97 /** The panel that contains the collection tree. */ 98 private JPanel collection_pane = null; 99 /** The panel that contains the various controls including the status area. */ 100 private JPanel control_pane = null; 101 /** The panel that contains the workspace tree. */ 102 private JPanel workspace_pane = null; 103 /** The scrollable area into which the collection tree is placed. */ 104 private JScrollPane collection_scroll = null; 105 /** The scrollable area into which the workspace tree is placed. */ 106 private JScrollPane workspace_scroll = null; 107 /** A split pane seperating the two trees, allowing for the screen real-estate for each to be changed. */ 108 private JSplitPane tree_pane = null; 109 /** Text fragment arguments used to fill in phrases returned from the dictionary. */ 110 private String args[] = null; 111 /** Ensures that expansion and selection events between collection trees based on the same model are synchronized. */ 112 private TreeSynchronizer collection_tree_sync = null; 113 /** Ensures that expansion and selection events between workspace trees based on the same model are synchronized. */ 114 private TreeSynchronizer workspace_tree_sync = null; 115 /** The button used to delete files, which also doubles as a drop target for files from the Trees. */ 116 private UndoManager bin_button = null; 117 /** The default size of a label in the interface. */ 118 static final private Dimension LABEL_SIZE = new Dimension(100,30); 119 /** The default size of a special mapping dialog. */ 120 static final Dimension DIALOG_SIZE = new Dimension(400, 120); 121 /** The minimum size a gui component can become. */ 122 static private Dimension MIN_SIZE = new Dimension( 90, 90); 123 /** The default size of the status area. */ 124 static private Dimension STATUS_SIZE = new Dimension(450, 120); 125 /** The initial size of the trees. */ 126 static private Dimension TREE_SIZE = new Dimension(400, 430); 127 128 /* Constructor. 129 * @param tree_sync Ensures that expansion events between like trees are synchronized. 130 * @see org.greenstone.gatherer.file.FileManager 131 * @see org.greenstone.gatherer.file.FileQueue 132 */ 133 public CollectionPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizer collection_tree_sync) { 134 134 this.group = new DragGroup(); 135 135 this.file_queue = Gatherer.f_man.getQueue(); … … 149 149 new_folder.setPreferredSize(MIN_SIZE); 150 150 Dictionary.registerTooltip(new_folder, "Collection.New_Folder_Tooltip"); 151 152 153 154 151 } 152 153 /** Any implementation of ActionListener requires this method so that when an action is performed the appropriate effect can occur. In this case there are three valid possibilities. If the action occured on the recycle bin, then delete the current selection from the collection tree. If the action instead occured on the new folder button, then create a new folder under the current (single) selection in the collection tree. And finally if the cancel button was pressed, cancel the current, and remaining, jobs on the file queue. */ 154 public void actionPerformed(ActionEvent event) { 155 155 // If a user has clicked on the bin button directly remove whatever 156 156 // files are selected in the active tree. 157 157 if(event.getSource() == bin_button) { 158 158 if(!bin_button.ignore()) { 159 159 // Find the active tree (you've made selections in). 160 160 DragTree tree = (DragTree) group.getActive(); … … 164 164 TreePath paths[] = tree.getSelectionPaths(); 165 165 if(paths != null) { 166 167 166 FileNode[] source_nodes = new FileNode[paths.length]; 167 for(int i = 0; i < paths.length; i++) { 168 168 source_nodes[i] = (FileNode)(paths[i].getLastPathComponent()); 169 170 171 } 172 169 } 170 Gatherer.f_man.action(tree, source_nodes, bin_button, null); 171 } 172 } 173 173 } 174 174 // If a user has clicked on new_folder create a new folder under 175 175 // whatever node is selected. 176 176 else if(event.getSource() == new_folder && collection_tree != null) { 177 178 179 177 int count = collection_tree.getSelectionCount(); 178 boolean error = false; 179 if(count == 1) { 180 180 TreePath path = collection_tree.getSelectionPath(); 181 181 FileNode node = (FileNode) path.getLastPathComponent(); 182 182 if(node.getAllowsChildren()) { 183 183 Gatherer.f_man.newFolder(collection_tree, node); 184 184 } 185 185 else { 186 187 188 186 // try the parent 187 FileNode parent = (FileNode)node.getParent(); 188 if (parent!=null && parent.getAllowsChildren()) { 189 189 Gatherer.f_man.newFolder(collection_tree, parent); 190 190 } else { 191 191 error = true; 192 193 } 194 195 192 } 193 } 194 } 195 else { 196 196 error = true; 197 198 197 } 198 if(error) { 199 199 // instead of an error, we now create a new folder at the root 200 200 FileNode node = (FileNode) collection_tree.getModel().getRoot(); 201 201 Gatherer.f_man.newFolder(collection_tree, node); 202 202 //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.No_Parent_For_New_Folder"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 203 203 } 204 204 } 205 205 else if(event.getSource() == stop_action) { 206 207 } 208 209 210 211 212 213 214 215 216 217 218 206 file_queue.cancelAction(); 207 } 208 } 209 /** 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. 210 * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise. 211 * @see org.greenstone.gatherer.Configuration 212 * @see org.greenstone.gatherer.Gatherer 213 * @see org.greenstone.gatherer.collection.CollectionManager 214 * @see org.greenstone.gatherer.gui.Coloring 215 * @see org.greenstone.gatherer.gui.Filter 216 * @see org.greenstone.gatherer.util.TreeSynchronizer 217 */ 218 public void collectionChanged(boolean ready) { 219 219 // Try to retrieve the collections record set. 220 220 collection = Gatherer.c_man.getRecordSet(); 221 221 if(collection != null) { 222 223 224 Dictionary.registerText(collection_label, "Collection.Collection", args);225 226 227 222 //args = new String[1]; 223 //args[0] = Gatherer.c_man.getCollection().getName(); 224 Dictionary.registerText(collection_label, "Collection.Collection"); 225 collection_tree.setModel(collection); 226 collection_tree.repaint(); 227 collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false)); 228 228 } 229 229 else { 230 231 232 233 234 235 230 String args[] = new String[1]; 231 args[0] = Dictionary.get("Collection.No_Collection"); 232 Dictionary.registerText(collection_label, "Collection.Collection", args); 233 args = null; 234 collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error"))); 235 collection_filter.setBackground(Color.lightGray); 236 236 } 237 237 collection_tree.setEnabled(ready); … … 251 251 stop_action.setEnabled(ready); 252 252 new_folder.setEnabled(ready); 253 254 255 256 253 } 254 255 /** Generates the pane on controls used to 'collect' files into the collection. Resposible for creating, connecting and laying out these controls. */ 256 public void display() { 257 257 // Create Components. 258 258 KeyListenerImpl key_listener = new KeyListenerImpl(); … … 306 306 collection_pane.setSize(TREE_SIZE); 307 307 308 args = new String[1];309 args[0] = Dictionary.get("Collection.No_Collection");308 //args = new String[1]; 309 //args[0] = Dictionary.get("Collection.No_Collection"); 310 310 collection_label = new JLabel(); 311 311 collection_label.setOpaque(true); 312 Dictionary.registerText(collection_label, "Collection. Collection", args);312 Dictionary.registerText(collection_label, "Collection.No_Collection"); 313 313 314 314 collection = Gatherer.c_man.getRecordSet(); 315 315 if(collection != null) { 316 317 316 collection_tree = new DragTree(Utility.COLLECTION_TREE, collection, null, true); 317 collection_tree.setEnabled(true); 318 318 } 319 319 else { 320 321 320 collection_tree = new DragTree(Utility.COLLECTION_TREE, null, true); 321 collection_tree.setEnabled(false); 322 322 } 323 323 group.add(collection_tree); … … 340 340 collection_filter = Gatherer.g_man.getFilter(collection_tree); 341 341 if(collection != null) { 342 342 collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false)); 343 343 } 344 344 else { 345 345 collection_filter.setBackground(Color.lightGray); 346 346 } 347 347 // Change the default colours of this filters combobox. … … 427 427 this.add(tree_pane, BorderLayout.CENTER); 428 428 this.add(control_pane, BorderLayout.SOUTH); 429 430 431 429 } 430 /** This method ensures that a certain tree path is visible and selected within the collection tree, expanding nodes if necessary. If the method is successful the bounds of the new selection are returned. */ 431 public Rectangle expandPath(TreePath path) { 432 432 collection_tree.setImmediate(true); 433 433 collection_tree.scrollPathToVisible(path); … … 435 435 collection_tree.setImmediate(false); 436 436 return collection_tree.getRowBounds(collection_tree.getRowForPath(path)); 437 438 439 440 441 437 } 438 /** Called whenever this pane gains focus, this method ensures that the various tree renderers are correctly colouring the tree (as these settings sometimes get lost). 439 * @param event A <strong>FocusEvent</strong> containing details about the focus action performed. 440 */ 441 public void focusGained(FocusEvent event) { 442 442 DefaultTreeCellRenderer def = new DefaultTreeCellRenderer(); 443 443 DefaultTreeCellRenderer w = (DefaultTreeCellRenderer)workspace_tree.getCellRenderer(); 444 444 DefaultTreeCellRenderer c = (DefaultTreeCellRenderer)collection_tree.getCellRenderer(); 445 445 if(event.getSource() == workspace_tree) { 446 447 446 w.setBackgroundSelectionColor(def.getBackgroundSelectionColor()); 447 c.setBackgroundSelectionColor(Color.lightGray); 448 448 } 449 449 else if(event.getSource() == collection_tree) { 450 451 450 c.setBackgroundSelectionColor(def.getBackgroundSelectionColor()); 451 w.setBackgroundSelectionColor(Color.lightGray); 452 452 } 453 453 repaint(); 454 455 456 457 458 459 460 461 462 463 464 454 } 455 /** Implementation side-effect, not used in any way. 456 * @param event A <strong>FocusEvent</strong> containing details about the focus action performed. 457 */ 458 public void focusLost(FocusEvent event) { 459 } 460 461 /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab. 462 * @see org.greenstone.gatherer.tree.GTree 463 */ 464 public void gainFocus() { 465 465 // Update the menubar's idea of whats been selected 466 466 if (collection_tree != null) { 467 467 if (collection_tree.isSelectionEmpty()) { 468 468 Gatherer.g_man.menu_bar.setMetaAuditSuffix(null); 469 470 469 } 470 else { 471 471 Gatherer.g_man.menu_bar.setMetaAuditSuffix(collection_tree.getSelectionDetails()); 472 472 } 473 473 } 474 474 // Update the meta-audit view to show the current selection, if any. 475 475 Gatherer.g_man.meta_audit.setRecords(getSelected()); 476 477 478 479 476 } 477 478 /** Retrieve a list of the currently selected file records in the active tree. */ 479 public FileNode[] getSelected() { 480 480 TreePath paths[] = collection_tree.getSelectionPaths(); 481 481 FileNode records[] = null; 482 482 if(paths != null) { 483 484 483 records = new FileNode[paths.length]; 484 for(int i = 0; i < records.length; i++) { 485 485 records[i] = (FileNode) paths[i].getLastPathComponent(); 486 486 } 487 487 } 488 488 return records; 489 490 491 489 } 490 491 public String getSelectionDetails() { 492 492 return collection_tree.getSelectionDetails(); 493 494 495 496 497 493 } 494 495 496 public void refreshCollectionTree(int refresh_reason) 497 { 498 498 collection_tree.refresh(null); 499 500 501 502 503 499 } 500 501 502 public void refreshWorkspaceTree(int refresh_reason) 503 { 504 504 workspace_tree.refresh(refresh_reason); 505 506 507 508 509 510 511 512 513 514 505 } 506 507 508 /** Used to set the enabled state, and hence the colouring, of the two tree labels. 509 * @param label The <strong>JLabel</strong> to be affected. 510 * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise. 511 * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled. 512 * @param background The <strong>Color</strong> to make the background of the label when enabled. 513 */ 514 private void setEnabled(JLabel label, boolean state, Color foreground, Color background) { 515 515 ///ystem.err.println("Setting the label color to state " + state); 516 516 if(state) { 517 518 517 label.setBackground(background); 518 label.setForeground(foreground); 519 519 } 520 520 else { 521 522 521 label.setBackground(Color.lightGray); 522 label.setForeground(Color.black); 523 523 } 524 524 label.repaint(); 525 525 ///ystem.err.println("Color is now " + label.getBackground()); 526 } 527 528 /** When a user right-clicks within the trees on the collection pane view they are presented with a small popup menu of context based options. This class provides such functionality. 529 */ 530 private class GPopupMenu 531 extends JPopupMenu 532 implements ActionListener { 533 /** The tree over which the right click action occured. */ 534 private DragTree tree = null; 535 /** The file record over which the right click action occured, if any. */ 536 private FileNode node = null; 537 /** A menu item enabled if a delete action is appropriate in the menus current context. */ 538 private JMenuItem delete = null; 539 /** A menu item enabled if a special directory mapping is appropriate in the menus current context. */ 540 private JMenuItem map = null; 541 /** A menu item enabled if a new folder action is appropriate in the menus current context. */ 542 private JMenuItem new_folder = null; 543 /** A menu item enabled if a show meta-audit dialog action is appropriate in the menus current context. */ 544 private JMenuItem show_metaaudit = null; 545 /** A menu item allowing a user to unmap a special directory, if and only if a special directory is selected. */ 546 private JMenuItem unmap = null; 547 /** Constructor. */ 548 public GPopupMenu(DragTree tree, MouseEvent event) { 549 super(); 550 this.tree = tree; 551 TreePath path = tree.getClosestPathForLocation(event.getX(), event.getY()); 552 if(path != null) { 553 node = (FileNode)path.getLastPathComponent(); 554 // Set Options based on selection and tree 555 if(tree.getSelectionCount() != 0 && tree == collection_tree) { 556 String[] args = new String[1]; 557 args[0] = collection_tree.getSelectionDetails(); 558 show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V); 559 show_metaaudit.addActionListener(this); 560 add(show_metaaudit); 561 } 562 if(tree == collection_tree && node != null && node.getFile() != null && node.getFile().isDirectory() && !node.isReadOnly()) { 563 new_folder = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Folder"), KeyEvent.VK_N); 564 new_folder.addActionListener(this); 565 add(new_folder); 566 add(new JSeparator()); 567 } 568 if(tree == collection_tree && tree.getSelectionCount() != 0 && node != null && !node.isReadOnly()) { 569 delete = new JMenuItem(Dictionary.get("CollectionPopupMenu.Delete"), KeyEvent.VK_D); 570 delete.addActionListener(this); 571 add(delete); 572 } 573 if(tree == workspace_tree && node != null && !node.isLeaf()) { 574 String node_name = node.toString(); 575 FileNode root = (FileNode) tree.getModel().getRoot(); 576 if(!node_name.equals(Dictionary.get("Tree.World")) && !node_name.equals(Dictionary.get("Tree.Root")) && !node_name.equals(Dictionary.get("Tree.Public")) && !node_name.equals(Dictionary.get("Tree.Private"))) { 577 // You can unmap 1st level nodes. 578 if(root.getIndex(node) != -1) { 579 unmap = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_U); 580 unmap.addActionListener(this); 581 add(unmap); 526 } 527 528 /** When a user right-clicks within the trees on the collection pane view they are presented with a small popup menu of context based options. This class provides such functionality. 529 */ 530 private class GPopupMenu 531 extends JPopupMenu 532 implements ActionListener { 533 534 /** The tree over which the right click action occured. */ 535 private DragTree tree = null; 536 /** The file record over which the right click action occured, if any. */ 537 private FileNode node = null; 538 private JMenuItem collapse_expand_folder_menuitem; 539 /** A menu item enabled if a delete action is appropriate in the menus current context. */ 540 private JMenuItem delete = null; 541 /** A menu item enabled if a special directory mapping is appropriate in the menus current context. */ 542 private JMenuItem map = null; 543 /** A menu item enabled if a new folder action is appropriate in the menus current context. */ 544 private JMenuItem new_folder = null; 545 /** A menu item enabled if a show meta-audit dialog action is appropriate in the menus current context. */ 546 private JMenuItem show_metaaudit = null; 547 /** A menu item allowing a user to unmap a special directory, if and only if a special directory is selected. */ 548 private JMenuItem unmap = null; 549 private TreePath path = null; 550 /** Constructor. */ 551 public GPopupMenu(DragTree tree, MouseEvent event) { 552 super(); 553 this.tree = tree; 554 this.path = tree.getClosestPathForLocation(event.getX(), event.getY()); 555 if(path != null) { 556 node = (FileNode)path.getLastPathComponent(); 557 // Any folder node gets a menu item allowing you to collapse or expand it depending on its current status 558 if(!node.isLeaf()) { 559 // Collapse 560 if(tree.isExpanded(path)) { 561 collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C); 562 } 563 // Expand 564 else { 565 collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Expand"), KeyEvent.VK_O); 566 } 567 collapse_expand_folder_menuitem.addActionListener(this); 568 add(collapse_expand_folder_menuitem); 569 } 570 // Set Options based on selection and tree 571 if(tree.getSelectionCount() != 0 && tree == collection_tree) { 572 String[] args = new String[1]; 573 args[0] = collection_tree.getSelectionDetails(); 574 show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V); 575 show_metaaudit.addActionListener(this); 576 add(show_metaaudit); 577 } 578 if(tree == collection_tree && node != null && node.getFile() != null && node.getFile().isDirectory() && !node.isReadOnly()) { 579 new_folder = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Folder"), KeyEvent.VK_N); 580 new_folder.addActionListener(this); 581 add(new_folder); 582 add(new JSeparator()); 583 } 584 if(tree == collection_tree && tree.getSelectionCount() != 0 && node != null && !node.isReadOnly()) { 585 delete = new JMenuItem(Dictionary.get("CollectionPopupMenu.Delete"), KeyEvent.VK_D); 586 delete.addActionListener(this); 587 add(delete); 588 } 589 if(tree == workspace_tree && node != null && !node.isLeaf()) { 590 String node_name = node.toString(); 591 FileNode root = (FileNode) tree.getModel().getRoot(); 592 if(!node_name.equals(Dictionary.get("Tree.World")) && !node_name.equals(Dictionary.get("Tree.Root")) && !node_name.equals(Dictionary.get("Tree.Public")) && !node_name.equals(Dictionary.get("Tree.Private"))) { 593 // You can unmap 1st level nodes. 594 if(root.getIndex(node) != -1) { 595 unmap = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_U); 596 unmap.addActionListener(this); 597 add(unmap); 598 } 599 // Or map any other level directories. 600 else { 601 map = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_M); 602 map.addActionListener(this); 603 add(map); 604 } 605 } 606 } 607 show(tree, event.getX(), event.getY()); 608 } 582 609 } 583 // Or map any other level directories. 584 else { 585 map = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_M); 586 map.addActionListener(this); 587 add(map); 610 611 /** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */ 612 public void actionPerformed(ActionEvent event) { 613 Object source = event.getSource(); 614 if(source == delete) { 615 // Retrieve the selection. Of course this gets a bit tricky as the user may have right clicked over a node not in the current selection, in which case we remove only that node. 616 TreePath[] selection_paths = tree.getSelectionPaths(); 617 if(selection_paths != null) { 618 FileNode[] source_nodes = new FileNode[selection_paths.length]; 619 boolean found = false; 620 for(int i = 0; i < selection_paths.length; i++) { 621 source_nodes[i] = (FileNode) selection_paths[i].getLastPathComponent(); 622 if(node != null) { 623 found = found || source_nodes[i].equals(node); 624 } 625 } 626 if(node != null && !found) { 627 source_nodes = null; 628 source_nodes = new FileNode[1]; 629 source_nodes[0] = node; 630 } 631 // Fire a delete action 632 Gatherer.f_man.action(tree, source_nodes, bin_button, null); 633 source_nodes = null; 634 } 635 selection_paths = null; 636 } 637 else if(source == map && node != null) { 638 MappingPrompt mp = new MappingPrompt(node.getFile()); 639 mp.destroy(); 640 mp = null; 641 } 642 else if(source == new_folder && node != null) { 643 Gatherer.f_man.newFolder(tree, node); 644 } 645 else if(source == show_metaaudit) { 646 Gatherer.g_man.showMetaAuditBox(); 647 } 648 else if(source == unmap && node != null) { 649 Gatherer.c_man.removeDirectoryMapping(node); 650 } 651 else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) { 652 // Collapse 653 if(tree.isExpanded(path)) { 654 tree.collapsePath(path); 655 } 656 // Expand 657 else { 658 tree.expandPath(path); 659 } 660 } 588 661 } 589 } 590 } 591 show(tree, event.getX(), event.getY()); 592 } 593 } 594 /** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */ 595 public void actionPerformed(ActionEvent event) { 596 if(event.getSource() == delete) { 597 // Retrieve the selection. Of course this gets a bit tricky as the user may have right clicked over a node not in the current selection, in which case we remove only that node. 598 TreePath[] selection_paths = tree.getSelectionPaths(); 599 if(selection_paths != null) { 600 FileNode[] source_nodes = new FileNode[selection_paths.length]; 601 boolean found = false; 602 for(int i = 0; i < selection_paths.length; i++) { 603 source_nodes[i] = (FileNode) selection_paths[i].getLastPathComponent(); 604 if(node != null) { 605 found = found || source_nodes[i].equals(node); 606 } 607 } 608 if(node != null && !found) { 609 source_nodes = null; 610 source_nodes = new FileNode[1]; 611 source_nodes[0] = node; 612 } 613 // Fire a delete action 614 Gatherer.f_man.action(tree, source_nodes, bin_button, null); 615 source_nodes = null; 616 } 617 selection_paths = null; 618 } 619 else if(event.getSource() == map && node != null) { 620 MappingPrompt mp = new MappingPrompt(node.getFile()); 621 mp.destroy(); 622 mp = null; 623 } 624 else if(event.getSource() == new_folder && node != null) { 625 Gatherer.f_man.newFolder(tree, node); 626 } 627 else if(event.getSource() == show_metaaudit) { 628 Gatherer.g_man.showMetaAuditBox(); 629 } 630 else if(event.getSource() == unmap && node != null) { 631 Gatherer.c_man.removeDirectoryMapping(node); 632 } 633 } 634 } 635 636 /** This class listens for certain key presses, such as [Enter] or [Delete], and responds appropriately. */ 637 private class KeyListenerImpl 662 } 663 664 /** This class listens for certain key presses, such as [Enter] or [Delete], and responds appropriately. */ 665 private class KeyListenerImpl 638 666 extends KeyAdapter { 639 667 /** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */ 640 668 public void keyReleased(KeyEvent event) { 641 669 ///ystem.err.println("Key Release detected. " + event.getKeyCode()); 642 670 if(event.getKeyCode() == KeyEvent.VK_DELETE) { 643 671 // Get the selected files from the tree and removal them using the default dnd removal method. 644 672 // Find the active tree (you've made selections in). … … 649 677 TreePath paths[] = tree.getSelectionPaths(); 650 678 if(paths != null) { 651 652 679 FileNode[] source_nodes = new FileNode[paths.length]; 680 for(int i = 0; i < source_nodes.length; i++) { 653 681 source_nodes[i] = (FileNode) paths[i].getLastPathComponent(); 654 655 656 657 } 658 659 682 } 683 Gatherer.f_man.action(tree, source_nodes, bin_button, null); 684 source_nodes = null; 685 } 686 } 687 else if(event.getKeyCode() == KeyEvent.VK_ENTER) { 660 688 // Get the first selected file. 661 689 DragTree tree = (DragTree)event.getSource(); 662 690 TreePath path = tree.getSelectionPath(); 663 691 if(path != null) { 664 665 692 File file = ((FileNode)path.getLastPathComponent()).getFile(); 693 if(file != null && file.isFile()) { 666 694 Gatherer.self.spawnApplication(file); 667 }668 else {669 if(!tree.isExpanded(path)) {670 tree.expandPath(path);671 695 } 672 696 else { 673 tree.collapsePath(path); 697 if(!tree.isExpanded(path)) { 698 tree.expandPath(path); 674 699 } 675 } 676 } 677 } 678 } 679 } 680 681 /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */ 682 private class MappingPrompt 700 else { 701 tree.collapsePath(path); 702 } 703 } 704 } 705 } 706 } 707 } 708 709 /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */ 710 private class MappingPrompt 683 711 extends JDialog 684 712 implements ActionListener, KeyListener { … … 688 716 private JTextField name_field = null; 689 717 public MappingPrompt(File file) { 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 718 super(Gatherer.g_man); 719 setModal(true); 720 setSize(DIALOG_SIZE); 721 Dictionary.setText(this, "MappingPrompt.Title"); 722 723 // Creation 724 JPanel content_pane = (JPanel) getContentPane(); 725 JPanel center_pane = new JPanel(); 726 JPanel file_pane = new JPanel(); 727 JLabel file_label = new JLabel(); 728 file_label.setPreferredSize(LABEL_SIZE); 729 Dictionary.setText(file_label, "MappingPrompt.File"); 730 JLabel file_field = new JLabel(file.getAbsolutePath()); 731 JPanel name_pane = new JPanel(); 732 JLabel name_label = new JLabel(); 733 name_label.setPreferredSize(LABEL_SIZE); 734 Dictionary.setText(name_label, "MappingPrompt.Name"); 735 name_field = new JTextField(file.getName()); 736 JPanel button_pane = new JPanel(); 737 ok_button = new JButton(); 738 ok_button.setEnabled(name_field.getText().length() > 0); 739 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip"); 740 cancel_button = new JButton(); 741 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip"); 742 743 // Connection 744 cancel_button.addActionListener(this); 745 ok_button.addActionListener(this); 746 name_field.addKeyListener(this); 747 // Layout 748 file_pane.setLayout(new BorderLayout()); 749 file_pane.add(file_label, BorderLayout.WEST); 750 file_pane.add(file_field, BorderLayout.CENTER); 751 752 name_pane.setLayout(new BorderLayout()); 753 name_pane.add(name_label, BorderLayout.WEST); 754 name_pane.add(name_field, BorderLayout.CENTER); 755 756 center_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); 757 center_pane.setLayout(new GridLayout(2,1,5,5)); 758 center_pane.add(file_pane); 759 center_pane.add(name_pane); 760 761 button_pane.setLayout(new GridLayout(1,2,5,5)); 762 button_pane.add(ok_button); 763 button_pane.add(cancel_button); 764 765 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 766 content_pane.setLayout(new BorderLayout()); 767 content_pane.add(center_pane, BorderLayout.CENTER); 768 content_pane.add(button_pane, BorderLayout.SOUTH); 769 // Display 770 Dimension screen_size = Gatherer.config.screen_size; 771 setLocation((screen_size.width - DIALOG_SIZE.width) / 2, (screen_size.height - DIALOG_SIZE.height) / 2); 772 show(); 773 // If not cancelled create mapping. 774 if(!cancelled) { 747 775 Gatherer.c_man.addDirectoryMapping(name_field.getText(), file); 748 776 } 749 777 } 750 778 public void actionPerformed(ActionEvent event) { 751 779 if(event.getSource() == cancel_button) { 752 780 cancelled = true; 753 754 781 } 782 dispose(); 755 783 } 756 784 public void destroy() { 757 758 759 785 cancel_button = null; 786 ok_button = null; 787 name_field = null; 760 788 } 761 789 public void keyPressed(KeyEvent event) { 762 790 } 763 791 public void keyReleased(KeyEvent event) { 764 792 ok_button.setEnabled(name_field.getText().length() > 0); 765 793 766 794 } 767 795 public void keyTyped(KeyEvent event) { 768 796 } 769 770 771 797 } 798 /** This class listens for mouse clicks and responds right mouse button clicks (popup menu). */ 799 private class MouseListenerImpl 772 800 extends MouseAdapter { 773 801 /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */ 774 802 public void mouseClicked(MouseEvent event) { 775 803 if(SwingUtilities.isRightMouseButton(event)) { 776 804 new GPopupMenu((DragTree)event.getSource(), event); 777 778 } 779 805 } 806 } 807 } 780 808 } -
trunk/gli/src/org/greenstone/gatherer/gui/Filter.java
r5772 r6051 74 74 static final private Dimension SIZE = new Dimension(100,25); 75 75 /** Preprogrammed default filters. */ 76 static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^. \\.gif$)|(^.\\.bmp$)|(^.\\.tif$)"};76 static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tif$)"}; 77 77 78 78 /** Constructor. … … 129 129 } 130 130 131 /** Used to restore the filter state to enabled, the normal state during collection editing. 131 /** Used to restore the filter state to enabled, the normal state during collection editing. 132 132 * @param state The new state for the filter. <i>true</i> for enabled, <i>false</i> otherwise. 133 133 */ … … 282 282 } 283 283 /** An object that holds a filter entry. This is string used for the filter pattern and, if not custom built, its name. */ 284 private class Entry 284 private class Entry 285 285 implements Comparable { 286 286 /** The compiled pattern created from a regular expression. */ -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r6040 r6051 202 202 } 203 203 else if(esrc == menu_bar.file_options) { 204 // Just incase the user has edited the GeneralSettings of a collection without losing focus afterwards. Well I'm forever losing foc... ooh shiney. 205 config_pane.loseFocus(); 206 // And spawn a new preferences. 204 207 new Preferences(); 205 208 } … … 459 462 460 463 preview_pane = new PreviewPane(); 461 preview_pane.display(); 462 if(Gatherer.config.get("workflow.preview", true)) { 464 preview_pane.display(); 465 if(Gatherer.config.get("workflow.preview", true)) { 463 466 tab_pane.addTab("GUI.Preview", Utility.getImage("final.gif"), preview_pane); 464 467 tab_pane.setEnabledAt(tab_pane.indexOfComponent(preview_pane), false); -
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r6027 r6051 234 234 this.element = element; 235 235 // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model 236 this.value = Codec.transform(value, Codec.ENCODE_PATH); 236 this.value = Codec.transform(value, Codec.ENCODE_PATH); 237 237 this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET); 238 238 this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM); … … 335 335 if(ready) { 336 336 TreeModel collection_model = Gatherer.c_man.getRecordSet(); 337 String[] args = new String[1];338 args[0] = Gatherer.c_man.getCollection().getName();339 Dictionary.registerText(collection_label, "Collection.Collection" , args);337 //String[] args = new String[1]; 338 //args[0] = Gatherer.c_man.getCollection().getName(); 339 Dictionary.registerText(collection_label, "Collection.Collection"); 340 340 // Update label coloring. 341 341 collection_label.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false)); … … 389 389 ///atherer.println("\tCreating collection_label"); 390 390 collection_label = new JLabel(); 391 Dictionary.registerText(collection_label, "Collection. Collection");391 Dictionary.registerText(collection_label, "Collection.No_Collection"); 392 392 collection_label.setOpaque(true); 393 393 … … 972 972 973 973 974 /** Provides a popup menu to display when a right mouse button click is detected over the collection tree. */ 975 private class RightButtonMenu 976 extends JPopupMenu 977 implements ActionListener { 978 /** Constructor. 979 * @param event The <strong>MouseEvent</strong> that triggered the creation of this menu. Used to determine where the menu will be located. 980 */ 981 private RightButtonMenu(MouseEvent event) { 982 super(); 983 // Creation 984 String[] args = new String[1]; 985 args[0] = collection_tree.getSelectionDetails(); 986 JMenuItem show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V); 987 show_metaaudit.addActionListener(this); 988 add(show_metaaudit); 989 // Display 990 show(collection_tree, event.getX(), event.getY()); 991 show_metaaudit = null; 992 } 993 994 /** Called whenever a user clicks on the single menu item, view all assigned metadata. 995 * @param event An <strong>ActionEvent</strong> containing further information about the action. 996 * @see org.greenstone.gatherer.Gatherer 997 * @see org.greenstone.gatherer.gui.GUIManager 998 */ 999 public void actionPerformed(ActionEvent event) { 1000 Gatherer.g_man.showMetaAuditBox(); 1001 } 1002 } 974 /** Provides a popup menu to display when a right mouse button click is detected over the collection tree. */ 975 private class RightButtonMenu 976 extends JPopupMenu 977 implements ActionListener { 978 979 private FileNode node; 980 private JMenuItem collapse_expand_folder_menuitem; 981 private JMenuItem show_metaaudit; 982 private TreePath path; 983 984 /** Constructor. 985 * @param event The <strong>MouseEvent</strong> that triggered the creation of this menu. Used to determine where the menu will be located. 986 */ 987 private RightButtonMenu(MouseEvent event) { 988 super(); 989 this.path = collection_tree.getClosestPathForLocation(event.getX(), event.getY()); 990 this.node = (FileNode)path.getLastPathComponent(); 991 // Creation 992 // Any folder node gets a menu item allowing you to collapse or expand it depending on its current status 993 if(!node.isLeaf()) { 994 // Collapse 995 if(collection_tree.isExpanded(path)) { 996 collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C); 997 } 998 // Expand 999 else { 1000 collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Expand"), KeyEvent.VK_O); 1001 } 1002 collapse_expand_folder_menuitem.addActionListener(this); 1003 add(collapse_expand_folder_menuitem); 1004 } 1005 String[] args = new String[1]; 1006 args[0] = collection_tree.getSelectionDetails(); 1007 show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V); 1008 show_metaaudit.addActionListener(this); 1009 add(show_metaaudit); 1010 // Display 1011 show(collection_tree, event.getX(), event.getY()); 1012 show_metaaudit = null; 1013 } 1014 1015 /** Called whenever a user clicks on the single menu item, view all assigned metadata. 1016 * @param event An <strong>ActionEvent</strong> containing further information about the action. 1017 * @see org.greenstone.gatherer.Gatherer 1018 * @see org.greenstone.gatherer.gui.GUIManager 1019 */ 1020 public void actionPerformed(ActionEvent event) { 1021 Object source = event.getSource(); 1022 if(source == show_metaaudit) { 1023 Gatherer.g_man.showMetaAuditBox(); 1024 } 1025 else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) { 1026 // Collapse 1027 if(collection_tree.isExpanded(path)) { 1028 collection_tree.collapsePath(path); 1029 } 1030 // Expand 1031 else { 1032 collection_tree.expandPath(path); 1033 } 1034 } 1035 } 1036 } 1003 1037 1004 1038 -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r6041 r6051 1 /** 2 *######################################################################### 3 * 4 * A component of the Gatherer application, part of the Greenstone digital 5 * library suite from the New Zealand Digital Library Project at the 6 * University of Waikato, New Zealand. 7 * 8 * Author: John Thompson, Greenstone Digital Library, University of Waikato 9 * 10 * Copyright (C) 1999 New Zealand Digital Library Project 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 *######################################################################## 26 */ 1 27 package org.greenstone.gatherer.gui; 2 28 … … 10 36 import org.greenstone.gatherer.Dictionary; 11 37 import org.greenstone.gatherer.Gatherer; 12 import org.greenstone.gatherer.collection. CollectionConfiguration;38 import org.greenstone.gatherer.collection.BasicCollectionConfiguration; 13 39 import org.greenstone.gatherer.util.Utility; 14 40 import org.greenstone.gatherer.gui.SimpleMenuBar; … … 60 86 File metadata_directory = new File(possible_collections[i], Utility.META_DIR); 61 87 if(collect_cfg_file.exists()) { 62 CollectionConfiguration collect_cfg = newCollectionConfiguration(collect_cfg_file);88 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file); 63 89 String collection_name = collect_cfg.getName(); 64 90 // Even if there is no metadata directory we add it if its one of the 'big five + 1' that we know how to handle. … … 74 100 // Else not a collection at all. Someones pulling a fast one. 75 101 } 76 102 77 103 // Sort the result. 78 104 Collections.sort(base_collection_model); … … 135 161 cancel_button.setMnemonic(KeyEvent.VK_C); 136 162 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip"); 137 163 138 164 //ColorListener email_color_listener = new ColorListener(address, host); No more email 139 165 … … 203 229 center_pane.setLayout(new BorderLayout()); 204 230 center_pane.add(description_pane, BorderLayout.CENTER); 205 231 206 232 bottom_pane.setLayout(new BorderLayout()); 207 233 bottom_pane.add(base_collection_pane, BorderLayout.CENTER); … … 245 271 * @return the filename as a String 246 272 */ 247 public String getName() { 248 // Retrieve the first 8 non-whitespace characters of title_final. 249 StringBuffer name_buffer = new StringBuffer(""); 250 int i = 0; 251 while(i < title_final.length() && name_buffer.length() < 8) { 252 char c = title_final.charAt(i); 253 if(!Character.isWhitespace(c)) { 254 name_buffer.append(Character.toLowerCase(c)); 255 } 256 i++; 257 } 258 // We need to ensure the filename is unique 259 int counter = 0; 260 while(filenameClashes(name_buffer.toString())) { 261 counter++; 262 String suffix = String.valueOf(counter); 263 name_buffer.replace(name_buffer.length() - suffix.length(), name_buffer.length(), suffix); 264 } 265 // All done 266 return name_buffer.toString(); 267 } 273 public String getName() { 274 // Retrieve the first 8 non-whitespace characters of title_final. 275 StringBuffer name_buffer = new StringBuffer(""); 276 int i = 0; 277 while(i < title_final.length() && name_buffer.length() < 8) { 278 char c = title_final.charAt(i); 279 if(!Character.isWhitespace(c)) { 280 name_buffer.append(Character.toLowerCase(c)); 281 } 282 i++; 283 } 284 // We need to ensure the filename is unique 285 int counter = 0; 286 StringBuffer new_name_buffer = new StringBuffer(name_buffer.toString()); 287 while(filenameClashes(new_name_buffer.toString())) { 288 new_name_buffer = new StringBuffer(name_buffer.toString()); 289 counter++; 290 String suffix = String.valueOf(counter); 291 // If we have to truncate the namestring so as to fit the suffix 292 if(suffix.length() + new_name_buffer.length() > 8) { 293 new_name_buffer.replace(new_name_buffer.length() - suffix.length(), new_name_buffer.length(), suffix); 294 } 295 // Or just append it if that isn't necessary 296 else { 297 new_name_buffer.append(suffix); 298 } 299 300 } 301 // All done 302 return new_name_buffer.toString(); 303 } 268 304 269 305 private boolean filenameClashes(String filename) { … … 283 319 284 320 285 private class BrowseListener 321 private class BrowseListener 286 322 implements ActionListener { 287 323 public void actionPerformed(ActionEvent event) { … … 298 334 if(file != null) { 299 335 file = file.getParentFile(); 300 CollectionConfiguration collect_cfg = newCollectionConfiguration(new File(file, Utility.META_DIR));336 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(file, Utility.META_DIR)); 301 337 Item item = new Item(file, collect_cfg.getName()); 302 338 base_collection.addItem(item); 303 339 base_collection.setSelectedItem(item); 304 } 340 } 305 341 } 306 342 } … … 336 372 } 337 373 338 private class CreateListener 339 implements ActionListener { 374 private class CreateListener 375 implements ActionListener { 376 340 377 public void actionPerformed(ActionEvent event) { 341 // Validate. 342 title_final = title.getText(); 343 if(title_final.length() == 0) { 344 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Error"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE); 345 title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false)); 346 title.setBackground(Gatherer.config.getColor("coloring.error_background", false)); 347 return; 348 } 349 // We must ensure that the collection title is unique. This is a pain in the nether regions as we are forced to load the collect.cfg of each other collection in turn looking for a conflicting title 350 else { 351 352 353 } 378 // Validate. 379 title_final = title.getText(); 380 if(title_final.length() == 0) { 381 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Error"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE); 382 title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false)); 383 title.setBackground(Gatherer.config.getColor("coloring.error_background", false)); 384 return; 385 } 386 // We must ensure that the collection title is unique. This is a pain in the nether regions as we are forced to load the collect.cfg of each other collection in turn looking for a conflicting title 387 else { 388 File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path)); 389 File children[] = collection_directory.listFiles(); 390 for(int i = 0; children != null && i < children.length; i++) { 391 if(children[i].isDirectory()) { 392 BasicCollectionConfiguration other_collection = new BasicCollectionConfiguration(new File(children[i], Utility.CONFIG_DIR)); 393 if(other_collection.getName().equalsIgnoreCase(title_final)) { 394 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Clash"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE); 395 title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false)); 396 title.setBackground(Gatherer.config.getColor("coloring.error_background", false)); 397 return; 398 } 399 other_collection = null; 400 } 401 } 402 } 403 354 404 /* Suppress filename 355 405 name_final = file.getText(); … … 382 432 host.setForeground(Gatherer.config.getColor("coloring.error_foreground", false)); 383 433 host.setBackground(Gatherer.config.getColor("coloring.error_background", false)); 384 return; 434 return; 385 435 } 386 436 */ … … 412 462 } 413 463 414 private class Item 464 private class Item 415 465 implements Comparable { 416 466 private File file; … … 435 485 436 486 /* 437 private class RestrictedTextField 487 private class RestrictedTextField 438 488 extends JTextField { 439 489 public RestrictedTextField(RestrictedTextDocument document, String value, int cols) { … … 445 495 } 446 496 447 private class RestrictedTextDocument 497 private class RestrictedTextDocument 448 498 extends PlainDocument { 449 499 private char block[]; … … 468 518 } 469 519 } 470 public void insertString(int offs, String str, AttributeSet a) 520 public void insertString(int offs, String str, AttributeSet a) 471 521 throws BadLocationException { 472 522 // Remove any blocked characters. … … 505 555 updateFilename(); 506 556 } 507 557 508 558 ** Gives notification that a portion of the document has been removed. * 509 559 public void removeUpdate(DocumentEvent e) { -
trunk/gli/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java
r5593 r6051 48 48 import org.greenstone.gatherer.Dictionary; 49 49 import org.greenstone.gatherer.Gatherer; 50 import org.greenstone.gatherer.collection. CollectionConfiguration;50 import org.greenstone.gatherer.collection.BasicCollectionConfiguration; 51 51 import org.greenstone.gatherer.collection.CollectionManager; 52 import org.greenstone.gatherer.util.StaticStrings; 52 53 import org.greenstone.gatherer.util.Utility; 53 54 54 public class OpenCollectionDialog 55 public class OpenCollectionDialog 55 56 extends JFileChooser { 56 57 static final private ImageIcon LOCKED_COLLECTION_ICON = Utility.getImage("lcolicn.gif"); 57 58 static final private ImageIcon NORMAL_COLLECTION_ICON = Utility.getImage("ncolicn.gif"); 58 /** The name of the mouse listener that initiates editing on a double click. */ 59 /** The name of the mouse listener that initiates editing on a double click. */ 59 60 static final private String SINGLE_CLICK_LISTENER = "SingleClickListener"; 60 61 … … 81 82 } 82 83 83 public void destroy() { 84 public void destroy() { 84 85 } 85 86 … … 104 105 */ 105 106 static public void disableRename(Component c) { 106 if (c instanceof JList){ 107 if (c instanceof JList){ 107 108 EventListener[] listeners=c.getListeners(MouseListener.class); 108 109 for(int i=0; listeners != null && i < listeners.length; i++) { … … 122 123 } 123 124 } 124 } 125 } 125 126 126 127 127 128 /* The DescriptionPreview accessory is adapted from the ImagePreview.java (an example used by FileChooserDemo2.java). */ 128 private class DescriptionPreview 129 private class DescriptionPreview 129 130 extends JPanel 130 131 implements PropertyChangeListener { … … 153 154 if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) { 154 155 file = null; 155 update = true; 156 update = true; 156 157 } 157 158 // If a file became selected, find out which one. … … 170 171 File config_file = new File(file.getParentFile(), Utility.CONFIG_DIR); 171 172 if(config_file.exists()) { 172 CollectionConfiguration collect_cfg = new CollectionConfiguration(config_file); 173 BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(config_file); 174 text.setText(StaticStrings.SPEECH_CHARACTER + collect_cfg.getName() + StaticStrings.SPEECH_CHARACTER + StaticStrings.NEW_LINE_CHAR); 173 175 text.setText(collect_cfg.getDescription()); 174 176 text.setCaretPosition(0); … … 180 182 181 183 /** ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */ 182 private class GathererFilter 184 private class GathererFilter 183 185 extends FileFilter { 184 186 … … 196 198 private class GathererFileSystemView 197 199 extends FileSystemView { 198 200 199 201 private FileSystemView default_system_view = FileSystemView.getFileSystemView(); 200 202 201 203 /** Creates a new folder with a default folder name. */ 202 public File createNewFolder(File containingDir) 204 public File createNewFolder(File containingDir) 203 205 throws IOException { 204 206 return default_system_view.createNewFolder(containingDir); 205 } 207 } 206 208 207 209 /** Gets the list of shown (i.e. */ -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r5847 r6051 13 13 import org.greenstone.gatherer.checklist.CheckList; 14 14 import org.greenstone.gatherer.checklist.Entry; 15 import org.greenstone.gatherer.gui.EmailField; 15 16 import org.greenstone.gatherer.gui.ModalDialog; 16 17 import org.greenstone.gatherer.gui.SimpleMenuBar; … … 24 25 25 26 private CheckList warning_preferences_check_list; 27 private EmailField email_field; 26 28 private JButton apply_button; 27 29 private JButton cancel_button; … … 39 41 private JCheckBox workflow_preview; 40 42 private JComboBox language_combobox; 43 private JLabel email_label; 41 44 private JLabel language_label; 42 45 private JLabel library_path_label; … … 51 54 private Preferences self; 52 55 53 static final Dimension LABEL_SIZE = new Dimension(1 50, 25);56 static final Dimension LABEL_SIZE = new Dimension(175, 25); 54 57 static final Dimension ROW_SIZE = new Dimension(640, 25); 55 58 static final Dimension SIZE = new Dimension(640, 345); … … 136 139 proxy_host_label = new JLabel(); 137 140 proxy_host_label.setPreferredSize(LABEL_SIZE); 138 Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host"); 141 Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host"); 139 142 proxy_host_field = new JTextField(Gatherer.config.getString("general.proxy_host", true)); 140 143 proxy_host_field.setEnabled(currently_enabled); … … 227 230 classes_folder = null; 228 231 232 // Users email 233 JPanel email_pane = new JPanel(); 234 email_label = new JLabel(); 235 email_label.setPreferredSize(LABEL_SIZE); 236 Dictionary.registerText(email_label, "Preferences.General.Email"); 237 email_field = new EmailField(Gatherer.config.getColor("coloring.error_background", false)); 238 email_field.setText(Gatherer.config.getEmail()); 239 Dictionary.registerTooltip(email_field, "Preferences.General.Email_Tooltip"); 240 229 241 // Extracted metadata 230 242 view_extracted_metadata_checkbox = new JCheckBox(); … … 255 267 256 268 // Layout 269 email_pane.setLayout(new BorderLayout()); 270 email_pane.add(email_label, BorderLayout.WEST); 271 email_pane.add(email_field, BorderLayout.CENTER); 272 257 273 language_pane.setLayout(new BorderLayout()); 258 274 language_pane.add(language_label, BorderLayout.WEST); … … 261 277 general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 262 278 general_pane.setLayout(new GridLayout(5,1,0,5)); 279 general_pane.add(email_pane); 280 general_pane.add(language_pane); 263 281 general_pane.add(view_extracted_metadata_checkbox); 264 282 general_pane.add(show_file_size_checkbox); 265 general_pane.add(language_pane);266 283 267 284 return general_pane; … … 399 416 400 417 public void dispose() { 401 // Dispose 402 super.dispose(); 418 // Where's my code for unregistering all of the components?!? 419 420 // Dispose 421 super.dispose(); 403 422 } 404 423 … … 428 447 429 448 // General preferences 449 Gatherer.config.setEmail(email_field.getText()); 450 430 451 Gatherer.config.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected()); 431 452 Gatherer.g_man.refreshTrees(DragTree.TREE_DISPLAY_CHANGED); … … 472 493 } 473 494 474 private class DictionaryEntry 495 private class DictionaryEntry 475 496 implements Comparable { 476 497 private Locale locale; … … 526 547 workflow_design.setSelected(element.getEnabled("design")); 527 548 workflow_export.setSelected(element.getEnabled("export")); 528 workflow_preview.setSelected(element.getEnabled("preview")); 549 workflow_preview.setSelected(element.getEnabled("preview")); 529 550 } 530 551 } … … 570 591 public String toString() { 571 592 if(text == null) { 572 text = element.getFirstChild().getNodeValue(); 593 text = element.getFirstChild().getNodeValue(); 573 594 } 574 595 return text; -
trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java
r5815 r6051 49 49 50 50 public class PreviewPane 51 52 53 54 private int back_count= 0;55 56 private JButton back= null;57 private JButton forward= null;58 private JButton home= null;59 60 private JLabel status= null;61 62 63 64 65 66 51 extends JPanel { 52 53 private CalHTMLPane view = null; 54 private int back_count = 0; 55 private int forward_count = 0; 56 private JButton back = null; 57 private JButton forward = null; 58 private JButton home = null; 59 private JButton reload = null; 60 private JLabel status = null; 61 private Observer observer = null; 62 private URL homepage = null; 63 64 static final public String BLANK_PAGE = "<html><head><title>No Page</title></head><body></body></html>"; 65 66 public PreviewPane() { 67 67 super(); 68 68 … … 95 95 96 96 status = new JLabel(); 97 Dictionary.registerText(status, "Browser.Ready"); 98 99 100 97 Dictionary.registerText(status, "Browser.Ready"); 98 } 99 100 public void collectionChanged(boolean ready) { 101 101 // If we were showing a page, but that page is no longer available, then return to a blank page 102 102 if(!ready && homepage != null) { 103 104 103 homepage = null; 104 view.showHTMLDocument(BLANK_PAGE); 105 105 } 106 106 if (ready && Gatherer.config.exec_address != null) { 107 108 107 // reload the home page for the current collection 108 try { 109 109 // Now load the collection 110 Collection this_coll = Gatherer.c_man.getCollection(); 110 Collection this_collection = Gatherer.c_man.getCollection(); 111 String search_types = this_collection.cdm.searchtype_manager.getSearchTypes(); 111 112 String extra_args = ""; 112 String build_type = this_coll.getCollectionType(); 113 if (build_type.equals("mgpp")) { 114 // we need some more args on the url 115 String search_types = this_coll.getSearchTypes(); 116 if (search_types.equals("")) { 117 extra_args = "&ct=1&qt=0&qto=3"; 118 } else if (search_types.equals("plain")) { 119 extra_args = "&ct=1&qt=0&qto=1"; 120 } else if (search_types.equals("form")) { 121 extra_args = "&ct=1&qt=1&qto=2"; 122 } else if (search_types.equals("plain,form")) { 123 extra_args = "&ct=1&qt=0&qto=3"; 124 } else if (search_types.equals("form,plain")) { 125 extra_args = "&ct=1&qt=1&qto=3"; 126 } 127 } 128 129 homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + this_coll.getName()+extra_args); 113 if (search_types.length() > 0) { 114 // we need some more args on the url 115 if (search_types.equals("")) { 116 extra_args = "&ct=1&qt=0&qto=3"; 117 } else if (search_types.equals("plain")) { 118 extra_args = "&ct=1&qt=0&qto=1"; 119 } else if (search_types.equals("form")) { 120 extra_args = "&ct=1&qt=1&qto=2"; 121 } else if (search_types.equals("plain,form")) { 122 extra_args = "&ct=1&qt=0&qto=3"; 123 } else if (search_types.equals("form,plain")) { 124 extra_args = "&ct=1&qt=1&qto=3"; 125 } 126 } 127 128 homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + this_collection.getName() + extra_args); 130 129 String[] args = new String[1]; 131 130 args[0] = homepage.toString(); 132 131 Dictionary.registerText(status, "Browser.Loading", args); 133 132 view.showHTMLDocument(homepage, null, true); 134 135 133 } 134 catch (MalformedURLException exception) { 136 135 Gatherer.printStackTrace(exception); 137 138 } 139 140 141 136 } 137 } 138 } 139 140 public void display() { 142 141 JPanel control_pane = new JPanel(); 143 142 control_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0)); … … 157 156 add(a_panel, BorderLayout.CENTER); 158 157 add(status, BorderLayout.SOUTH); 159 160 161 162 163 158 } 159 160 /** This method is called when the user selects the 'Preview' tab from the views bar. Can be used to display a particular page or perform some other relevant tests (ensure internet connection to specified server maybe?) 161 */ 162 public void gainFocus() { 164 163 if(Gatherer.c_man.ready() && Gatherer.c_man.built()) { 165 164 if(homepage == null && Gatherer.config.exec_address != null) { 166 165 try { 167 168 169 170 171 172 166 // Now load the collection 167 homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName()); 168 String[] args = new String[1]; 169 args[0] = homepage.toString(); 170 Dictionary.registerText(status, "Browser.Loading", args); 171 view.showHTMLDocument(homepage); 173 172 } 174 173 catch (MalformedURLException exception) { 175 176 } 177 174 Gatherer.printStackTrace(exception); 175 } 176 } 178 177 } 179 178 validate(); 180 181 182 179 } 180 181 public void configServer(String command) { 183 182 try { 184 185 186 187 188 189 190 183 String url = Gatherer.config.exec_address.toString() + command; 184 ///ystem.err.println("Action: " + url); 185 view.setLoadSynchronously(true); 186 view.showHTMLDocument(new URL(url)); 187 view.setLoadSynchronously(false); 188 ///ystem.err.println("Complete."); 189 url = null; 191 190 } 192 191 catch(Exception error) { 193 194 } 195 196 197 192 ///ystem.err.println("Bad URL."); 193 } 194 } 195 196 public void validate() { 198 197 back.setEnabled(back_count > 0); 199 198 home.setEnabled(homepage != null); 200 199 forward.setEnabled(forward_count > 0); 201 200 reload.setEnabled(homepage != null); 202 203 204 201 } 202 203 private class BackListener 205 204 implements ActionListener { 206 205 public void actionPerformed(ActionEvent event) { 207 208 209 210 211 } 212 213 214 206 view.goBack(); 207 back_count--; 208 forward_count++; 209 validate(); 210 } 211 } 212 213 private class ForwardListener 215 214 implements ActionListener { 216 215 public void actionPerformed(ActionEvent event) { 217 218 219 220 221 } 222 223 224 216 view.goForward(); 217 back_count++; 218 forward_count--; 219 validate(); 220 } 221 } 222 223 private class HomeListener 225 224 implements ActionListener { 226 225 public void actionPerformed(ActionEvent event) { 227 228 229 230 231 } 232 233 234 226 view.showHTMLDocument(homepage); 227 back_count++; 228 forward_count = 0; 229 validate(); 230 } 231 } 232 233 private class ReloadListener 235 234 implements ActionListener { 236 235 public void actionPerformed(ActionEvent event) { 237 238 } 239 240 241 236 view.reloadDocument(); 237 } 238 } 239 240 private class Observer 242 241 extends DefaultCalHTMLObserver { 243 242 public int state = CalCons.DOC_LOADED; 244 243 public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) { 245 246 247 244 back_count++; 245 forward_count = 0; 246 validate(); 248 247 } 249 248 250 249 public void linkFocusUpdate(CalHTMLPane pane, URL url) { 251 252 253 250 String[] args = new String[1]; 251 args[0] = url.toString(); 252 Dictionary.registerText(status, "Browser.Follow", args); 254 253 } 255 254 256 255 public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) { 257 258 259 260 261 256 this.state = state; 257 String[] args = new String[1]; 258 args[0] = url.toString(); 259 260 switch(state) { 262 261 // The Pane is attempting to connect to the given URL to receive data. 263 262 case CalCons.PRE_CONNECT: 264 263 ///ystem.err.println("Preconnect: " + state + " - " + message); 265 264 break; 266 265 // The Pane was unable to connect to the given URL or was unable to parse the content. Most likely this will be due to an incorrectly specified URL. The message argument may contain further details of the reason for failure. 267 266 case CalCons.PARSE_FAILED: 268 267 ///ystem.err.println("Parse Failed: " + state + " - " + message); 269 268 Dictionary.registerText(status, "Browser.CannotConnect", args); 270 269 break; 271 270 // The Pane has established a connection to the given URL and is receiving any content. 272 271 case CalCons.CONNECTED: 273 272 ///ystem.err.println("Connected: " + state + " - " + message); 274 273 Dictionary.registerText(status, "Browser.Loading", args); 275 274 break; 276 275 // The size of the content at the given URL is known and is contained in the value argument. 277 276 case CalCons.DOC_LENGTH: 278 277 ///ystem.err.println("Doc Length: " + state + " - " + message); 279 278 break; 280 279 // The title of the document for the given URL is known and is contained in the message argument. Only the title of a document in the Pane's top level frame will be sent to this method. If the document has no name, the message will be null, unless the document is a Frameset document in which case the message "Frameset" will be sent. 281 280 case CalCons.TITLE: 282 281 ///ystem.err.println("Title: " + state + " - " + message); 283 282 break; 284 283 // An exception has been thrown during parsing of the data from the URL. This will most likely be an IOException such as a server time-out. 285 284 case CalCons.PARSE_FAILED_POST_CONNECT: 286 285 ///ystem.err.println("Parse Failed Post Connect: " + state + " - " + message); 287 286 Dictionary.registerText(status, "Browser.TimedOut", args); 288 287 break; 289 288 // The document has been parsed but formatting cannot be completed because the document contains images of unspecified size. The parsing thread is waiting for image updates to give it the information it needs to format and display the document. 290 289 case CalCons.WAITING_FOR_IMAGES: 291 290 ///ystem.err.println("Waiting For Images: " + state + " - " + message + " - " + url.toString()); 292 291 break; 293 292 // All text and image data has been received, parsed and the document structure determined. 294 293 case CalCons.DOC_LOADED: 295 294 ///ystem.err.println("Doc Loaded: " + state + " - " + message); 296 295 Dictionary.registerText(status, "Browser.Ready"); 297 296 break; 298 299 } 300 297 } 298 } 299 } 301 300 } -
trunk/gli/src/org/greenstone/gatherer/gui/SimpleOpenCollectionDialog.java
r5939 r6051 35 35 import org.greenstone.gatherer.Dictionary; 36 36 import org.greenstone.gatherer.Gatherer; 37 import org.greenstone.gatherer.collection. CollectionConfiguration;37 import org.greenstone.gatherer.collection.BasicCollectionConfiguration; 38 38 import org.greenstone.gatherer.gui.ModalDialog; 39 39 import org.greenstone.gatherer.util.StaticStrings; … … 71 71 72 72 JPanel center_pane = new JPanel(); 73 73 74 74 JPanel collection_list_pane = new JPanel(); 75 75 JLabel collection_list_label = new JLabel(); … … 155 155 private class AdvancedListener 156 156 implements ActionListener { 157 157 158 158 public void actionPerformed(ActionEvent event) { 159 159 result = BROWSE_OPTION; … … 164 164 private class CancelListener 165 165 implements ActionListener { 166 166 167 167 public void actionPerformed(ActionEvent event) { 168 168 result = CANCEL_OPTION; 169 169 SimpleOpenCollectionDialog.this.dispose(); 170 170 } 171 } 171 } 172 172 173 173 private class CollectionListSelectionListener … … 192 192 } 193 193 else { 194 CollectionConfiguration collection_configuration = (CollectionConfiguration) collection_list.getSelectedValue();194 BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration) collection_list.getSelectedValue(); 195 195 description_textarea.setText(collection_configuration.getDescription()); 196 196 description_textarea.setCaretPosition(0); … … 214 214 String collection_foldername = collection_folder.getName(); 215 215 if(!collection_folder.isFile() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) { 216 CollectionConfiguration collection_configuration = newCollectionConfiguration(new File(collection_folder, Utility.CONFIG_DIR));216 BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(new File(collection_folder, Utility.CONFIG_DIR)); 217 217 if(!collection_configuration.getName().equals(StaticStrings.ERROR_STR)) { 218 218 data.add(collection_configuration); … … 247 247 private class OpenListener 248 248 implements ActionListener { 249 249 250 250 public void actionPerformed(ActionEvent event) { 251 251 result = OK_OPTION; 252 CollectionConfiguration collection_configuration = (CollectionConfiguration) collection_list.getSelectedValue();252 BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration) collection_list.getSelectedValue(); 253 253 File collect_cfg_file = collection_configuration.getFile(); 254 254 File etc_folder = collect_cfg_file.getParentFile(); … … 261 261 SimpleOpenCollectionDialog.this.dispose(); 262 262 } 263 } 263 } 264 264 } -
trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java
r6028 r6051 50 50 * @version 2.3b 51 51 */ 52 public class GTableModel 53 extends AbstractTableModel 52 public class GTableModel 53 extends AbstractTableModel 54 54 implements MSMListener { 55 55 … … 70 70 // Register this model with the msm manager. 71 71 if (Gatherer.c_man.ready()) { 72 Gatherer.c_man.getCollection().msm.addMSMListener(this); 72 Gatherer.c_man.getCollection().msm.addMSMListener(this); 73 73 } 74 74 } … … 200 200 // Ensure the position is within the current metadata 201 201 if (i >= current_metadata.size()) { 202 i = current_metadata.size() - 1;202 i = current_metadata.size() - 1; 203 203 } 204 204 205 205 // Select the same row as before, except if it would select a different element 206 206 ElementWrapper element = metadatum.getElement(); 207 if(i < 0) { 208 Gatherer.println("Could not find suitable row to select!"); 209 return; 210 } 207 211 Metadata newly_selected_metadatum = (Metadata) current_metadata.get(i); 208 212 if (!newly_selected_metadatum.getElement().equals(element)) { 209 // Try one row previous 210 i--; 211 newly_selected_metadatum = (Metadata) current_metadata.get(i); 212 if (!newly_selected_metadatum.getElement().equals(element)) { 213 Gatherer.println("Could not find suitable row to select!"); 214 return; 215 } 213 // Try one row previous 214 i--; 215 if(i < 0) { 216 Gatherer.println("Could not find suitable row to select!"); 217 return; 218 } 219 220 newly_selected_metadatum = (Metadata) current_metadata.get(i); 221 if (!newly_selected_metadatum.getElement().equals(element)) { 222 Gatherer.println("Could not find suitable row to select!"); 223 return; 224 } 216 225 } 217 226 … … 298 307 /** Determine if the given metadata is common to all selected file nodes given the context of the current view. */ 299 308 public boolean isCommon(Metadata entry) { 300 return (entry.getCount() == file_nodes.length);309 return (entry.getCount() >= file_nodes.length); 301 310 } 302 311 303 312 /** Determine if the given metadata is common to all selected file nodes given the context of the current view. */ 304 313 public boolean isCommon(int row) { … … 352 361 showInheritedMetadataWarning(); 353 362 } 354 363 355 364 // If the piece of metadata is in the list, increment its count 356 365 int index = current_metadata.indexOf(metadatum); … … 364 373 index = add(current_metadata, metadatum); 365 374 fireTableRowsInserted(index, index); 366 375 367 376 // Remember we have seen this element 368 377 if (known_elements.contains(element) == false) { -
trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTreeCellRenderer.java
r5915 r6051 46 46 import org.greenstone.gatherer.util.Utility; 47 47 48 public class DragTreeCellRenderer 48 public class DragTreeCellRenderer 49 49 extends DefaultTreeCellRenderer { 50 50 51 51 private boolean in_focus = false; 52 52 private Color selection_background; 53 53 private Color selection_foreground; 54 55 static final private ImageIcon GREY_FOLDER = Utility.getImage("greyfolder.gif", true);56 static final private ImageIcon GREEN_FILE = Utility.getImage("greenfile.gif", true);57 static final private ImageIcon GREEN_FOLDER = Utility.getImage("greenfolder.gif", true);54 55 //static final private ImageIcon GREY_FOLDER = Utility.getImage("greyfolder.gif", true); 56 //static final private ImageIcon GREEN_FILE = Utility.getImage("greenfile.gif", true); 57 //static final private ImageIcon GREEN_FOLDER = Utility.getImage("greenfolder.gif", true); 58 58 59 59 public DragTreeCellRenderer() { … … 74 74 if(value instanceof FileNode) { 75 75 FileNode node = (FileNode) value; 76 76 77 77 String new_value = null; 78 78 if(Gatherer.config.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC) && node.getFile() != null && !node.getAllowsChildren()) { … … 85 85 tree_cell = (JLabel) super.getTreeCellRendererComponent(tree, new_value, sel, expanded, leaf, row, hasFocus); 86 86 87 /* 87 88 if(node.getFile() == null || node.isFileSystemRoot()) { 88 ((JLabel)tree_cell).setIcon(GREY_FOLDER);89 ((JLabel)tree_cell).setIcon(GREY_FOLDER); 89 90 } 90 91 else if(node.isInCurrentCollection()) { 91 if(!node.getFile().isFile()) {92 if(!node.getFile().isFile()) { 92 93 ((JLabel)tree_cell).setIcon(GREEN_FOLDER); 93 }94 else {94 } 95 else { 95 96 ((JLabel)tree_cell).setIcon(GREEN_FILE); 96 }97 } 97 98 } 99 */ 98 100 } 99 101 else { … … 102 104 return tree_cell; 103 105 } 104 106 105 107 public void loseFocus() { 106 108 setBackgroundSelectionColor(Color.lightGray);
Note:
See TracChangeset
for help on using the changeset viewer.