Changeset 5564 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2003-10-03T14:07:35+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.