1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the GAI 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 | * <BR><BR>
|
---|
9 | *
|
---|
10 | * Author: Chi-Yu Huang, Greenstone Digital Library, University of Waikato
|
---|
11 | * Date: 03.2005
|
---|
12 | *
|
---|
13 | * <BR><BR>
|
---|
14 | *
|
---|
15 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
16 | *
|
---|
17 | * <BR><BR>
|
---|
18 | *
|
---|
19 | * This program is free software; you can redistribute it and/or modify
|
---|
20 | * it under the terms of the GNU General Public License as published by
|
---|
21 | * the Free Software Foundation; either version 2 of the License, or
|
---|
22 | * (at your option) any later version.
|
---|
23 | *
|
---|
24 | * <BR><BR>
|
---|
25 | *
|
---|
26 | * This program is distributed in the hope that it will be useful,
|
---|
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
29 | * GNU General Public License for more details.
|
---|
30 | *
|
---|
31 | * <BR><BR>
|
---|
32 | *
|
---|
33 | * You should have received a copy of the GNU General Public License
|
---|
34 | * along with this program; if not, write to the Free Software
|
---|
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
36 | *########################################################################
|
---|
37 | */
|
---|
38 | /* This program is intended to confirm the initial user's setting about
|
---|
39 | * the Tomcat server and MySQL server they would like to run GSDL3 with
|
---|
40 | */
|
---|
41 | package org.greenstone.admin;
|
---|
42 |
|
---|
43 | import java.awt.*;
|
---|
44 | import java.awt.event.*;
|
---|
45 | import java.io.*;
|
---|
46 | import java.lang.Object;
|
---|
47 | import javax.swing.*;
|
---|
48 | import javax.swing.event.*;
|
---|
49 | import javax.swing.tree.*;
|
---|
50 |
|
---|
51 | import org.greenstone.util.Configuration;
|
---|
52 | import org.greenstone.core.ParsingProgress;
|
---|
53 | import org.greenstone.admin.gui.SetServerPane;
|
---|
54 | import org.greenstone.admin.GAI;
|
---|
55 |
|
---|
56 | /** The initial setting pane is to request the user to input the preferred
|
---|
57 | * Tomcat and Mysql server,they would like to run GSDL3 with
|
---|
58 | * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
|
---|
59 | * @version
|
---|
60 | */
|
---|
61 | public class GAIFirstSettingFrame
|
---|
62 | extends JFrame
|
---|
63 | implements ActionListener {
|
---|
64 |
|
---|
65 | public static Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
66 |
|
---|
67 | /* This pane is to inform the user to set up the tomcat and mysql server
|
---|
68 | * if they are the first time run GAI, if the user doen't want to set up
|
---|
69 | * the installation will be based on the gsdl3 default value*/
|
---|
70 | protected JScrollPane setting_message_pane = null;
|
---|
71 | protected JPanel first_setting_pane = null;
|
---|
72 | protected JPanel main_pane = null;
|
---|
73 | protected JTextArea first_setting_message = null;
|
---|
74 | protected JButton fset_yes_button = null;
|
---|
75 | protected JButton fset_no_button = null;
|
---|
76 | protected JPanel button_pane = null;
|
---|
77 | protected JPanel control_pane = null;
|
---|
78 |
|
---|
79 | public boolean setting_confirm = false;
|
---|
80 |
|
---|
81 | /** The various sizes for the screen layout*/
|
---|
82 | static private Dimension MIN_SIZE = new Dimension( 90, 90);
|
---|
83 | static private Dimension LIST_SIZE = new Dimension(200, 450);
|
---|
84 | static private Dimension DIALOG_SIZE = new Dimension (400,300);
|
---|
85 | static private Dimension TABLE_SIZE = new Dimension(500,200);
|
---|
86 | static final Dimension SIZE = new Dimension(400,75);
|
---|
87 |
|
---|
88 | //Constructor
|
---|
89 | public GAIFirstSettingFrame() {
|
---|
90 | super();
|
---|
91 |
|
---|
92 | this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
---|
93 | this.setSize(DIALOG_SIZE);
|
---|
94 | this.setTitle("First time setting Tomcat/MYSQL Server");
|
---|
95 |
|
---|
96 | // create all the control button panes
|
---|
97 | button_pane = new JPanel();
|
---|
98 |
|
---|
99 | //First time running button
|
---|
100 | FirstSetYesButtonListener fsybl = new FirstSetYesButtonListener();
|
---|
101 | FirstSetNoButtonListener fsnbl = new FirstSetNoButtonListener();
|
---|
102 |
|
---|
103 | // ImagesIcon for the buttons
|
---|
104 | ImageIcon setYesButtonIcon = new ImageIcon(GAI.images_path + "refresh.gif");
|
---|
105 | ImageIcon setNoButtonIcon = new ImageIcon(GAI.images_path + "exit.gif");
|
---|
106 |
|
---|
107 | fset_yes_button = new JButton("Yes", setYesButtonIcon);
|
---|
108 | fset_yes_button.addActionListener(fsybl);
|
---|
109 | fset_yes_button.setMnemonic(KeyEvent.VK_S);
|
---|
110 | fset_yes_button.setToolTipText("Click this button to Set up the Tomcat/MYSQL server");
|
---|
111 | fset_yes_button.setEnabled(false);
|
---|
112 | fset_no_button = new JButton("No", setNoButtonIcon);
|
---|
113 | fset_no_button.addActionListener(fsnbl);
|
---|
114 | fset_no_button.setEnabled(false);
|
---|
115 | fset_no_button.setMnemonic(KeyEvent.VK_N);
|
---|
116 | fset_no_button.setToolTipText("Click this button to skip the First time Tomcat/MYSQL server setting");
|
---|
117 |
|
---|
118 | //First time running setting buttons
|
---|
119 | fsybl = null;
|
---|
120 | fsnbl = null;
|
---|
121 | display();
|
---|
122 | }
|
---|
123 |
|
---|
124 | /** Any implementation of ActionListener requires this method so that when an
|
---|
125 | **action is performed the appropriate effect can occur.*/
|
---|
126 | public void actionPerformed(ActionEvent event) {
|
---|
127 | }
|
---|
128 |
|
---|
129 | /** This method is callsed to actually layout the components.*/
|
---|
130 | public void display() {
|
---|
131 | //KeyListenerImpl key_listener = new KeyListenerImpl();
|
---|
132 | //MouseListenerImpl mouse_listener = new MouseListenerImpl();
|
---|
133 | //this.addKeyListener(key_listener);
|
---|
134 |
|
---|
135 | first_setting_message = new JTextArea();
|
---|
136 | first_setting_message.setEditable(false);
|
---|
137 | first_setting_message.setLineWrap(true);
|
---|
138 |
|
---|
139 | first_setting_message.setText("If you are about the first time to run GAI, you can set up " +
|
---|
140 | "your own TOMCAT/MYSQL server. Otherwise, your GSDL3 " +
|
---|
141 | "will be installed with the TOMCAT/MYSQL setting come " +
|
---|
142 | "with the package. You may change the setting later on.");
|
---|
143 |
|
---|
144 | first_setting_message.setFont(new Font("Arial", Font.BOLD, 14));
|
---|
145 |
|
---|
146 | setting_message_pane = new JScrollPane(first_setting_message);
|
---|
147 |
|
---|
148 | // The pane to store setting_message_pane
|
---|
149 | first_setting_pane = new JPanel();
|
---|
150 | first_setting_pane.setBorder(BorderFactory.createEmptyBorder(5,5,20,5));
|
---|
151 | first_setting_pane.setLayout (new BorderLayout());
|
---|
152 | first_setting_pane.add(setting_message_pane, BorderLayout.CENTER);
|
---|
153 |
|
---|
154 | // Button Control Layout
|
---|
155 | fset_yes_button.setEnabled(true);
|
---|
156 | fset_no_button.setEnabled(true);
|
---|
157 |
|
---|
158 | button_pane.setLayout (new GridLayout(1,2));
|
---|
159 | button_pane.add(fset_yes_button);
|
---|
160 | button_pane.add(fset_no_button);
|
---|
161 |
|
---|
162 | control_pane = new JPanel();
|
---|
163 | control_pane.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
164 | control_pane.setLayout(new BorderLayout());
|
---|
165 | control_pane.add(new JLabel("Do you want to set up your own running Tomcat/Mysql Servers?"), BorderLayout.CENTER);
|
---|
166 | control_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
167 |
|
---|
168 | main_pane = (JPanel) getContentPane();
|
---|
169 | //main_pane.setBorder(BorderFactory.createLoweredBevelBorder());
|
---|
170 | main_pane.setLayout (new BorderLayout());
|
---|
171 | main_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
172 | main_pane.add(first_setting_pane,BorderLayout.CENTER);
|
---|
173 | main_pane.add(control_pane, BorderLayout.SOUTH);
|
---|
174 | main_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
|
---|
175 | main_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
|
---|
176 |
|
---|
177 | // Center and display
|
---|
178 | Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
|
---|
179 | setLocation((screen_size.width - SIZE.width) / 2,
|
---|
180 | (screen_size.height - SIZE.height) / 2);
|
---|
181 | setVisible(true);
|
---|
182 | }
|
---|
183 |
|
---|
184 | public boolean checkSettingConfirm(){
|
---|
185 | return setting_confirm;
|
---|
186 | }
|
---|
187 |
|
---|
188 | public void destroy() {
|
---|
189 | }
|
---|
190 |
|
---|
191 | /** This class serves as the listener for actions on the build button.*/
|
---|
192 | private class FirstSetYesButtonListener
|
---|
193 | implements ActionListener {
|
---|
194 | /** If you want to give up the change you have made to the build properties
|
---|
195 | * file before you save the change, This button is to reload the log file
|
---|
196 | * whenever user want to */
|
---|
197 | public void actionPerformed(ActionEvent event) {
|
---|
198 | SetServerPane set_server_pane = new SetServerPane ();
|
---|
199 | set_server_pane.display();
|
---|
200 | //disable the GAIFirstSettingFrame
|
---|
201 | setVisible (false);
|
---|
202 | setting_confirm = true;
|
---|
203 | }
|
---|
204 | }
|
---|
205 | private class FirstSetNoButtonListener
|
---|
206 | implements ActionListener {
|
---|
207 | // Exit the Adminstration tool
|
---|
208 | public void actionPerformed(ActionEvent event) {
|
---|
209 | setting_confirm = false;
|
---|
210 | setVisible (false);
|
---|
211 | //return setting_confirm;
|
---|
212 | if (!setting_confirm) {
|
---|
213 | GAIManager gai = new GAIManager(screen_size);
|
---|
214 | }
|
---|
215 | }
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 |
|
---|