Changeset 4675
- Timestamp:
- 2003-06-16T10:47:06+12:00 (21 years ago)
- Location:
- trunk/gli
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/Gatherer.bat
r4293 r4675 12 12 :Run 13 13 REM ******************************************** 14 set GSDLHOME=**GSDLHOME** 15 set PERLHOME=**PERLHOME** 16 set JAVAHOME=**JAVAHOME** 17 set CGIBINHOME=**CGIBINHOME** 14 set GSDLHOME=D:\Progra~1\gsdl\ 15 set PERLHOME=D:\Progra~1\Perl\bin\ 16 set JAVAHOME=D:\Progra~1\j2sdk1.4.0 17 REM set CGIBINHOME=http://vektor/gsdl 18 set CGIBINHOME=D:\Progra~1\gsdl\server.exe 18 19 REM ******************************************** 19 20 … … 22 23 if "%OS%" == "" set PATH="%PATH%";"%PERLHOME%";"%JAVAHOME%\bin";"%GSDLHOME%\bin\windows";"%GSDLHOME%\bin\script" 23 24 24 java.exe -cp Gatherer.jar;classes/;lib/apache.jar;lib/calpa.jar;lib/jp.jar;lib/polloxml.jar;lib/qfslib.jar;lib/skinlf.jar org.greenstone.gatherer.Gatherer -gsdl %GSDLHOME% -perl %PERLHOME% -library %CGIBINHOME%25 java.exe -cp classes/;Gatherer.jar;lib/apache.jar;lib/calpa.jar;lib/jp.jar;lib/polloxml.jar;lib/qfslib.jar;lib/skinlf.jar org.greenstone.gatherer.Gatherer -gsdl %GSDLHOME% -perl %PERLHOME% -library %CGIBINHOME% 25 26 echo "Done!" 26 27 27 28 :End 29 30 if "%1" == "SetEnv" goto EndAndExit 31 32 echo "Closing initial console." 33 34 cls 35 36 :EndAndExit 37 38 echo "Closing second console." 39 40 exit 41 cls -
trunk/gli/classes/dictionary.properties
r4673 r4675 118 118 CDM.ClassifierManager.Assigned:Currently Assigned Classifiers 119 119 CDM.ClassifierManager.Classifier:Select classifier to add: 120 CDM.ClassifierManager.Classifier_XML_Parse_Failed: Unable to determine the arguments for the {0}\nclassifier. Please ensure that the classifier in question\nprovides the -xml flag by running the classinfo.pl script\nsimilar to the description of the pluginfo.pl script in\nsection 2.1 of the Greenstone Developers Guide.120 CDM.ClassifierManager.Classifier_XML_Parse_Failed:GLI has been unable to determine the arguments for the {0}\nclassifier. Please ensure that the classifier in question\nprovides the -xml flag by running the classinfo.pl script\nsimilar to the description of the pluginfo.pl script in\nsection 2.1 of the Greenstone Developers Guide. 121 121 CDM.ClassifierManager.Configure:Configure Selected Classifier 122 122 CDM.ClassifierManager.Controls:Editing Controls … … 210 210 CDM.PlugInManager.Move_Up:Move Up 211 211 CDM.PlugInManager.PlugIn:Select plugin to add: 212 CDM.PlugInManager.PlugIn_XML_Parse_Failed: Unable to determine the arguments for the {0}\nplugin. Please ensure that the plugin in question provides\nthe -xml flag by running the pluginfo.pl script described\nin section 2.1 of the Greenstone Developers Guide.212 CDM.PlugInManager.PlugIn_XML_Parse_Failed:GLI has been unable to determine the arguments for the {0}\nplugin. Please ensure that the plugin in question provides\nthe -xml flag by running the pluginfo.pl script described\nin section 2.1 of the Greenstone Developers Guide. 213 213 CDM.PlugInManager.Remove:Remove Selected Plugin 214 214 CDM.PlugInManager.Title:{39}{46}Plugin Selection & Configuration{47}{34} … … 350 350 DeleteCollectionPrompt.Collection_List:Available collections. 351 351 DeleteCollectionPrompt.Confirm_Delete:Please tick the box to confirm collection deletion. 352 DeleteCollectionPrompt.Details:Title - {0}\nFilename - {1}\nEmail - {2}\nDescription\n{3}352 DeleteCollectionPrompt.Details:Title - {0}\nFilename - {1}\nCreator - {2}\nMaintainer - {3}\nDescription\n{4} 353 353 DeleteCollectionPrompt.Failed_Delete:Collection could not be completely deleted. 354 354 DeleteCollectionPrompt.Failed_Title:Deletion Failed! … … 769 769 MSMPrompt.Select_Element_Element:Select Element: 770 770 MSMPrompt.Select_Element_Ignore:Ignore 771 MSMPrompt.Select_Element_Instructions:The metadata element {0} cannot be automatically imported into the collection. Select a metadata set and either:\n(1) press 'Add' to add the metadata to that set (only available if no element with that name already exists), or\n(2) choose an element and press 'Merge' to import {0} metadata to this element.771 MSMPrompt.Select_Element_Instructions:The metadata element {0} cannot be automatically imported into the collection. Select a metadata set and either:\n(1) press 'Add' to add the metadata to that set, or\n(2) choose an element and press 'Merge' to import {0} metadata to this element. 772 772 MSMPrompt.Select_Element_Merge:Merge 773 773 MSMPrompt.Select_Element_Original:Original element name: … … 795 795 NewCollectionPrompt.Instructions:To create a new collection fill out the fields below. 796 796 NewCollectionPrompt.Metadata_Elements:Elements within selected set: 797 NewCollectionPrompt.Metadata_Instructions:Check the boxes beside the metadata sets to include in your collection. (Note: You can add new ones later). 797 NewCollectionPrompt.Metadata_Instructions1:Check the boxes beside the metadata sets to include in your collection. 798 NewCollectionPrompt.Metadata_Instructions2:(Note: You can add new ones later). 798 799 NewCollectionPrompt.Name_Error:You have either failed to enter a name for the collection, or the name you have choosen is already in use. Please correct. 799 800 NewCollectionPrompt.NewCollection:-- New Collection -- -
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r4669 r4675 733 733 734 734 private void stopServerEXE() { 735 if(server != null ) {735 if(server != null && config.exec_address != null) { 736 736 // See if its already exited for some reason. 737 737 gsdlsite_cfg.load(); -
trunk/gli/src/org/greenstone/gatherer/cdm/TranslationManager.java
r4657 r4675 89 89 if(!features_model.contains(bob)) { 90 90 features_model.add(bob); 91 } 91 } 92 92 } 93 93 Collections.sort(features_model); 94 94 return features_model.toArray(); 95 95 } 96 96 97 97 98 98 private class BobTheMagicalComparableWrapper … … 174 174 JPanel fragment_selection_panel = new JPanel(); 175 175 JLabel fragment_label = new JLabel(get("Assigned_Fragments")); 176 176 177 fragment_table = new JTable(fragment_table_model); 177 178 fragment_table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); … … 187 188 //fragment_table.sizeColumnsToFit(0); 188 189 190 JScrollPane table_scroll = new JScrollPane(fragment_table); 191 table_scroll.getViewport().setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 192 table_scroll.setOpaque(true); 193 189 194 JPanel south_panel = new JPanel(); 190 195 … … 211 216 translation_area.setLineWrap(true); 212 217 translation_area.setWrapStyleWord(true); 213 218 214 219 // Connection 215 220 language_combobox.addActionListener(new LanguageActionListener()); … … 229 234 fragment_selection_panel.setLayout(new BorderLayout()); 230 235 fragment_selection_panel.add(fragment_label, BorderLayout.NORTH); 231 fragment_selection_panel.add( new JScrollPane(fragment_table), BorderLayout.CENTER);236 fragment_selection_panel.add(table_scroll, BorderLayout.CENTER); 232 237 233 238 selection_panel.setLayout(new GridLayout(2,1,0,5)); … … 278 283 } 279 284 280 private class FeaturesListSelectionListener 285 private class FeaturesListSelectionListener 281 286 implements ListSelectionListener { 282 287 public void valueChanged(ListSelectionEvent event) { … … 302 307 String language_name = language_combobox.getSelectedItem().toString(); 303 308 int index = fragment_table_model.getMetadataIndexByLanguage(language_name); 304 if(index != -1) { 309 if(index != -1) { 305 310 CollectionMeta metadata = fragment_table_model.getMetadata(index); 306 311 fragment_table.setRowSelectionInterval(index, index); … … 322 327 // Update and disable the text area 323 328 translation_area.setText(""); 324 translation_area.setEnabled(false); 329 translation_area.setEnabled(false); 325 330 translation_area.setBackground(Gatherer.config.getColor("coloring.disabled", false)); 326 331 } … … 364 369 private class FragmentTableModel 365 370 extends AbstractTableModel { 366 371 367 372 private ArrayList metadatum; 368 373 … … 409 414 return "#Error"; 410 415 } 411 416 412 417 public void remove(int index) { 413 418 metadatum.remove(index); … … 453 458 String language_name = language_combobox.getSelectedItem().toString(); 454 459 int index = fragment_table_model.getMetadataIndexByLanguage(language_name); 455 if(index != -1) { 460 if(index != -1) { 456 461 CollectionMeta metadata = fragment_table_model.getMetadata(index); 457 462 fragment_table.setRowSelectionInterval(index, index); … … 463 468 } 464 469 // Ready the text area 465 translation_area.setEnabled(true); 470 translation_area.setEnabled(true); 466 471 translation_area.setBackground(Gatherer.config.getColor("coloring.editable", false)); 467 472 ignore_event = false; 468 473 } 469 } 474 } 470 475 } 471 476 -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionConfiguration.java
r4366 r4675 14 14 private Element maintainer_element; 15 15 private Element name_element; 16 private File file; 16 17 private String creator; 17 18 private String description; … … 20 21 21 22 public CollectionConfiguration(File file) { 23 this.file = file; 22 24 try { 23 25 String filename = file.getName().toLowerCase(); 24 26 if(filename.endsWith(".xml")) { 25 27 26 28 } 27 29 else if(filename.endsWith(".cfg")) { … … 56 58 String language = temp.substring(temp.indexOf("=") + 1, temp.length() - 1); 57 59 if(name == null || language.equalsIgnoreCase(Gatherer.dictionary.getLanguage())) { 58 name = Utility.decodeGreenstone(tokenizer.nextToken()); 60 name = Utility.decodeGreenstone(tokenizer.nextToken()); 59 61 } 60 62 } … … 101 103 ///ystem.err.println("creator = " + creator); 102 104 ///ystem.err.println("maintainer = " + maintainer); 103 ///ystem.err.println("description = " + description); 105 ///ystem.err.println("description = " + description); 104 106 } 105 107 catch(Exception error) { … … 131 133 } 132 134 135 public File getFile() { 136 return file; 137 } 138 133 139 public String getMaintainer() { 134 140 String result = ""; … … 153 159 } 154 160 161 /** Retrieve the short name for this collection which, given this current file is in <col_name>/etc/collect.cfg, is the name of this file's parent file's parent. 162 * @return the short name of this collection as a String 163 */ 164 public String getShortName() { 165 return file.getParentFile().getParentFile().getName(); 166 } 167 155 168 public void setName(String name) { 156 169 /** @todo */ 157 170 } 171 172 /** Display the title for this collection. */ 173 public String toString() { 174 return getName(); 175 } 158 176 } -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r4673 r4675 103 103 104 104 private int special_case = -1; 105 /** Holds a reference to the thread responsible for closing the collection. If non-null then only calls from the given thread will see the collection is non-ready. All other threads will have to wait until closing thread, and all of it consequential calls, are completely finished. */ 106 private Thread closing_thread = null; 107 105 108 /** The name of the standard lock file. */ 106 109 static final public String LOCK_FILE = "gatherer.lck"; … … 142 145 */ 143 146 public void buildCollection() { 144 Gatherer.println(" Building collection");147 Gatherer.println("CollectionManager.buildCollection()"); 145 148 building = true; 146 149 … … 162 165 shell.addGShellListener(Gatherer.g_man.create_pane); 163 166 shell.start(); 167 Gatherer.println("CollectionManager.buildCollection().return"); 164 168 } 165 169 /** Used to determine whether the currently active collection has been built. … … 178 182 */ 179 183 public void closeCollection() { 184 Gatherer.println("Close collection: " + collection.getName()); 185 // We set the closing thread, as it should be the only one who can actually see the collection is closed, at least until the closing thread expires. 186 closing_thread = Thread.currentThread(); 180 187 // System.err.println("Closing collection..."); 181 188 // Remove the lock on this file, then remove the collection. … … 190 197 Gatherer.g_man.collectionChanged(false); 191 198 // System.err.println("Closed collection."); 199 // All of the consequences of a close should have been processed by now, so others should now see the collection as non-ready. 200 closing_thread = null; 192 201 } 193 202 … … 199 208 } 200 209 201 /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the colection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl. 210 /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the colection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl. 202 211 * @param description a description of the collection as a String 203 212 * @param email the email address of the author/maintainer as a String … … 243 252 progress.setNote(get("Log_Created")); 244 253 } 245 254 246 255 progress.setProgress(2); 247 256 … … 707 716 */ 708 717 public void importCollection() { 718 Gatherer.println("CollectionManager.importCollection()"); 709 719 if(!saved()) { 710 720 // Force save. … … 742 752 shell.start(); 743 753 } 754 Gatherer.println("CollectionManager.importCollection().return"); 744 755 } 745 756 /** Attempts to load the given collection. Currently uses simple serialization of the collection class. … … 890 901 */ 891 902 public synchronized void processBegun(GShellEvent event) { 903 Gatherer.println("CollectionManager.processBegun(" + event.getType() + ")"); 892 904 ///ystem.err.println("ProcessBegun " + event.getType()); 893 905 // If this is one of the types where we wish to lock user control … … 901 913 */ 902 914 public synchronized void processComplete(GShellEvent event) { 915 Gatherer.println("CollectionManager.processComplete(" + event.getType() + ")"); 903 916 ///ystem.err.println("ProcessComplete " + event.getType()); 904 917 Gatherer.g_man.lockCollection((event.getType() == GShell.IMPORT), false); … … 936 949 * @return A <i>boolean</i> which is <i>true</i> to indicate a collection has been loaded and thus the collection is ready for editing, <i>false</i> otherwise. 937 950 */ 938 public boolean ready() { 939 if(collection != null) { 940 return true; 941 } 942 return false; 943 } 951 952 public synchronized boolean ready() { 953 if(collection != null) { 954 return true; 955 } 956 else { 957 return false; 958 } 959 } 960 961 public synchronized boolean reallyReady() { 962 if(collection == null) { 963 Gatherer.println("Called reallyReady() when collection was null."); 964 Gatherer.println("Closing thread = " + closing_thread); 965 Gatherer.println("This thread = " + Thread.currentThread()); 966 Gatherer.println("Thus we return: " + (closing_thread == null || closing_thread == Thread.currentThread() ? "not ready" : "ready")); 967 } 968 // If the closing thread is non-null we should only allow that thread to see the collection as closed. 969 if(closing_thread != null) { 970 // Only the closing thread sees the truth 971 if(Thread.currentThread() == closing_thread) { 972 return (collection == null); 973 } 974 // All other threads are told a lie. 975 else { 976 return true; 977 } 978 } 979 else { 980 if(collection != null) { 981 return true; 982 } 983 else { 984 return false; 985 } 986 } 987 } 944 988 /** Called to refresh the models upon which the trees are based. 945 989 * @see org.greenstone.gatherer.collection.Collection … … 1001 1045 */ 1002 1046 public void saveCollection(boolean close_after, boolean exit_after) { 1047 Gatherer.println("Save collection: " + collection.getName()); 1003 1048 try { 1004 1049 SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after); 1050 save_task.start(); 1005 1051 // Run this in the same thread 1006 save_task.run();1052 //save_task.run(); 1007 1053 } 1008 1054 catch(Exception error) { … … 1088 1134 1089 1135 try { 1090 // We have to ensure that the local library 1136 // We have to ensure that the local library 1091 1137 if(Gatherer.config.exec_file != null) { 1092 1138 ///ystem.err.println("Local Library Found!"); -
trunk/gli/src/org/greenstone/gatherer/collection/DeleteCollectionPrompt.java
r4660 r4675 43 43 import org.greenstone.gatherer.Gatherer; 44 44 import org.greenstone.gatherer.collection.Collection; 45 import org.greenstone.gatherer.gui.ModalDialog;46 import org.greenstone.gatherer.gui.SimpleMenuBar;47 45 import org.greenstone.gatherer.util.ArrayTools; 48 import org.greenstone.gatherer.util.GSDLSiteConfig;49 46 import org.greenstone.gatherer.util.Utility; 50 47 /** This class provides the functionality to delete current collections from the GSDLHOME/collect/ directory. The user chooses the collection from a list, where each entry also displays details about itself, confirms the delete of a collection by checking a checkbox then presses the ok button to actually delete the collection. … … 53 50 */ 54 51 public class DeleteCollectionPrompt 55 extends ModalDialog {52 extends JDialog { 56 53 /** The currently selected collection for deletion. */ 57 private Collection Entrycollection = null;54 private CollectionConfiguration collection = null; 58 55 /** The model behind the list. */ 59 56 private DefaultListModel list_model = null; … … 76 73 /** A string array used to pass arguments to the phrase retrieval method. */ 77 74 private String args[] = null; 78 79 private boolean current_coll_deleted = false;80 75 /** The size of the delete prompt screen. */ 81 76 public static final Dimension SIZE = new Dimension(500, 500); … … 87 82 */ 88 83 public DeleteCollectionPrompt() { 89 super( Gatherer.g_man);84 super(); 90 85 this.close_button = new JButton(get("General.Close", null)); 91 86 this.confirmation = new JCheckBox(get("Confirm_Delete", null)); … … 100 95 this.setSize(SIZE); 101 96 this.setTitle(get("Title", null)); 102 this.setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at103 97 close_button.addActionListener(new CloseButtonListener()); 104 98 confirmation.addActionListener(new ConfirmationCheckBoxListener()); … … 127 121 prompt = null; 128 122 } 129 /** This method causes the modal prompt to be displayed. 130 * returns true if it has deleted the collection that is currently open*/ 131 public boolean display() { 123 /** This method causes the modal prompt to be displayed. */ 124 public void display() { 132 125 // Central pane 133 126 JPanel list_pane = new JPanel(new BorderLayout()); … … 170 163 Dimension screen_size = Gatherer.config.screen_size; 171 164 this.setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 172 this.setVisible(true); // blocks until the dialog is killed 173 return current_coll_deleted; 174 175 } 176 /** Shows a delete complete prompt. 165 this.show(); 166 } 167 168 /** Shows a delete complete prompt. 177 169 * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted. 178 170 * @see org.greenstone.gatherer.collection.Collection … … 188 180 } 189 181 } 182 190 183 /** Retrieves a phrase from the <strong>Dictionary</strong> in <strong>Gatherer</strong>. 191 184 * @param key A <strong>String</strong> used to match against a specific phrase in the dictionary. … … 199 192 return Gatherer.dictionary.get(key, args); 200 193 } 201 /** Attempts to load the given collection. Currently uses simple 202 * serialization of the collection class. 203 * @param location The path to the serialized collection. 204 */ 205 // public Collection loadCollection(File file) { 206 // Collection col = null; 207 // try { 208 // FileInputStream fis = new FileInputStream(file); 209 // BufferedInputStream bin = new BufferedInputStream(fis); 210 // ObjectInputStream input = new ObjectInputStream(bin); 211 // col = (Collection) input.readObject(); 212 // input.close(); 213 // input = null; 214 // bin.close(); 215 // bin = null; 216 // fis.close(); 217 // fis = null; 218 // } 219 // catch (Exception error) { 220 // error.printStackTrace(); 221 // } 222 // return col; 223 // } 194 224 195 /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections. 225 196 * @see org.greenstone.gatherer.Configuration … … 233 204 File collect_directory = new File(collect_directory_name); 234 205 if(collect_directory.exists()) { 235 // Now for each child directory see if it contains a .col file and 236 // if so try to load it.. 206 // Now for each child directory see if it contains a .col file and if so try to load it.. 237 207 File collections[] = collect_directory.listFiles(); 238 208 ArrayTools.sort(collections); 239 209 for(int i = 0; collections != null && i < collections.length; i++) { 240 File config_file = Utility.findConfigFile(collections[i]); 241 if (config_file != null) { 242 CollectionConfiguration config = new CollectionConfiguration(config_file); 243 if (config != null) { 244 CollectionEntry col = new CollectionEntry(collections[i].getName(), config); 245 list_model.addElement(col); 210 File children[] = collections[i].listFiles(); 211 for(int j = 0; children != null && j < children.length; j++) { 212 if(children[j].getAbsolutePath().endsWith(".col")) { 213 list_model.addElement(new CollectionConfiguration(children[j])); 246 214 } 247 248 //File children[] = collections[i].listFiles();249 //for(int j = 0; children != null && j < children.length; j++) {250 //if(children[j].getAbsolutePath().endsWith(".col")) {251 //Collection col = loadCollection(children[j]);252 // If we've actually loaded253 //if(col != null) {254 // list_model.addElement(col);255 //}256 //}257 215 } 258 216 } … … 261 219 } 262 220 /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */ 263 private class CloseButtonListener 221 private class CloseButtonListener 264 222 implements ActionListener { 265 223 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. … … 272 230 /** This private class listens for selection events in from the list and then displays the appropriate details for that collection. 273 231 */ 274 private class CollectionListListener 232 private class CollectionListListener 275 233 implements ListSelectionListener { 276 234 /** Any implementation of ListSelectionListener must include this method so we can be informed when the list selection changes. … … 280 238 if(!list.isSelectionEmpty()) { 281 239 confirmation.setEnabled(true); 282 collection = (Collection Entry) list.getSelectedValue();283 args = new String[ 4];284 args[0] = collection.get Title();285 args[1] = collection.get Name();240 collection = (CollectionConfiguration) list.getSelectedValue(); 241 args = new String[5]; 242 args[0] = collection.getName(); 243 args[1] = collection.getShortName(); 286 244 args[2] = collection.getCreator(); 287 args[3] = collection.getDescription(); 245 args[3] = collection.getMaintainer(); 246 args[4] = collection.getDescription(); 288 247 details.setText(get("Details", args)); 289 details.setCaretPosition(0);290 248 } 291 249 else { … … 309 267 } 310 268 } 311 } 269 } 312 270 /** The OK button listener implementation. */ 313 private class OKButtonListener 271 private class OKButtonListener 314 272 implements ActionListener { 315 273 /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned. … … 320 278 */ 321 279 public void actionPerformed(ActionEvent event) { 322 // Delete the selected collection. 323 324 // first of all we must release it from the local library 325 if(Gatherer.config.exec_file != null) { 326 ///ystem.err.println("Local Library Found!"); 327 Gatherer.g_man.preview_pane.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName()); 328 } 329 330 File delete_me = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path) + collection.getName() + File.separator); 280 // Delete the selected collection. 281 File delete_me = collection.getFile().getParentFile().getParentFile(); 331 282 if(Utility.delete(delete_me)) { 332 if (collection.getName().equals(Gatherer.c_man.getCollection().getName())) {333 current_coll_deleted = true;334 }335 336 283 resultPrompt(true); 337 284 list_model.removeElement(collection); … … 347 294 } 348 295 } 349 350 private class CollectionEntry {351 352 private String name = null;353 private CollectionConfiguration config = null;354 355 public CollectionEntry(String name, CollectionConfiguration config) {356 this.name = name;357 this.config = config;358 }359 360 public String getName() {361 return name;362 }363 364 public String getTitle() {365 return config.getName();366 }367 368 public String getCreator() {369 return config.getCreator();370 }371 372 public String getDescription() {373 return config.getDescription();374 }375 376 public String toString() {377 return config.getName();378 379 }380 }381 296 } 382 297 -
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r4383 r4675 46 46 import org.greenstone.gatherer.util.DragComponent; 47 47 import org.greenstone.gatherer.util.SynchronizedTreeModelTools; 48 /** Manages the moving of files within a separate thread. 48 /** Manages the moving of files within a separate thread. 49 49 * @author John Thompson, Greenstone Digital Library, University of Waikato 50 50 * @version 2.3 … … 70 70 // If source and target are different 71 71 else { 72 72 // If target is the UndoManager, we're deleting 73 73 if(target instanceof UndoManager) { 74 74 // If the source is the workspace then display an error message. Workspace is read only. … … 141 141 public void run() { 142 142 // Reset, and calculate progress bar size. 143 queue.calculateSize(source_nodes);143 boolean cancelled = queue.calculateSize(source_nodes); 144 144 // Now we queue the job(s). Note that this may fail if a read only file is encountered and we have been asked to delete. 145 for(int i = 0; source_nodes != null && i < source_nodes.length; i++) {145 for(int i = 0; !cancelled && source_nodes != null && i < source_nodes.length; i++) { 146 146 queue.addJob(id, source, source_nodes[i], target, target_node, type, true, true, true); 147 147 } -
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r4615 r4675 140 140 } 141 141 142 public void calculateSize(FileNode[] files) { 142 /** Calculates the total deep file size of the selected file nodes. 143 * @param files a FileNode[] of selected files 144 * @return true if a cancel was signalled, false otherwise 145 * @see org.greenstone.gatherer.file.FileManager.Task#run() 146 */ 147 public boolean calculateSize(FileNode[] files) { 143 148 progress.reset(); 144 149 progress.setString(get("FileActions.Calculating_Size")); 145 150 progress.setIndeterminate(true); 146 151 Vector remaining = new Vector(); 147 for(int i = 0; i < files.length; i++) {152 for(int i = 0; !cancel_action && i < files.length; i++) { 148 153 remaining.add(files[i]); 149 154 } 150 while( remaining.size() > 0) {155 while(!cancel_action && remaining.size() > 0) { 151 156 FileNode node = (FileNode)remaining.remove(0); 152 157 if(node.isLeaf()) { … … 154 159 } 155 160 else { 156 for(int i = 0; i < node.getChildCount(); i++) {161 for(int i = 0; !cancel_action && i < node.getChildCount(); i++) { 157 162 remaining.add(node.getChildAt(i)); 158 163 } … … 161 166 progress.setString(get("No_Activity")); 162 167 progress.setIndeterminate(false); 168 // Now we return if calculation was cancelled so that the FileManagers Task can skip the addJob phase correctly. 169 if(cancel_action) { 170 cancel_action = false; // reset 171 return true; 172 } 173 else { 174 return false; 175 } 163 176 } 164 177 … … 171 184 return file_status; 172 185 } 173 /** Access to the job state label. */ 186 /** Access to the job state label. */ 174 187 // public JLabel getJobStatus() { 175 188 // return job_status; … … 203 216 ///ystem.err.println("Found job: " + job); 204 217 // The user can cancel this individual action at several places, so keep track if the state is 'ready' for the next step. 205 boolean ready = true; 218 boolean ready = true; 206 219 FileNode origin_node = job.getOrigin(); 207 220 FileNode destination_node = job.getDestination(); … … 394 407 source_model.refresh(new TreePath(((FileNode)origin_node.getParent()).getPath())); 395 408 } 396 409 397 410 // We can't have been cancelled, and we must have created a new FileNode during the above phase, before we can handle metadata. 398 411 if(!cancel_action && new_node != null) { … … 403 416 GDMManager gdm = Gatherer.c_man.getCollection().gdm; 404 417 // we just retrieve the metadata attached to the origin node... 405 ArrayList existing_metadata = gdm.getMetadata (source_file);406 // /ystem.err.println("Existing metadata for " + origin_node + ": " + gdm.toString(existing_metadata));418 ArrayList existing_metadata = gdm.getMetadataOnly(source_file); 419 //Gatherer.println("Existing metadata for " + origin_node + ": " + gdm.toString(existing_metadata)); 407 420 // then assign this remainder to the new folder. 408 421 ///ystem.err.println("New metadata: " + gdm.toString(existing_metadata)); … … 533 546 // We add an entry to the complete mappings to ensure this directory isn't added again 534 547 completed_folder_mappings.put(origin_node, recycle_folder_record); 535 ///ystem.err.println("Added completed directories mapping " + origin_node); 536 // queue all of its children, (both filtered and non-filtered), but for deleting only. Don't queue jobs for a current move event, as they would be queued as part of copying. I have no idea way, per sec, however the children within the origin node are always invalid during deletion (there are several copies of some nodes?!?). I'll check that each child is only added once. 548 ///ystem.err.println("Added completed directories mapping " + origin_node); 549 // queue all of its children, (both filtered and non-filtered), but for deleting only. Don't queue jobs for a current move event, as they would be queued as part of copying. I have no idea way, per sec, however the children within the origin node are always invalid during deletion (there are several copies of some nodes?!?). I'll check that each child is only added once. 537 550 ///ystem.err.println("Directory has " + origin_node.getChildCount() + " children."); 538 551 ///ystem.err.println("Directory actually has " + child_list.length + " children."); … … 586 599 progress.reset(); 587 600 progress.setString(get("No_Activity")); 588 yes_to_all = false; 601 yes_to_all = false; 589 602 completed_folder_mappings.clear(); 590 603 recycle_folder_mappings.clear(); … … 599 612 } 600 613 catch (Exception error) { 601 Gatherer.printStackTrace(error); 614 Gatherer.printStackTrace(error); 602 615 } 603 616 } … … 655 668 * @see org.greenstone.gatherer.Gatherer 656 669 */ 657 public void copyFile(File source, File destination, LongProgressBar progress) 670 public void copyFile(File source, File destination, LongProgressBar progress) 658 671 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException { 659 672 if(source.isDirectory()) { -
trunk/gli/src/org/greenstone/gatherer/gui/CollectionPane.java
r4666 r4675 230 230 collection_filter.setBackground(Color.lightGray); 231 231 } 232 232 233 233 collection_tree.setEnabled(ready); 234 234 collection_filter.setEnabled(ready); … … 242 242 workspace_tree.setModel(workspace); 243 243 workspace_tree_sync.add(workspace_tree); 244 244 245 245 // Enable or disable the control buttons 246 246 bin_button.setEnabled(ready); … … 290 290 fcb.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable", false)); 291 291 fcb.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false)); 292 fcb.setBackgroundSelectionColor(Gatherer.config.getColor("coloring. workspace_selection_background", false));293 fcb.setTextSelectionColor(Gatherer.config.getColor("coloring. workspace_selection_foreground", false));292 fcb.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false)); 293 fcb.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false)); 294 294 fcb = null; 295 295 … … 354 354 355 355 JPanel file_pane = new JPanel(); 356 file_pane.setBackground(Color.white);356 //file_pane.setBackground(Color.white); 357 357 //JPanel job_pane = new JPanel(); 358 358 //job_pane.setBackground(Color.white); 359 359 JPanel progress_pane = new JPanel(); 360 progress_pane.setBackground(Color.white);360 //progress_pane.setBackground(Color.white); 361 361 JLabel file_status = file_queue.getFileStatus(); 362 362 //JLabel job_status = job_queue.getJobStatus(); … … 372 372 bin_button.setPreferredSize(MIN_SIZE); 373 373 group.add(bin_button); 374 374 375 375 // Layout Components. 376 376 workspace_pane.setLayout(new BorderLayout()); … … 689 689 /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */ 690 690 private class MappingPrompt 691 extends JDialog 691 extends JDialog 692 692 implements ActionListener, KeyListener { 693 693 private boolean cancelled = false; … … 723 723 file_pane.add(file_label, BorderLayout.WEST); 724 724 file_pane.add(file_field, BorderLayout.CENTER); 725 725 726 726 name_pane.setLayout(new BorderLayout()); 727 727 name_pane.add(name_label, BorderLayout.WEST); … … 773 773 private class MouseListenerImpl 774 774 extends MouseAdapter { 775 /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */ 775 /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */ 776 776 public void mouseClicked(MouseEvent event) { 777 777 if(SwingUtilities.isRightMouseButton(event)) { -
trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java
r4673 r4675 54 54 /** This class provides a GUI view showing some statistics on your current collection, and options for building it. As the collection is built this initial view is replaced with one showing progress bars and a message log of the creation process. This log can be later accessed via the options tree located in the center of the initial pane. This class is also responsible for creating the GShellProgressMonitors that are then attatched to external shell processes, and calling the methods in the CollectionManager for actually importing and building the collection. <br><BR> 55 55 * <center><table width=80% border=2 cellspacing=0 cellpadding=2><tr><td align=center colspan=4> 56 * The (i)mport and/or (b)uild options supported:</td></tr> 56 * The (i)mport and/or (b)uild options supported:</td></tr> 57 57 * <tr background=black><font color=white><td>Script</td><td>Associated Argument</td><td>Control</td><td>Comments</td></font></tr> 58 58 * <tr><td>b</td><td>-allclassifications</td><td>JCheckBox</td><td> </td></tr> … … 80 80 */ 81 81 public class CreatePane 82 extends JPanel 82 extends JPanel 83 83 implements GShellListener { 84 84 /** Determines the current view that should be shown for this pane. */ … … 101 101 private JButton cancel_button = null; 102 102 /** The label displaying the number of documents in this collection. */ 103 private JLabel document_count = null; 103 private JLabel document_count = null; 104 104 /** The label alongside the build progress bar gets some special treatment so... */ 105 105 private JLabel progress_build_label = null; … … 216 216 ///ystem.err.println("Collection changed... "); 217 217 if(Gatherer.c_man != null && Gatherer.c_man.ready()) { 218 218 219 219 if (!processing &&this.options_pane!=null) { 220 220 // we only do this if we are not processing - if we are processing, then we haven't added the new entry yet, and it will be added by another method 221 221 this.options_pane.resetLogList(); // saves any residual message 222 } 222 } 223 223 Collection current_collection = Gatherer.c_man.getCollection(); 224 224 if (current_collection != previous_collection) { … … 239 239 stats_area.setLayout(new GridLayout(1,1)); 240 240 stats_area.add(document_count); 241 241 242 242 JPanel left = new JPanel(); 243 243 left.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); … … 275 275 build_pane.setLayout(new BorderLayout()); 276 276 build_pane.add(progress_build_label, BorderLayout.WEST); 277 build_pane.add(build_monitor.getProgress(), BorderLayout.CENTER); 277 build_pane.add(build_monitor.getProgress(), BorderLayout.CENTER); 278 278 279 279 JPanel bar_area = new JPanel(); … … 463 463 options_pane.addNewLog(OptionsPane.CANCELLED); 464 464 card_layout.show(main_pane, CONTROL); 465 465 // Set the stop flag in all the process monitor. 466 466 build_monitor.setStop(true); 467 467 copy_monitor.setStop(true); 468 468 import_monitor.setStop(true); 469 // Set removeold automatically. 470 if(Gatherer.c_man.ready()) { // and it should be. 471 Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null); 472 } 473 // Remove the collection lock. 474 Gatherer.g_man.lockCollection(false, false); 469 // Set removeold automatically. 470 Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null); 471 // Remove the collection lock. 472 //Gatherer.g_man.lockCollection(false, false); 475 473 } 476 474 } 477 475 /** The OptionTree is simply a tree structure that has a root node labelled "Options" and then has a child node for each available options screen. These screens are either combinations of the available import and build arguments, or a message log detailing the shell processes progress. */ 478 476 private class OptionTree 479 extends JTree 477 extends JTree 480 478 implements TreeSelectionListener { 481 479 /** The model behind the tree. */ … … 491 489 /** The root node of the options tree, which has no associated options view. */ 492 490 private OptionTreeNode options = null; 493 /** Constructor. 491 /** Constructor. 494 492 * @see org.greenstone.gatherer.gui.CreatePane.OptionTreeNode 495 493 */ … … 505 503 log = new OptionTreeNode(get("Log")); 506 504 options = new OptionTreeNode(get("Options")); 507 505 508 506 model = new DefaultTreeModel(options); 509 507 setModel(model); … … 520 518 public void valueChanged(TreeSelectionEvent event) { 521 519 TreePath path = null; 522 OptionTreeNode node = null; 520 OptionTreeNode node = null; 523 521 //if(event != null) { 524 522 //path = event.getPath(); … … 565 563 /** The <strong>OptionTree</strong> is built from these nodes, each of which has several methods used in creating the option panes. 566 564 */ 567 private class OptionTreeNode 568 extends DefaultMutableTreeNode 565 private class OptionTreeNode 566 extends DefaultMutableTreeNode 569 567 implements Comparable { 570 568 /** The text label given to this node in the tree. */ -
trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java
r4367 r4675 147 147 UI ui = new UI(); 148 148 setUI(ui); 149 ui.setB ackground(Color.white);149 ui.setButtonBackground(); 150 150 // Initialization 151 151 this.background = Gatherer.config.getColor("coloring.collection_tree_background", false); … … 163 163 setBackground(background); 164 164 setForeground(foreground); 165 setSelectionColor(selection_background); 165 setSelectionColor(selection_background); 166 166 setSelectedTextColor(selection_foreground); 167 167 } … … 224 224 } 225 225 226 private class Renderer 227 extends JLabel 226 private class Renderer 227 extends JLabel 228 228 implements ListCellRenderer { 229 229 public Renderer() { … … 258 258 scroller.setPreferredSize( popupBounds.getSize() ); 259 259 scroller.setMinimumSize( popupBounds.getSize() ); 260 list.invalidate(); 260 list.invalidate(); 261 261 int selectedIndex = comboBox.getSelectedIndex(); 262 262 if ( selectedIndex == -1 ) { 263 263 list.clearSelection(); 264 } 264 } 265 265 else { 266 266 list.setSelectedIndex( selectedIndex ); 267 } 267 } 268 268 list.ensureIndexIsVisible( list.getSelectedIndex() ); 269 269 setLightWeightPopupEnabled( comboBox.isLightWeightPopupEnabled() ); … … 276 276 } 277 277 278 public void setB ackground(Color background) {279 arrowButton.setBackground(background);278 public void setButtonBackground() { 279 arrowButton.setBackground(Gatherer.config.getColor("coloring.button_background", false)); 280 280 } 281 281 } -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r4659 r4675 99 99 /** The message pane is optional and contains the log of messages sent. */ 100 100 public MessagePane message_pane = null; 101 101 102 102 public MetaAuditFrame meta_audit; 103 103 /** The metaedit pane is used to assign, edit and remove metadata from files within the collection. */ … … 177 177 else if(esrc == menu_bar.file_delete) { 178 178 DeleteCollectionPrompt dcp = new DeleteCollectionPrompt(); 179 boolean current_deleted =dcp.display();179 dcp.display(); 180 180 dcp.destroy(); 181 181 dcp = null; 182 // need to close the current collection?183 if (current_deleted) {184 Gatherer.c_man.closeCollection();185 tab_pane.setSelectedComponent(collection_pane);186 }187 182 System.gc(); 188 183 } … … 283 278 284 279 int SIZE = 5000; 285 Object[] array = new Object[SIZE]; 286 Runtime.getRuntime().gc(); 280 Object[] array = new Object[SIZE]; 281 Runtime.getRuntime().gc(); 287 282 long start = Runtime.getRuntime().freeMemory(); 288 283 for (int i = 0; i < SIZE; i++) { … … 292 287 long end = Runtime.getRuntime().freeMemory(); 293 288 long difference = (( start - end ) / SIZE); 294 ///ystem.out.println(difference + " bytes used." ); 289 ///ystem.out.println(difference + " bytes used." ); 295 290 } 296 291 } … … 309 304 } 310 305 else if(esrc == menu_bar.help_collect) { 311 help.setView("5.0"); 306 help.setView("5.0"); 312 307 } 313 308 else if(esrc == menu_bar.help_design) { 314 help.setView("7.0"); 309 help.setView("7.0"); 315 310 } 316 311 else if(esrc == menu_bar.help_general) { 317 help.setView(""); 312 help.setView(""); 318 313 } 319 314 else if(esrc == menu_bar.help_metaedit) { … … 321 316 } 322 317 else if(esrc == menu_bar.help_mirror) { 323 help.setView("4.0"); 318 help.setView("4.0"); 324 319 } 325 320 else if(esrc == menu_bar.help_preview) { … … 411 406 // Create the menu-bar and stick it up the top. 412 407 menu_bar = new MenuBar(new MenuListenerImpl()); 413 content_pane.add(menu_bar, BorderLayout.NORTH); 414 // Create the tabbed pane and plop it in the center where it will 408 content_pane.add(menu_bar, BorderLayout.NORTH); 409 // Create the tabbed pane and plop it in the center where it will 415 410 // expand to consume all available space like any good gas would. 416 411 tab_pane = new JTabbedPane(); … … 424 419 tab_pane.setEnabledAt(tab_pane.indexOfComponent(browser_pane), Gatherer.config.get("workflow.browse", false)); 425 420 } 426 421 427 422 if(Gatherer.config.get("workflow.mirror", true)) { 428 423 mirror_pane = new MirrorPane(workspace_tree_sync); … … 430 425 tab_pane.addTab(get("Mirroring"), Utility.getImage("mirroring.gif"), mirror_pane); 431 426 tab_pane.setEnabledAt(tab_pane.indexOfComponent(mirror_pane), Gatherer.config.get("workflow.mirror", false)); 432 } 427 } 433 428 434 429 if(Gatherer.config.get("workflow.gather", true)) { … … 445 440 tab_pane.setEnabledAt(tab_pane.indexOfComponent(metaedit_pane), false); 446 441 } 447 442 448 443 if(Gatherer.config.get("workflow.design", true)) { 449 444 config_pane = new GConfigPane(); … … 452 447 tab_pane.setEnabledAt(tab_pane.indexOfComponent(config_pane), false); 453 448 } 454 449 455 450 if(Gatherer.config.get("workflow.export", true)) { 456 451 tab_pane.addTab(get("Export"), Utility.getImage("export.gif"), export_pane); 457 452 tab_pane.setEnabledAt(tab_pane.indexOfComponent(export_pane), false); 458 453 } 459 454 460 455 if(Gatherer.config.get("workflow.create", true)) { 461 456 create_pane = new CreatePane(); … … 464 459 tab_pane.setEnabledAt(tab_pane.indexOfComponent(create_pane), false); 465 460 } 466 461 467 462 if(Gatherer.config.get("workflow.preview", true)) { 468 463 preview_pane = new PreviewPane(); … … 542 537 } 543 538 544 /** Allows the system to programatically set the selected tab. 539 /** Allows the system to programatically set the selected tab. 545 540 * @param component The view you wish to make visable in the tab pane as a <strong>Component</strong>. 546 541 */ … … 609 604 // If there is already a collection open, save and close it. 610 605 if(Gatherer.c_man.ready()) { 611 showSaveCollectionBox(true, false); 606 showSaveCollectionBox(true, false); 612 607 // Wait until it is closed. 613 // try { 614 // while(Gatherer.c_man.ready()) { 615 // wait(10); 616 // } 617 // } 618 // catch(Exception error) { 619 // System.err.println("Exception: " + error); 620 // error.printStackTrace(); 621 // } 608 try { 609 synchronized(this) { 610 while(Gatherer.c_man.reallyReady()) { 611 wait(10); 612 } 613 } 614 } 615 catch(Exception error) { 616 Gatherer.println("Exception: " + error); 617 Gatherer.printStackTrace(error); 618 } 622 619 } 623 620 result = Gatherer.c_man.loadCollection(filename); … … 653 650 showSaveCollectionBox(true, false); 654 651 // Wait until it is closed. 655 //try {656 //synchronized(this) {657 // while(Gatherer.c_man.ready()) {658 //wait(10);659 //}660 //}661 //}662 //catch(Exception error) {663 // System.err.println("Exception: " + error);664 // error.printStackTrace();665 //}652 try { 653 synchronized(this) { 654 while(Gatherer.c_man.reallyReady()) { 655 wait(10); 656 } 657 } 658 } 659 catch(Exception error) { 660 Gatherer.println("Exception: " + error); 661 Gatherer.printStackTrace(error); 662 } 666 663 } 667 664 … … 679 676 extends Thread { 680 677 private NewCollectionDetailsPrompt ncd_prompt = null; 681 private NewCollectionMetadataPrompt ncm_prompt = null; 678 private NewCollectionMetadataPrompt ncm_prompt = null; 682 679 public CreationTask(NewCollectionDetailsPrompt ncd_prompt, NewCollectionMetadataPrompt ncm_prompt) { 683 680 this.ncd_prompt = ncd_prompt; … … 717 714 //case SaveCollectionBox.SAVE_YES: 718 715 Gatherer.c_man.saveCollection(close_after, exit_after); 716 // Wait until it is closed. 717 try { 718 synchronized(this) { 719 while(Gatherer.c_man.reallyReady()) { 720 wait(10); 721 } 722 } 723 } 724 catch(Exception error) { 725 Gatherer.println("Exception: " + error); 726 Gatherer.printStackTrace(error); 727 } 728 719 729 //content_pane.paintImmediately(bounds); 720 return true; 730 return true; 721 731 //case SaveCollectionBox.SAVE_NO: 722 732 // Close collection. … … 862 872 } 863 873 } 864 private class TabUpdater 874 private class TabUpdater 865 875 implements Runnable { 866 876 private boolean ready = false; -
trunk/gli/src/org/greenstone/gatherer/gui/LockFileDialog.java
r4459 r4675 52 52 name_label.setPreferredSize(LABEL_SIZE); 53 53 TextFieldLabel name_field = new TextFieldLabel(name); 54 name_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 54 55 JPanel person_pane = new JPanel(); 55 56 JLabel person_label = new JLabel(get("User")); 56 57 person_label.setPreferredSize(LABEL_SIZE); 57 58 TextFieldLabel person_field = new TextFieldLabel(getValue("User")); 59 person_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 58 60 JPanel machine_pane = new JPanel(); 59 61 JLabel machine_label = new JLabel(get("Machine")); 60 62 machine_label.setPreferredSize(LABEL_SIZE); 61 63 TextFieldLabel machine_field = new TextFieldLabel(getValue("Machine")); 64 machine_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 62 65 JPanel created_pane = new JPanel(); 63 66 JLabel created_label = new JLabel(get("Date")); 64 67 created_label.setPreferredSize(LABEL_SIZE); 65 68 TextFieldLabel created_field = new TextFieldLabel(getValue("Date")); 69 created_field.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false)); 66 70 JLabel central_label = new JLabel(get("Lockfile_Message_Two")); 67 71 JPanel button_pane = new JPanel(); -
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r4667 r4675 406 406 // Change the default colours of this filters combobox. 407 407 GComboBox fcb = filter.getComboBox(); 408 fcb.setBackgroundNonSelectionColor( Gatherer.config.getColor("coloring.editable", false));408 fcb.setBackgroundNonSelectionColor(Color.white); 409 409 fcb.setTextNonSelectionColor(Gatherer.config.getColor("coloring.collection_tree_foreground", false)); 410 410 fcb.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false)); -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r4664 r4675 112 112 description_label.setOpaque(false); 113 113 description = new JTextArea(); 114 description.setBackground(Gatherer.config.getColor("coloring.editable", false));115 114 description.setRows(5); 116 115 -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionMetadataPrompt.java
r4630 r4675 19 19 import org.w3c.dom.*; 20 20 21 public class NewCollectionMetadataPrompt 21 public class NewCollectionMetadataPrompt 22 22 extends ModalDialog { 23 23 … … 45 45 if(name.endsWith(".mds")) { 46 46 sets.add(new MetadataSet(possible_mdses[i])); 47 } 48 } 47 } 48 } 49 49 50 50 // Creation 51 51 JPanel content_pane = (JPanel) getContentPane(); 52 52 53 JLabel instructions_label = new JLabel(get("Metadata_Instructions")); 53 JPanel instructions_panel = new JPanel(); 54 JLabel instructions_label1 = new JLabel(get("Metadata_Instructions1")); 55 JLabel instructions_label2 = new JLabel(get("Metadata_Instructions2")); 54 56 55 57 JPanel center_pane = new JPanel(); … … 76 78 sets_list.addListSelectionListener(new MetadataListSelectionListener()); 77 79 // Display 80 instructions_panel.setLayout(new GridLayout(2,1)); 81 instructions_panel.add(instructions_label1); 82 instructions_panel.add(instructions_label2); 83 78 84 sets_list_pane.setLayout(new BorderLayout()); 79 85 sets_list_pane.add(sets_list_label, BorderLayout.NORTH); … … 96 102 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 97 103 content_pane.setLayout(new BorderLayout()); 98 content_pane.add(instructions_ label, BorderLayout.NORTH);104 content_pane.add(instructions_panel, BorderLayout.NORTH); 99 105 content_pane.add(center_pane, BorderLayout.CENTER); 100 106 content_pane.add(button_pane, BorderLayout.SOUTH); -
trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java
r4596 r4675 51 51 import org.greenstone.gatherer.util.Utility; 52 52 import org.w3c.dom.*; 53 /** This class serves as the data holder for all subclasses of option panes, such as Import options or All options. It also contains methods for creating each of the option lines as they would appear in the subpane. Futhermore it has a method for considering all the arguments and generating a <strong>String[]</strong> to allow you to pass them to the <strong>GShell</strong>. 53 /** This class serves as the data holder for all subclasses of option panes, such as Import options or All options. It also contains methods for creating each of the option lines as they would appear in the subpane. Futhermore it has a method for considering all the arguments and generating a <strong>String[]</strong> to allow you to pass them to the <strong>GShell</strong>. 54 54 * @author John Thompson, Greenstone Digital Library, University of Waikato 55 55 * @version 2.2 … … 75 75 static final public char UNSUCCESSFUL = 'u'; 76 76 static final public char CANCELLED = 'c'; 77 77 78 78 static private int BUILD = 0; 79 79 static private int IMPORT = 1; … … 85 85 static private Dimension SPINNER_SIZE = new Dimension(100, 25); 86 86 static private String DESCRIPTION_SEP = " + "; 87 88 87 88 89 89 /** The default constructor creates the few session length options, but either retrieves the rest from the current collection, or creates a default set of options. */ 90 90 public OptionsPane(JTextArea log, BuildOptions build_options) { … … 95 95 } 96 96 97 /** creates a new log from the text in log. The new file is named 97 /** creates a new log from the text in log. The new file is named 98 98 * build_log.<current time>.txt. A new FileEntry is added to teh log list 99 99 * and made selected. A fresh listener is added to teh document */ 100 100 public void addNewLog(char success) { 101 101 ///ystem.out.println("add new log"); 102 102 103 103 // create the file name 104 104 long time = System.currentTimeMillis(); … … 153 153 } 154 154 return pane; 155 } 155 } 156 156 /** This method creates the panel with all the import only options on it. 157 157 * @return A <strong>JPanel</strong> which can be used to display all the import only options. … … 189 189 if (log_pane == null) { 190 190 log_pane = new JPanel(new BorderLayout()); 191 191 192 192 // Build a list of the log files available, ordering by last modified. Log files are like build_log.date.txt 193 193 DefaultListModel contents = new DefaultListModel(); … … 213 213 } 214 214 } 215 216 log_list = new JList(contents); 215 216 log_list = new JList(contents); 217 217 log_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 218 218 log_list.setLayoutOrientation(JList.VERTICAL); 219 219 log_list.setVisibleRowCount(3); 220 220 log_list.addListSelectionListener(new LogListListener()); 221 221 222 222 JScrollPane list_scroller = new JScrollPane(log_list); 223 223 224 224 // If log is not empty and we have something in displayed_log - make that element selected 225 225 if (log_display.getText().length()>0 && displayed_log != null) { … … 228 228 log_list.setSelectedIndex(index); 229 229 } 230 230 231 231 } 232 232 log_pane.add(new JScrollPane(log_display), BorderLayout.CENTER); … … 261 261 return Gatherer.dictionary.get(key, args); 262 262 } 263 /** Attempts to discover the latest document count. 263 /** Attempts to discover the latest document count. 264 264 * @return An <strong>int</strong> detailing the number of documents in this collection. 265 265 */ … … 273 273 return 1; 274 274 } 275 275 276 276 /** Loads a new log into the log text - saves the currently showing one, 277 277 * and loads the new one, adding a fresh listener to the document 278 * Note, we need to remove any listener before making the changes, then 279 * add a listener back in 278 * Note, we need to remove any listener before making the changes, then 279 * add a listener back in 280 280 */ 281 281 public void loadSelectedLog(FileEntry fe) { … … 286 286 log_display.getDocument().removeDocumentListener(log_change_listener); 287 287 } 288 288 289 289 displayed_log = fe; 290 290 if (fe != null) { … … 295 295 is_log_changed=false; 296 296 log_display.getDocument().addDocumentListener(log_change_listener); 297 297 298 298 } 299 299 300 300 /** Neutralizes the log list - saves any unsaved changes to the current log 301 * clears the log text, unselects the log list, and adds a fresh listener 302 * to the log's document 303 * Note, we need to remove any listener before making the changes, then 301 * clears the log text, unselects the log list, and adds a fresh listener 302 * to the log's document 303 * Note, we need to remove any listener before making the changes, then 304 304 * add a listener back in */ 305 305 public void resetLogList() { … … 317 317 is_log_changed=false; 318 318 log_display.getDocument().addDocumentListener(log_change_listener); 319 319 320 320 } 321 321 322 322 /** saves the current text in log to the File specified */ 323 323 public void saveLogFile(File file) { 324 324 325 325 try { 326 326 BufferedWriter out = new BufferedWriter(new FileWriter(file)); // uses the default encoding … … 331 331 String token = t.nextToken(); 332 332 if (token.equals("\n")) { 333 out.newLine(); 333 out.newLine(); 334 334 } else { 335 335 out.write(token, 0, token.length()); 336 336 } 337 337 338 338 } 339 339 out.close(); 340 340 341 341 } catch(Exception e) { 342 342 System.out.println("Error in saving log file: "+file.toString()); 343 343 e.printStackTrace(); 344 344 } 345 346 345 346 347 347 } 348 348 … … 550 550 /** Constructor. */ 551 551 public EnabledListener(JComponent target) { 552 this.target = target; 552 this.target = target; 553 553 } 554 554 /** Any implementation of ActionListener must include this method so that we can be informed when an action has been performed on or registered check box, prompting us to change the state of the other controls as per the users request. … … 587 587 588 588 /** holds a File which has a particular naming convention 589 * build_log.date.txt 589 * build_log.date.txt 590 590 * also keeps a Date corresponding to the date in its name*/ 591 591 private class FileEntry { 592 592 593 593 private Date date=null; 594 594 private File file=null; … … 598 598 this.date = getDateFromFileName(); 599 599 this.display = createDisplayText(); 600 600 601 601 } 602 602 … … 606 606 return date.compareTo(d); 607 607 } 608 608 609 609 public Date getDate() { 610 610 return this.date; … … 622 622 BufferedReader in = new BufferedReader(new FileReader(this.file)); 623 623 String line; 624 624 625 625 while ((line = in.readLine()) != null) { 626 626 contents.append(line); … … 632 632 } catch (IOException ioe) { 633 633 System.err.println("Error: exception occurred when trying to read in file "+this.file.toString()+", "+ioe.getMessage()); 634 635 } 636 634 635 } 636 637 637 return contents.toString(); 638 638 } 639 639 /** we only want the date out of the file name, not the whole path */ 640 640 public String toString() { 641 return this.display; 641 return this.display; 642 642 } 643 643 /** creates the display text for the list */ … … 645 645 StringBuffer d = new StringBuffer(); 646 646 d.append(date.toString()); 647 char success= this.file.getName().charAt(23); 648 switch (success) { 649 case OptionsPane.SUCCESSFUL: 650 d.append(get("Successful")); 651 break; 652 case OptionsPane.UNSUCCESSFUL: 653 d.append(get("Unsuccessful")); 654 break; 655 case OptionsPane.CANCELLED: 656 d.append(get("Cancelled")); 657 break; 658 } 647 //char success= this.file.getName().charAt(23); 648 String filename = this.file.getName(); 649 int index = filename.lastIndexOf(".") - 1; 650 if(index >= 0) { 651 char success = filename.charAt(index); 652 switch (success) { 653 case OptionsPane.SUCCESSFUL: 654 d.append(get("Successful")); 655 break; 656 case OptionsPane.UNSUCCESSFUL: 657 d.append(get("Unsuccessful")); 658 break; 659 case OptionsPane.CANCELLED: 660 d.append(get("Cancelled")); 661 break; 662 } 663 } 659 664 return d.toString(); 660 665 } … … 675 680 } 676 681 677 682 678 683 } 679 684 680 685 /** A DocumentListener that listens for changes in the log_display document 681 686 * if a change is registered, the flag is_log_changed is set to true, 682 * and the listener removes itself from log_display 687 * and the listener removes itself from log_display 683 688 * Because we only want to register user's changes, the listener must be removed before the system makes any changes, and then put back. For example, each time we switchlogs to display, a remove event and an insert event are sent. We dont want to register these as changes to the document, so the listener must be removed before the switch, and added back afterwards */ 684 689 private class LogChangeListener implements DocumentListener { … … 703 708 } 704 709 } 705 706 /** a ListSelectionListener that triggers the load of a newly selected 710 711 /** a ListSelectionListener that triggers the load of a newly selected 707 712 log */ 708 713 private class LogListListener implements ListSelectionListener { 709 714 710 715 public void valueChanged(ListSelectionEvent e) { 711 if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one) 716 if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one) 712 717 JList source = (JList)e.getSource(); 713 718 FileEntry fe = (FileEntry) source.getSelectedValue(); -
trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java
r4600 r4675 172 172 view.setLoadSynchronously(false); 173 173 ///ystem.err.println("Complete."); 174 url = null; 175 } 176 catch( MalformedURLException error) {174 url = null; 175 } 176 catch(Exception error) { 177 177 ///ystem.err.println("Bad URL."); 178 178 } -
trunk/gli/src/org/greenstone/gatherer/undo/UndoManager.java
r4524 r4675 58 58 import org.greenstone.gatherer.util.DragGroup; 59 59 import org.greenstone.gatherer.util.Utility; 60 /** Manages the rather complex task of undoing and redoing actions. It does this by storing two queues, undo and redo, containing undo jobs which encapsulate all the information needed to undo or redo an action. It is also important to note that the manage creates a temporary directory, and then places any deleted files in this directory, and saves their associated metadata with them, for the life of the session. This is to facilitate the restoring of deleted files. 61 * @author John Thompson, Greenstone Digital Library, University of Waikato 60 /** Manages the rather complex task of undoing and redoing actions. It does this by storing two queues, undo and redo, containing undo jobs which encapsulate all the information needed to undo or redo an action. It is also important to note that the manage creates a temporary directory, and then places any deleted files in this directory, and saves their associated metadata with them, for the life of the session. This is to facilitate the restoring of deleted files. 61 * @author John Thompson, Greenstone Digital Library, University of Waikato 62 62 * @version 2.3c 63 63 */ … … 270 270 redo.push(job); 271 271 } 272 } 272 } 273 273 274 274 public void fileMoved(long id, DragComponent source_model, FileNode source_parent, DragComponent target_model, FileNode target_parent, FileNode record, boolean undo_event) { … … 291 291 public ArrayList getMetadata(File file) { 292 292 ///ystem.err.println("UndoMetadata: " + file.getAbsolutePath()); 293 return obsolete_metadata.getMetadata(file.getAbsolutePath(), true, new ArrayList(), file );293 return obsolete_metadata.getMetadata(file.getAbsolutePath(), true, new ArrayList(), file, false); 294 294 } 295 295 … … 392 392 this.type = type; 393 393 } 394 394 395 395 public void action(boolean is_undo, FileQueue file_queue) { 396 396 // Retrieve the lastest version of each file record … … 414 414 latest_source_parent = source_parent; 415 415 } 416 // Heres the fraction, too much friction. 416 // Heres the fraction, too much friction. 417 417 switch(type) { 418 case FILE_COPY: 418 case FILE_COPY: 419 419 // To undo a file copy we issue a delete file action on the destination file record. 420 420 file_queue.addJob(id, target_model, latest_record, source_model, latest_source_parent, FileJob.DELETE, !is_undo, true, false); … … 424 424 file_queue.addJob(id, target_model, latest_record, source_model, latest_source_parent, FileJob.MOVE, !is_undo, true, false); 425 425 break; 426 case FILE_MOVE: 426 case FILE_MOVE: 427 427 // This may be a legitimate move, or may be a side effect of an undelete. If the formed source model and parent will be non-null. 428 428 if(source_model != null && source_parent != null) { … … 449 449 } 450 450 451 private class UndoJobAdder 451 private class UndoJobAdder 452 452 implements Runnable { 453 453 private boolean undo_event; … … 478 478 } 479 479 480 private class UndoStack 480 private class UndoStack 481 481 extends LinkedList { 482 482 private boolean enabled = false; … … 491 491 if(enabled) { 492 492 setEnabled(false); 493 } 493 } 494 494 } 495 495 public UndoJob getJob(long id) {
Note:
See TracChangeset
for help on using the changeset viewer.