Changeset 5564 for trunk/gli/src
- Timestamp:
- 2003-10-03T14:07:35+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Configuration.java
r5529 r5564 43 43 import javax.swing.*; 44 44 import javax.swing.plaf.*; 45 import org.greenstone.gatherer.Message;46 45 import org.greenstone.gatherer.cdm.Language; 47 46 import org.greenstone.gatherer.gui.Coloring; -
trunk/gli/src/org/greenstone/gatherer/Dictionary.java
r5536 r5564 235 235 236 236 237 static public String newget(String key, String arg) 238 { 239 String[] args = new String[1]; 240 args[0] = arg; 241 return self.get(key, args); 242 } 243 244 237 245 static public String newget(String key, String[] args) 238 246 { -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r5316 r5564 210 210 211 211 // Having loaded the configuration (necessary to determine if certain warnings have been disabled) and dictionary, we now check if the necessary path variables have been provided. 212 213 212 if(config.exec_file == null && config.exec_address == null) { 214 213 if(config.exec_file == null) { … … 263 262 size.height = config.screen_size.height; 264 263 } 265 264 // Set default font 266 265 setUIFont(config.getFont("general.font", true), config.getFont("general.tooltip_font", true)); 267 266 // Set up proxy 268 267 setProxy(); 269 268 // Now we set up an Authenticator 270 269 Authenticator.setDefault(new GAuthenticator()); 271 270 272 271 assoc_man = new FileAssociationManager(); 273 272 // Create File Manager 274 273 f_man = new FileManager(); 275 274 // Create Collection Manager 276 275 c_man = new CollectionManager(); 277 276 // If there was an open collection last session, reopen it. 278 277 if(open_collection == null) { 279 278 open_collection = config.getString("general.open_collection", true); … … 282 281 c_man.loadCollection(open_collection); 283 282 } 284 283 // Create GUI Manager (last) or else suffer the death of a thousand NPE's 285 284 splash.toFront(); 286 285 g_man = new GUIManager(size); … … 302 301 // The 'after-display' triggers several events which don't occur until after the visual components are actually available on screen. Examples of these would be the various html renderings, as they can't happen offscreen. 303 302 g_man.afterDisplay(); 304 303 // Hide the splash. 305 304 splash.hide(); 306 305 splash.destroy(); … … 326 325 config.setString("general.open_collection", true, null); 327 326 if(c_man.ready()) { 328 327 ///ystem.err.println("Collection open."); 329 328 if(c_man.saved()) { 330 329 ///ystem.err.println("Collection has been recently saved, so I'll remember it for next time."); … … 368 367 } 369 368 else { 370 JOptionPane.showMessageDialog(g_man, get("General.Outstanding_Processes"),get("General.Outstanding_Processes_Title"), JOptionPane.ERROR_MESSAGE);369 JOptionPane.showMessageDialog(g_man, Dictionary.newget("General.Outstanding_Processes"), Dictionary.newget("General.Outstanding_Processes_Title"), JOptionPane.ERROR_MESSAGE); 371 370 g_man.hide(); 372 371 } 373 372 } 374 /** Overloaded to call get with both a key and an empty argument array. 375 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle. 376 * @return A <strong>String</strong> which has been referenced by the key String and that either contains no argument fields, or has had the argument fields automatiically populated with formatting Strings of with argument String provided in the get call. 377 */ 378 public String get(String key) { 379 return dictionary.get(key, (String[])null); 380 } 381 /** Overloaded to call get with both a key and an argument array with one element. 382 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle. 383 * @param arg A single argument as a <strong>String</strong>. 384 * @return A <strong>String</strong> which has been referenced by the key String and that either contains no argument fields, or has had the argument fields automatiically populated with formatting Strings of with argument String provided in the get call. 385 */ 386 public String get(String key, String arg) { 387 String args[] = new String[1]; 388 args[0] = arg; 389 return dictionary.get(key, args); 390 } 391 /** Used to retrieve a property value from the Locale specific ResourceBundle, based upon the key and arguments supplied. If the key cannot be found or if some other part of the call fails a default (English) error message is returned. <BR> 392 * Here the get recieves a second argument which is an array of Strings used to populate argument fields, denoted {<I>n</I>}, within the value String returned. Note that argument numbers greater than or equal to 32 are automatically mapped to the formatting String named Farg<I>n</I>. 393 * @param key A <strong>String</strong> which is mapped to a initial String within the ResourceBundle. 394 * @param args A <strong>String[]</strong> used to populate argument fields within the complete String. 395 * @return A <strong>String</strong> which has been referenced by the key String and that either contains no argument fields, or has had the argument fields automatically populated with formatting Strings of with argument String provided in the get call. 396 * @see org.greenstone.gatherer.Gatherer 397 * @see org.greenstone.gatherer.Dictionary 398 */ 399 public String get(String key, String args[]) { 400 return dictionary.get(key, args); 401 } 373 402 374 /** Retrieve the metadata directory, as required by any MSMCaller implementation. 403 375 * @return The currently active collection metadata directory as a <strong>String</strong>. … … 405 377 */ 406 378 public String getCollectionMetadata() { 407 if (c_man != null && c_man.ready()) {379 if (c_man != null && c_man.ready()) { 408 380 return c_man.getCollectionMetadata(); 409 381 } 410 382 return ""; 411 383 } 384 412 385 /** Retrieve a reference to the frame that any dialog boxes will appear relative to, as required by any MSMCaller or CDMCaller implementation. 413 386 * @return A <strong>JFrame</strong>. … … 417 390 return g_man; 418 391 } 392 419 393 /** Method to retrieve a reference to the metadata set manager class. This is then used to create the 'metadataset' commands in the collection configuration file. 420 394 * @return A reference to the <Strong>MetadataSetManager</strong>. … … 440 414 } 441 415 else { 442 416 ///ystem.err.println("No open command available."); 443 417 } 444 418 } … … 590 564 } 591 565 // Otherwise its fine as it is 592 566 } 593 567 } 594 568 } … … 613 587 dialog.dispose(); 614 588 dialog = null; 615 ///ystem.out.println( dictionary.get("General.Missing_EXEC"));589 ///ystem.out.println(Dictionary.newget("General.Missing_EXEC")); 616 590 } 617 591 … … 623 597 dialog.dispose(); 624 598 dialog = null; 625 ///ystem.out.println( dictionary.get("General.Missing_GSDL"));599 ///ystem.out.println(Dictionary.newget("General.Missing_GSDL")); 626 600 } 627 601 … … 632 606 dialog.dispose(); 633 607 dialog = null; 634 ///ystem.out.println( dictionary.get("General.Missing_PERL"));608 ///ystem.out.println(Dictionary.newget("General.Missing_PERL")); 635 609 } 636 610 … … 653 627 */ 654 628 static public void printUsage(Dictionary dictionary) { 655 System.out.println( dictionary.get("General.Usage"));629 System.out.println(Dictionary.newget("General.Usage")); 656 630 } 657 631 … … 742 716 743 717 private void startServerEXE() { 744 if(config.exec_file != null && config.exec_address == null && Utility.isWindows()) { 745 // First of all we create a GSDLSiteCFG object and check if a URL is already present, in which case the server is already running. 746 gsdlsite_cfg = new GSDLSiteConfig(config.exec_file); 747 String url = gsdlsite_cfg.getURL(); 748 // If its already running then set exec address. 749 if(url != null) { 750 try { 751 config.exec_address = new URL(url); 752 } 753 catch(Exception error) { 754 } 718 if(config.exec_file != null && config.exec_address == null && Utility.isWindows()) { 719 // First of all we create a GSDLSiteCFG object and check if a URL is already present, in which case the server is already running. 720 gsdlsite_cfg = new GSDLSiteConfig(config.exec_file); 721 String url = gsdlsite_cfg.getURL(); 722 // If its already running then set exec address. 723 if(url != null) { 724 try { 725 config.exec_address = new URL(url); 726 } 727 catch(Exception error) { 728 } 729 } 730 // Otherwise its time to run the server in a spawned process. 731 if(config.exec_address == null && config.exec_file.exists()) { 732 // Configure for immediate entry. Note that this only works if the gsdlsite.cfg file exists. 733 gsdlsite_cfg.set(); 734 // Spawn server 735 String command = config.exec_file.getAbsolutePath() + " " + gsdlsite_cfg.getSiteConfigFilename(); 736 server = new ExternalApplication(command); 737 server.start(); 738 command = null; 739 // Now we have to wait until program has started. We do this by reloading and checking 740 ///ystem.err.print("Waiting until the local library has loaded"); 741 try { 742 gsdlsite_cfg.load(); 743 744 int try_again = JOptionPane.YES_OPTION; 745 int attempt_count = 0; 746 while(gsdlsite_cfg.getURL() == null && try_again == JOptionPane.YES_OPTION) { 747 ///ystem.err.print("."); 748 if(attempt_count == 60) { 749 try_again = JOptionPane.showConfirmDialog(Gatherer.g_man, Dictionary.newget("Server.QuitTimeOut"), Dictionary.newget("General.Warning"), JOptionPane.YES_NO_OPTION); 750 } 751 else { 752 synchronized(this) { 753 wait(1000); // Wait one second (give or take) 754 } 755 gsdlsite_cfg.load(); 756 attempt_count++; 757 } 755 758 } 756 // Otherwise its time to run the server in a spawned process. 757 if(config.exec_address == null && config.exec_file.exists()) { 758 // Configure for immediate entry. Note that this only works if the gsdlsite.cfg file exists. 759 gsdlsite_cfg.set(); 760 // Spawn server 761 String command = config.exec_file.getAbsolutePath() + " " + gsdlsite_cfg.getSiteConfigFilename(); 762 server = new ExternalApplication(command); 763 server.start(); 764 command = null; 765 // Now we have to wait until program has started. We do this by reloading and checking 766 ///ystem.err.print("Waiting until the local library has loaded"); 767 try { 768 gsdlsite_cfg.load(); 769 770 int try_again = JOptionPane.YES_OPTION; 771 int attempt_count = 0; 772 while(gsdlsite_cfg.getURL() == null && try_again == JOptionPane.YES_OPTION) { 773 ///ystem.err.print("."); 774 if(attempt_count == 60) { 775 try_again = JOptionPane.showConfirmDialog(Gatherer.g_man, dictionary.get("Server.QuitTimeOut"), dictionary.get("General.Warning"), JOptionPane.YES_NO_OPTION); 776 } 777 else { 778 synchronized(this) { 779 wait(1000); // Wait one second (give or take) 780 } 781 gsdlsite_cfg.load(); 782 attempt_count++; 783 } 784 } 785 786 if((url = gsdlsite_cfg.getURL()) != null) { 787 // Ta-da. Now the url should be available. 788 config.exec_address = new URL(url); 789 790 // A quick test involves opening a connection to get the home page for this collection. If this fails then we try changing the url to be localhost. 791 try { 792 Gatherer.println("Try connecting to server on config url: '" + config.exec_address + "'"); 793 URLConnection connection = config.exec_address.openConnection(); 794 connection.getContent(); 795 } 796 catch(IOException bad_url_connection) { 797 try { 798 Gatherer.println("Try connecting to server on local host: '" + gsdlsite_cfg.getLocalHostURL() + "'"); 799 config.exec_address = new URL(gsdlsite_cfg.getLocalHostURL ()); 800 URLConnection connection = config.exec_address.openConnection(); 801 connection.getContent(); 802 } 803 catch(IOException worse_url_connection) { 804 Gatherer.println("Can't connect to server on either address."); 805 config.exec_address = null; 806 config.exec_file = null; 807 } 808 } 809 } 810 // Unable to start local library. Show appropriate message. 811 else { 812 missingEXEC(dictionary); 813 } 814 } 815 catch (Exception error) { 816 error.printStackTrace(); 817 } 818 } 759 760 if((url = gsdlsite_cfg.getURL()) != null) { 761 // Ta-da. Now the url should be available. 762 config.exec_address = new URL(url); 763 764 // A quick test involves opening a connection to get the home page for this collection. If this fails then we try changing the url to be localhost. 765 try { 766 Gatherer.println("Try connecting to server on config url: '" + config.exec_address + "'"); 767 URLConnection connection = config.exec_address.openConnection(); 768 connection.getContent(); 769 } 770 catch(IOException bad_url_connection) { 771 try { 772 Gatherer.println("Try connecting to server on local host: '" + gsdlsite_cfg.getLocalHostURL() + "'"); 773 config.exec_address = new URL(gsdlsite_cfg.getLocalHostURL ()); 774 URLConnection connection = config.exec_address.openConnection(); 775 connection.getContent(); 776 } 777 catch(IOException worse_url_connection) { 778 Gatherer.println("Can't connect to server on either address."); 779 config.exec_address = null; 780 config.exec_file = null; 781 } 782 } 783 } 784 // Unable to start local library. Show appropriate message. 785 else { 786 missingEXEC(dictionary); 787 } 788 } 789 catch (Exception error) { 790 error.printStackTrace(); 791 } 792 } 819 793 // Can't do a damb thing. 820 821 794 } 795 Gatherer.println("Having started server.exe, exec_address is: " + config.exec_address); 822 796 } 823 797 … … 833 807 gsdlsite_cfg.load(); 834 808 int try_again = JOptionPane.YES_OPTION; 835 809 int attempt_count = 0; 836 810 while(gsdlsite_cfg.getURL() != null && try_again == JOptionPane.YES_OPTION) { 837 838 try_again = JOptionPane.showConfirmDialog(Gatherer.g_man, dictionary.get("Server.QuitTimeOut"), dictionary.get("General.Warning"), JOptionPane.YES_NO_OPTION);839 840 841 842 843 844 845 846 847 811 if(attempt_count == 60) { 812 try_again = JOptionPane.showConfirmDialog(Gatherer.g_man, Dictionary.newget("Server.QuitTimeOut"), Dictionary.newget("General.Warning"), JOptionPane.YES_NO_OPTION); 813 } 814 else { 815 synchronized(this) { 816 wait(1000); // Wait one second (give or take) 817 } 818 gsdlsite_cfg.load(); 819 attempt_count++; 820 } 821 } 848 822 //if(gsdlsite_cfg.getURL() != null) { 849 //JOptionPane.showMessageDialog(Gatherer.g_man, dictionary.get("Server.QuitManual"), dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);823 //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Server.QuitManual"), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 850 824 //} 851 825 } … … 860 834 // If the local server is still running then our changed values will get overwritten. 861 835 if(gsdlsite_cfg.getURL() != null) { 862 JOptionPane.showMessageDialog(Gatherer.g_man, dictionary.get("Server.QuitFailed"), dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);836 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Server.QuitFailed"), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 863 837 } 864 838 gsdlsite_cfg = null; -
trunk/gli/src/org/greenstone/gatherer/Message.java
r5527 r5564 35 35 *######################################################################## 36 36 */ 37 package org.greenstone.gatherer; 37 38 38 39 40 41 42 43 package org.greenstone.gatherer;44 39 /************************************************************************************** 45 40 * Title: Gatherer … … 50 45 * Revised: 28/05/01 51 46 **************************************************************************************/ 47 52 48 import java.util.Date; 53 49 import java.util.Random; 50 54 51 /** Provides an event-type wrapper around a message for displaying to the user. 55 52 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 102 99 this.message = message; 103 100 } 101 104 102 /** 105 103 * Used to display a message, stating level and source. … … 108 106 */ 109 107 public String toString(Gatherer gatherer) { 108 // public String toString() { 110 109 String source_str = ""; 111 110 switch(source) { 112 111 case GENERAL: 113 source_str = gatherer.dictionary.get("Source.General");112 source_str = Dictionary.newget("Source.General"); 114 113 break; 115 114 case BROWSER: 116 source_str = gatherer.dictionary.get("GUI.Hunt");115 source_str = Dictionary.newget("GUI.Hunt"); 117 116 break; 118 117 case MIRRORING: 119 source_str = gatherer.dictionary.get("GUI.Mirror");118 source_str = Dictionary.newget("GUI.Mirror"); 120 119 break; 121 120 case COLLECT: 122 source_str = gatherer.dictionary.get("GUI.Gather");121 source_str = Dictionary.newget("GUI.Gather"); 123 122 break; 124 123 case METAEDIT: 125 source_str = gatherer.dictionary.get("GUI.Enrich");124 source_str = Dictionary.newget("GUI.Enrich"); 126 125 break; 127 126 case BUILDING: 128 source_str = gatherer.dictionary.get("Source.Building");127 source_str = Dictionary.newget("Source.Building"); 129 128 break; 130 129 default: 131 source_str = gatherer.dictionary.get("Source.Unknown");130 source_str = Dictionary.newget("Source.Unknown"); 132 131 } 133 132 … … 135 134 switch(level) { 136 135 case MAIN: 137 level_str = gatherer.dictionary.get("Level.Main");136 level_str = Dictionary.newget("Level.Main"); 138 137 break; 139 138 case EVENT: 140 level_str = gatherer.dictionary.get("Level.Event");139 level_str = Dictionary.newget("Level.Event"); 141 140 break; 142 141 case INFO: 143 level_str = gatherer.dictionary.get("Level.Information");142 level_str = Dictionary.newget("Level.Information"); 144 143 break; 145 144 case ERROR: 146 level_str = gatherer.dictionary.get("Level.Error");145 level_str = Dictionary.newget("Level.Error"); 147 146 break; 148 147 default: 149 level_str = gatherer.dictionary.get("Level.Unknown");148 level_str = Dictionary.newget("Level.Unknown"); 150 149 } 151 150 return source_str + " " + level_str + " > " + message; 152 151 } 152 153 153 /** Used during testing testing to generate a random message. 154 154 * @return A new <strong>Message</strong> object which has a random source, level and a message body of the current system time. -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMetaManager.java
r5164 r5564 26 26 */ 27 27 package org.greenstone.gatherer.cdm; 28 28 29 import java.awt.*; 29 30 import java.awt.event.*; … … 36 37 import org.greenstone.gatherer.cdm.DOMProxyListModel; 37 38 import org.greenstone.gatherer.cdm.Index; 38 import org.greenstone.gatherer.gui.EditorDialog;39 39 import org.greenstone.gatherer.util.StaticStrings; 40 40 import org.greenstone.gatherer.util.Utility; -
trunk/gli/src/org/greenstone/gatherer/checklist/Entry.java
r5159 r5564 2 2 3 3 import javax.swing.JCheckBox; 4 import org.greenstone.gatherer.Dictionary; 4 5 import org.greenstone.gatherer.Gatherer; 5 6 import org.greenstone.gatherer.msm.MetadataSet; … … 7 8 import org.greenstone.gatherer.util.Utility; 8 9 import org.w3c.dom.Element; 10 9 11 /** An Entry encapsulates a single row of the list, both its check box and the object the row represents. */ 10 12 public class Entry … … 26 28 MetadataSet set = (MetadataSet) object; 27 29 // Build tooltip 28 StringBuffer tip = new StringBuffer( Gatherer.dictionary.get("NewCollectionPrompt.Set_Contains"));30 StringBuffer tip = new StringBuffer(Dictionary.newget("NewCollectionPrompt.Set_Contains")); 29 31 tip.append(":\n"); 30 32 for(int i = 0; i < set.size(); i++) { … … 61 63 62 64 /** Retrieve the object associated with this entry. 63 64 65 * @return An <strong>Object</strong>. 66 */ 65 67 public Object getObject() { 66 68 //Gatherer.println("Retrieving the object for " + toString()); -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r5527 r5564 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.io.*; 39 40 import java.lang.Class; … … 42 43 import javax.swing.event.*; 43 44 import javax.swing.tree.*; 45 import org.greenstone.gatherer.Dictionary; 44 46 import org.greenstone.gatherer.Gatherer; 45 47 import org.greenstone.gatherer.Message; … … 69 71 import org.greenstone.gatherer.util.Codec; 70 72 import org.greenstone.gatherer.util.GSDLSiteConfig; 71 import org.greenstone.gatherer.util.MetadataXML;72 73 import org.greenstone.gatherer.util.StaticStrings; 73 74 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; … … 120 121 } 121 122 /** Add a special directory mapping. 122 123 124 123 * @param name The name for this directory mapping as a <strong>String</strong>. 124 * @param file The directory this mapping maps to as a <strong>File</strong>. 125 */ 125 126 public void addDirectoryMapping(String name, File file) { 126 127 if(ready()) { 127 128 // Update the information stored in the collection 128 129 collection.addDirectoryMapping(name, file); 129 130 // Now update the tree 130 131 FileSystemModel model = (FileSystemModel) Gatherer.g_man.collection_pane.getWorkspaceTree().getModel(); 131 132 FileNode parent = (FileNode) model.getRoot(); … … 135 136 } 136 137 /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor. 137 138 139 140 141 142 143 144 145 146 138 * @see org.greenstone.gatherer.Configuration 139 * @see org.greenstone.gatherer.Gatherer 140 * @see org.greenstone.gatherer.Message 141 * @see org.greenstone.gatherer.collection.Collection 142 * @see org.greenstone.gatherer.gui.BuildOptions 143 * @see org.greenstone.gatherer.shell.GShell 144 * @see org.greenstone.gatherer.shell.GShellListener 145 * @see org.greenstone.gatherer.shell.GShellProgressMonitor 146 * @see org.greenstone.gatherer.util.Utility 147 */ 147 148 public void buildCollection() { 148 149 Gatherer.println("CollectionManager.buildCollection()"); … … 222 223 try { 223 224 // Create a progress monitor. 224 ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, get("CollectionManager.Creating_New"), "mkcol.pl", 0, 7);225 ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.newget("CollectionManager.Creating_New"), "mkcol.pl", 0, 7); 225 226 // Create the new collection. 226 227 makeCollection(description, email, name, title); … … 234 235 gcache_dir.mkdirs(); 235 236 if(progress != null) { 236 progress.setNote( get("CollectionManager.Gcache_Created"));237 progress.setNote(Dictionary.newget("CollectionManager.Gcache_Created")); 237 238 } 238 239 … … 242 243 log_dir.mkdirs(); 243 244 if(progress != null) { 244 progress.setNote( get("CollectionManager.Log_Created"));245 progress.setNote(Dictionary.newget("CollectionManager.Log_Created")); 245 246 } 246 247 … … 395 396 String args[] = new String[1]; 396 397 args[0] = name; 397 progress.setNote( get("CollectionManager.Session_Ready", args));398 progress.setNote(Dictionary.newget("CollectionManager.Session_Ready", args)); 398 399 progress.close(); 399 400 } … … 436 437 437 438 /** Method that is called whenever an element within a set is changed or modified. We want to mark the collection so that it needs saving again. 438 439 440 439 * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired. 440 * @see org.greenstone.gatherer.collection.Collection 441 */ 441 442 public void elementChanged(MSMEvent event) { 442 443 // This means the state of the collections has changed, so we should set saved to false. … … 444 445 } 445 446 /** Used to retrieve the build options associated with the currently loaded collection. If none yet exist, default ones are created. 446 447 448 447 * @return A <strong>BuildOptions</strong> object containing the build options for the current collection. 448 * @see org.greenstone.gatherer.collection.Collection 449 */ 449 450 public BuildOptions getBuildOptions() { 450 451 return collection.build_options; … … 452 453 453 454 /** Retrieve the current collection. 454 455 455 * @return The <strong>Collection</strong> itself. 456 */ 456 457 public Collection getCollection() { 457 458 return collection; … … 578 579 return collection.getTitle(); 579 580 } 580 return get("Collection.No_Collection");581 return Dictionary.newget("Collection.No_Collection"); 581 582 } 582 583 … … 610 611 // Create and add Greenstone collections node. 611 612 // Starting at the collection directory of gsdl... 612 FileNode world_root = new FileNode( get("Tree.World"));613 FileNode world_root = new FileNode(Dictionary.newget("Tree.World")); 613 614 world_root.unmap(); 614 615 workspace_root.insert(world_root); … … 619 620 if(roots != null) { 620 621 FileNode file_root; 621 String name = get("Tree.Root");622 String name = Dictionary.newget("Tree.Root"); 622 623 if(roots.length == 1) { 623 624 file_root = new FileNode(roots[0], name); … … 644 645 if(home_folder_str != null && home_folder_str.length() > 0) { 645 646 File home_folder = new File(home_folder_str); 646 FileNode home_folder_node = new FileNode(home_folder, get("Tree.Home", home_folder.getName())); 647 String[] args = new String[1]; 648 args[0] = home_folder.getName(); 649 FileNode home_folder_node = new FileNode(home_folder, Dictionary.newget("Tree.Home", args)); 647 650 workspace_root.insert(home_folder_node); 648 651 } … … 651 654 if(Gatherer.config.get("workflow.mirror", false)) { 652 655 // Add Public workspace 653 FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), get("Tree.Public"));656 FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), Dictionary.newget("Tree.Public")); 654 657 workspace_root.insert(public_root); 655 658 // Add Private workspace if a collection has been loaded. 656 659 if(ready()) { 657 FileNode private_root = new FileNode(new File(getCollectionCache()), get("Tree.Private"));660 FileNode private_root = new FileNode(new File(getCollectionCache()), Dictionary.newget("Tree.Private")); 658 661 workspace_root.insert(private_root); 659 662 } … … 753 756 File metadata_directory = new File(collection_directory, Utility.META_DIR); 754 757 if(!metadata_directory.exists()) { 755 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Old_Collection", args2),get("General.Warning"), JOptionPane.INFORMATION_MESSAGE);758 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Old_Collection", args2), Dictionary.newget("General.Warning"), JOptionPane.INFORMATION_MESSAGE); 756 759 } 757 760 // Normal GLI collection … … 783 786 collection.gdm = new GDMManager(); 784 787 // Tell everyone that it worked. 785 Gatherer.println(get("CollectionManager.Loading_Successful", name)); 788 String[] args = new String[1]; 789 args[0] = name; 790 Gatherer.println(Dictionary.newget("CollectionManager.Loading_Successful", args)); 786 791 // Now we need to hook up classes that depend on messages from the metadata set manager to keep their content fresh. 787 792 collection.msm.addMSMListener(this); … … 796 801 // There is obviously no existing collection present. 797 802 Gatherer.printStackTrace(error); 798 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Cannot_Open", args2),get("General.Error"), JOptionPane.ERROR_MESSAGE);803 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Cannot_Open", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 799 804 } 800 805 } … … 803 808 } 804 809 else { 805 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.File_Not_Found", args2),get("General.Error"), JOptionPane.ERROR_MESSAGE);810 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.File_Not_Found", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 806 811 } 807 812 collection_directory = null; 808 813 } 809 814 else { 810 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Not_Col_File", args2),get("General.Error"), JOptionPane.ERROR_MESSAGE);815 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Not_Col_File", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 811 816 Gatherer.println("Not a Gatherer Collection."); 812 817 } … … 929 934 workspace_model = null; 930 935 Gatherer.g_man.collectionChanged(ready()); 931 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Preview_Ready"),get("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);936 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Preview_Ready"), Dictionary.newget("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE); 932 937 } 933 938 else if(event.getStatus() == GShell.ERROR) { 934 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Preview_Ready_Failed"),get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);939 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Preview_Ready_Failed"), Dictionary.newget("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 935 940 Gatherer.g_man.collectionChanged(ready()); 936 941 } … … 977 982 FileNode greenstone_collections_node = null; 978 983 int root_child_count = root.getChildCount(); 979 String greenstone_collections_str = get("Tree.World");984 String greenstone_collections_str = Dictionary.newget("Tree.World"); 980 985 for(int i = 0; greenstone_collections_node == null && i < root_child_count; i++) { 981 986 TreeNode child = root.getChildAt(i); … … 1097 1102 model.removeNodeFromParent(old); 1098 1103 // Create and insert new. 1099 FileNode private_workspace = new FileNode(new File(getCollectionCache()), get("Tree.Private"));1104 FileNode private_workspace = new FileNode(new File(getCollectionCache()), Dictionary.newget("Tree.Private")); 1100 1105 model.insertNodeInto(private_workspace, root, 2); 1101 1106 } … … 1108 1113 collection.setSaved(false); 1109 1114 } 1110 /** Used to retrive a value from the dictionary based on the key. 1111 * @param key A <strong>String</strong> indicating what value to retrieve. 1112 * @return A <strong>String</strong> representing the value. 1113 */ 1114 private String get(String key) { 1115 return get(key, (String[])null); 1116 } 1117 1118 /** Used to retrive a value from the dictionary based on the key. */ 1119 private String get(String key, String arg) { 1120 String[] args = new String[1]; 1121 args[0] = arg; 1122 return get(key, args); 1123 } 1124 1125 /** Used to retrive a value from the dictionary based on the key, and an array of arguments. 1126 * @param key A <strong>String</strong> indicating what value to retrieve. 1127 * @param args A <strong>String[]</strong> of arguments to be inserted into the phrase. 1128 * @return A <strong>String</strong> representing the value. 1129 */ 1130 private String get(String key, String args[]) { 1131 if(key.indexOf('.') == -1) { 1132 key = "CollectionManager." + key; 1133 } 1134 return Gatherer.dictionary.get(key, args); 1135 } 1115 1136 1116 /** Install collection by moving its files from building to index after a successful build. 1137 1138 1139 1117 * @see org.greenstone.gatherer.Gatherer 1118 * @see org.greenstone.gatherer.util.Utility 1119 */ 1140 1120 private void installCollection() { 1141 1121 Gatherer.println("Build complete. Moving files."); 1142 1122 1143 1144 1123 try { 1145 1124 // We have to ensure that the local library 1146 1125 if(Gatherer.config.exec_file != null) { 1147 1126 ///ystem.err.println("Local Library Found!"); … … 1161 1140 1162 1141 // Special case for build mode "all": replace index dir with building dir 1163 if (build_mode == null || build_mode.equals( get("CreatePane.Mode_All"))) {1142 if (build_mode == null || build_mode.equals(Dictionary.newget("CreatePane.Mode_All"))) { 1164 1143 // Remove the old index directory 1165 1144 if (index_dir.exists()) { … … 1209 1188 } 1210 1189 } 1190 1211 1191 /** Creates and dispatches a message given the initial details. 1212 1213 1214 1215 1216 1192 * @param level An <i>int</i> indicating the message level for this message. 1193 * @param message A <strong>String</strong> which contains the payload of this message. 1194 * @see org.greenstone.gatherer.Log 1195 * @see org.greenstone.gatherer.Message 1196 */ 1217 1197 private void message(int level, String message) { 1218 1198 Message msg = new Message(Message.COLLECT, level, message); -
trunk/gli/src/org/greenstone/gatherer/collection/Job.java
r5335 r5564 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.awt.event.*; 39 40 import java.io.*; … … 41 42 import java.util.*; 42 43 import javax.swing.tree.*; 44 import org.greenstone.gatherer.Dictionary; 43 45 import org.greenstone.gatherer.Gatherer; 44 46 import org.greenstone.gatherer.WGet; … … 218 220 int count = 0; 219 221 while(count < 3 && (user_pass = (String) Gatherer.authentications.get(address)) == null) { 220 Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Gatherer.dictionary.get("WGet.Prompt"), "HTTP");222 Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.newget("WGet.Prompt"), "HTTP"); 221 223 count++; 222 224 } -
trunk/gli/src/org/greenstone/gatherer/collection/LoadCollectionBox.java
r4675 r5564 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.awt.event.*; 39 40 import java.io.*; 40 41 import javax.swing.*; 41 42 import javax.swing.filechooser.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.util.Utility; 44 46 import org.outerj.pollo.util.*; 47 45 48 /** 46 49 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 56 59 String defaultPath = Utility.getCollectionDir(Gatherer.config.gsdl_path); 57 60 chooser = new JFileChooser(new File(defaultPath)); 58 chooser.setDialogTitle( Gatherer.dictionary.get("SaveCollectionBox.Title"));59 ExtensionFileFilter filter1 = new ExtensionFileFilter(".col", Gatherer.dictionary.get("General.File_Description"));61 chooser.setDialogTitle(Dictionary.newget("SaveCollectionBox.Title")); 62 ExtensionFileFilter filter1 = new ExtensionFileFilter(".col", Dictionary.newget("General.File_Description")); 60 63 chooser.setFileFilter(filter1); 61 64 chooser.setAcceptAllFileFilterUsed(false); -
trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionBox.java
r5536 r5564 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; 40 41 import javax.swing.*; 42 import org.greenstone.gatherer.Dictionary; 41 43 import org.greenstone.gatherer.Gatherer; 44 42 45 /** Provides a prompt allowing the user some choice in whether a collection saves. */ 43 46 public class SaveCollectionBox … … 67 70 // Dialog setup 68 71 this.setModal(true); 69 this.setTitle( get("SaveCollectionBox.Title"));72 this.setTitle(Dictionary.newget("SaveCollectionBox.Title")); 70 73 this.setSize(360,100); 71 74 } … … 103 106 String args[] = new String[1]; 104 107 args[0] = name; 105 JLabel save_label = new JLabel(get("SaveCollectionBox.Label", args)); 108 JLabel save_label = new JLabel(); 109 Dictionary.setText(save_label, "SaveCollectionBox.Label", args); 106 110 content_pane.add(save_label); 107 111 JPanel button_pane = new JPanel(new GridLayout(1,3)); 108 112 content_pane.add(button_pane); 109 113 // We add both mnemonics and key listener so that the 'y' of yes is underlined, but pressing just [Y] (rather than [CTL]-[Y]) performs a systematic click. 110 yes = new JButton( get("General.Yes"));114 yes = new JButton(); 111 115 yes.addActionListener(this); 112 116 KeyListenerImpl key_listener = new KeyListenerImpl(); 113 117 yes.addKeyListener(key_listener); 114 118 yes.setMnemonic(KeyEvent.VK_Y); 119 Dictionary.setBoth(yes, "General.Yes", "General.Yes_Tooltip"); 115 120 button_pane.add(yes); 116 no = new JButton( get("General.No"));121 no = new JButton(); 117 122 no.addActionListener(this); 118 123 no.addKeyListener(key_listener); 119 124 no.setMnemonic(KeyEvent.VK_N); 125 Dictionary.setBoth(no, "General.No", "General.No_Tooltip"); 120 126 button_pane.add(no); 121 cancel = new JButton( get("General.Cancel"));127 cancel = new JButton(); 122 128 cancel.addActionListener(this); 123 129 cancel.addKeyListener(key_listener); 124 130 cancel.setMnemonic(KeyEvent.VK_C); 131 Dictionary.setBoth(cancel, "General.Cancel", "General.Cancel_Tooltip"); 125 132 button_pane.add(cancel); 126 133 // Center on screen. … … 144 151 return result; 145 152 } 146 /** Method to retrieve a phrase from the dictionary based of a key. 147 * @param key A <strong>String</strong> used to find the correct phrase. 148 * @return A <strong>String</strong> containing the correct phrase with the correct formatting. 149 */ 150 private String get(String key) { 151 return get(key, null); 152 } 153 /** Method to retrieve a phrase from the dictionary based of a key and including arguments. 154 * @param key A <strong>String</strong> used to find the correct phrase. 155 * @param args A <strong>String[]</strong> of arguments used in formatting and filling out the phrase. 156 * @return A <strong>String</strong> containing the correct phrase with the correct formatting. 157 */ 158 private String get(String key, String args[]) { 159 if(key.indexOf('.') == -1) { 160 key = "SaveCollectionBox." + key; 161 } 162 return Gatherer.dictionary.get(key, args); 163 } 153 164 154 /** Listens for key presses when the focus is on one of the buttons. Note that the key pressed needn't be the one associated with the button in focus. */ 165 155 private class KeyListenerImpl -
trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionTask.java
r4675 r5564 1 package org.greenstone.gatherer.collection;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.collection; 38 38 39 import java.io.*; 39 40 import java.util.*; 40 41 import javax.swing.*; 41 42 import org.greenstone.gatherer.Gatherer; 42 import org.greenstone.gatherer.Message;43 43 import org.greenstone.gatherer.collection.Collection; 44 import org.greenstone.gatherer.gui.GUIManager;45 import org.greenstone.gatherer.undo.UndoManager;46 44 import org.greenstone.gatherer.util.Utility; 45 47 46 /** The actually saving of a collection must run in a thread other than the AWTEvent thread, or else the save progress box will never get updated. To that end this class provides a threaded save method, which saves the various parts of the collection to the appropriate disk location. 48 47 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 111 110 // Create progress monitor box. It will display itself as necessary. 112 111 // WARNING: ProgressMonitors seem to be extremely dodgy, and are not recommended! 113 // ProgressMonitor spd = new ProgressMonitor(Gatherer.g_man, Gatherer.dictionary.get("SaveProgressDialog.Title", collection.getName()), null, 0, 100);112 // ProgressMonitor spd = new ProgressMonitor(Gatherer.g_man, Dictionary.newget("SaveProgressDialog.Title", collection.getName()), null, 0, 100); 114 113 // spd.setMillisToDecideToPopup(100); 115 114 // spd.setMillisToPopup(100); -
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r4675 r5564 1 package org.greenstone.gatherer.file;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.file; 38 38 39 import java.io.File; 39 40 import javax.swing.*; 41 import org.greenstone.gatherer.Dictionary; 40 42 import org.greenstone.gatherer.Gatherer; 41 43 import org.greenstone.gatherer.file.FileNode; … … 46 48 import org.greenstone.gatherer.util.DragComponent; 47 49 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; 50 48 51 /** Manages the moving of files within a separate thread. 49 52 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 74 77 // If the source is the workspace then display an error message. Workspace is read only. 75 78 if(source.toString().equals("Workspace")) { 76 JOptionPane.showMessageDialog(Gatherer.g_man, Gatherer.dictionary.get("FileActions.Read_Only"), Gatherer.dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);79 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.Read_Only"), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 77 80 return; 78 81 } … … 106 109 FileSystemModel model = (FileSystemModel) tree.getModel(); 107 110 File folder_file = new File(parent_node.getFile(), name); 108 111 //... check if it already exists. 109 112 if(folder_file.exists()) { 110 JOptionPane.showMessageDialog(Gatherer.g_man, Gatherer.dictionary.get("FileActions.Folder_Already_Exists", name), Gatherer.dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);113 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.Folder_Already_Exists", name), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 111 114 } 112 115 // Otherwise create it. 113 116 else { 114 117 folder_file.mkdirs(); -
trunk/gli/src/org/greenstone/gatherer/file/FileNode.java
r5164 r5564 6 6 import javax.swing.filechooser.*; 7 7 import javax.swing.tree.*; 8 import org.greenstone.gatherer.Dictionary; 8 9 import org.greenstone.gatherer.Gatherer; 9 10 import org.greenstone.gatherer.file.FileFilter; … … 237 238 children = new ArrayList(); 238 239 // Super Special Case: if the name of this node is the Tree.World string, then we actually map the collections installed in greenstone. The file in this case will actually by the collect directory of greenstone. 239 if(file == null && title.equals( Gatherer.dictionary.get("Tree.World"))) {240 if(file == null && title.equals(Dictionary.newget("Tree.World"))) { 240 241 ///atherer.println("Map the 'Greenstone Collections' node."); 241 242 // For each of the children directories, which are collections... … … 386 387 public void unmap() { 387 388 // You cannot unmap nodes that have no file basis. 388 if(file != null || title.equals( Gatherer.dictionary.get("Tree.World"))) {389 if(file != null || title.equals(Dictionary.newget("Tree.World"))) { 389 390 ///atherer.println("Unmap: " + this); 390 391 children = null; -
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r5536 r5564 32 32 import javax.swing.event.*; 33 33 import javax.swing.tree.*; 34 import org.greenstone.gatherer.Dictionary; 34 35 import org.greenstone.gatherer.Gatherer; 35 36 import org.greenstone.gatherer.file.FileJob; 36 37 import org.greenstone.gatherer.file.FileNode; 37 38 import org.greenstone.gatherer.gui.LongProgressBar; 38 import org.greenstone.gatherer.gui.SmudgyLabel;39 39 import org.greenstone.gatherer.gui.tree.DragTree; 40 40 import org.greenstone.gatherer.msm.GDMManager; … … 44 44 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; 45 45 import org.greenstone.gatherer.util.Utility; 46 46 47 /** A threaded object which processes a queue of file actions such as copying and movement. It also handles updating the various trees involved so they are an accurate representation of the file system they are meant to match. 47 48 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 64 65 private HashMap recycle_folder_mappings = new HashMap(); 65 66 /** A label explaining the current moving files status. */ 66 private JLabel file_status = null; // was a SmudgyLabel 67 /** A label explaining the status of this job. */ 68 //private JLabel job_status = null; // no longer used 67 private JLabel file_status = null; 69 68 /** A list containing a queue of waiting movement jobs. */ 70 69 //private LinkedList queue; … … 75 74 private String previous = null; 76 75 /** Constructor. 77 78 79 80 81 76 * @param return_immediately true to cause this file queue to return from run() as soon as there are no jobs left on the queue. 77 * @see org.greenstone.gatherer.Configuration 78 * @see org.greenstone.gatherer.gui.Coloring 79 * @see org.greenstone.gatherer.gui.LongProgressBar 80 */ 82 81 public FileQueue(boolean return_immediately) { 83 82 this.return_immediately = return_immediately; … … 86 85 args[0] = "0"; 87 86 args[1] = "0"; 88 file_status = new JLabel( get("FileActions.Selected", args)); //new SmudgyLabel(get("Selected", args));89 //job_status = new JLabel(get("No_Activity"));87 file_status = new JLabel(); 88 Dictionary.setText(file_status, "FileActions.Selected", args); 90 89 progress = new LongProgressBar(); 91 90 progress.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 92 91 progress.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false)); 93 progress.setString( get("FileActions.No_Activity"));92 progress.setString(Dictionary.newget("FileActions.No_Activity")); 94 93 progress.setStringPainted(true); 95 94 args = null; … … 106 105 107 106 /** Add a new job to the queue, specifiying as many arguments as is necessary to complete this type of job (ie delete needs no target information). 108 109 110 111 112 113 114 115 116 107 * @param id A long id unique to all jobs created by a single action. 108 * @param source The DragComponent source of this file, most likely a DragTree. 109 * @param child The FileNode you wish to mode. 110 * @param target The DragComponent to move the file to, again most likely a DragTree. 111 * @param parent The files new FileNode parent within the target. 112 * @param type The type of this movement as an int, either COPY or DELETE. 113 * @param undo true if this job should generate undo jobs, false for redo ones. 114 * @param undoable true if this job can generate undo or redo jobs at all, false otherwise. 115 */ 117 116 public void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean undo, boolean undoable, boolean folder_level) { 118 117 addJob(id, source, child, target, parent, type, undo, undoable, folder_level, -1); 119 118 } 119 120 120 synchronized public void addJob(long id, DragComponent source, FileNode child, DragComponent target, FileNode parent, byte type, boolean undo, boolean undoable, boolean folder_level, int position) { 121 121 FileJob job = new FileJob(id, source, child, target, parent, type, undo, undoable); … … 131 131 } 132 132 133 134 135 136 137 133 /** Calculates the total deep file size of the selected file nodes. 134 * @param files a FileNode[] of selected files 135 * @return true if a cancel was signalled, false otherwise 136 * @see org.greenstone.gatherer.file.FileManager.Task#run() 137 */ 138 138 public boolean calculateSize(FileNode[] files) { 139 139 progress.reset(); 140 progress.setString( get("FileActions.Calculating_Size"));140 progress.setString(Dictionary.newget("FileActions.Calculating_Size")); 141 141 progress.setIndeterminate(true); 142 142 Vector remaining = new Vector(); … … 155 155 } 156 156 } 157 progress.setString( get("FileActions.No_Activity"));157 progress.setString(Dictionary.newget("FileActions.No_Activity")); 158 158 progress.setIndeterminate(false); 159 159 // Now we return if calculation was cancelled so that the FileManagers Task can skip the addJob phase correctly. 160 160 if(cancel_action) { 161 162 161 cancel_action = false; // reset 162 return true; 163 163 } 164 164 else { 165 165 return false; 166 166 } 167 167 } … … 188 188 } 189 189 /** The run method exists in every thread, and here it is used to work its way through the queue of Jobs. If no jobs are waiting and it cans, it waits until a job arrives. If a job is present then it is either COPIED or DELETED, with the records being copied or removed as necessary, and directories being recursed through. Finally the user can press cancel to cause the loop to prematurely dump the job queue then wait. 190 191 192 193 194 195 196 197 198 190 * @see org.greenstone.gatherer.Gatherer 191 * @see org.greenstone.gatherer.collection.CollectionManager 192 * @see org.greenstone.gatherer.file.FileJob 193 * @see org.greenstone.gatherer.file.FileNode 194 * @see org.greenstone.gatherer.gui.LongProgressBar 195 * @see org.greenstone.gatherer.msm.MetadataSetManager 196 * @see org.greenstone.gatherer.undo.UndoManager 197 * @see org.greenstone.gatherer.util.Utility 198 */ 199 199 public void run() { 200 200 super.setName("FileQueue"); … … 239 239 else { 240 240 ///atherer.println("Opps! This filename already exists. Give the user some options."); 241 Object[] options = { get("General.Yes"), get("FileActions.Yes_To_All"), get("General.No"),get("General.Cancel") };242 int result = JOptionPane.showOptionDialog(Gatherer.g_man, get("FileActions.File_Exists", target_file.getName()),get("General.Warning"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);241 Object[] options = { Dictionary.newget("General.Yes"), Dictionary.newget("FileActions.Yes_To_All"), Dictionary.newget("General.No"), Dictionary.newget("General.Cancel") }; 242 int result = JOptionPane.showOptionDialog(Gatherer.g_man, Dictionary.newget("FileActions.File_Exists", target_file.getName()), Dictionary.newget("General.Warning"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); 243 243 switch(result) { 244 244 case 1: // Yes To All … … 271 271 String args[] = new String[1]; 272 272 args[0] = "" + (queue.size() + 1) + ""; 273 //job_status.setText(get("Jobs", args));274 273 if(job.type == FileJob.COPY) { 275 274 args[0] = Utility.formatPath("FileActions.Copying", source_file.getAbsolutePath(), file_status.getSize().width); 276 file_status.setText( get("FileActions.Copying", args));275 file_status.setText(Dictionary.newget("FileActions.Copying", args)); 277 276 } 278 277 else { 279 278 args[0] = Utility.formatPath("FileActions.Moving", source_file.getAbsolutePath(), file_status.getSize().width); 280 file_status.setText( get("FileActions.Moving", args));279 file_status.setText(Dictionary.newget("FileActions.Moving", args)); 281 280 } 282 281 args = null; … … 293 292 cancel_action = true; 294 293 // Show warning. 295 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.File_Not_Found_Message", source_file.getName()),get("FileActions.File_Not_Found_Title"), JOptionPane.ERROR_MESSAGE);294 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.File_Not_Found_Message", source_file.getName()), Dictionary.newget("FileActions.File_Not_Found_Title"), JOptionPane.ERROR_MESSAGE); 296 295 // Force refresh of source folder. 297 296 source_model.refresh(new TreePath(((FileNode)origin_node.getParent()).getPath())); … … 301 300 cancel_action = true; 302 301 // Show warning. 303 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.File_Already_Exists_Message", target_file.getName()),get("FileActions.File_Already_Exists_Title"), JOptionPane.ERROR_MESSAGE);302 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.File_Already_Exists_Message", target_file.getName()), Dictionary.newget("FileActions.File_Already_Exists_Title"), JOptionPane.ERROR_MESSAGE); 304 303 // Nothing else can be done by the Gatherer. 305 304 } … … 308 307 cancel_action = true; 309 308 // Show warning. The message body of the expection explains how much more space is required for this file copy. 310 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.Insufficient_Space_Message", is_exception.getMessage()),get("FileActions.Insufficient_Space_Title"), JOptionPane.ERROR_MESSAGE);309 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.Insufficient_Space_Message", is_exception.getMessage()), Dictionary.newget("FileActions.Insufficient_Space_Title"), JOptionPane.ERROR_MESSAGE); 311 310 // Nothing else can be done by the Gatherer. In fact if we are really out of space I'm not even sure we can quit safely. 312 311 } … … 315 314 cancel_action = true; 316 315 // Show warning 317 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.Unknown_File_Error_Message"),get("FileActions.Unknown_File_Error_Title"), JOptionPane.ERROR_MESSAGE);316 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.Unknown_File_Error_Message"), Dictionary.newget("FileActions.Unknown_File_Error_Title"), JOptionPane.ERROR_MESSAGE); 318 317 // Nothing else we can do. 319 318 } … … 322 321 cancel_action = true; 323 322 // Show warning 324 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.Write_Not_Permitted_Message", target_file.getAbsolutePath()),get("FileActions.Write_Not_Permitted_Title"), JOptionPane.ERROR_MESSAGE);323 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.Write_Not_Permitted_Message", target_file.getAbsolutePath()), Dictionary.newget("FileActions.Write_Not_Permitted_Title"), JOptionPane.ERROR_MESSAGE); 325 324 // Nothing else we can do. 326 325 } … … 378 377 // Else inform the users that a directory already exists and files will be copied into it 379 378 //else { 380 // JOptionPane.showMessageDialog(null, get("Directory_Exists", target_file.toString()),get("General.Warning"), JOptionPane.WARNING_MESSAGE);379 // JOptionPane.showMessageDialog(null, Dictionary.newget("Directory_Exists", target_file.toString()), Dictionary.newget("General.Warning"), JOptionPane.WARNING_MESSAGE); 381 380 //} 382 381 // Queue non-filtered child files for copying. If this directory already existed, the child records will have to generate the undo jobs, as we don't want to entirely delete this directory if it already existed. … … 401 400 cancel_action = true; 402 401 // Show warning. 403 JOptionPane.showMessageDialog(Gatherer.g_man, get("FileActions.File_Not_Found_Message", source_file.getName()),get("FileActions.File_Not_Found_Title"), JOptionPane.ERROR_MESSAGE);402 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("FileActions.File_Not_Found_Message", source_file.getName()), Dictionary.newget("FileActions.File_Not_Found_Title"), JOptionPane.ERROR_MESSAGE); 404 403 // Force refresh of source folder. 405 404 source_model.refresh(new TreePath(((FileNode)origin_node.getParent()).getPath())); … … 457 456 String args[] = new String[1]; 458 457 args[0] = "" + (queue.size() + 1) + ""; 459 //job_status.setText( get("Jobs", args));458 //job_status.setText(Dictionary.newget("Jobs", args)); 460 459 args[0] = Utility.formatPath("FileActions.Deleting", source_file.getAbsolutePath(), file_status.getSize().width); 461 file_status.setText( get("FileActions.Deleting", args));460 file_status.setText(Dictionary.newget("FileActions.Deleting", args)); 462 461 args = null; 463 462 … … 593 592 } 594 593 // Reset status area 595 //job_status.setText( get("No_Selection"));596 file_status.setText( get("FileActions.No_Activity"));594 //job_status.setText(Dictionary.newget("No_Selection")); 595 file_status.setText(Dictionary.newget("FileActions.No_Activity")); 597 596 progress.reset(); 598 progress.setString( get("FileActions.No_Activity"));597 progress.setString(Dictionary.newget("FileActions.No_Activity")); 599 598 yes_to_all = false; 600 599 completed_folder_mappings.clear(); … … 615 614 } 616 615 /** A second lock is necessary to prevent the thread waiting, because its notify occured momentarily before it waited. If the flag is set then the thread can't wait, but loops around. This may chew processor time so should only be used if you are certain files are about to be placed on the queue. 617 618 616 * @param wait_allowed The new state of the wait_allowed flag, as a boolean. 617 */ 619 618 public void setWaitAllowed(boolean wait_allowed) { 620 619 this.wait_allowed = wait_allowed; 621 620 } 622 621 /** Restore the progress bar so that it updates normally. 623 624 622 * @see org.greenstone.gatherer.gui.LongProgressBar 623 */ 625 624 synchronized public void unpause() { 626 625 progress.setIndeterminate(false); … … 730 729 } 731 730 } 732 /** Retrieve a phrase from the dictionary based on the key. 733 * @param key The key index as a String. 734 * @return The desired phrase also as a String. 735 */ 736 private String get(String key) { 737 return get(key, (String[])null); 738 } 739 /** Retrieve a phrase from the dictionary based on the key, and taking into account the given argument. 740 * @param key The key index as a String. 741 * @param args A String which is the argument to be added to the phrase. 742 * @return The desired phrase also as a String. 743 */ 744 private String get(String key, String arg) { 745 String args[] = new String[1]; 746 args[0] = arg; 747 return get(key, args); 748 } 749 /** Retrieve a phrase from the dictionary based on the key, and taking into account the given arguments. 750 * @param key The key index as a String. 751 * @param args A String[] of arguments to be added to the phrase. 752 * @return The desired phrase also as a String. 753 * @see org.greenstone.gatherer.Dictionary 754 * @see org.greenstone.gatherer.Gatherer 755 */ 756 private String get(String key, String args[]) { 757 if(key.indexOf('.') == -1) { 758 key = "FileActions." + key; 759 } 760 return Gatherer.dictionary.get(key, args); 761 } 731 762 732 763 733 private FileJob removeJob(int position) { -
trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java
r5300 r5564 6 6 import javax.swing.event.*; 7 7 import javax.swing.tree.*; 8 import org.greenstone.gatherer.Dictionary; 8 9 import org.greenstone.gatherer.Gatherer; 9 10 import org.greenstone.gatherer.file.FileFilter; … … 111 112 FileNode node = (FileNode) path.getLastPathComponent(); 112 113 // If this error node is a dummy node (ie has no associated file) we can't unmap it, so we iterate through its children refreshing each in turn. The exception being Greenstone Collections, as it is a dummy node but we can map/unmap it 113 if(node.getFile() == null && !node.toString().equals( Gatherer.dictionary.get("Tree.World"))) {114 if(node.getFile() == null && !node.toString().equals(Dictionary.newget("Tree.World"))) { 114 115 for(int i = 0; i < node.getChildCount(); i++) { 115 116 FileNode child = (FileNode) node.getChildAt(i); -
trunk/gli/src/org/greenstone/gatherer/gui/EditorDialog.java
r5527 r5564 1 package org.greenstone.gatherer.gui;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; 40 41 import javax.swing.*; 42 import org.greenstone.gatherer.Dictionary; 41 43 import org.greenstone.gatherer.Gatherer; 42 44 import org.greenstone.gatherer.gui.SimpleMenuBar; … … 60 62 /** The size of the edit pop-up. */ 61 63 final static private Dimension SIZE = new Dimension(400,425); 62 /** Constructor.*/ 64 65 /** Constructor */ 63 66 public EditorDialog() { 64 67 super(Gatherer.g_man); 65 66 68 } 69 67 70 /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we generate a pop-up window to edit in. 68 69 71 * @param event An <strong>ActionEvent</strong> containing information about the event. 72 */ 70 73 public void actionPerformed(ActionEvent event) { 71 if (event.getSource() == ok) {74 if (event.getSource() == ok) { 72 75 result = text.getText(); 73 76 } 74 77 dispose(); 75 78 } 79 76 80 /** Method to display the editing box on screen. 77 78 79 81 * @param value The initial text to be displayed in the editing area, as a <strong>String</strong>. 82 * @return The new value for the metadata value as a <strong>String</strong> or <i>null</i> if the user has pressed cancel. 83 */ 80 84 public String display(String value) { 81 85 setModal(true); 82 86 setSize(SIZE); 83 setTitle(Gatherer.dictionary.get("General.Edit"));84 87 setJMenuBar(new SimpleMenuBar("theenrichview")); 88 Dictionary.setText(this, "General.Edit"); 89 85 90 // Create 86 cancel = new JButton(Gatherer.dictionary.get("General.Cancel"));87 ok = new JButton(Gatherer.dictionary.get("General.OK"));88 91 text = new JTextArea(value); 89 92 text.setCaretPosition(value.length()); … … 91 94 text.setLineWrap(true); 92 95 text.setWrapStyleWord(true); 96 Dictionary.setTooltip(text, "MetaEdit.Value_Field_Tooltip"); 97 98 cancel = new JButton(); 99 cancel.setMnemonic(KeyEvent.VK_C); 100 Dictionary.setBoth(cancel, "General.Cancel", "General.Pure_Cancel_Tooltip"); 101 ok = new JButton(); 102 ok.setMnemonic(KeyEvent.VK_0); 103 Dictionary.setBoth(ok, "General.OK", "General.OK_Tooltip"); 104 93 105 // Listeners 94 106 cancel.addActionListener(this); 95 107 ok.addActionListener(this); 108 96 109 // Layout 97 110 JPanel button_pane = new JPanel(); -
trunk/gli/src/org/greenstone/gatherer/gui/Filter.java
r5527 r5564 1 package org.greenstone.gatherer.gui;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; … … 42 43 import javax.swing.*; 43 44 import javax.swing.tree.*; 45 import org.greenstone.gatherer.Dictionary; 44 46 import org.greenstone.gatherer.Gatherer; 45 47 import org.greenstone.gatherer.file.FileSystemModel; 46 48 import org.greenstone.gatherer.gui.tree.DragTree; 49 47 50 /** <p>This object allows the user to set a filter on one of the workspace trees, specifying a preset type, or a regular expression that a files must match to be in the tree. Note that all directories are included. This class includes the controls for editing the filter. The trick is that several instances of the Filter class can share the same internal data (termed a 'run' of filters), so that the filter set on the CollectionPane and the MetaEditPane are virtually the same.</p> 48 * <p>The regular expression typed can uses '*' as a wildcard character (equivelent to '.*'), and does not use '.' to match any single character (use '?' instead).</p>51 * <p>The regular expression typed uses '*' as a wildcard character (equivalent to '.*'), and does not use '.' to match any single character (use '?' instead).</p> 49 52 * @author John Thompson, Greenstone Digital Library, University of Waikato 50 53 * @version 2.3 … … 72 75 /** Preprogrammed default filters. */ 73 76 static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.\\.gif$)|(^.\\.bmp$)|(^.\\.tif$)"}; 77 74 78 /** Constructor. 75 79 * @param tree A reference to the <strong>JTree</strong> being affected. … … 78 82 this(tree, null); 79 83 } 84 80 85 /** Constructor. 81 86 * @param tree A reference to the <strong>JTree</strong> being affected. … … 84 89 public Filter(DragTree tree, ArrayList others) { 85 90 super(); 86 if(others == null) { 87 this.others = new ArrayList(); 88 } 89 else { 90 this.others = others; 91 } 91 if (others == null) { 92 others = new ArrayList(); 93 } 94 this.others = others; 92 95 this.others.add(this); 93 96 this.this_filter = this; … … 98 101 for(int i = 0; i < DEFAULTS.length; i++) { 99 102 try { 100 Entry entry = new Entry( get((new Integer(i)).toString(), null), Pattern.compile(DEFAULTS[i]));103 Entry entry = new Entry(Dictionary.newget("Filter." + i), Pattern.compile(DEFAULTS[i])); 101 104 combobox.add(entry); 102 105 } … … 106 109 } 107 110 combobox.setEditable(true); 108 label = new JLabel( get("Filter.Filter_Tree"));111 label = new JLabel(); 109 112 label.setPreferredSize(SIZE); 113 Dictionary.setText(label, "Filter.Filter_Tree"); 110 114 // Add listeners. 111 115 combobox.addActionListener(new ComboBoxListener()); … … 141 145 ignore = false; 142 146 } 147 143 148 /** Set the combobox model for this filter. 144 149 * @param model The new <strong>ComboBoxModel</strong> to use. … … 147 152 combobox.setModel(model); 148 153 } 154 149 155 /** Ensure that a certain entry is selected from the combobox. 150 156 * @param selection The <strong>Entry</strong> that should be selected. … … 155 161 ignore = false; 156 162 } 163 157 164 /** Set to signify that this filter is the first in a new run of filters. 158 165 * @param first <i>true</i> if this is the first filter in a run, <i>false</i> if it will just be added to the current run. … … 161 168 this.first = first; 162 169 } 163 /** Spawn produces a copy of this filter, which has new controls, but shares listeners wih this filter, and vice versa. Thus we can have two synchronized, but differing sets of controls. 170 171 /** Spawn produces a copy of this filter, which has new controls, but shares listeners with this filter, and vice versa. Thus we can have two synchronized, but differing sets of controls. 164 172 * @param tree_spawn The <strong>JTree</strong> this filter will affect. 165 173 * @return A new <strong>Filter</strong> which is in the same run as this filter. … … 172 180 return filter; 173 181 } 174 /** Retrieve a phrase from the dictionary. 175 * @param key The unique identification <strong>String</strong> of a phrase from the dictionary. 176 */ 177 private String get(String key) { 178 return get(key, null); 179 } 180 /** Retrieve a phrase from the dictionary, augmenting with the given text fragments 181 * @param key The unique identification <strong>String</strong> of a phrase from the dictionary. 182 * @param args A <strong>String[]</strong> of arguments to be used to fill out parameter fields in the phrase returned. 183 * @see org.greenstone.gatherer.Dictionary 184 * @see org.greenstone.gatherer.Gatherer 185 */ 186 private String get(String key, String args[]) { 187 if(key.indexOf(".") == -1) { 188 key = "Filter." + key; 189 } 190 return Gatherer.dictionary.get(key, args); 191 } 182 192 183 /** Encode an expression in pseudo-regular expression into regular expression. 193 184 * @param raw The pseudo-regular expression <strong>String</strong> which includes several characters which differ in meaning from regular expression queries. … … 231 222 Gatherer.g_man.wait(false); 232 223 } 224 233 225 /** Listens for changes in the combobox as when one is detected attempts to compile a regular expression from whatever text was entered. If successful, or if the item chosen was a predefined filter, it then applies the filter to the target tree. */ 234 226 private class ComboBoxListener … … 246 238 ///ystem.err.println("Filter = " + temp_str); 247 239 // Ignore any string which matches a predefined filter, starting with All Files. 248 if(temp_str.equals( get("Filter.All_Files"))) {240 if(temp_str.equals(Dictionary.newget("Filter.All_Files"))) { 249 241 } 250 242 // HTM & HTML 251 else if(temp_str.equals( get("Filter.0"))) {243 else if(temp_str.equals(Dictionary.newget("Filter.0"))) { 252 244 } 253 245 // XML 254 else if(temp_str.equals( get("Filter.1"))) {246 else if(temp_str.equals(Dictionary.newget("Filter.1"))) { 255 247 } 256 248 // Text files 257 else if(temp_str.equals( get("Filter.2"))) {249 else if(temp_str.equals(Dictionary.newget("Filter.2"))) { 258 250 } 259 251 // Images 260 else if(temp_str.equals( get("Filter.3"))) {252 else if(temp_str.equals(Dictionary.newget("Filter.3"))) { 261 253 } 262 254 else { … … 281 273 catch (PatternSyntaxException error) { 282 274 if(first) { 283 JOptionPane.showMessageDialog(Gatherer.g_man, get("Filter.Invalid_Pattern"),get("General.Error"), JOptionPane.ERROR_MESSAGE);275 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Filter.Invalid_Pattern"), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 284 276 } 285 277 } … … 322 314 public String toString() { 323 315 String result = null; 324 if (name != null) {316 if (name != null) { 325 317 result = name; 326 318 } 327 else if (pattern == null) {328 result = get("Filter.All_Files");319 else if (pattern == null) { 320 result = Dictionary.newget("Filter.All_Files"); 329 321 } 330 322 else { -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r5536 r5564 1 package org.greenstone.gatherer.gui;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui; 38 38 39 import java.awt.*; 39 40 import java.awt.datatransfer.*; … … 66 67 import org.greenstone.gatherer.gui.MirrorPane; 67 68 import org.greenstone.gatherer.gui.OpenCollectionDialog; 68 import org.greenstone.gatherer.gui.OptionsBox;69 69 import org.greenstone.gatherer.gui.Preferences; 70 70 import org.greenstone.gatherer.gui.PreviewPane; … … 76 76 import org.greenstone.gatherer.msm.ElementWrapper; 77 77 import org.greenstone.gatherer.msm.Metadata; 78 // import org.greenstone.gatherer.sarm.SearchAndReplace;79 78 import org.greenstone.gatherer.shell.GShell; 80 79 import org.greenstone.gatherer.util.TreeSynchronizer; 81 80 import org.greenstone.gatherer.util.Utility; 82 import org.greenstone.gatherer.valuetree.GValueNode; 81 83 82 /** The GUIManager is in charge of creating the Gatherer window frame then filling it with the goodness of the view panes. GUIManager not only creates these panes, but allows some messaging between them. Furthermore GUIManager includes functionality from menu driven choices, simply as it was easier to put it here once and have it accessible from all pane children. */ 84 83 public class GUIManager … … 154 153 thread_group = bob.getThreadGroup(); 155 154 // Set up some other UI stuff. (fonts handled in Gatherer.main()) 156 UIManager.put("FileChooser.lookInLabelText", Gatherer.dictionary.get("SaveCollectionBox.Look_In"));157 UIManager.put("FileChooser.filesOfTypeLabelText", Gatherer.dictionary.get("SaveCollectionBox.Files_Of_Type"));158 UIManager.put("FileChooser.fileNameLabelText", Gatherer.dictionary.get("SaveCollectionBox.File_Name"));155 UIManager.put("FileChooser.lookInLabelText", Dictionary.newget("SaveCollectionBox.Look_In")); 156 UIManager.put("FileChooser.filesOfTypeLabelText", Dictionary.newget("SaveCollectionBox.Files_Of_Type")); 157 UIManager.put("FileChooser.fileNameLabelText", Dictionary.newget("SaveCollectionBox.File_Name")); 159 158 } 160 159 /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed when an action has occured. In this case we are listening to actions from the menu-bar, and should react appropriately. … … 264 263 // sar = new SearchAndReplace(true); 265 264 // } 265 266 266 // ************* 267 267 // Tools Options. 268 268 // ************* 269 else if(esrc == menu_bar.tools_size) { 270 FileNode records[] = metaedit_pane.getSelectedNode(); 271 if(records != null && records.length > 0) { 272 ArrayList metadatum = Gatherer.c_man.getCollection().gdm.getMetadata(records[0].getFile()); 273 if(metadatum.size() >= 4) { 274 Metadata metadata = (Metadata) metadatum.get(0); 275 ElementWrapper ew = metadata.getElement(); 276 277 int SIZE = 5000; 278 Object[] array = new Object[SIZE]; 279 Runtime.getRuntime().gc(); 280 long start = Runtime.getRuntime().freeMemory(); 281 for (int i = 0; i < SIZE; i++) { 282 array[i] = ew.copy(); 283 } 284 Runtime.getRuntime().gc(); 285 long end = Runtime.getRuntime().freeMemory(); 286 long difference = (( start - end ) / SIZE); 287 ///ystem.out.println(difference + " bytes used." ); 288 } 289 } 290 } 269 // else if(esrc == menu_bar.tools_size) { 270 // FileNode records[] = metaedit_pane.getSelectedNode(); 271 // if(records != null && records.length > 0) { 272 // ArrayList metadatum = Gatherer.c_man.getCollection().gdm.getMetadata(records[0].getFile()); 273 // if(metadatum.size() >= 4) { 274 // Metadata metadata = (Metadata) metadatum.get(0); 275 // ElementWrapper ew = metadata.getElement(); 276 277 // int SIZE = 5000; 278 // Object[] array = new Object[SIZE]; 279 // Runtime.getRuntime().gc(); 280 // long start = Runtime.getRuntime().freeMemory(); 281 // for (int i = 0; i < SIZE; i++) { 282 // array[i] = ew.copy(); 283 // } 284 // Runtime.getRuntime().gc(); 285 // long end = Runtime.getRuntime().freeMemory(); 286 // long difference = (( start - end ) / SIZE); 287 // ///ystem.out.println(difference + " bytes used." ); 288 // } 289 // } 290 // } 291 291 292 // ************* 292 293 // Help Options. … … 322 323 // Metadata Options. 323 324 // ***************** 324 else if(esrc == menu_bar.metadata_ add) {325 else if(esrc == menu_bar.metadata_import) { 325 326 Gatherer.c_man.getCollection().msm.importMDS(); 326 327 } … … 339 340 } 340 341 /** Any actions that should happen after the display of the Gatherer window can be called here. Currently only updates the browser pane if it is active to work around bug in Mozilla renderer implementation. 341 342 */ 342 343 public void afterDisplay() { 343 344 if(Gatherer.config.get("workflow.mirror", true)) { … … 347 348 } 348 349 /** Once a collection has been made available to Gatherer, either by its creation or by it being reloaded, we need to inform all the visual components to update necessary data components (such as tree models), enable certain controls that depend on a collection being accessible, and refresh themselves. 349 350 350 * @param ready <i>true</i> if the collection is ready for editing, <i>false</i> otherwise. 351 */ 351 352 public void collectionChanged(final boolean ready) { 352 353 if(Gatherer.config.get("workflow.mirror", true)) { … … 372 373 } 373 374 // Finally display the collection name in the title bar. 374 if (ready) {375 if (ready) { 375 376 this.setTitle(Utility.PROGRAM_NAME + ":\"" + Gatherer.c_man.getCollection().getTitle() + "\""); 376 377 } 377 378 else { 378 this.setTitle(Utility.PROGRAM_NAME + ": " + get("Collection.No_Collection"));379 this.setTitle(Utility.PROGRAM_NAME + ": " + Dictionary.newget("Collection.No_Collection")); 379 380 } 380 381 // Now is a good time to force a garbage collect. … … 396 397 } 397 398 else { 398 this.setTitle(Utility.PROGRAM_NAME + ": " + get("Collection.No_Collection"));399 this.setTitle(Utility.PROGRAM_NAME + ": " + Dictionary.newget("Collection.No_Collection")); 399 400 } 400 401 // Pretty corner icon … … 487 488 } 488 489 /** When called this method ensures that all the things needing saving are saved before Gatherer.exit() is called. This includes a save collection prompt if necessary. 489 490 */ 490 491 public void exit() { 491 492 boolean cont = true; … … 546 547 public void setTabEnabled(String rawname, boolean state) { 547 548 // Retrieve the dictionary based name. 548 String name = get(rawname);549 String name = Dictionary.newget("GUI." + rawname); 549 550 int index = tab_pane.indexOfTab(name); 550 551 // Of course we may not have this tab available. … … 720 721 } 721 722 722 /** This method is used to open the options box on the screen. 723 */ 724 public void showOptionsBox() { 725 new OptionsBox(); 726 } 723 727 724 /** This method is used to open the save collection box/prompt on the screen. 728 725 * @return A <i>boolean</i> which is <i>true</i> if the collection was saved successfully, <i>false</i> otherwise. … … 827 824 } 828 825 829 /** Retrieves a phrase from the Dictionary based on the key.830 * @param key A <strong>String</strong> uniquely identifying a phrase from the Dictionary.831 * @return The desired phrase as a <strong>String</strong>.832 * @see org.greenstone.gatherer.Dictionary833 */834 private String get(String key) {835 return get(key, null);836 }837 /** Retrieves a phrase from the Dictionary based on the key and including the arguments.838 * @param key A <strong>String</strong> uniquely identifying a phrase from the Dictionary.839 * @param args A <strong>String[]</strong> of arguments available to be inserted into the phrase.840 * @return The desired phrase as a <strong>String</strong>.841 * @see org.greenstone.gatherer.Dictionary842 */843 private String get(String key, String args[]) {844 if(key.indexOf('.') == -1) {845 key = "GUI." + key;846 }847 return Gatherer.dictionary.get(key, args);848 }849 826 /** Called to determine if we should wait for a thread to finish before continuing. We wait for threads if they are named: GSHELL_BUILD, GSHELL_IMPORT, or GSHELL_NEW. 850 851 827 * @return <i>true</i> if we should wait for a thread, <i>false</i> if it is safe to continue. 828 */ 852 829 private boolean waitForThread() { 853 830 Thread active[] = new Thread[thread_group.activeCount()]; -
trunk/gli/src/org/greenstone/gatherer/gui/LockFileDialog.java
r5536 r5564 7 7 import org.greenstone.gatherer.Dictionary; 8 8 import org.greenstone.gatherer.Gatherer; 9 import org.greenstone.gatherer.gui.SimpleMenuBar; 10 import org.greenstone.gatherer.gui.ModalDialog; 9 11 import org.greenstone.gatherer.msm.MSMUtils; 10 12 import org.greenstone.gatherer.util.Utility; 11 import org.greenstone.gatherer.gui.SimpleMenuBar;12 import org.greenstone.gatherer.gui.ModalDialog;13 13 import org.w3c.dom.*; 14 14 … … 31 31 32 32 public LockFileDialog(JFrame parent, String name, File lock_file) { 33 super(parent, get("LockFileDialog.Title"), true);33 super(parent, Dictionary.newget("LockFileDialog.Title"), true); 34 34 setSize(SIZE); 35 35 setJMenuBar(new SimpleMenuBar("openingacollection")); 36 36 this.self = this; 37 37 38 // Parse the lock file, but do so quietly so that if the XML is poorly formed it doesn't show exception. 38 39 document = Utility.parse(lock_file, false); 40 39 41 // Creation 40 42 JPanel content_pane = (JPanel) getContentPane(); … … 44 46 JLabel icon_label = new JLabel(scaled_icon); 45 47 JPanel title_pane = new JPanel(); 46 JLabel title_one_label = new JLabel(get("General.Warning")); 47 JLabel title_two_label = new JLabel(get("LockFileDialog.Lockfile_Message_One")); 48 JLabel title_one_label = new JLabel(); 49 Dictionary.setText(title_one_label, "General.Warning"); 50 JLabel title_two_label = new JLabel(); 51 Dictionary.setText(title_two_label, "LockFileDialog.Lockfile_Message_One"); 48 52 JPanel central_pane = new JPanel(); 53 49 54 JPanel name_pane = new JPanel(); 50 JLabel name_label = new JLabel( get("LockFileDialog.Name"));55 JLabel name_label = new JLabel(); 51 56 name_label.setPreferredSize(LABEL_SIZE); 57 Dictionary.setText(name_label, "LockFileDialog.Name"); 52 58 JTextField name_field = new JTextField(name); 53 59 name_field.setEditable(false); 54 60 name_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 61 55 62 JPanel person_pane = new JPanel(); 56 JLabel person_label = new JLabel( get("LockFileDialog.User"));63 JLabel person_label = new JLabel(); 57 64 person_label.setPreferredSize(LABEL_SIZE); 65 Dictionary.setText(person_label, "LockFileDialog.User"); 58 66 JTextField person_field = new JTextField(getValue("User")); 59 67 person_field.setEditable(false); 60 68 person_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 69 61 70 JPanel machine_pane = new JPanel(); 62 JLabel machine_label = new JLabel( get("LockFileDialog.Machine"));71 JLabel machine_label = new JLabel(); 63 72 machine_label.setPreferredSize(LABEL_SIZE); 73 Dictionary.setText(machine_label, "LockFileDialog.Machine"); 64 74 JTextField machine_field = new JTextField(getValue("Machine")); 65 75 machine_field.setEditable(false); 66 76 machine_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 77 67 78 JPanel created_pane = new JPanel(); 68 JLabel created_label = new JLabel( get("LockFileDialog.Date"));79 JLabel created_label = new JLabel(); 69 80 created_label.setPreferredSize(LABEL_SIZE); 81 Dictionary.setText(created_label, "LockFileDialog.Date"); 70 82 JTextField created_field = new JTextField(getValue("Date")); 71 83 created_field.setEditable(false); 72 84 created_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 73 JLabel central_label = new JLabel(get("LockFileDialog.Lockfile_Message_Two")); 85 86 JLabel central_label = new JLabel(); 87 Dictionary.setText(central_label, "LockFileDialog.Lockfile_Message_Two"); 74 88 JPanel button_pane = new JPanel(); 75 ok_button = new JButton(get("General.OK")); 76 cancel_button = new JButton(get("General.Cancel")); 89 ok_button = new JButton(); 90 Dictionary.setBoth(ok_button, "General.OK", "LockFileDialog.OK_Tooltip"); 91 cancel_button = new JButton(); 92 Dictionary.setBoth(cancel_button, "General.Cancel", "LockFileDialog.Cancel_Tooltip"); 93 77 94 // Connection 78 95 ok_button.addActionListener(new MyActionListener()); 79 96 cancel_button.addActionListener(new MyActionListener()); 97 80 98 // Layout 81 99 icon_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,10)); … … 121 139 content_pane.add(central_pane, BorderLayout.CENTER); 122 140 content_pane.add(button_pane, BorderLayout.SOUTH); 141 123 142 // Display 124 if (parent != null) {143 if (parent != null) { 125 144 Rectangle frame_bounds = parent.getBounds(); 126 145 setLocation(frame_bounds.x + (frame_bounds.width - SIZE.width) / 2, frame_bounds.y + (frame_bounds.height - SIZE.height) / 2); … … 148 167 } 149 168 else { 150 value = get("LockFileDialog.Error");169 value = Dictionary.newget("LockFileDialog.Error"); 151 170 } 152 171 return value; … … 165 184 } 166 185 } 167 168 static public void main(String[] args) {169 JFrame frame = new JFrame();170 frame.setSize(640,480);171 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);172 frame.show();173 LockFileDialog dialog = new LockFileDialog(frame, "Test", new File(args[0]));174 int choice = dialog.getChoice();175 }176 177 static private String get(String key) {178 if(key.indexOf(".") == -1) {179 key = "LockFileDialog." + key;180 }181 return Gatherer.dictionary.get(key);182 }183 186 } -
trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java
r5527 r5564 1 package org.greenstone.gatherer.gui;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; 40 41 import javax.swing.*; 41 42 import javax.swing.event.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.util.Utility; 46 44 47 /** The menu bar for the Gatherer main GUI. 45 48 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 50 53 /** The icon to be displayed alongside the context choosen help file. */ 51 54 private int current_tab = -1; 55 52 56 private JMenu file = null; 53 57 private JMenu edit = null; 54 58 private JMenu metadata = null; 55 59 private JMenu tools = null; 56 private JMenu log = null;57 private JMenu window = null;58 private JMenu source = null;59 private JMenu level = null;60 60 public JMenu help = null; 61 61 public JMenuItem file_associations; … … 75 75 public JMenuItem edit_replace = null; 76 76 public JMenuItem edit_search = null; 77 public JMenuItem metadata_ add= null;77 public JMenuItem metadata_import = null; 78 78 public JMenuItem metadata_edit = null; 79 79 public JMenuItem metadata_export = null; … … 92 92 public MagicMenuItem metadata_view = null; 93 93 94 public MenuBar(MenuListener menu_listener) {95 96 file = new JMenu( get("Menu.File"));94 public MenuBar(MenuListener menu_listener) 95 { 96 file = new JMenu(); 97 97 file.setMnemonic(KeyEvent.VK_F); 98 this.add(file);99 100 file_associations = new JMenuItem( get("Menu.File_Associations"), KeyEvent.VK_A);98 Dictionary.registerText(file, "Menu.File"); 99 100 file_associations = new JMenuItem(); 101 101 file_associations.addActionListener(Gatherer.g_man); 102 103 file_close = new JMenuItem(get("Menu.File_Close"), KeyEvent.VK_C); 102 file_associations.setMnemonic(KeyEvent.VK_A); 103 Dictionary.registerText(file_associations, "Menu.File_Associations"); 104 105 file_close = new JMenuItem(); 104 106 file_close.addActionListener(Gatherer.g_man); 105 107 file_close.setEnabled(false); 106 107 file_delete = new JMenuItem(get("Menu.File_Delete"), KeyEvent.VK_D); 108 file_close.setMnemonic(KeyEvent.VK_C); 109 Dictionary.registerText(file_close, "Menu.File_Close"); 110 111 file_delete = new JMenuItem(); 108 112 file_delete.addActionListener(Gatherer.g_man); 109 110 file_exit = new JMenuItem(get("Menu.File_Exit"), KeyEvent.VK_X); 113 file_delete.setMnemonic(KeyEvent.VK_D); 114 Dictionary.registerText(file_delete, "Menu.File_Delete"); 115 116 file_exit = new JMenuItem(); 111 117 file_exit.addActionListener(Gatherer.g_man); 112 113 file_new = new JMenuItem(get("Menu.File_New"), KeyEvent.VK_N); 118 file_exit.setMnemonic(KeyEvent.VK_X); 119 Dictionary.registerText(file_exit, "Menu.File_Exit"); 120 121 file_new = new JMenuItem(); 114 122 file_new.addActionListener(Gatherer.g_man); 115 116 file_open = new JMenuItem(get("Menu.File_Open"), KeyEvent.VK_O); 123 file_new.setMnemonic(KeyEvent.VK_N); 124 Dictionary.registerText(file_new, "Menu.File_New"); 125 126 file_open = new JMenuItem(); 117 127 file_open.addActionListener(Gatherer.g_man); 118 119 file_options = new JMenuItem(get("Menu.File_Options"), KeyEvent.VK_P); 120 file_options.addActionListener(Gatherer.g_man); 121 122 file_save = new JMenuItem(get("Menu.File_Save"), KeyEvent.VK_S); 128 file_open.setMnemonic(KeyEvent.VK_O); 129 Dictionary.registerText(file_open, "Menu.File_Open"); 130 131 file_options = new JMenuItem(); 132 file_options.addActionListener(Gatherer.g_man); 133 file_options.setMnemonic(KeyEvent.VK_P); 134 Dictionary.registerText(file_options, "Menu.File_Options"); 135 136 file_save = new JMenuItem(); 123 137 file_save.addActionListener(Gatherer.g_man); 124 138 file_save.setEnabled(false); 125 126 file_save_as = new JMenuItem(get("Menu.File_Save_As"), KeyEvent.VK_A); 127 //file_save_as.addActionListener(Gatherer.g_man); 128 file_save_as.setEnabled(false); 129 130 // Layout file menu 139 file_save.setMnemonic(KeyEvent.VK_S); 140 Dictionary.registerText(file_save, "Menu.File_Save"); 141 142 // file_save_as = new JMenuItem(); 143 // file_save_as.addActionListener(Gatherer.g_man); 144 // file_save_as.setEnabled(false); 145 // file_save_as.setMnemonic(KeyEvent.VK_A); 146 // Dictionary.registerText(file_save_as, "Menu.File_Save_As"); 147 148 // Layout (file menu) 131 149 file.add(file_new); 132 150 file.add(file_open); 133 151 file.add(file_save); 134 // file.add(file_save_as);152 // file.add(file_save_as); 135 153 file.add(file_close); 136 //file.add(new JSeparator());137 154 file.add(file_delete); 138 155 file.add(new JSeparator()); … … 143 160 144 161 // Edit menu 145 edit = new JMenu( get("Menu.Edit"));162 edit = new JMenu(); 146 163 edit.setMnemonic(KeyEvent.VK_E); 147 this.add(Box.createHorizontalStrut(15)); 148 this.add(edit); 164 Dictionary.registerText(edit, "Menu.Edit"); 149 165 150 edit_cut = new JMenuItem( get("Menu.Edit_Cut") + " (ctrl-x)", KeyEvent.VK_X);166 edit_cut = new JMenuItem(); 151 167 edit_cut.addActionListener(Gatherer.g_man); 152 153 edit_copy = new JMenuItem(get("Menu.Edit_Copy") + " (ctrl-c)", KeyEvent.VK_C); 168 edit_cut.setMnemonic(KeyEvent.VK_X); 169 Dictionary.registerText(edit_cut, "Menu.Edit_Cut"); 170 171 edit_copy = new JMenuItem(); 154 172 edit_copy.addActionListener(Gatherer.g_man); 155 156 edit_paste = new JMenuItem(get("Menu.Edit_Paste") + " (ctrl-v)", KeyEvent.VK_V); 173 edit_copy.setMnemonic(KeyEvent.VK_C); 174 Dictionary.registerText(edit_copy, "Menu.Edit_Copy"); 175 176 edit_paste = new JMenuItem(); 157 177 edit_paste.addActionListener(Gatherer.g_man); 158 159 edit_undo = new JMenuItem(get("Menu.Edit_Undo"), KeyEvent.VK_U); 160 edit_undo.setEnabled(false); 161 162 edit_redo = new JMenuItem(get("Menu.Edit_Redo"), KeyEvent.VK_D); 163 edit_redo.setEnabled(false); 164 165 edit_search = new JMenuItem(get("Menu.Edit_Search"), KeyEvent.VK_S); 166 edit_search.addActionListener(Gatherer.g_man); 167 168 edit_replace = new JMenuItem(get("Menu.Edit_Replace"), KeyEvent.VK_R); 169 edit_replace.addActionListener(Gatherer.g_man); 170 178 edit_paste.setMnemonic(KeyEvent.VK_V); 179 Dictionary.registerText(edit_paste, "Menu.Edit_Paste"); 180 181 // edit_undo = new JMenuItem(); 182 // edit_undo.setEnabled(false); 183 // edit_undo.setMnemonic(KeyEvent.VK_U); 184 // Dictionary.registerText(edit_undo, "Menu.Edit_Undo"); 185 186 // edit_redo = new JMenuItem(); 187 // edit_redo.setEnabled(false); 188 // edit_redo.setMnemonic(KeyEvent.VK_D); 189 // Dictionary.registerText(edit_redo, "Menu.Edit_Redo"); 190 191 // edit_search = new JMenuItem(); 192 // edit_search.addActionListener(Gatherer.g_man); 193 // edit_search.setMnemonic(KeyEvent.VK_S); 194 // Dictionary.registerText(edit_search, "Menu.Edit_Search"); 195 196 // edit_replace = new JMenuItem(); 197 // edit_replace.addActionListener(Gatherer.g_man); 198 // edit_replace.setMnemonic(KeyEvent.VK_R); 199 // Dictionary.registerText(edit_replace, "Menu.Edit_Replace"); 200 201 // Layout (edit menu) 171 202 edit.add(edit_cut); 172 203 edit.add(edit_copy); 173 204 edit.add(edit_paste); 174 // edit.add(new JSeparator());175 // edit.add(edit_undo);176 // edit.add(edit_redo);177 // edit.add(new JSeparator());178 // edit.add(edit_search);179 // edit.add(edit_replace);205 // edit.add(new JSeparator()); 206 // edit.add(edit_undo); 207 // edit.add(edit_redo); 208 // edit.add(new JSeparator()); 209 // edit.add(edit_search); 210 // edit.add(edit_replace); 180 211 181 212 // Metadata menu 182 metadata = new JMenu( get("Menu.Metadata"));213 metadata = new JMenu(); 183 214 metadata.setEnabled(false); 184 215 metadata.setMnemonic(KeyEvent.VK_M); 185 186 metadata_add = new JMenuItem(get("Menu.Metadata_Add"), KeyEvent.VK_I); 187 metadata_add.addActionListener(Gatherer.g_man); 188 189 metadata_edit = new JMenuItem(get("Menu.Metadata_Edit"), KeyEvent.VK_E); 216 Dictionary.registerText(metadata, "Menu.Metadata"); 217 218 metadata_import = new JMenuItem(); 219 metadata_import.addActionListener(Gatherer.g_man); 220 metadata_import.setMnemonic(KeyEvent.VK_I); 221 Dictionary.registerText(metadata_import, "Menu.Metadata_Import"); 222 223 metadata_edit = new JMenuItem(); 190 224 metadata_edit.addActionListener(Gatherer.g_man); 191 192 metadata_export = new JMenuItem(get("Menu.Metadata_Export"), KeyEvent.VK_X); 225 metadata_edit.setMnemonic(KeyEvent.VK_E); 226 Dictionary.registerText(metadata_edit, "Menu.Metadata_Edit"); 227 228 metadata_export = new JMenuItem(); 193 229 metadata_export.addActionListener(Gatherer.g_man); 194 195 metadata_view = new MagicMenuItem(get("Menu.Metadata_View") + " " + get("FileActions.No_Selection"), KeyEvent.VK_A); 230 metadata_export.setMnemonic(KeyEvent.VK_X); 231 Dictionary.registerText(metadata_export, "Menu.Metadata_Export"); 232 233 metadata_view = new MagicMenuItem(Dictionary.newget("Menu.Metadata_View") + " " + Dictionary.newget("FileActions.No_Selection"), KeyEvent.VK_A); 196 234 metadata_view.addActionListener(Gatherer.g_man); 197 235 198 metadata.add(metadata_add); 236 // Layout (metadata sets menu) 237 metadata.add(metadata_import); 199 238 metadata.add(metadata_edit); 200 239 metadata.add(metadata_export); 201 240 metadata.add(metadata_view); 241 242 // Tools menu 243 // tools = new JMenu(); 244 // tools.setEnabled(false); 245 // tools.setMnemonic(KeyEvent.VK_T); 246 // Dictionary.registerText(tools, "Menu.Tools"); 247 248 // tools_log = new JMenuItem(); 249 // tools_log.addActionListener(Gatherer.g_man); 250 // tools_log.setMnemonic(KeyEvent.VK_L); 251 // Dictionary.registerText(tools_log, "Menu.Tools_Log"); 252 253 // tools_size = new JMenuItem(); 254 // tools_size.addActionListener(Gatherer.g_man); 255 // tools_size.setMnemonic(KeyEvent.VK_C); 256 // Dictionary.registerText(tools_size, "Menu.Tools_Calculate_Record_Size"); 257 258 // Layout (tools menu) 259 // tools.add(tools_log); 260 // tools.add(tools_size); 261 262 // Help menu 263 help = new JMenu(); 264 help.setIcon(Utility.HELP_ICON); 265 Dictionary.setText(help, "Menu.Help"); 266 267 help_about = new JMenuItem(); 268 help_about.addActionListener(Gatherer.g_man); 269 Dictionary.registerText(help_about, "Menu.Help_About"); 270 271 help_browse = new JMenuItem(Utility.BLANK_ICON); 272 help_browse.addActionListener(Gatherer.g_man); 273 Dictionary.registerText(help_browse, "GUI.Hunt"); 274 275 help_build = new JMenuItem(Utility.BLANK_ICON); 276 help_build.addActionListener(Gatherer.g_man); 277 Dictionary.registerText(help_build, "GUI.Create"); 278 279 help_collect = new JMenuItem(Utility.BLANK_ICON); 280 help_collect.addActionListener(Gatherer.g_man); 281 Dictionary.registerText(help_collect, "GUI.Gather"); 282 283 help_design = new JMenuItem(Utility.BLANK_ICON); 284 help_design.addActionListener(Gatherer.g_man); 285 Dictionary.registerText(help_design, "GUI.Design"); 286 287 help_export = new JMenuItem(Utility.BLANK_ICON); 288 help_export.addActionListener(Gatherer.g_man); 289 Dictionary.registerText(help_export, "GUI.Export"); 290 291 help_general = new JMenuItem(); 292 help_general.addActionListener(Gatherer.g_man); 293 Dictionary.registerText(help_general, "Source.General"); 294 295 help_metaedit = new JMenuItem(Utility.BLANK_ICON); 296 help_metaedit.addActionListener(Gatherer.g_man); 297 Dictionary.registerText(help_metaedit, "GUI.Enrich"); 298 299 help_mirror = new JMenuItem(Utility.BLANK_ICON); 300 help_mirror.addActionListener(Gatherer.g_man); 301 Dictionary.registerText(help_mirror, "GUI.Mirror"); 302 303 help_preview = new JMenuItem(Utility.BLANK_ICON); 304 help_preview.addActionListener(Gatherer.g_man); 305 Dictionary.registerText(help_preview, "GUI.Preview"); 306 307 // Layout (help menu) 308 help.add(help_general); 309 help.add(new JSeparator()); 310 if (Gatherer.config.get("workflow.browse", true)) { 311 help.add(help_browse); 312 } 313 if (Gatherer.config.get("workflow.mirror", true)) { 314 help.add(help_mirror); 315 } 316 if (Gatherer.config.get("workflow.gather", true)) { 317 help.add(help_collect); 318 } 319 if (Gatherer.config.get("workflow.enrich", true)) { 320 help.add(help_metaedit); 321 } 322 if (Gatherer.config.get("workflow.design", true)) { 323 help.add(help_design); 324 } 325 if (Gatherer.config.get("workflow.export", true)) { 326 help.add(help_export); 327 } 328 if (Gatherer.config.get("workflow.create", true)) { 329 help.add(help_build); 330 } 331 if (Gatherer.config.get("workflow.preview", true)) { 332 help.add(help_preview); 333 } 334 help.add(new JSeparator()); 335 help.add(help_about); 336 337 // Layout (menu bar) 338 this.add(file); 339 this.add(Box.createHorizontalStrut(15)); 340 this.add(edit); 202 341 this.add(Box.createHorizontalStrut(15)); 203 342 this.add(metadata); 204 205 // Tools menu 206 tools = new JMenu(get("Menu.Tools")); 207 208 tools_log = new JMenuItem(get("Menu.Tools_Log"), KeyEvent.VK_L); 209 tools_log.addActionListener(Gatherer.g_man); 210 211 tools_size = new JMenuItem("Calculate Record Size", KeyEvent.VK_S); 212 tools_size.addActionListener(Gatherer.g_man); 213 214 tools.add(tools_log); 215 tools.add(tools_size); 216 //this.add(Box.createHorizontalStrut(15)); 217 //this.add(tools); 218 219 // Help menu 220 help = new JMenu(get("Menu.Help")); 221 //help.addMenuListener(menu_listener); 222 help.setIcon(Utility.HELP_ICON); 223 224 help_about = new JMenuItem(get("Menu.Help_About")); 225 help_about.addActionListener(Gatherer.g_man); 226 227 help_browse = new JMenuItem(get("GUI.Hunt"), Utility.BLANK_ICON); 228 help_browse.addActionListener(Gatherer.g_man); 229 230 help_build = new JMenuItem(get("GUI.Create"), Utility.BLANK_ICON); 231 help_build.addActionListener(Gatherer.g_man); 232 233 help_collect = new JMenuItem(get("GUI.Gather"), Utility.BLANK_ICON); 234 help_collect.addActionListener(Gatherer.g_man); 235 236 help_design = new JMenuItem(get("GUI.Design"), Utility.BLANK_ICON); 237 help_design.addActionListener(Gatherer.g_man); 238 239 help_export = new JMenuItem(get("GUI.Export"), Utility.BLANK_ICON); 240 help_export.addActionListener(Gatherer.g_man); 241 242 help_general = new JMenuItem(get("Source.General")); 243 help_general.addActionListener(Gatherer.g_man); 244 245 help_metaedit = new JMenuItem(get("GUI.Enrich"), Utility.BLANK_ICON); 246 help_metaedit.addActionListener(Gatherer.g_man); 247 248 help_mirror = new JMenuItem(get("GUI.Mirror"), Utility.BLANK_ICON); 249 help_mirror.addActionListener(Gatherer.g_man); 250 251 help_preview = new JMenuItem(get("GUI.Preview"), Utility.BLANK_ICON); 252 help_preview.addActionListener(Gatherer.g_man); 253 254 // Layout help 255 help.add(help_general); 256 help.add(new JSeparator()); 257 if(Gatherer.config.get("workflow.browse", true)) { 258 help.add(help_browse); 259 } 260 if(Gatherer.config.get("workflow.mirror", true)) { 261 help.add(help_mirror); 262 } 263 if(Gatherer.config.get("workflow.gather", true)) { 264 help.add(help_collect); 265 } 266 if(Gatherer.config.get("workflow.enrich", true)) { 267 help.add(help_metaedit); 268 } 269 if(Gatherer.config.get("workflow.design", true)) { 270 help.add(help_design); 271 } 272 if(Gatherer.config.get("workflow.export", true)) { 273 help.add(help_export); 274 } 275 if(Gatherer.config.get("workflow.create", true)) { 276 help.add(help_build); 277 } 278 if(Gatherer.config.get("workflow.preview", true)) { 279 help.add(help_preview); 280 } 281 help.add(new JSeparator()); 282 help.add(help_about); 343 // this.add(Box.createHorizontalStrut(15)); 344 // this.add(tools); 283 345 this.add(Box.createHorizontalGlue()); 284 346 this.add(help); … … 288 350 file_close.setEnabled(ready); 289 351 file_save.setEnabled(ready); 290 file_save_as.setEnabled(ready);352 // file_save_as.setEnabled(ready); 291 353 metadata.setEnabled(ready); 292 tools.setEnabled(ready);293 if (ready) {294 Gatherer.c_man.undo.registerRedoSource(edit_redo);295 Gatherer.c_man.undo.registerUndoSource(edit_undo);354 // tools.setEnabled(ready); 355 if (ready) { 356 // Gatherer.c_man.undo.registerRedoSource(edit_redo); 357 // Gatherer.c_man.undo.registerUndoSource(edit_undo); 296 358 } 297 359 } … … 299 361 /** Once a quit has been requested by the user, prevent any further menu selections. */ 300 362 public void exit() { 363 file.setEnabled(false); 301 364 edit.setEnabled(false); 302 file.setEnabled(false); 365 metadata.setEnabled(false); 366 // tools.setEnabled(false); 303 367 help.setEnabled(false); 304 metadata.setEnabled(false);305 368 } 306 369 … … 308 371 ///ystem.err.println("**** Set suffix: " + metaaudit_suffix); 309 372 if(metaaudit_suffix == null) { 310 metadata_view.setText( get("Menu.Metadata_View") + " " +get("FileActions.No_Selection"));373 metadata_view.setText(Dictionary.newget("Menu.Metadata_View") + " " + Dictionary.newget("FileActions.No_Selection")); 311 374 metadata_view.setEnabled(false); 312 375 } 313 376 else { 314 377 ///ystem.err.println("Set metadata view suffix: " + metaaudit_suffix); 315 metadata_view.setText( get("Menu.Metadata_View") + " " + metaaudit_suffix);378 metadata_view.setText(Dictionary.newget("Menu.Metadata_View") + " " + metaaudit_suffix); 316 379 metadata_view.setEnabled(true); 317 380 } … … 332 395 JMenuItem selected; 333 396 if(current_tab != -1) { 334 397 // Remove the image 335 398 selected = help.getItem(current_tab); 336 399 if(selected != null) { … … 345 408 selected = null; 346 409 } 347 348 /** Retrieves a key from the Dictionary, using no extra arguments. 349 * @param key A String which maps to a certain phrase from the Dictionary. 350 * @return The String the matches the key or an error String if no match 351 * found. 352 */ 353 private String get(String key) { 354 // return get(key, null); 355 return Gatherer.dictionary.get(key, (String[]) null); 356 } 357 358 /** Retrieves a key from the Dictionary, providing extra arguments to 359 * be inserted using a String array. 360 * @param key A String which maps to a certain phrase from the Dictionary. 361 * @param args A String array containing further arguments (such as 362 * formatting instructions and variable values) to be taken into account 363 * when Dictionary creates the return String. 364 * @return The String the matches the key or an error String if no match 365 * found. 366 */ 367 /* private String get(String key, String args[]) { 368 if(key.indexOf('.') == -1) { 369 key = "Menu." + key; 370 } 371 return Gatherer.dictionary.get(key, args); 372 } */ 410 373 411 374 412 public class MagicMenuItem 375 413 extends JMenuItem { 376 414 377 415 private boolean can_enable; 378 416 private boolean should_enable; … … 386 424 387 425 public void setCanEnable(boolean can_enable) { 388 ///ystem.err.println("can_enable = " + can_enable);389 426 this.can_enable = can_enable; 390 427 if (can_enable) { 391 ///ystem.err.println("setEnable(" + should_enable + ")");392 428 super.setEnabled(should_enable); 393 429 } … … 398 434 399 435 public void setEnabled(boolean should_enable) { 400 ///ystem.err.println("should_enable = " + should_enable);401 436 this.should_enable = should_enable; 402 if(can_enable) { 403 ///ystem.err.println("setEnable(" + should_enable + ")"); 437 if (can_enable) { 404 438 super.setEnabled(should_enable); 405 439 } 406 440 } 407 441 } 408 409 private class NonFocusMenu410 extends JMenu {411 public NonFocusMenu(String name) {412 super(name);413 setFocusPainted(false);414 }415 416 public boolean isFocusable(){417 return false;418 }419 420 public void requestFocus(){421 }422 423 public boolean requestFocus(boolean t){424 return false;425 }426 427 public void setFocusable(boolean f) {428 }429 }430 431 private class NonFocusMenuItem432 extends JMenuItem {433 public NonFocusMenuItem(String name, int key) {434 super(name, key);435 setFocusPainted(false);436 }437 438 public boolean isFocusable(){439 return false;440 }441 442 public void requestFocus(){443 }444 445 public boolean requestFocus(boolean t){446 return false;447 }448 449 public void setFocusable(boolean f) {450 }451 452 }453 442 } -
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r5536 r5564 1008 1008 1009 1009 JPanel value_pane = new JPanel(); 1010 JLabel value_label = new JLabel( "MetaEdit.Value");1010 JLabel value_label = new JLabel(); 1011 1011 value_label.setPreferredSize(VALUE_LABEL_SIZE); 1012 Dictionary.registerText(value_label, "MetaEdit.Value"); 1012 1013 1013 1014 JPanel value_field_pane = new JPanel(); 1014 value = new JTextField( "MetaEdit.Value_Field");1015 value = new JTextField(); 1015 1016 value.setBackground(Gatherer.config.getColor("coloring.editable_background", false)); 1016 1017 value.setForeground(Gatherer.config.getColor("coloring.editable_foreground", false)); … … 1019 1020 value.addKeyListener(new MetadataFieldListener()); 1020 1021 value.setFocusTraversalKeysEnabled(false); 1022 Dictionary.setTooltip(value, "MetaEdit.Value_Field_Tooltip"); 1021 1023 1022 1024 JPanel button_pane = new JPanel(); 1023 1025 1024 1026 JPanel tree_pane = new JPanel(); 1025 JLabel tree_label = new JLabel("MetaEdit.Tree"); 1027 JLabel tree_label = new JLabel(); 1028 Dictionary.registerText(tree_label, "MetaEdit.Tree"); 1026 1029 1027 1030 tree = new JTree(new GValueModel()); -
trunk/gli/src/org/greenstone/gatherer/gui/NewFolderPrompt.java
r4675 r5564 8 8 import org.greenstone.gatherer.Gatherer; 9 9 import org.greenstone.gatherer.file.FileNode; 10 import org.greenstone.gatherer.gui.GUIManager;11 10 12 11 public class NewFolderPrompt … … 20 19 static final private Dimension LABEL_SIZE = new Dimension(100,25); 21 20 static final private Dimension SIZE = new Dimension(300,100); 21 22 22 public NewFolderPrompt(FileNode node) { 23 super(Gatherer.g_man, Gatherer.dictionary.get("NewFolderPrompt.Title"), true);23 super(Gatherer.g_man, Dictionary.newget("NewFolderPrompt.Title"), true); 24 24 this.node = node; 25 25 } 26 26 27 27 public void actionPerformed(ActionEvent event) { 28 if (event.getSource() == ok_button) {28 if (event.getSource() == ok_button) { 29 29 name = name_field.getText(); 30 30 } … … 39 39 JPanel content_pane = (JPanel) getContentPane(); 40 40 JPanel name_pane = new JPanel(); 41 JLabel name_label = new JLabel( Gatherer.dictionary.get("NewFolderPrompt.Folder_Name"));41 JLabel name_label = new JLabel(); 42 42 name_label.setPreferredSize(LABEL_SIZE); 43 Dictionary.setText(name_label, "NewFolderPrompt.Folder_Name"); 43 44 name_field = new JTextField(getAutomaticName()); 45 Dictionary.setTooltip(name_field, "NewFolderPrompt.Folder_Name_Tooltip"); 46 44 47 JPanel button_pane = new JPanel(); 45 ok_button = new JButton(Gatherer.dictionary.get("General.OK")); 46 cancel_button = new JButton(Gatherer.dictionary.get("General.Cancel")); 48 ok_button = new JButton(); 49 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip"); 50 cancel_button = new JButton(); 51 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Good_Cancel_Tooltip"); 52 47 53 // Connection 48 54 cancel_button.addActionListener(this); 49 55 ok_button.addActionListener(this); 56 50 57 // Layout 51 58 name_pane.setLayout(new BorderLayout()); … … 61 68 content_pane.add(name_pane, BorderLayout.CENTER); 62 69 content_pane.add(button_pane, BorderLayout.SOUTH); 70 63 71 // Display 64 72 Rectangle frame_bounds = Gatherer.g_man.getBounds(); … … 68 76 } 69 77 70 private String getAutomaticName() { 78 private String getAutomaticName() 79 { 71 80 File file = node.getFile(); 72 String default_name = Gatherer.dictionary.get("NewFolderPrompt.Default_Folder_Name");81 String default_name = Dictionary.newget("NewFolderPrompt.Default_Folder_Name"); 73 82 File temp_file = new File(file, default_name); 74 83 int count = 1; 75 if(temp_file.exists()) {84 while (temp_file.exists()) { 76 85 temp_file = new File(file, default_name + " " + count); 77 86 count++; -
trunk/gli/src/org/greenstone/gatherer/gui/SmarterTextArea.java
r4675 r5564 35 35 *######################################################################## 36 36 */ 37 38 37 package org.greenstone.gatherer.gui; 39 38 … … 69 68 init = false; 70 69 } 70 71 71 private class UnchangingDocument 72 72 extends PlainDocument { -
trunk/gli/src/org/greenstone/gatherer/gui/WarningDialog.java
r5185 r5564 7 7 import org.greenstone.gatherer.Dictionary; 8 8 import org.greenstone.gatherer.Gatherer; 9 import org.greenstone.gatherer.gui.SmarterTextArea;9 // import org.greenstone.gatherer.gui.SmarterTextArea; 10 10 import org.greenstone.gatherer.util.FocusChangerTask; 11 11 import org.greenstone.gatherer.util.Utility; … … 57 57 public WarningDialog(String full_property, boolean can_cancel, String affected_property, Dictionary dictionary) { 58 58 super(Gatherer.g_man, "Warning", true); 59 59 60 // Determine the name of this prompt. 60 61 this.affected_property = affected_property; … … 62 63 this.full_property = full_property; 63 64 warning_name = full_property.substring(full_property.indexOf(".") + 1); 65 64 66 // Now build dialog. 65 if (affected_property != null) {67 if (affected_property != null) { 66 68 setSize(SETTING_SIZE); 67 69 } … … 69 71 setSize(NORMAL_SIZE); 70 72 } 71 setTitle(get("Title")); 73 Dictionary.setText(this, warning_name + ".Title"); 74 72 75 // Creation 73 76 JPanel content_pane = (JPanel) getContentPane(); 74 77 JPanel text_pane = new JPanel(); 75 78 JLabel icon_label = new JLabel(Utility.getImage("gatherer_medium.gif")); 76 SmarterTextArea text_area = new SmarterTextArea(get("Message"), false); 79 80 // SmarterTextArea text_area = new SmarterTextArea("", false); 81 JTextArea text_area = new JTextArea(); 77 82 text_area.setCaretPosition(0); 83 text_area.setEditable(false); 78 84 text_area.setLineWrap(true); 79 85 text_area.setWrapStyleWord(true); 86 Dictionary.setText(text_area, warning_name + ".Message"); 87 80 88 value_panel = new JPanel(); 81 JLabel value_label = new JLabel( get("WarningDialog.Value"));89 JLabel value_label = new JLabel(); 82 90 value_label.setPreferredSize(LABEL_SIZE); 91 Dictionary.setText(value_label, "WarningDialog.Value"); 92 83 93 value_field = new JTextField(); 84 94 JPanel bottom_pane = new JPanel(); 85 show_check = new JCheckBox(get("WarningDialog.Dont_Show_Again"), false); 95 show_check = new JCheckBox(); 96 Dictionary.setText(show_check, "WarningDialog.Dont_Show_Again"); 86 97 JPanel control_pane = new JPanel(); 87 ok_button = new JButton(get("General.OK")); 88 cancel_button = new JButton(get("General.Cancel")); 98 ok_button = new JButton(); 99 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip"); 100 cancel_button = new JButton(); 101 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip"); 102 89 103 // Connection 90 104 ok_button.addActionListener(this); … … 92 106 ok_button.addKeyListener(this); 93 107 cancel_button.addKeyListener(this); 108 94 109 // Layout 95 110 icon_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); … … 108 123 text_pane.add(value_panel, BorderLayout.SOUTH); 109 124 } 110 125 111 126 if(can_cancel) { 112 127 control_pane.setLayout(new GridLayout(1,2,5,0)); … … 128 143 content_pane.add(text_pane, BorderLayout.CENTER); 129 144 content_pane.add(bottom_pane, BorderLayout.SOUTH); 145 130 146 // Position 131 147 Dimension size = getSize(); 132 if (Gatherer.g_man != null) {148 if (Gatherer.g_man != null) { 133 149 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 134 150 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); … … 169 185 } 170 186 else { 171 JOptionPane.showMessageDialog(Gatherer.g_man, get("WarningDialog.Invalid_Value"),get("General.Error"), JOptionPane.ERROR_MESSAGE);187 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("WarningDialog.Invalid_Value"), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE); 172 188 } 173 189 } … … 222 238 value_panel.add(value_field, BorderLayout.CENTER); 223 239 } 224 225 private String get(String key) {226 if(key.indexOf(".") == -1) {227 key = warning_name + "." + key;228 }229 return dictionary.get(key);230 }231 240 } -
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/AutofilterDialog.java
r5527 r5564 1 package org.greenstone.gatherer.gui.metaaudit;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui.metaaudit; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; 40 41 import java.util.*; 41 42 import javax.swing.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.gui.metaaudit.Autofilter; … … 61 63 /** The button used to cancel the prompt. */ 62 64 private JButton cancel_button = null; 63 /** The button used to accept and commit any changes to the autofilter. */64 private JButton ok_button = null;65 /** A check box used to specify that the given filters should be applied conjunctly. */66 private J CheckBox and_check= null;65 private JButton remove_button = null; 66 private JButton set_button = null; 67 /** Used to specify that the given filters should be applied conjunctly. */ 68 private JRadioButton and_radiobutton = null; 67 69 /** The check box used to specify whether the first filter is case sensitive. */ 68 70 private JCheckBox first_case = null; 69 /** The none check is used to disable the second filter. */70 private J CheckBox none_check= null;71 /** The check box used to specify that the given filters should be applied disjunctly. */72 private J CheckBox or_check= null;71 /** Used to disable the second filter. */ 72 private JRadioButton none_radiobutton = null; 73 /** Used to specify that the given filters should be applied disjunctly. */ 74 private JRadioButton or_radiobutton = null; 73 75 /** The check box used to specify whether the second filter is case sensitive. */ 74 76 private JCheckBox second_case = null; … … 93 95 /** The default size for the autofilter control. */ 94 96 static final private Dimension SIZE = new Dimension(640, 245); 97 95 98 /** Constructor. 96 99 * @param dialog A reference to the <strong>MetaAuditFrame</strong> that spawned this dialog. … … 104 107 this.self = this; 105 108 setModal(true); 109 setJMenuBar(new SimpleMenuBar("reviewingmetadata")); 106 110 setSize(SIZE); 107 setTitle(get("Autofilter.Title"));108 setJMenuBar(new SimpleMenuBar("reviewingmetadata")); 111 Dictionary.setText(this, "Autofilter.Title"); 112 109 113 // Creation 110 114 JPanel content_pane = (JPanel) getContentPane(); 111 115 JPanel name_pane = new JPanel(); 112 JLabel name_label = new JLabel(get("Autofilter.Name")); 116 JLabel name_label = new JLabel(); 117 Dictionary.setText(name_label, "Autofilter.Name"); 113 118 JTextField name_template = new JTextField(); 114 119 name = new JLabel(); … … 117 122 JPanel value_pane = new JPanel(); 118 123 JPanel inner_value_pane = new JPanel(); 119 JLabel value_label = new JLabel(get("Autofilter.eqeq")); 124 JLabel value_label = new JLabel(); 125 Dictionary.setText(value_label, "Autofilter.eqeq"); 120 126 value = new JComboBox(); 121 127 value.setEditable(false); 122 128 JPanel custom_pane = new JPanel(); 129 123 130 JPanel first_pane = new JPanel(); 124 131 first_method = new JComboBox(); … … 127 134 first_value.addItem(""); 128 135 first_value.setSelectedItem(""); 129 first_case = new JCheckBox(get("Autofilter.Case_Sensitive")); 136 first_case = new JCheckBox(); 137 Dictionary.setText(first_case, "Autofilter.Case_Sensitive"); 130 138 JPanel operator_pane = new JPanel(); 131 JLabel operator_label = new JLabel(get("Autofilter.Operator")); 139 JLabel operator_label = new JLabel(); 140 Dictionary.setText(operator_label, "Autofilter.Operator"); 132 141 ButtonGroup operator_group = new ButtonGroup(); 133 and_check = new JCheckBox(get("Autofilter.AND")); 134 none_check = new JCheckBox(get("Autofilter.None")); 135 or_check = new JCheckBox(get("Autofilter.OR")); 136 none_check.setSelected(true); 137 operator_group.add(none_check); 138 operator_group.add(and_check); 139 operator_group.add(or_check); 142 and_radiobutton = new JRadioButton(); 143 and_radiobutton.setOpaque(false); 144 Dictionary.setText(and_radiobutton, "Autofilter.AND"); 145 none_radiobutton = new JRadioButton(); 146 none_radiobutton.setOpaque(false); 147 none_radiobutton.setSelected(true); 148 Dictionary.setText(none_radiobutton, "Autofilter.None"); 149 or_radiobutton = new JRadioButton(); 150 or_radiobutton.setOpaque(false); 151 Dictionary.setText(or_radiobutton, "Autofilter.OR"); 152 operator_group.add(none_radiobutton); 153 operator_group.add(and_radiobutton); 154 operator_group.add(or_radiobutton); 155 140 156 JPanel second_pane = new JPanel(); 141 157 second_method = new JComboBox(); … … 146 162 second_value.addItem(""); 147 163 second_value.setSelectedItem(""); 148 second_case = new JCheckBox(get("Autofilter.Case_Sensitive")); 164 second_case = new JCheckBox(); 165 Dictionary.setText(second_case, "Autofilter.Case_Sensitive"); 149 166 JPanel lower_pane = new JPanel(); 150 167 JPanel order_pane = new JPanel(); 151 JLabel order_label = new JLabel(get("Autofilter.Order")); 168 JLabel order_label = new JLabel(); 169 Dictionary.setText(order_label, "Autofilter.Order"); 152 170 order = new JComboBox(); 153 order.addItem(get("Autofilter.Ascending")); 154 order.addItem(get("Autofilter.Descending")); 171 order.addItem(Dictionary.newget("Autofilter.Ascending")); 172 order.addItem(Dictionary.newget("Autofilter.Descending")); 173 Dictionary.setTooltip(order, "Autofilter.Order_Tooltip"); 174 155 175 // Assign values to method comboboxes. 156 176 for(int i = 0; i < Autofilter.METHOD_LIST.length; i++) { 157 first_method.addItem( get(Autofilter.METHOD_LIST[i]));158 second_method.addItem( get(Autofilter.METHOD_LIST[i]));177 first_method.addItem(Dictionary.newget("Autofilter." + Autofilter.METHOD_LIST[i])); 178 second_method.addItem(Dictionary.newget("Autofilter." + Autofilter.METHOD_LIST[i])); 159 179 } 160 180 JPanel button_pane = new JPanel(); 161 cancel_button = new JButton( get("Autofilter.Clear"));181 cancel_button = new JButton(); 162 182 cancel_button.setMnemonic(KeyEvent.VK_C); 163 ok_button = new JButton(get("Autofilter.Set")); 164 ok_button.setMnemonic(KeyEvent.VK_S); 183 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip"); 184 remove_button = new JButton(); 185 remove_button.setMnemonic(KeyEvent.VK_R); 186 Dictionary.setBoth(remove_button, "Autofilter.Remove", "Autofilter.Remove_Tooltip"); 187 set_button = new JButton(); 188 set_button.setMnemonic(KeyEvent.VK_S); 189 Dictionary.setBoth(set_button, "Autofilter.Set", "Autofilter.Set_Tooltip"); 190 165 191 // Connection 166 and_check.addActionListener(new CheckListener(true)); 192 and_radiobutton.addActionListener(new CheckListener(true)); 193 none_radiobutton.addActionListener(new CheckListener(false)); 194 or_radiobutton.addActionListener(new CheckListener(true)); 167 195 cancel_button.addActionListener(new ButtonListener(false)); 168 none_check.addActionListener(new CheckListener(false));169 ok_button.addActionListener(new ButtonListener(true));170 or_check.addActionListener(new CheckListener(true)); 196 remove_button.addActionListener(new ButtonListener(false)); 197 set_button.addActionListener(new ButtonListener(true)); 198 171 199 // Layout 172 200 name_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); … … 194 222 operator_pane.setLayout(new GridLayout(1,4)); 195 223 operator_pane.add(operator_label); 196 operator_pane.add(none_ check);197 operator_pane.add(and_ check);198 operator_pane.add(or_ check);224 operator_pane.add(none_radiobutton); 225 operator_pane.add(and_radiobutton); 226 operator_pane.add(or_radiobutton); 199 227 200 228 second_pane.setLayout(new BorderLayout()); … … 213 241 custom_pane.add(operator_pane); 214 242 custom_pane.add(second_pane); 215 216 control.add( get("Autofilter.Filter_By_Value"), value_pane);217 control.add( get("Autofilter.Custom_Filter"), custom_pane);243 244 control.add(Dictionary.newget("Autofilter.Filter_By_Value"), value_pane); 245 control.add(Dictionary.newget("Autofilter.Custom_Filter"), custom_pane); 218 246 219 247 button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 220 button_pane.setLayout(new GridLayout(1,2)); 221 button_pane.add(ok_button); 248 button_pane.setLayout(new GridLayout(1, 3)); 249 button_pane.add(set_button); 250 button_pane.add(remove_button); 222 251 button_pane.add(cancel_button); 223 252 … … 236 265 screen_size = null; 237 266 } 267 238 268 /** Destructor. */ 239 269 public void destroy() { 240 270 dispose(); 241 cancel_button = null;242 ok_button = null;243 and_check = null;244 271 first_case = null; 245 none_check = null;246 or_check = null;247 272 second_case = null; 248 273 order = null; … … 258 283 } 259 284 /** Display the modal dialog box, allowing the user to define the filter. When the user presses one of the buttons, dispose and return to the caller providing an indication of which button was pressed. 260 261 285 * @return An <i>int</i> which indicates which button was pressed to dismiss the dialog. 286 */ 262 287 public Autofilter display(Autofilter filter, ArrayList raw_values, String column_name) { 263 288 this.filter = filter; … … 277 302 first_value.setSelectedItem(filter.value_one); 278 303 first_case.setSelected(filter.casesense_one); 279 if (filter.value_two == null) {280 none_ check.setSelected(true);304 if (filter.value_two == null) { 305 none_radiobutton.setSelected(true); 281 306 } 282 307 else { 283 if (filter.operation) {284 and_ check.setSelected(true);308 if (filter.operation) { 309 and_radiobutton.setSelected(true); 285 310 } 286 311 else { 287 or_ check.setSelected(true);312 or_radiobutton.setSelected(true); 288 313 } 289 314 second_method.setSelectedIndex(filter.method_two); … … 303 328 return this.filter; 304 329 } 305 /** Use the given key to retrieve a phrase from the dictionary. 306 * @param key A <strong>String</strong> which uniquely maps to an entry in the Dictionary. 307 * @return The <strong>String</strong> to key mapped to. 308 * @see org.greenstone.gatherer.Dictionary 309 */ 310 private final String get(String key) { 311 if(key.indexOf(".") == -1) { 312 key = "Autofilter." + key; 313 } 314 return Gatherer.dictionary.get(key, (String[])null); 315 } 330 316 331 /** Listens for actions on the button it is attached to, and when notified sets the return_value and disposes of the dialog. */ 317 332 private final class ButtonListener … … 337 352 else { 338 353 filter.setFilter(1, first_method.getSelectedIndex(), (String)first_value.getSelectedItem(), first_case.isSelected()); 339 if(!none_ check.isSelected()) {340 if (and_check.isSelected()) {354 if(!none_radiobutton.isSelected()) { 355 if (and_radiobutton.isSelected()) { 341 356 filter.setOperation(Autofilter.AND); 342 357 } -
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditFrame.java
r5527 r5564 1 package org.greenstone.gatherer.gui.metaaudit;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui.metaaudit; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; … … 41 42 import javax.swing.event.*; 42 43 import javax.swing.tree.*; 44 import org.greenstone.gatherer.Dictionary; 43 45 import org.greenstone.gatherer.Gatherer; 44 import org.greenstone.gatherer.collection.Collection;45 46 import org.greenstone.gatherer.file.FileNode; 46 47 import org.greenstone.gatherer.util.TreeSynchronizer; … … 94 95 /** The default size for the metaaudit dialog. */ 95 96 static final private Dimension SIZE = new Dimension(640,505); 96 /** The tolerance used to determine between a column resize, and a request for an AutoFilterDialog. */ 97 static final private int TOLERANCE = 3; 97 98 98 /** Constructor.*/ 99 99 public MetaAuditFrame(TreeSynchronizer tree_sync, FileNode records[]) { 100 100 super(Gatherer.g_man); 101 101 102 // Arguments 102 103 this.autofilter_dialog = new AutofilterDialog(this); … … 104 105 this.self = this; 105 106 this.table = new MetaAuditTable(this); 107 106 108 // Creation 107 109 setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); 108 110 setSize(SIZE); 109 setTitle(get("MetaAudit.Title"));110 111 setJMenuBar(new SimpleMenuBar("reviewingmetadata")); 112 Dictionary.registerText(this, "MetaAudit.Title"); 111 113 JPanel content_pane = (JPanel) getContentPane(); 112 114 JPanel button_pane = new JPanel(); 113 115 114 JButton close_button = new JButton( get("MetaAudit.Close"));116 JButton close_button = new JButton(); 115 117 close_button.setMnemonic(KeyEvent.VK_C); 118 Dictionary.registerBoth(close_button, "MetaAudit.Close", "MetaAudit.Close_Tooltip"); 119 116 120 // Connection 117 121 close_button.addActionListener(new CloseListener()); 118 122 tree_sync.addTreeSelectionListener(this); 123 119 124 // Layout 120 125 button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 134 139 content_pane = null; 135 140 } 141 136 142 /** Destructor. */ 137 143 public void destroy() { … … 140 146 table = null; 141 147 } 148 142 149 /** Display the dialog on screen. */ 143 150 public void display() { … … 195 202 } 196 203 197 /** Retrieve a phrase from the Dictionary.198 * @param key A <strong>String</strong> which uniquely maps to a phrase.199 * @return The desired phrase as a </strong>String</strong>.200 * @see org.greenstone.gatherer.Dictionary201 */202 private String get(String key) {203 return Gatherer.dictionary.get(key);204 }205 204 /** Rebuild the metaaudit table model using the current collection tree selection. 206 205 */ … … 211 210 invalid = false; 212 211 } 213 /** Listens for actions apon the close button, and if detected closes the dialog (storing its current size first). */ 212 213 /** Listens for actions upon the close button, and if detected closes the dialog */ 214 214 private class CloseListener 215 215 implements ActionListener { … … 222 222 } 223 223 } 224 225 226 227 228 229 230 231 232 233 -
trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/MetaAuditModel.java
r4641 r5564 1 package org.greenstone.gatherer.gui.metaaudit;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.gui.metaaudit; 38 38 39 import java.awt.*; 39 40 import java.util.*; 40 41 import java.io.*; 41 42 import javax.swing.table.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.file.FileNode; 44 import org.greenstone.gatherer.msm.ElementWrapper;45 46 import org.greenstone.gatherer.msm.Metadata; 46 import org.greenstone.gatherer.msm.MetadataSetManager;47 47 import org.greenstone.gatherer.msm.MSMUtils; 48 import org.greenstone.gatherer.valuetree.GValueNode; 48 49 49 /** 50 50 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 77 77 String result; 78 78 if(column == 0) { 79 result = Gatherer.dictionary.get("AuditTable.File");79 result = Dictionary.newget("AuditTable.File"); 80 80 } 81 81 else { … … 179 179 } 180 180 } 181 182 183 184 -
trunk/gli/src/org/greenstone/gatherer/mem/MEMNode.java
r4365 r5564 1 package org.greenstone.gatherer.mem;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.mem; 38 38 39 import java.util.*; 39 40 import javax.swing.tree.*; 41 import org.greenstone.gatherer.Dictionary; 40 42 import org.greenstone.gatherer.Gatherer; 41 43 import org.greenstone.gatherer.mem.AttributeTableModel; … … 160 162 v = null; 161 163 // Add the profile set. 162 children.add(new MEMNode(PROFILER, Gatherer.dictionary.get("MEM.Profiles"), this));164 children.add(new MEMNode(PROFILER, Dictionary.newget("MEM.Profiles"), this)); 163 165 break; 164 166 case SET: // Add the elements as children -
trunk/gli/src/org/greenstone/gatherer/mem/MetadataEditorManager.java
r5527 r5564 1 package org.greenstone.gatherer.mem;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.mem; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; -
trunk/gli/src/org/greenstone/gatherer/msm/ExportMDSPrompt.java
r5355 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; … … 41 42 import javax.swing.*; 42 43 import javax.swing.filechooser.*; 44 import org.greenstone.gatherer.Dictionary; 43 45 import org.greenstone.gatherer.Gatherer; 44 46 import org.greenstone.gatherer.msm.MetadataSet; … … 85 87 /** The default export action (there are several depending on how much information you wish to export). */ 86 88 final static public int EXPORT = 0; 89 87 90 /** Constructor. 88 91 * @param manager A reference to the <strong>MetadataSetManager</strong>. … … 93 96 super(Gatherer.g_man); 94 97 this.export = export; 98 95 99 // Creation 96 100 setModal(true); 97 101 if(export) { 98 102 setSize(EXPORT_SIZE); 99 setTitle(get("MSMPrompt.Export_Title"));100 setJMenuBar(new SimpleMenuBar(" 0")); // need to find an appropriate help page to open at103 Dictionary.setText(this, "MSMPrompt.Export_Title"); 104 setJMenuBar(new SimpleMenuBar("selectingmetadatasets")); 101 105 } 102 106 else { 103 107 setSize(IMPORT_SIZE); 104 setTitle(get("MSMPrompt.Import_Title"));105 setJMenuBar(new SimpleMenuBar(" 0")); // need to find an appropriate help page to open at108 Dictionary.setText(this, "MSMPrompt.Import_Title"); 109 setJMenuBar(new SimpleMenuBar("selectingmetadatasets")); 106 110 } 107 111 JPanel content_pane = (JPanel) getContentPane(); 108 112 JPanel control_pane = new JPanel(); 109 JLabel set_label = new JLabel(get("MSMPrompt.Export_Set")); 113 JLabel set_label = new JLabel(); 114 Dictionary.setText(set_label, "MSMPrompt.Export_Set"); 110 115 sets = new JComboBox(manager.getSets()); 111 JLabel condition_label = new JLabel(get("MSMPrompt.Export_Conditions")); 116 Dictionary.setTooltip(sets, "MSMPrompt.Export_Set_Tooltip"); 117 JLabel condition_label = new JLabel(); 118 Dictionary.setText(condition_label, "MSMPrompt.Export_Conditions"); 112 119 JPanel condition_pane = new JPanel(); 113 120 ButtonGroup condition_group = new ButtonGroup(); 114 all_values = new JRadioButton( get("MSMPrompt.Export_All_Values"));121 all_values = new JRadioButton(); 115 122 all_values.setOpaque(false); 123 Dictionary.setText(all_values, "MSMPrompt.Export_All_Values"); 116 124 condition_group.add(all_values); 117 no_values = new JRadioButton( get("MSMPrompt.Export_No_Values"));125 no_values = new JRadioButton(); 118 126 no_values.setOpaque(false); 127 Dictionary.setText(no_values, "MSMPrompt.Export_No_Values"); 119 128 condition_group.add(no_values); 120 structure_only = new JRadioButton( get("MSMPrompt.Export_Subjects_Only"));129 structure_only = new JRadioButton(); 121 130 structure_only.setOpaque(false); 131 Dictionary.setText(structure_only, "MSMPrompt.Export_Subjects_Only"); 122 132 condition_group.add(structure_only); 123 133 all_values.setSelected(true); 124 JLabel file_label = new JLabel(get("MSMPrompt.Export_File")); 134 JLabel file_label = new JLabel(); 135 Dictionary.setText(file_label, "MSMPrompt.Export_File"); 125 136 JPanel file_pane = new JPanel(); 126 137 file_name = new JTextField(Utility.METADATA_DIR); 127 browse_button = new JButton(get("General.Browse")); 138 Dictionary.setTooltip(file_name, "MSMPrompt.Export_File_Tooltip"); 139 browse_button = new JButton(); 140 Dictionary.setBoth(browse_button, "General.Browse", "General.Browse_Tooltip"); 141 128 142 JPanel button_pane = new JPanel(); 129 143 if(export) { 130 export_button = new JButton( get("MSMPrompt.File_Export"));144 export_button = new JButton(); 131 145 export_button.setEnabled(false); 132 } 133 else { 134 export_button = new JButton(get("MSMPrompt.File_Import")); 146 Dictionary.setBoth(export_button, "MSMPrompt.File_Export", "MSMPrompt.File_Export_Tooltip"); 147 } 148 else { 149 export_button = new JButton(); 135 150 export_button.setEnabled(true); 136 } 137 cancel_button = new JButton(get("General.Cancel")); 151 Dictionary.setBoth(export_button, "MSMPrompt.File_Import", "MSMPrompt.File_Import_Tooltip"); 152 } 153 154 cancel_button = new JButton(); 155 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip"); 156 138 157 // Listeners 139 158 browse_button.addActionListener(this); … … 141 160 export_button.addActionListener(this); 142 161 file_name.addKeyListener(this); 162 143 163 // Layout 144 164 condition_pane.setLayout(new GridLayout(1,3)); … … 179 199 setLocation((screen_size.width - getSize().width) / 2, (screen_size.height - getSize().height) / 2); 180 200 } 201 181 202 /** Whenever one of the buttons in the dialog is actioned this method is called to trigger the appropriate effects. 182 183 184 185 186 203 * @param event An <strong>ActionEvent</strong> containing information about the action performed. 204 * @see org.greenstone.gatherer.Gatherer 205 * @see org.greenstone.gatherer.msm.MDSFileFilter 206 * @see org.greenstone.gatherer.util.Utility 207 */ 187 208 public void actionPerformed(ActionEvent event) { 188 209 if(event.getSource() == export_button) { … … 197 218 JFileChooser chooser = new JFileChooser(new File(Utility.METADATA_DIR)); 198 219 javax.swing.filechooser.FileFilter filter = new MDSFileFilter(); 199 chooser.setApproveButtonText( get("General.OK"));220 chooser.setApproveButtonText(Dictionary.newget("General.OK")); 200 221 chooser.setFileFilter(filter); 201 222 int returnVal = chooser.showSaveDialog(Gatherer.g_man); … … 211 232 } 212 233 /** Show the prompt and get the user input. 213 214 234 * @return An <i>int</i> specifying what action the user has choosen. 235 */ 215 236 public int display() { 216 237 setVisible(true); … … 218 239 } 219 240 /** Get the current value of condition. 220 221 222 241 * @return The value as an <i>int</i>. 242 * @see org.greenstone.gatherer.msm.MetadataSet 243 */ 223 244 public int getSelectedCondition() { 224 245 if(all_values.isSelected()) { … … 233 254 } 234 255 /** Get the current value of file. 235 236 256 * @return The value as a <strong>File</strong>. 257 */ 237 258 public File getSelectedFile() { 238 259 return file; 239 260 } 240 261 /** Get the current value of set. 241 242 262 * @return The value as a <strong>MetadataSet</strong>. 263 */ 243 264 public MetadataSet getSelectedSet() { 244 265 return (MetadataSet) sets.getSelectedItem(); 245 266 } 246 267 /** Any implementation of KeyListener must include this method so that we can be informed when a key has been pressed. In this case we ignore it. 247 248 268 * @param event A <strong>KeyEvent</strong> containing information about the key pressed. 269 */ 249 270 public void keyPressed(KeyEvent event) { 250 271 } 251 272 /** Any implementation of KeyListener must include this method so that we can be informed once a key has been released. This is the earliest the VK code becomes stable and usable, so we will check if the file named in file_name can be written to and if so enable the export button. 252 253 273 * @param event A <strong>KeyEvent</strong> containing information about the key typed. 274 */ 254 275 public void keyReleased(KeyEvent event) { 255 276 String pos_file = file_name.getText(); … … 265 286 } 266 287 /** Any implementation of KeyListener must include this method so that we can be informed when a key has been typed. In this case we ignore it. 267 268 288 * @param event A <strong>KeyEvent</strong> containing information about the key typed. 289 */ 269 290 public void keyTyped(KeyEvent event) { 270 291 } 271 272 private String get(String key) {273 return get(key, null);274 }275 private String get(String key, String[] args) {276 if(key.indexOf(".") == -1) {277 key = "MSMPrompt." + key;278 }279 return Gatherer.dictionary.get(key, args);280 }281 292 } -
trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java
r5164 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.io.*; 39 40 import java.net.*; 40 41 import java.util.*; 41 42 import org.greenstone.gatherer.Configuration; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.collection.Collection; … … 80 82 args[0] = document_directories[i].getName(); 81 83 args[1] = String.valueOf(count); 82 shell.fireMessage(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Gatherer.dictionary.get("GShell.Extracted", args), GShell.OK);84 shell.fireMessage(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Dictionary.newget("GShell.Extracted", args), GShell.OK); 83 85 args = null; 84 86 progress.increment(); -
trunk/gli/src/org/greenstone/gatherer/msm/MDSFileFilter.java
r4674 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.io.*; 39 40 import javax.swing.filechooser.*; 41 import org.greenstone.gatherer.Dictionary; 40 42 import org.greenstone.gatherer.Gatherer; 43 41 44 /** A custom <strong>FileFilter</strong> for the file choosers. */ 42 45 final public class MDSFileFilter 43 46 extends javax.swing.filechooser.FileFilter { 44 47 private String description = null; 48 45 49 /** Constructor. 46 50 * @see org.greenstone.gatherer.Dictionary 47 51 */ 48 52 public MDSFileFilter() { 49 description = Gatherer.dictionary.get("MSMPrompt.File_Filter_Description");53 description = Dictionary.newget("MSMPrompt.File_Filter_Description"); 50 54 } 55 51 56 /** Override this method to return <i>true</i> only if the file extension is .mds. 52 57 * @param f A possible mds <strong>File</strong>. … … 61 66 return false; 62 67 } 68 63 69 /** Retrieve the description for this filter. 64 70 * @return The description as a <strong>String</strong>. -
trunk/gli/src/org/greenstone/gatherer/msm/MSMPrompt.java
r5527 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.awt.*; 39 40 import java.awt.event.*; … … 42 43 import javax.swing.*; 43 44 import javax.swing.event.*; 45 import org.greenstone.gatherer.Dictionary; 44 46 import org.greenstone.gatherer.Gatherer; 45 47 import org.greenstone.gatherer.gui.ModalDialog; … … 49 51 import org.greenstone.gatherer.msm.MetadataSetManager; 50 52 import org.greenstone.gatherer.util.ArrayTools; 51 import org.greenstone.gatherer.util.MED;52 53 import org.w3c.dom.*; 54 53 55 /** A class dedicated to producing the visual components used by the MSM package. 54 56 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 91 93 public MSMPrompt(MetadataSetManager manager) { 92 94 this.manager = manager; 95 93 96 // Create components 94 95 add = new JButton(get("MSMPrompt.Add")); 97 add = new JButton(); 96 98 add.addActionListener(this); 97 99 add.setEnabled(false); 98 100 add.setMnemonic(KeyEvent.VK_A); 99 100 101 cancel = new JButton( get("MSMPrompt.Cancel"));101 Dictionary.registerBoth(add, "MSMPrompt.Add", "MSMPrompt.Add_Tooltip"); 102 103 cancel = new JButton(); 102 104 cancel.addActionListener(this); 103 105 cancel.setEnabled(true); 104 106 cancel.setMnemonic(KeyEvent.VK_C); 105 106 current_details = new JTextArea(get("MSMPrompt.No_Details")); 107 108 current_details_label = new JLabel(get("MSMPrompt.Current_Details")); 109 110 merge = new JButton(get("MSMPrompt.Merge")); 107 Dictionary.registerBoth(add, "MSMPrompt.Cancel", "MSMPrompt.Cancel_Tooltip"); 108 109 current_details = new JTextArea(); 110 Dictionary.registerText(current_details, "MSMPrompt.No_Details"); 111 112 current_details_label = new JLabel(); 113 Dictionary.registerText(current_details_label, "MSMPrompt.Current_Details"); 114 115 merge = new JButton(); 111 116 merge.addActionListener(this); 112 117 merge.setEnabled(true); 113 118 merge.setMnemonic(KeyEvent.VK_M); 114 115 new_details = new JTextArea(get("MSMPrompt.No_Details")); 116 117 new_details_label = new JLabel(get("MSMPrompt.New_Details")); 119 Dictionary.registerBoth(merge, "MSMPrompt.Merge", "MSMPrompt.Merge_Tooltip"); 120 121 new_details = new JTextArea(); 122 Dictionary.registerText(new_details, "MSMPrompt.No_Details"); 123 124 new_details_label = new JLabel(); 125 Dictionary.registerText(new_details_label, "MSMPrompt.New_Details"); 118 126 119 127 progress = new JProgressBar(); 120 128 progress.setStringPainted(true); 121 129 122 progress_label = new JLabel(get("MSMPrompt.Progress")); 123 124 rename = new JButton(get("MSMPrompt.Rename")); 130 progress_label = new JLabel(); 131 Dictionary.registerText(progress_label, "MSMPrompt.Progress"); 132 133 rename = new JButton(); 125 134 rename.addActionListener(this); 126 135 rename.setEnabled(false); 127 136 rename.setMnemonic(KeyEvent.VK_N); 128 129 replace = new JButton(get("MSMPrompt.Replace")); 137 Dictionary.registerBoth(rename, "MSMPrompt.Rename", "MSMPrompt.Rename_Tooltip"); 138 139 replace = new JButton(); 130 140 replace.addActionListener(this); 131 141 replace.setEnabled(false); 132 142 replace.setMnemonic(KeyEvent.VK_R); 133 134 skip = new JButton(get("MSMPrompt.Skip")); 143 Dictionary.registerBoth(replace, "MSMPrompt.Replace", "MSMPrompt.Replace_Tooltip"); 144 145 skip = new JButton(); 135 146 skip.addActionListener(this); 136 147 skip.setEnabled(true); 137 148 skip.setMnemonic(KeyEvent.VK_S); 149 Dictionary.registerBoth(skip, "MSMPrompt.Skip", "MSMPrompt.Skip_Tooltip"); 138 150 139 151 screen_size = Gatherer.config.screen_size; … … 147 159 String args[] = new String[2]; 148 160 args[0] = mde_new.getAttribute("name"); 149 args[1] = get(reason, null);150 JOptionPane.showMessageDialog(Gatherer.g_man, get("MSMPrompt.Add_Failed", args), get("MSMPrompt.Add_Failed_Title", null), JOptionPane.ERROR_MESSAGE);161 args[1] = Dictionary.newget(reason); 162 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("MSMPrompt.Add_Failed", args), Dictionary.newget("MSMPrompt.Add_Failed_Title"), JOptionPane.ERROR_MESSAGE); 151 163 } 152 164 … … 181 193 public void endMerge() { 182 194 } 195 183 196 /** Method to indicate that yet another element has been succesfully merged, so that progress bar should reflect this. 184 197 */ … … 201 214 dialog.setModal(true); 202 215 dialog.setSize(MDE_SIZE); 203 dialog.setTitle(get("MSMPrompt.Merge_MDE"));216 Dictionary.setText(dialog, "MSMPrompt.Merge_MDE"); 204 217 dialog.setJMenuBar(new SimpleMenuBar("importingpreviouslyassignedmetadata")); 205 218 JPanel content_pane = (JPanel)dialog.getContentPane(); 206 219 207 JLabel element_name_label = new JLabel(get("MSMPrompt.Element_Name")); 220 JLabel element_name_label = new JLabel(); 221 Dictionary.setText(element_name_label, "MSMPrompt.Element_Name"); 208 222 JLabel element_name = new JLabel(MSMUtils.getFullName(mde_cur)); 209 223 210 JLabel attribute_name_label = new JLabel(get("MSMPrompt.Attribute")); 224 JLabel attribute_name_label = new JLabel(); 225 Dictionary.setText(attribute_name_label, "MSMPrompt.Attribute"); 211 226 JLabel attribute_name = new JLabel(att_new.getAttribute("name")); 212 227 … … 231 246 JPanel current_pane = new JPanel(); 232 247 current_pane.setLayout(new BorderLayout()); 233 current_pane.setBorder(BorderFactory.createTitledBorder( get("MSMPrompt.Current_Values")));248 current_pane.setBorder(BorderFactory.createTitledBorder(Dictionary.newget("MSMPrompt.Current_Values"))); 234 249 JScrollPane scroll = new JScrollPane(cur_values); 235 250 current_pane.add(scroll, BorderLayout.CENTER); 236 251 237 252 JPanel new_pane = new JPanel(); 238 new_pane.setBorder(BorderFactory.createTitledBorder( get("MSMPrompt.New_Value")));253 new_pane.setBorder(BorderFactory.createTitledBorder(Dictionary.newget("MSMPrompt.New_Value"))); 239 254 new_pane.setLayout(new BorderLayout()); 240 255 JLabel new_att = new JLabel(MSMUtils.getValue(att_new)); … … 304 319 dialog.setModal(true); 305 320 dialog.setSize(MDS_SIZE); 306 dialog.setTitle(get("MSMPrompt.Merge_MDS"));321 Dictionary.setText(dialog, "MSMPrompt.Merge_MDS"); 307 322 dialog.setJMenuBar(new SimpleMenuBar("importingpreviouslyassignedmetadata")); 308 323 JPanel content_pane = (JPanel)dialog.getContentPane(); … … 318 333 String opt_cur[] = MSMUtils.getOptionListDetails(mde_cur); 319 334 String ass_cur[] = MSMUtils.getAssignedValuesDetails(mds_cur, mde_cur); 320 String details_cur = get("MSMPrompt.Structural", str_cur);335 String details_cur = Dictionary.newget("MSMPrompt.Structural", str_cur); 321 336 if(opt_cur != null) { 322 details_cur = details_cur + "\n" + get("MSMPrompt.OptionList", opt_cur);337 details_cur = details_cur + "\n" + Dictionary.newget("MSMPrompt.OptionList", opt_cur); 323 338 } 324 339 if(ass_cur != null) { 325 details_cur = details_cur + "\n" + get("MSMPrompt.AssignedValues", ass_cur);340 details_cur = details_cur + "\n" + Dictionary.newget("MSMPrompt.AssignedValues", ass_cur); 326 341 } 327 342 current_details.setText(details_cur); … … 338 353 replace.setEnabled(false); 339 354 skip.setEnabled(true); 340 current_details.setText( get("MSMPrompt.No_Element"));355 current_details.setText(Dictionary.newget("MSMPrompt.No_Element")); 341 356 } 342 357 // New details. … … 344 359 String opt_new[] = MSMUtils.getOptionListDetails(mde_new); 345 360 String ass_new[] = MSMUtils.getAssignedValuesDetails(mds_new, mde_new); 346 String details_new = get("MSMPrompt.Structural", str_new);361 String details_new = Dictionary.newget("MSMPrompt.Structural", str_new); 347 362 if(opt_new != null) { 348 details_new = details_new + "\n" + get("MSMPrompt.OptionList", opt_new);363 details_new = details_new + "\n" + Dictionary.newget("MSMPrompt.OptionList", opt_new); 349 364 } 350 365 if(ass_new != null) { 351 details_new = details_new + "\n" + get("MSMPrompt.AssignedValues", ass_new);366 details_new = details_new + "\n" + Dictionary.newget("MSMPrompt.AssignedValues", ass_new); 352 367 } 353 368 new_details.setText(details_new); … … 439 454 dialog.setModal(true); 440 455 dialog.setSize(RENAME_SIZE); 441 dialog.setTitle(get("MSMPrompt.Rename"));442 456 dialog.setJMenuBar(new SimpleMenuBar("importingpreviouslyassignedmetadata")); 443 JLabel old_name_label = new JLabel(get("MSMPrompt.Old_Name")); 457 Dictionary.setText(dialog, "MSMPrompt.Rename"); 458 459 JLabel old_name_label = new JLabel(); 444 460 old_name_label.setPreferredSize(RENAME_LABEL_SIZE); 461 Dictionary.setText(old_name_label, "MSMPrompt.Old_Name"); 445 462 446 463 JLabel old_name = new JLabel(mde_new.getAttribute("name")); 447 464 old_name.setBackground(Color.white); 448 465 old_name.setOpaque(true); 449 450 JLabel new_name_label = new JLabel(get("MSMPrompt.New_Name")); 466 Dictionary.setTooltip(old_name, "MSMPrompt.Old_Name_Tooltip"); 467 468 JLabel new_name_label = new JLabel(); 451 469 new_name_label.setPreferredSize(RENAME_LABEL_SIZE); 452 470 Dictionary.setText(new_name_label, "MSMPrompt.New_Name"); 471 453 472 JTextField new_name = new JTextField(""); 454 473 new_name.grabFocus(); 455 456 JButton ok = new JButton(get("General.OK")); 474 Dictionary.setTooltip(new_name, "MSMPrompt.New_Name_Tooltip"); 475 476 JButton ok = new JButton(); 457 477 ok.addActionListener(this); 458 478 ok.setMnemonic(KeyEvent.VK_O); 479 Dictionary.setBoth(ok, "General.OK", "General.OK_Tooltip"); 459 480 460 481 JPanel content_pane = (JPanel) dialog.getContentPane(); … … 523 544 String args[] = new String[2]; 524 545 args[0] = mde_cur.getAttribute("name"); 525 args[1] = get(reason, null);526 JOptionPane.showMessageDialog(Gatherer.g_man, get("MSMPrompt.Remove_Failed", args), get("MSMPrompt.Remove_Failed_Title", null), JOptionPane.ERROR_MESSAGE);546 args[1] = Dictionary.newget(reason); 547 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("MSMPrompt.Remove_Failed", args), Dictionary.newget("MSMPrompt.Remove_Failed_Title"), JOptionPane.ERROR_MESSAGE); 527 548 } 528 549 … … 536 557 args[0] = mde_new.getAttribute("name"); 537 558 args[1] = new_name; 538 args[2] = get(reason, null);539 JOptionPane.showMessageDialog(Gatherer.g_man, get("MSMPrompt.Rename_Failed", args), get("MSMPrompt.Rename_Failed_Title", null), JOptionPane.ERROR_MESSAGE);559 args[2] = Dictionary.newget(reason); 560 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("MSMPrompt.Rename_Failed", args), Dictionary.newget("MSMPrompt.Rename_Failed_Title"), JOptionPane.ERROR_MESSAGE); 540 561 } 541 562 … … 546 567 public Element selectElement(MetadataSet mds_cur) { 547 568 action = Declarations.NO_ACTION; 569 548 570 // Create 549 571 JDialog dialog = new ModalDialog(Gatherer.g_man); 550 572 dialog.setModal(true); 551 573 dialog.setSize(SELECT_SIZE); 552 dialog.setTitle(get("MSMPrompt.Select"));553 574 dialog.setJMenuBar(new SimpleMenuBar("importingpreviouslyassignedmetadata")); 554 555 JButton ok = new JButton(get("General.OK")); 575 Dictionary.setText(dialog, "MSMPrompt.Select"); 576 577 JButton ok = new JButton(); 556 578 ok.addActionListener(this); 557 579 ok.setMnemonic(KeyEvent.VK_O); 558 580 ok.setEnabled(false); 581 Dictionary.setBoth(ok, "General.OK", "General.OK_Tooltip"); 559 582 560 583 Node elements_raw[] = ArrayTools.nodeListToNodeArray(mds_cur.getElements()); … … 567 590 list.addListSelectionListener(element_list_listener); 568 591 JPanel content_pane = (JPanel) dialog.getContentPane(); 592 569 593 // Layout 570 594 JPanel list_pane = new JPanel(); … … 582 606 content_pane.add(list_pane, BorderLayout.CENTER); 583 607 content_pane.add(button_pane, BorderLayout.SOUTH); 608 584 609 // Display 585 610 dialog.setLocation((screen_size.width - SELECT_SIZE.width) / 2, (screen_size.height - SELECT_SIZE.height) / 2); … … 615 640 * @return An ElementWrapper around the element that it has been matched to. 616 641 * @see org.greenstone.gatherer.msm.MSMPrompt.MSMDialog 617 * @see org.greenstone.gatherer.util.MED618 642 */ 619 643 public ElementWrapper selectElement(String name) { … … 626 650 dialog.setModal(true); 627 651 dialog.setSize(SELECT_ELEMENT_SIZE); 628 dialog.setTitle(get("MSMPrompt.Select_Element_Title"));629 652 dialog.setJMenuBar(new SimpleMenuBar("importingpreviouslyassignedmetadata")); 653 Dictionary.setText(dialog, "MSMPrompt.Select_Element_Title"); 654 630 655 JPanel content_pane = (JPanel) dialog.getContentPane(); 631 656 JPanel control_pane = new JPanel(); -
trunk/gli/src/org/greenstone/gatherer/msm/MetadataSet.java
r5154 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.io.*; 39 40 import java.net.*; 40 41 import java.util.*; 41 42 import org.apache.xerces.dom.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 45 import org.greenstone.gatherer.valuetree.GValueModel; … … 102 104 ElementWrapper value_element = new ElementWrapper((Element)elements.item(i)); 103 105 File value_file = new File(file.getParentFile(), value_element.getName() + ".mdv"); 104 106 ///ystem.err.println("Searching for " + value_file.getAbsolutePath()); 105 107 if(value_file.exists()) { 106 108 Document value_document = Utility.parse(value_file, false); … … 354 356 // Failing all that set an error message 355 357 if(description == null) { 356 description = Gatherer.dictionary.get("MSM.No_Description");358 description = Dictionary.newget("MSM.No_Description"); 357 359 } 358 360 } … … 461 463 // Failing all that set an error message 462 464 if(name == null) { 463 name = Gatherer.dictionary.get("MSM.No_Name");465 name = Dictionary.newget("MSM.No_Name"); 464 466 } 465 467 } -
trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java
r5305 r5564 1 package org.greenstone.gatherer.msm;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.msm; 38 38 39 import java.io.*; 39 40 import java.util.*; … … 41 42 import javax.swing.filechooser.*; 42 43 import org.greenstone.gatherer.Configuration; 44 import org.greenstone.gatherer.Dictionary; 43 45 import org.greenstone.gatherer.Gatherer; 44 46 import org.greenstone.gatherer.cdm.CommandTokenizer; … … 61 63 import org.w3c.dom.*; 62 64 import org.xml.sax.*; 65 63 66 /** This class is responsible for managing all the metadata sets in the collection and for providing methods for manipulating the aforementioned sets contents. 64 67 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 545 548 javax.swing.filechooser.FileFilter filter = new MDSFileFilter(); 546 549 chooser.setFileFilter(filter); 547 int returnVal = chooser.showDialog(Gatherer.g_man, Gatherer.dictionary.get("MSMPrompt.File_Import"));550 int returnVal = chooser.showDialog(Gatherer.g_man, Dictionary.newget("MSMPrompt.File_Import")); 548 551 if(returnVal == JFileChooser.APPROVE_OPTION) { 549 552 return importMDS(chooser.getSelectedFile(), true); -
trunk/gli/src/org/greenstone/gatherer/shell/GImportProgressMonitor.java
r5325 r5564 1 package org.greenstone.gatherer.shell;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.shell; 38 38 39 import java.awt.Component; 39 40 import java.util.StringTokenizer; 40 41 import javax.swing.JProgressBar; 42 import org.greenstone.gatherer.Dictionary; 41 43 import org.greenstone.gatherer.Gatherer; 42 44 import org.greenstone.gatherer.shell.GShellProgressMonitor; 45 43 46 /** This implementation of <i>GShellProgressMonitor</i> is designed to parse and translate the progress of a import.pl call. 44 47 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 156 159 157 160 public void saving() { 158 progress_bar.setString( Gatherer.dictionary.get("SaveProgressDialog.Title", (String)null));161 progress_bar.setString(Dictionary.newget("SaveProgressDialog.Title")); 159 162 progress_bar.setValue(MAX / (10 * 2)); 160 163 } … … 171 174 */ 172 175 public void start() { 173 progress_bar.setString( Gatherer.dictionary.get("FileActions.Calculating_Size", (String)null));176 progress_bar.setString(Dictionary.newget("FileActions.Calculating_Size")); 174 177 progress_bar.setValue(MAX / 10); 175 178 num_files = Gatherer.c_man.getCollection().getDocumentCount(); -
trunk/gli/src/org/greenstone/gatherer/shell/GShell.java
r5349 r5564 1 package org.greenstone.gatherer.shell;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.shell; 38 38 39 import java.io.*; 39 40 import javax.swing.*; 40 41 import javax.swing.event.*; 41 42 import javax.swing.tree.*; 43 import org.greenstone.gatherer.Dictionary; 42 44 import org.greenstone.gatherer.Gatherer; 43 import org.greenstone.gatherer.Message;44 45 import org.greenstone.gatherer.msm.GreenstoneArchiveParser; 45 46 import org.greenstone.gatherer.shell.GShellListener; … … 106 107 } 107 108 /** This method adds another shell listener to this process. 108 109 109 * @param listener The new <i>GShellListener</i>. 110 */ 110 111 public void addGShellListener(GShellListener listener) { 111 112 listeners.add(GShellListener.class, listener); 112 113 } 113 114 /** This method removes a certain shell listener from this process. 114 115 115 * @param listener The <i>GShellListener</i> to be removed. 116 */ 116 117 public void removeGShellListener(GShellListener listener) { 117 118 listeners.remove(GShellListener.class, listener); … … 150 151 } 151 152 ///ystem.err.println("Command: " + command); 152 fireMessage(type, get("GShell.Command") + ": " + command, status);153 fireMessage(type, Dictionary.newget("GShell.Command") + ": " + command, status); 153 154 154 155 Runtime rt = Runtime.getRuntime(); … … 188 189 if(prcs.exitValue() == 0) { 189 190 status = OK; 190 fireMessage(type, typeAsString(type) + "> " + get("GShell.Success"), status);191 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Success"), status); 191 192 192 193 } else { 193 194 status = ERROR; 194 fireMessage(type, typeAsString(type) + "> " + get("GShell.Failure"), status);195 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Failure"), status); 195 196 196 197 } … … 211 212 // If no error occured, and this was an import process we now extract any new metadata from the archive directory. 212 213 if(status == OK && type == IMPORT) { 213 fireMessage(type, typeAsString(type) + "> " + get("GShell.Parsing_Metadata_Start"), status);214 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Parsing_Metadata_Start"), status); 214 215 new GreenstoneArchiveParser(progress, this); 215 fireMessage(type, typeAsString(type) + "> " + get("GShell.Parsing_Metadata_Complete"), status);216 fireMessage(type, typeAsString(type) + "> " + Dictionary.newget("GShell.Parsing_Metadata_Complete"), status); 216 217 } 217 218 // Tidy up. … … 233 234 } 234 235 /** Method for firing a message to all interested listeners. 235 236 237 238 236 * @param type An <strong>int</strong> indicating the process type. 237 * @param message The message as a <strong>String</strong>. 238 * @param status An <strong>int</strong> specifying the current status of the process. 239 */ 239 240 public void fireMessage(int type, String message, int status) { 240 241 GShellEvent event = new GShellEvent(this, 0, type, message, status); … … 248 249 249 250 /** Method for firing a process begun event which is called, strangly enough, when the process begins. 250 251 252 251 * @param type An <strong>int</strong> indicating the process type. 252 * @param status An <strong>int</strong> specifying the current status of the process. 253 */ 253 254 protected void fireProcessBegun(int type, int status) { 254 255 GShellEvent event = new GShellEvent(this, 0, type, "", status); … … 261 262 } 262 263 /** Method for firing a process complete event which is called, no surprise here, when the process ends. 263 264 265 264 * @param type An <strong>int</strong> indicating the process type. 265 * @param status An <strong>int</strong> specifying the current status of the process. 266 */ 266 267 protected void fireProcessComplete(int type, int status) { 267 268 GShellEvent event = new GShellEvent(this, 0, type, "", status); … … 273 274 } 274 275 } 275 /** Retrieve a phrase from the dictionary based on the given key. 276 * @param key A <strong>String</strong> used to match against a phrase from the <strong>Dictionary</strong>. 277 * @return The phrase as a <strong>String</strong>. 278 */ 279 private String get(String key) { 280 if(key.indexOf('.') == -1) { 281 key = "GShell." + key; 282 } 283 return Gatherer.dictionary.get(key); 284 } 276 285 277 /** Method to determine if the user, via the progress monitor, has signalled stop. 286 287 278 * @return A <strong>boolean</strong> indicating if the user wanted to stop. 279 */ 288 280 private boolean hasSignalledStop() { 289 281 boolean has_signalled_stop = false; … … 295 287 296 288 /** Converts a type into a text representation. 297 298 299 289 * @param type An <strong>int</strong> which maps to a shell process type. 290 * @return A <strong>String</strong> which is the thread process's text name. 291 */ 300 292 public String typeAsString(int type) { 301 293 String name = null; 302 294 switch(type) { 303 295 case BUILD: 304 name = get("GShell.Build");296 name = Dictionary.newget("GShell.Build"); 305 297 break; 306 298 case IMPORT: 307 name = get("GShell.Import");299 name = Dictionary.newget("GShell.Import"); 308 300 break; 309 301 case NEW: 310 name = get("GShell.New");302 name = Dictionary.newget("GShell.New"); 311 303 break; 312 304 default: 313 name = get("GShell.Other");305 name = Dictionary.newget("GShell.Other"); 314 306 } 315 307 return name; -
trunk/gli/src/org/greenstone/gatherer/util/ApplyXSLT.java
r5524 r5564 20 20 package org.greenstone.gatherer.util; 21 21 22 // General Java classes 23 import java.io.StringReader; 24 import java.io.StringWriter; 25 import java.io.File; 26 22 27 // XML classes 23 28 import javax.xml.transform.Transformer; … … 25 30 import javax.xml.transform.TransformerConfigurationException; 26 31 import javax.xml.transform.TransformerException; 27 28 32 import javax.xml.transform.stream.StreamSource; 29 33 import javax.xml.transform.stream.StreamResult; 30 31 // other java classes32 import java.io.StringReader;33 import java.io.StringWriter;34 import java.io.File;35 34 36 35 … … 53 52 } 54 53 55 56 54 String stylesheet = args[0]; 57 55 String xml_in = args[1]; … … 65 63 System.out.println(output.toString()); 66 64 } 67 catch (TransformerConfigurationException e ) {68 System.err.println("XMLTransformer: couldn't create transformer object: " +e.getMessageAndLocation());69 System.err.println(e .getLocationAsString());65 catch (TransformerConfigurationException ex) { 66 System.err.println("XMLTransformer: couldn't create transformer object: " + ex.getMessageAndLocation()); 67 System.err.println(ex.getLocationAsString()); 70 68 } 71 catch (TransformerException e ) {72 System.err.println("XMLTransformer: couldn't transform the source: " + e .getMessage());69 catch (TransformerException ex) { 70 System.err.println("XMLTransformer: couldn't transform the source: " + ex.getMessage()); 73 71 } 74 72 } -
trunk/gli/src/org/greenstone/gatherer/util/DragTreeSelectionModel.java
r4674 r5564 1 package org.greenstone.gatherer.util;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.util; 38 38 39 39 import java.awt.Point; … … 114 114 args[0] = String.valueOf(file_count); 115 115 args[1] = String.valueOf(folder_count); 116 suffix = Gatherer.dictionary.get("FileActions.Selected", args);116 suffix = Dictionary.newget("FileActions.Selected", args); 117 117 } 118 118 else if(file_count > 1) { 119 119 args = new String[1]; 120 120 args[0] = String.valueOf(file_count); 121 suffix = Gatherer.dictionary.get("FileActions.Files_And_Directory_Selected", args);121 suffix = Dictionary.newget("FileActions.Files_And_Directory_Selected", args); 122 122 } 123 123 else if(folder_count > 1) { 124 124 args = new String[1]; 125 125 args[0] = String.valueOf(folder_count); 126 suffix = Gatherer.dictionary.get("FileActions.File_And_Directories_Selected", args);126 suffix = Dictionary.newget("FileActions.File_And_Directories_Selected", args); 127 127 } 128 128 else { 129 suffix = Gatherer.dictionary.get("FileActions.File_And_Directory_Selected");129 suffix = Dictionary.newget("FileActions.File_And_Directory_Selected"); 130 130 } 131 131 } … … 134 134 args = new String[1]; 135 135 args[0] = String.valueOf(file_count); 136 suffix = Gatherer.dictionary.get("FileActions.Files_Selected", args);136 suffix = Dictionary.newget("FileActions.Files_Selected", args); 137 137 } 138 138 else if(file_count == 1) { 139 suffix = Gatherer.dictionary.get("FileActions.File_Selected");139 suffix = Dictionary.newget("FileActions.File_Selected"); 140 140 } 141 141 } … … 144 144 args = new String[1]; 145 145 args[0] = String.valueOf(folder_count); 146 suffix = Gatherer.dictionary.get("FileActions.Directories_Selected", args);146 suffix = Dictionary.newget("FileActions.Directories_Selected", args); 147 147 } 148 148 else { 149 suffix = Gatherer.dictionary.get("FileActions.Directory_Selected");149 suffix = Dictionary.newget("FileActions.Directory_Selected"); 150 150 } 151 151 } -
trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java
r5523 r5564 1 package org.greenstone.gatherer.util;2 1 /** 3 2 *######################################################################### … … 26 25 *######################################################################## 27 26 */ 28 import java.awt.Point; 29 import java.io.BufferedReader; 30 import java.io.BufferedWriter; 31 import java.io.File; 32 import java.io.FileInputStream; 33 import java.io.FileOutputStream; 34 import java.io.FileReader; 35 import java.io.OutputStreamWriter; 36 import java.io.Writer; 37 import java.util.ArrayList; 38 import java.util.Collections; 39 import java.util.Hashtable; 40 import java.util.Vector; 41 import javax.swing.tree.TreePath; 27 package org.greenstone.gatherer.util; 28 29 import java.io.*; 30 import java.util.*; 31 import javax.swing.tree.*; 42 32 import org.greenstone.gatherer.Gatherer; 43 import org.greenstone.gatherer.gui.SaveProgressDialog;44 33 import org.greenstone.gatherer.msm.ElementWrapper; 45 import org.greenstone.gatherer.msm.Metadata;46 34 import org.greenstone.gatherer.msm.MetadataSetManager; 47 35 import org.greenstone.gatherer.util.Utility; 48 36 import org.greenstone.gatherer.valuetree.GValueModel; 49 37 import org.greenstone.gatherer.valuetree.GValueNode; 50 import org.w3c.dom.Element;51 38 52 public class MetadataXML { 53 //private boolean can_wait = true; 54 private Gatherer gatherer = null; 55 private Hashtable known_indexes = null; 56 //private int spare_processes = 25; 57 //private MetadataXML mummy = null; 58 private SaveProgressDialog spd = null; 59 //private Vector complete = null; 60 //private Vector processes = null; 61 62 static public String METADATA_FILE = "metadata.xml"; 63 64 /** 65 public static void write(Gatherer gatherer, String etc_dir) { 66 if(gatherer != null && gatherer.c_man != null && gatherer.c_man.getCollection() != null && gatherer.c_man.getCollection().msm != null) { 67 Vector elements = gatherer.c_man.getCollection().msm.getElements(true); 68 for(int i = 0; i < elements.size(); i++) { 69 ElementWrapper element = (ElementWrapper)elements.get(i); 70 ///ystem.err.print("Checking " + element + " for HFile: "); 71 GValueModel model = gatherer.c_man.getCollection().msm.getValueTree(element); 72 if(model != null && (element.getNamespace().equals(MetadataSetManager.HIDDEN) || model.isHierarchy())) { 73 ///ystem.err.println("Found. Writing file."); 74 write(model, gatherer.c_man.getCollection().msm, etc_dir); 75 } 76 else { 77 ///ystem.err.println("No file found."); 78 } 79 } 80 } 81 } 82 */ 83 84 private String getHIndex(Gatherer gatherer, GValueModel model, String value) { 85 String index = null; 86 index = (String) known_indexes.get(value); 87 if(index == null) { 88 index = model.getHIndex(value); 89 ///ystem.err.println("Adding to known indexes: " + value + " -> " + index); 90 known_indexes.put(value, index); 91 } 92 return index; 93 } 94 95 static private String safe(String unsafe) { 96 String safe_str = ""; 97 for(int i = 0; i < unsafe.length(); i++) { 98 char c = unsafe.charAt(i); 99 if(c != ' ') { 100 safe_str = safe_str + c; 101 } 102 } 103 return safe_str; 104 } 105 39 public class MetadataXML 40 { 106 41 static private void write(Writer w, String text) 107 42 throws Exception { … … 129 64 write(bw, "\"" + Utility.stripNL(value) + "\"\t" + index + "\t\"" + Utility.stripNL(value) + "\""); 130 65 } 131 132 66 // Very important we do this, or else buffer may not have 67 // flushed. 133 68 bw.flush(); 134 69 bw.close(); … … 138 73 } 139 74 } 140 141 /** Returns the given tree path as path formatted string (ie subject\subject\subject).142 * @param tree The <strong>JTree</strong> the TreePath came from. Used to determine if the root node should be encoded as well.143 * @param path A <strong>TreePath</strong> that you wish to encode to String.144 * @param full <i>true</i> if this is the full path (ie a leaf node), <i>false</i> otherwise.145 * @return A <strong>String</strong> encoding the information from the TreePath.146 * @see javax.swing.JTree147 * @see javax.swing.tree.TreePath148 */149 // static public String formatPath(JTree tree, TreePath path, boolean full) {150 // String text = "";151 // int i = 0;152 // if(tree == null || (!tree.isRootVisible() && !full)) {153 // i = 1;154 // }155 // for( ; i < path.getPathCount(); i++) {156 // GValueNode node = (GValueNode)path.getPathComponent(i);157 // text = text + node.toString();158 // if(node.getChildCount() > 0) {159 // text = text + "\\";160 // }161 // }162 // if(full && text.endsWith("\\")) {163 // return text.substring(0, text.length() - 1);164 // }165 // return text;166 // }167 168 static final private long showTime(String message, long time) {169 if(time == -1) {170 ///ystem.err.println(message + System.currentTimeMillis());171 }172 else {173 ///ystem.err.println(message + (System.currentTimeMillis() - time));174 }175 return System.currentTimeMillis();176 }177 75 } -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r5287 r5564 1 package org.greenstone.gatherer.util;2 1 /** 3 2 *######################################################################### … … 36 35 *######################################################################## 37 36 */ 37 package org.greenstone.gatherer.util; 38 38 39 import java.awt.*; 39 40 import java.io.*; … … 44 45 import org.apache.xerces.parsers.*; 45 46 import org.apache.xml.serialize.*; 47 import org.greenstone.gatherer.Dictionary; 46 48 import org.greenstone.gatherer.Gatherer; 47 49 import org.greenstone.gatherer.util.HTMLStringTokenizer; 48 50 import org.w3c.dom.*; 49 51 import org.xml.sax.*; 52 50 53 /** To provide a library of common methods, in a static context, for use in the Gatherer. 51 54 * @author John Thompson, Greenstone Digital Library, University of Waikato … … 167 170 String abs_path = file.getAbsolutePath(); 168 171 while(file != null) { 169 170 171 172 172 // If we are looking for a node within our collection, we expect 173 // its path from root to be <col_name>/... without any higher 174 // details and without gimport. So if we encounter a gimport we 175 // skip to its parent, add that, then return. 173 176 if(in_col && file.getName().equals("gimport")) { 174 177 file = file.getParentFile(); … … 251 254 } 252 255 if(result) { 253 256 // Delete file. 254 257 return file.delete(); 255 258 } … … 490 493 */ 491 494 static public String formatPath(String key, String raw, int width) { 492 JLabel label = new JLabel( Gatherer.dictionary.get(key, raw));495 JLabel label = new JLabel(Dictionary.newget(key, raw)); 493 496 int position = -1; 494 497 while(label.getPreferredSize().width > width && (position = raw.indexOf(File.separator)) != -1) { 495 498 raw = "..." + raw.substring(position + 1); 496 label.setText( Gatherer.dictionary.get(key, raw));499 label.setText(Dictionary.newget(key, raw)); 497 500 } 498 501 if(raw.indexOf(File.separator) == -1 && raw.startsWith("...")) { … … 599 602 ImageIcon image = null; 600 603 try { 601 image = new ImageIcon(ClassLoader.getSystemResource("images/" + Gatherer.dictionary.get("Version") + "/" + filename));604 image = new ImageIcon(ClassLoader.getSystemResource("images/" + Dictionary.newget("Version") + "/" + filename)); 602 605 } 603 606 catch(NullPointerException exception) { … … 659 662 * @return An <i>int</i> representing the value of the hexidecimal character or -1 if not a hexidecimal. 660 663 */ 661 public staticint hexidecimal(char chr) {664 static private int hexidecimal(char chr) { 662 665 switch(chr) { 663 666 case '0':
Note:
See TracChangeset
for help on using the changeset viewer.