1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
9 | *
|
---|
10 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
25 | *########################################################################
|
---|
26 | */
|
---|
27 | package org.greenstone.gatherer;
|
---|
28 |
|
---|
29 | /**************************************************************************************
|
---|
30 | * Written: ??/??/02
|
---|
31 | * Revised: ??/??/02 - Commented
|
---|
32 | * ??/??/03 - Added support for local library server
|
---|
33 | * 20/07/03 - Rewrote argument parsing so that spaces no longer cause GLI to die. Also added time out when starting local library.
|
---|
34 | **************************************************************************************/
|
---|
35 |
|
---|
36 | //import com.l2fprod.gui.*;
|
---|
37 | //import com.l2fprod.gui.plaf.skin.*;
|
---|
38 | //import com.l2fprod.util.*;
|
---|
39 | import java.awt.*;
|
---|
40 | import java.awt.event.*;
|
---|
41 | import java.io.*;
|
---|
42 | import java.lang.*;
|
---|
43 | import java.net.*;
|
---|
44 | import java.util.*;
|
---|
45 | import javax.swing.*;
|
---|
46 | import javax.swing.plaf.*;
|
---|
47 | import javax.swing.text.*;
|
---|
48 | import org.greenstone.gatherer.Configuration;
|
---|
49 | import org.greenstone.gatherer.GAuthenticator;
|
---|
50 | import org.greenstone.gatherer.cdm.CommandTokenizer;
|
---|
51 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
52 | import org.greenstone.gatherer.feedback.ActionRecorderDialog;
|
---|
53 | import org.greenstone.gatherer.file.FileManager;
|
---|
54 | import org.greenstone.gatherer.file.FileAssociationManager;
|
---|
55 | import org.greenstone.gatherer.gui.Coloring;
|
---|
56 | import org.greenstone.gatherer.gui.GUIManager;
|
---|
57 | import org.greenstone.gatherer.gui.ModalDialog;
|
---|
58 | import org.greenstone.gatherer.gui.Splash;
|
---|
59 | import org.greenstone.gatherer.gui.URLField;
|
---|
60 | import org.greenstone.gatherer.gui.WarningDialog;
|
---|
61 | import org.greenstone.gatherer.msm.MDSTest;
|
---|
62 | import org.greenstone.gatherer.msm.MetadataSetManager;
|
---|
63 | import org.greenstone.gatherer.util.ArrayTools;
|
---|
64 | import org.greenstone.gatherer.util.GSDLSiteConfig;
|
---|
65 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
66 | import org.greenstone.gatherer.util.Utility;
|
---|
67 | import sun.misc.*;
|
---|
68 |
|
---|
69 | /** Containing the main() method for the Gatherer, this class is the
|
---|
70 | * starting point for the rest of the application. Using GetOpt and
|
---|
71 | * GathererBase it first parses the command line arguments, preparing to
|
---|
72 | * update the configuration as required. Next it loads several important
|
---|
73 | * support classes such as the Configuration and Dictionary. Finally it
|
---|
74 | * creates the other important managers and sends them on their way.
|
---|
75 | * @author John Thompson, Greenstone Digital Library, University of Waikato
|
---|
76 | * @version 2.3
|
---|
77 | */
|
---|
78 |
|
---|
79 | // How to catch All Exceptions including those from the AWT Event thread.
|
---|
80 | // Step 1: register a handler class in your main()
|
---|
81 | //
|
---|
82 | // System.setProperty("sun.awt.exception.handler", "YourHandler");
|
---|
83 | //
|
---|
84 | // Step 2: implement your handler class.
|
---|
85 | //
|
---|
86 | // public class YourHandler {
|
---|
87 | // public void handle(Throwable thrown) {
|
---|
88 | // eat the exception without dumping to the console.
|
---|
89 | // }
|
---|
90 | // }
|
---|
91 |
|
---|
92 | public class GathererProg
|
---|
93 | {
|
---|
94 |
|
---|
95 | /** The entry point into the Gatherer. Parses arguments.
|
---|
96 | * @param args A collection of arguments that may include: initial screen size, dictionary, path to the GSDL etc.
|
---|
97 | * @see java.io.File
|
---|
98 | * @see java.io.FileInputStream
|
---|
99 | * @see java.lang.Exception
|
---|
100 | * @see java.util.Properties
|
---|
101 | * @see org.greenstone.gatherer.Dictionary
|
---|
102 | * @see org.greenstone.gatherer.Gatherer
|
---|
103 | * @see org.greenstone.gatherer.Gatherer
|
---|
104 | * @see org.greenstone.gatherer.gui.Splash
|
---|
105 | * @see org.greenstone.gatherer.util.StaticStrings
|
---|
106 | */
|
---|
107 | static public void main(String[] args) {
|
---|
108 | // A serious hack, but its good enough to stop crappy 'Could not
|
---|
109 | // lock user prefs' error messages. Thanks to Walter Schatz from
|
---|
110 | // the java forums.
|
---|
111 | System.setProperty("java.util.prefs.syncInterval","2000000");
|
---|
112 | // => results in One message every 600 hours!
|
---|
113 |
|
---|
114 | // Override the exception handler with a new one which we can
|
---|
115 | // easily quiet the exceptions from.
|
---|
116 | // System.setProperty("sun.awt.exception.handler", "GLIExceptionHandler");
|
---|
117 |
|
---|
118 | // Ensure platform specific LAF
|
---|
119 | try {
|
---|
120 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
---|
121 | }
|
---|
122 | catch(Exception exception) {
|
---|
123 | exception.printStackTrace();
|
---|
124 | }
|
---|
125 |
|
---|
126 | Gatherer gatherer = new Gatherer();
|
---|
127 |
|
---|
128 | Dimension size = new Dimension(800, 540);
|
---|
129 |
|
---|
130 | GetOpt go = new GetOpt(args);
|
---|
131 |
|
---|
132 | if (go.feedback_enabled) {
|
---|
133 | // If feedback is enabled, set up the recorder dialog.
|
---|
134 | // Use the default locale for now - this will be changed by the
|
---|
135 | // Gatherer run method
|
---|
136 | Locale currLocale = Locale.getDefault();
|
---|
137 | ActionRecorderDialog dlg = new ActionRecorderDialog (currLocale);
|
---|
138 | gatherer.feedback_enabled = true;
|
---|
139 | gatherer.feedback_dialog = dlg;
|
---|
140 | }
|
---|
141 |
|
---|
142 | // Splash screen.
|
---|
143 | Splash splash = new Splash();
|
---|
144 | GUIManager g_man
|
---|
145 | = gatherer.init(size, go.gsdl_path, go.gsdl3_path,
|
---|
146 | go.exec_path, go.debug, go.perl_path,
|
---|
147 | go.no_load, go.filename, go.site_name,
|
---|
148 | go.servlet_path, go.mirroring_enabled,
|
---|
149 | go.wget_version_str, go.wget_path);
|
---|
150 | gatherer.run(size,splash,g_man);
|
---|
151 | }
|
---|
152 |
|
---|
153 | // static public class GLIExceptionHandler {
|
---|
154 | // public void handle(Throwable thrown) {
|
---|
155 | // if(always_show_exceptions || debug != null) {
|
---|
156 | // thrown.printStackTrace();
|
---|
157 | // }
|
---|
158 | // }
|
---|
159 | // }
|
---|
160 | }
|
---|