1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Greenstone Administrator Interface, 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: Chi-Yu Huang, 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 |
|
---|
28 | package org.greenstone.admin;
|
---|
29 |
|
---|
30 | import java.awt.*;
|
---|
31 | import java.awt.event.*;
|
---|
32 | import java.io.*;
|
---|
33 | import java.lang.*;
|
---|
34 | import java.net.*;
|
---|
35 | import java.util.*;
|
---|
36 | import javax.swing.*;
|
---|
37 | import javax.swing.plaf.*;
|
---|
38 | import javax.swing.text.*;
|
---|
39 |
|
---|
40 | import org.greenstone.gsdl3.util.Dictionary;
|
---|
41 | import org.greenstone.admin.gui.SetServerPane;
|
---|
42 | import org.greenstone.gsdl3.util.GSPath;
|
---|
43 |
|
---|
44 | /** Containing the top-level "core" for the GAI(Greenstone Administrator
|
---|
45 | * Interface) this class is the common core for the GAI application and
|
---|
46 | * applet. It first parses the command line arguments, preparing to update
|
---|
47 | * the configuration as required. Next it loads several important support
|
---|
48 | * classes such as the Configuration and Dictionary. Finally it creates the
|
---|
49 | * other important managers and sends them on their way.
|
---|
50 | * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
|
---|
51 | * @version ###
|
---|
52 | */
|
---|
53 | public class GAI
|
---|
54 | {
|
---|
55 | public static Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
56 | public static String gsdl3_src_home;
|
---|
57 | public static String gsdl3_web_home;
|
---|
58 | public static String tomcat_home;
|
---|
59 |
|
---|
60 | public static File build_properties_file;
|
---|
61 |
|
---|
62 | public static String images_path;
|
---|
63 | /** A public reference to the GAIManager. */
|
---|
64 | static public GAIManager ga_man;
|
---|
65 |
|
---|
66 | /** a public reference to the Dictionary */
|
---|
67 | static public Dictionary dictionary = null;
|
---|
68 |
|
---|
69 | public GAI(String gsdl3_src_home, String gsdl3_web_home)
|
---|
70 | {
|
---|
71 | this.gsdl3_src_home = gsdl3_src_home;
|
---|
72 | this.gsdl3_web_home = gsdl3_web_home;
|
---|
73 |
|
---|
74 | // set up the Configuration
|
---|
75 | new Configuration();
|
---|
76 |
|
---|
77 | // Read Dictionary
|
---|
78 | this.dictionary = new Dictionary("gai", Configuration.getLocale("general.locale"));
|
---|
79 | this.build_properties_file = new File(this.gsdl3_src_home, "build.properties");
|
---|
80 | // this may change if using preinstalled tomcat
|
---|
81 | this.tomcat_home = this.gsdl3_src_home+File.separatorChar+"packages"+File.separatorChar+"tomcat";
|
---|
82 |
|
---|
83 | // should come from classpath ??
|
---|
84 | this.images_path = this.gsdl3_src_home+File.separatorChar+"resources"+File.separatorChar+"images"+File.separatorChar;
|
---|
85 | // start the GAIManager
|
---|
86 | ga_man = new GAIManager(screen_size);
|
---|
87 | ga_man.display();
|
---|
88 |
|
---|
89 | }
|
---|
90 |
|
---|
91 | public static String getGSDL3Home(){
|
---|
92 |
|
---|
93 | String gsdl3Home = gsdl3_web_home;
|
---|
94 | String os = "linux";
|
---|
95 |
|
---|
96 | if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){
|
---|
97 | gsdl3Home = gsdl3Home.replaceAll("\\\\", "/");
|
---|
98 | os = "windows";
|
---|
99 | }
|
---|
100 |
|
---|
101 | gsdl3Home = GSPath.removeLastLink(gsdl3Home);
|
---|
102 |
|
---|
103 | if(os.equals("windows")){
|
---|
104 | gsdl3Home = gsdl3Home.replaceAll("/", "\\\\");
|
---|
105 | }
|
---|
106 | return gsdl3Home;
|
---|
107 | }
|
---|
108 |
|
---|
109 | public static String getGSDL3ExtensionHome(){
|
---|
110 | String gsdl3ExtHome = gsdl3_web_home;
|
---|
111 | String os = "linux";
|
---|
112 |
|
---|
113 | if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){
|
---|
114 | gsdl3ExtHome = gsdl3ExtHome.replaceAll("\\\\", "/");
|
---|
115 | os = "windows";
|
---|
116 | }
|
---|
117 |
|
---|
118 | gsdl3ExtHome = GSPath.removeLastLink(gsdl3ExtHome);
|
---|
119 | gsdl3ExtHome += "/ext";
|
---|
120 |
|
---|
121 | if(os.equals("windows")){
|
---|
122 | gsdl3ExtHome = gsdl3ExtHome.replaceAll("/", "\\\\");
|
---|
123 | }
|
---|
124 | return gsdl3ExtHome;
|
---|
125 | }
|
---|
126 |
|
---|
127 | public static void main (String[] args){
|
---|
128 | // A serious hack, but its good enough to stop crappy 'Could not
|
---|
129 | // lock user prefs' error messages. Thanks to Walter Schatz from
|
---|
130 | // the java forums.
|
---|
131 | System.setProperty("java.util.prefs.syncInterval","2000000");
|
---|
132 |
|
---|
133 | if (args.length != 2) {
|
---|
134 | System.err.println("Usage: java org.greenstone.admin.GAI <gsdl3 src home> <gsdl3 web home>");
|
---|
135 | System.exit(1);
|
---|
136 | }
|
---|
137 |
|
---|
138 | File gsdl3_src_dir = new File(args[0]);
|
---|
139 | File gsdl3_web_dir = new File(args[1]);
|
---|
140 | if (!gsdl3_src_dir.isDirectory() || !gsdl3_web_dir.isDirectory()) {
|
---|
141 | System.err.println("Usage: java org.greenstone.admin.GAI <gsdl3 src home> <gsdl3 web home>");
|
---|
142 | System.err.println("src or web directory does not exist!");
|
---|
143 | System.exit(1);
|
---|
144 | }
|
---|
145 |
|
---|
146 | GAI gai = new GAI(args[0], args[1]);
|
---|
147 |
|
---|
148 | }
|
---|
149 |
|
---|
150 | }
|
---|
151 |
|
---|
152 |
|
---|