- Timestamp:
- 2005-07-13T14:10:18+12:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r10239 r10242 63 63 public class Gatherer 64 64 { 65 static private Dimension size = new Dimension(800, 540); 66 65 67 /** Has the exit flag been set? */ 66 68 public boolean exit = false; … … 79 81 static public FileManager f_man; 80 82 /** A public reference to the GUIManager. */ 81 static public GUIManager g_man ;83 static public GUIManager g_man = null; 82 84 static private boolean g_man_built = false; 83 85 … … 88 90 89 91 static public boolean isApplet = false; 90 static public boolean isGsdlRemote = false;92 static public boolean isGsdlRemote = true; 91 93 static public String cgiBase = ""; 92 94 … … 112 114 113 115 114 public Gatherer( )116 public Gatherer(String[] args) 115 117 { 116 118 this.self = this; 117 118 119 JarTools.initialise(this); 119 } 120 121 122 public GUIManager init(Dimension size, String gsdl_path, String gsdl3_path, String local_library_path, 123 String library_url_string, boolean debug_enabled, String perl_path, 124 boolean no_load, String open_collection, 125 String site_name, String servlet_path, String wget_path) 120 121 GetOpt go = new GetOpt(args); 122 123 // If feedback is enabled, set up the recorder dialog 124 if (go.feedback_enabled) { 125 // Use the default locale for now - this will be changed by the Gatherer run method 126 feedback_enabled = true; 127 feedback_dialog = new ActionRecorderDialog(Locale.getDefault()); 128 } 129 130 if (go.collect_directory_path != null) { 131 // Use non-standard collect directory (for when running one GLI in a network environment) 132 Gatherer.setCollectDirectoryPath(go.collect_directory_path); 133 } 134 135 // Special code for running with a remote Greenstone 136 if (isGsdlRemote) { 137 File gli_user_directory = Utility.getGLIUserFolder(); 138 139 Utility.BASE_DIR = gli_user_directory.toString(); 140 if (!Utility.BASE_DIR.endsWith(File.separator)) { 141 Utility.BASE_DIR += File.separator; 142 } 143 144 Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator; 145 Utility.TMP_DIR = Utility.BASE_DIR + "tmp" + File.separator; 146 147 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 148 Configuration.CONFIG_XML = "configRemote.xml"; 149 Configuration.GS3_CONFIG_XML = "config3Remote.xml"; 150 151 Gatherer.setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator); 152 File col_dir = new File(Gatherer.getCollectDirectoryPath()); 153 if (!col_dir.exists()) { 154 155 if (JarTools.isInJar(Utility.COLLECT_ZIP)) { 156 // Dig out collect.zip from JAR file and unzip it (thereby 157 // creating collect directory and descendants. 158 // This is done to seed gsdl home folder with config files 159 // for documented example collections so "base this on 160 // existing collection" works 161 Utility.unzipFromJar(Utility.COLLECT_ZIP, gli_user_directory.toString()); 162 } 163 else { 164 // Prepare an empty collect dir for general use 165 if (!col_dir.mkdir()) { 166 System.err.println("Warning: Unable to make directory: " + col_dir.toString()); 167 } 168 } 169 } 170 171 File tmp_dir = new File(Utility.TMP_DIR); 172 if (!tmp_dir.exists()) { 173 if (!tmp_dir.mkdir()) { 174 System.err.println("Warning: Unable to make directory: " + tmp_dir.toString()); 175 } 176 177 String username = System.getProperty("user.name"); 178 if ((username != null) && (username != "")) { 179 File user_tmp_dir = new File(Utility.TMP_DIR + File.separator + username); 180 if (!user_tmp_dir.exists()) { 181 if (!user_tmp_dir.mkdir()) { 182 System.err.println("Warning: Unable to make directory: " + user_tmp_dir.toString()); 183 } 184 } 185 } 186 } 187 188 File metadata_directory = new File(Utility.METADATA_DIR); 189 if (!metadata_directory.exists()) { 190 // dig out metadata.zip from JAR file and unzip it 191 Utility.unzipFromJar(Utility.METADATA_ZIP, gli_user_directory.toString()); 192 } 193 194 File plug_dat = new File(Utility.BASE_DIR + "plugins.dat"); 195 if (!plug_dat.exists()) { 196 JarTools.extractFromJar("plugins.dat", Utility.BASE_DIR, false); 197 } 198 199 File class_dat = new File(Utility.BASE_DIR + "classifiers.dat"); 200 if (!class_dat.exists()) { 201 JarTools.extractFromJar("classifiers.dat", Utility.BASE_DIR, false); 202 } 203 } 204 205 init(go.gsdl_path, go.gsdl3_path, go.local_library_path, go.library_url_string, go.debug, 206 go.perl_path, go.no_load, go.filename, go.site_name, go.servlet_path, go.wget_path); 207 } 208 209 210 public void init(String gsdl_path, String gsdl3_path, String local_library_path, 211 String library_url_string, boolean debug_enabled, String perl_path, 212 boolean no_load, String open_collection, 213 String site_name, String servlet_path, String wget_path) 126 214 { 127 215 if (gsdl3_path != null && !gsdl3_path.equals("")) { … … 329 417 // Create GUI Manager (last) or else suffer the death of a thousand NPE's 330 418 g_man = new GUIManager(size); 331 return g_man; 332 } 333 334 335 public void run(Dimension size, GUIManager g_man) 419 } 420 421 422 public void openGUI() 336 423 { 337 424 // Size and place the frame on the screen -
trunk/gli/src/org/greenstone/gatherer/GathererApplet.java
r10240 r10242 34 34 import javax.swing.JApplet; 35 35 36 import java.awt.*;37 36 import java.io.*; 38 import java.util.*;39 37 import javax.swing.*; 40 import org.greenstone.gatherer.Configuration;41 import org.greenstone.gatherer.feedback.ActionRecorderDialog;42 import org.greenstone.gatherer.gui.GUIManager;43 import org.greenstone.gatherer.util.JarTools;44 38 import org.greenstone.gatherer.util.Utility; 45 import org.greenstone.gatherer.shell.GShell;46 39 47 40 48 41 public class GathererApplet extends JApplet implements ActionListener 49 42 { 50 Gatherer gatherer; 51 GUIManager g_man; 52 Dimension size = new Dimension(800, 540); 43 private Gatherer gatherer = null; 44 53 45 54 46 protected String fullLibraryURL(String address) … … 73 65 } 74 66 67 68 /* This is the entry point for the GLI applet */ 75 69 public void init() 76 70 { 71 // Check if the user has agreed to the requested security settings 77 72 try { 78 73 // Work-around to reduce number of … … 81 76 System.setProperty("java.util.prefs.syncInterval","2000000"); 82 77 } 83 84 78 catch (Exception exception) { 85 // convenient way of finding out if user has agreed to 86 // to requested security settings 87 88 JLabel lab 89 = new JLabel("Greenstone Librarian Interface Applet deactivated", 90 JLabel.CENTER); 91 getContentPane().add(lab); 79 getContentPane().add(new JLabel("Greenstone Librarian Interface Applet deactivated", JLabel.CENTER)); 92 80 return; 93 81 } … … 101 89 } 102 90 103 String gwcgi = getParameter("gwcgi"); 104 String library_cgi = fullLibraryURL(gwcgi); 105 int cgi_base_cut = library_cgi.lastIndexOf('/'); 106 String cgi_base = library_cgi.substring(0,cgi_base_cut+1); 107 108 String windows_home = getParameter("windowsHome"); 109 File gli_user_directory = Utility.setGLIUserFolder(windows_home); 110 if (!gli_user_directory.exists()) { 111 if (!gli_user_directory.mkdirs()) { 112 System.err.println("Warning: Unable to make directory: " + gli_user_directory.toString()); 113 } 91 // Ensure the GLI user directory exists 92 File gli_user_directory = Utility.setGLIUserFolder(getParameter("windowsHome")); 93 if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) { 94 System.err.println("Error: Unable to make directory: " + gli_user_directory.toString()); 114 95 } 115 96 116 gatherer = new Gatherer(); 97 // Set some global variables so we know how we're running 98 Gatherer.isApplet = true; 99 Gatherer.isGsdlRemote = true; 100 String library_cgi = fullLibraryURL(getParameter("gwcgi")); 101 Gatherer.cgiBase = library_cgi.substring(0, library_cgi.lastIndexOf('/') + 1); 102 103 // String debug_param = getParameter("debug"); 104 // if ((debug_param != null) && (debug_param.matches("true"))) { 105 // go.debug = true; 106 // } 117 107 118 108 String[] args = { "-gsdl", gli_user_directory.toString(), … … 120 110 }; 121 111 122 GetOpt go = new GetOpt(args); 112 // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI 113 gatherer = new Gatherer(args); 123 114 124 String debug_param = getParameter("debug"); 125 126 if ((debug_param != null) && (debug_param.matches("true"))) { 127 go.debug = true; 128 } 129 130 if (go.feedback_enabled) { 131 // If feedback is enabled, set up the recorder dialog. 132 // Use the default locale for now - this will be changed by the 133 // Gatherer run method 134 Locale currLocale = Locale.getDefault(); 135 ActionRecorderDialog dlg = new ActionRecorderDialog (currLocale); 136 gatherer.feedback_enabled = true; 137 gatherer.feedback_dialog = dlg; 138 } 139 140 Gatherer.isApplet = true; 141 Gatherer.isGsdlRemote = true; 142 Gatherer.cgiBase = cgi_base; 143 144 Utility.BASE_DIR = go.gsdl_path; 145 if (!Utility.BASE_DIR.endsWith(File.separator)) { 146 Utility.BASE_DIR += File.separator; 147 } 148 149 Utility.METADATA_DIR = Utility.BASE_DIR + "metadata" + File.separator; 150 Utility.TMP_DIR = Utility.BASE_DIR + "tmp" + File.separator; 151 152 Configuration.TEMPLATE_CONFIG_XML = "xml/configRemote.xml"; 153 Configuration.CONFIG_XML = "configRemote.xml"; 154 Configuration.GS3_CONFIG_XML = "config3Remote.xml"; 155 156 Gatherer.setCollectDirectoryPath(go.gsdl_path + "collect" + File.separator); 157 File col_dir = new File(Gatherer.getCollectDirectoryPath()); 158 if (!col_dir.exists()) { 159 160 if (JarTools.isInJar(Utility.COLLECT_ZIP)) { 161 // Dig out collect.zip from JAR file and unzip it (thereby 162 // creating collect directory and descendants. 163 // This is done to seed gsdl home folder with config files 164 // for documented example collections so "base this on 165 // existing collection" works 166 Utility.unzipFromJar(Utility.COLLECT_ZIP,gli_user_directory.toString()); 167 } 168 else { 169 // Prepare an empty collect dir for general use 170 if (!col_dir.mkdir()) { 171 System.err.println("Warning: Unable to make directory: " + col_dir.toString()); 172 } 173 } 174 } 175 176 177 File tmp_dir = new File(Utility.TMP_DIR); 178 if (!tmp_dir.exists()) { 179 if (!tmp_dir.mkdir()) { 180 System.err.println("Warning: Unable to make directory: " + tmp_dir.toString()); 181 } 182 183 String username = System.getProperty("user.name"); 184 if ((username != null) && (username != "")) { 185 File user_tmp_dir = new File(Utility.TMP_DIR + File.separator + username); 186 if (!user_tmp_dir.exists()) { 187 if (!user_tmp_dir.mkdir()) { 188 System.err.println("Warning: Unable to make directory: " + user_tmp_dir.toString()); 189 } 190 } 191 } 192 } 193 194 File metadata_directory = new File(Utility.METADATA_DIR); 195 if (!metadata_directory.exists()) { 196 // dig out metadata.zip from JAR file and unzip it 197 Utility.unzipFromJar(Utility.METADATA_ZIP, gli_user_directory.toString()); 198 } 199 200 File plug_dat = new File(Utility.BASE_DIR + "plugins.dat"); 201 if (!plug_dat.exists()) { 202 JarTools.extractFromJar("plugins.dat", Utility.BASE_DIR, false); 203 } 204 205 File class_dat = new File(Utility.BASE_DIR + "classifiers.dat"); 206 if (!class_dat.exists()) { 207 JarTools.extractFromJar("classifiers.dat", Utility.BASE_DIR, false); 208 } 209 210 g_man = gatherer.init(size, go.gsdl_path, go.gsdl3_path, go.local_library_path, 211 go.library_url_string, go.debug, go.perl_path, 212 go.no_load, go.filename, go.site_name, 213 go.servlet_path, go.wget_path); 214 215 JButton bttn = new JButton("Launch Greenstone Librarian Interface ..."); 216 bttn.addActionListener(this); 217 getContentPane().add(bttn); 115 // Create a button for the user to press to open the GLI GUI 116 JButton launch_GLI_button = new JButton("Launch Greenstone Librarian Interface ..."); 117 launch_GLI_button.addActionListener(this); 118 getContentPane().add(launch_GLI_button); 218 119 } 219 120 … … 240 141 } 241 142 143 242 144 public void actionPerformed(ActionEvent e) 243 145 { 244 gatherer. run(size, g_man);146 gatherer.openGUI(); 245 147 246 // If there was an open collection last session, reopen it .148 // If there was an open collection last session, reopen it 247 149 if (Gatherer.open_collection_file_path != null) { 248 150 Gatherer.c_man.loadCollection(Gatherer.open_collection_file_path); -
trunk/gli/src/org/greenstone/gatherer/GathererProg.java
r9877 r10242 6 6 * University of Waikato, New Zealand. 7 7 * 8 * Author: John Thompson, Greenstone Digital Library, University of Waikato8 * Author: John Thompson, NZDL Project, University of Waikato 9 9 * 10 * Copyright (C) 1999New Zealand Digital Library Project10 * Copyright (C) 2005 New Zealand Digital Library Project 11 11 * 12 12 * This program is free software; you can redistribute it and/or modify … … 28 28 29 29 30 import java.awt.*;31 30 import java.io.*; 32 import java.util.*;33 31 import javax.swing.*; 34 import org.greenstone.gatherer.feedback.ActionRecorderDialog;35 import org.greenstone.gatherer.gui.GUIManager;36 32 import org.greenstone.gatherer.util.Utility; 37 33 38 34 39 /** Containing the main() method for the Gatherer, this class is the 40 * starting point for the rest of the application. Using GetOpt and 41 * GathererBase it first parses the command line arguments, preparing to 42 * update the configuration as required. Next it loads several important 43 * support classes such as the Configuration and Dictionary. Finally it 44 * creates the other important managers and sends them on their way. 45 * @author John Thompson, Greenstone Digital Library, University of Waikato 46 * @version 2.3 35 /** 36 * Containing the main() method, this class is the entry point for the 37 * stand-alone (non-Applet) GLI. The main point of this class is to set 38 * some stand-alone specific properties and then create an instance of the 39 * Gatherer class. 40 * @author John Thompson, NZDL Project, University of Waikato 47 41 */ 48 42 public class GathererProg 49 43 { 50 /** The entry point into the Gatherer. Parses arguments.44 /** The entry point into the stand-alone GLI. 51 45 * @param args A collection of arguments that may include: initial screen size, dictionary, path to the GSDL etc. 52 * @see java.io.File53 * @see java.io.FileInputStream54 * @see java.lang.Exception55 * @see java.util.Properties56 * @see org.greenstone.gatherer.Dictionary57 * @see org.greenstone.gatherer.Gatherer58 46 */ 59 static public void main(String[] args) { 47 static public void main(String[] args) 48 { 60 49 // A serious hack, but its good enough to stop crappy 'Could not 61 50 // lock user prefs' error messages. Thanks to Walter Schatz from 62 51 // the java forums. 63 52 System.setProperty("java.util.prefs.syncInterval","2000000"); 64 // => results in One message every 600 hours!53 // => results in one message every 600 hours! 65 54 66 55 // Ensure platform specific LAF … … 73 62 74 63 // Ensure the GLI user directory exists 75 File gli_user_directory = Utility.setGLIUserFolder(null); // # defaults to user's home area76 if (!gli_user_directory.exists() ) {77 gli_user_directory.mkdirs();64 File gli_user_directory = Utility.setGLIUserFolder(null); // Defaults to user's home area 65 if (!gli_user_directory.exists() && !gli_user_directory.mkdirs()) { 66 System.err.println("Error: Unable to make directory: " + gli_user_directory.toString()); 78 67 } 79 68 80 Gatherer gatherer = new Gatherer(); 69 // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI 70 Gatherer gatherer = new Gatherer(args); 81 71 82 Dimension size = new Dimension(800, 540); 72 // Display the GUI immediately 73 gatherer.openGUI(); 83 74 84 GetOpt go = new GetOpt(args); 85 86 if (go.feedback_enabled) { 87 // If feedback is enabled, set up the recorder dialog. 88 // Use the default locale for now - this will be changed by the 89 // Gatherer run method 90 Locale currLocale = Locale.getDefault(); 91 ActionRecorderDialog dlg = new ActionRecorderDialog (currLocale); 92 gatherer.feedback_enabled = true; 93 gatherer.feedback_dialog = dlg; 94 } 95 96 if (go.collect_directory_path != null) { 97 // Use non-standard collect directory (for when running one GLI in a network environment) 98 Gatherer.setCollectDirectoryPath(go.collect_directory_path); 99 } 100 101 GUIManager g_man 102 = gatherer.init(size, go.gsdl_path, go.gsdl3_path, go.local_library_path, 103 go.library_url_string, go.debug, go.perl_path, 104 go.no_load, go.filename, go.site_name, 105 go.servlet_path, go.wget_path); 106 gatherer.run(size, g_man); 107 108 // If there was an open collection last session, reopen it. 75 // If there was an open collection last session, reopen it 109 76 if (Gatherer.open_collection_file_path != null) { 110 77 Gatherer.c_man.loadCollection(Gatherer.open_collection_file_path); -
trunk/gli/src/org/greenstone/gatherer/GetOpt.java
r9339 r10242 39 39 40 40 public String collect_directory_path = null; 41 public String extra = null;42 41 public String filename = null; 43 42 public String gsdl_path = null;
Note:
See TracChangeset
for help on using the changeset viewer.