source: main/trunk/gli/src/org/greenstone/gatherer/GathererProg.java

Last change on this file was 38259, checked in by anupama, 7 months ago
  1. Removed some code that was unnecessary after all (it merely *seemed* to help things back when the actual problem was that the minus-webswing parameterwasn't being passed in to GLI because of the += in the webswing xsl's javascript code that appended to the args). 2. Removed or commented out debugging code. 3. I noticed that before adding my own actionName into the webswing xsl's javascript, emacs already reported mismatched braces. This may need further investigation. But counting them, they seem to me to match.
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
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, NZDL Project, University of Waikato
9 *
10 * Copyright (C) 2005 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 */
27package org.greenstone.gatherer;
28
29
30import java.io.*;
31import javax.swing.*;
32import org.greenstone.gatherer.util.Utility;
33
34/**
35 * Containing the main() method, this class is the entry point for the
36 * stand-alone (non-Applet) GLI. The main point of this class is to set
37 * some stand-alone specific properties and then create an instance of the
38 * Gatherer class.
39 * @author John Thompson, NZDL Project, University of Waikato
40 */
41public class GathererProg
42{
43 /** The entry point into the stand-alone GLI.
44 * @param args A collection of arguments that may include: initial screen size, dictionary, path to the GSDL etc.
45 */
46 static public void main(final String[] args)
47 {
48 // A serious hack, but its good enough to stop crappy 'Could not
49 // lock user prefs' error messages. Thanks to Walter Schatz from
50 // the java forums.
51 System.setProperty("java.util.prefs.syncInterval","2000000");
52 // => results in one message every 600 hours!
53
54 // Ensure platform specific LAF
55 try {
56 // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
57 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
58 }
59 catch (Exception exception) {
60 exception.printStackTrace();
61 }
62
63
64 GetOpt go = new GetOpt(args);
65
66 // Determine the GLI user directory path
67 String gli_user_directory_path = null;
68 if (go.webswing) {
69 //org.webswing.toolkit.api.WebswingUtil.getWebswingApi().sendActionEvent("javaToWebswingJSConsoleLog", "args are: " + java.util.Arrays.toString(args), null);
70
71 if (go.gsdl3_src_path != null) {
72 // above is a (albeit a crude) test at this early stage of running,
73 // that makes sure we're running GS3
74
75 // "user.dir" resolves to the user's current-working-directory
76 // which is engineered through webswing.config to be the GLI home directory
77
78 gli_user_directory_path = System.getProperty("user.dir") + File.separator + "webswing-users" + File.separator;
79
80 File gli_user_directory = new File(gli_user_directory_path);
81
82 if (!gli_user_directory.exists() && !gli_user_directory.mkdir()) {
83 System.err.println("Warning: Unable to make directory: " + gli_user_directory_path);
84 }
85 }
86 else {
87 System.err.println("Webswing for Greenstone2 not supported");
88 System.exit(1);
89 }
90 }
91 else {
92 gli_user_directory_path = System.getProperty("user.home") + File.separator;
93
94
95 if (Utility.isWindows()) {
96 gli_user_directory_path += "Application Data" + File.separator + "Greenstone" + File.separator + "GLI" + File.separator;
97 }
98 else {
99 gli_user_directory_path += ".gli" + File.separator;
100 }
101 }
102
103 Gatherer.setGLIUserDirectoryPath(gli_user_directory_path);
104
105 // We have a local GLI
106 Gatherer.setGLIDirectoryPath(System.getProperty("user.dir") + File.separator);
107
108 // Create an instance of the Gatherer class, which will parse the args and prepare the rest of the GLI
109 final Gatherer gatherer = new Gatherer(go);
110
111 // TESTING circumventing the old GUI event dispatch thread exceptions in GLI. Follows
112 // https://docs.oracle.com/javase/6/docs/api/javax/swing/package-summary.html#threading
113 // referred from Event Dispatch Thread page at https://joel-costigliola.github.io/assertj/assertj-swing-edt.html
114
115 // Schedule a job for the event-dispatching thread:
116 // creating and showing this application's GUI.
117
118
119 // Display all Java properties,
120 // https://stackoverflow.com/questions/228477/how-do-i-programmatically-determine-operating-system-in-java
121 //System.getProperties().list(System.out);
122
123 SwingUtilities.invokeLater(new Runnable() {
124 public void run() {
125 // This line used to be done immediately after setGLIDirectoryPath()
126 // and new Gatherer() above, but is now inside an invokeLater() to do graphical stuff here.
127
128 // Display the GUI immediately
129 gatherer.openGUI();
130 }
131 });
132
133 }
134}
Note: See TracBrowser for help on using the repository browser.