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.gui;
|
---|
28 |
|
---|
29 | import java.awt.*;
|
---|
30 | import java.awt.event.*;
|
---|
31 | import java.io.*;
|
---|
32 | import java.net.*;
|
---|
33 | import java.util.*;
|
---|
34 | import javax.swing.*;
|
---|
35 | import javax.swing.event.*;
|
---|
36 | import javax.swing.plaf.*;
|
---|
37 | import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
|
---|
38 | import org.greenstone.gatherer.Configuration;
|
---|
39 | import org.greenstone.gatherer.GAuthenticator;
|
---|
40 | import org.greenstone.gatherer.DebugStream;
|
---|
41 | import org.greenstone.gatherer.Dictionary;
|
---|
42 | import org.greenstone.gatherer.Gatherer;
|
---|
43 | import org.greenstone.gatherer.cdm.ClassifierManager;
|
---|
44 | import org.greenstone.gatherer.cdm.LanguageManager;
|
---|
45 | import org.greenstone.gatherer.cdm.PluginManager;
|
---|
46 | import org.greenstone.gatherer.collection.Collection;
|
---|
47 | import org.greenstone.gatherer.gui.tree.DragTree;
|
---|
48 | import org.greenstone.gatherer.util.ArrayTools; // just for debug
|
---|
49 | import org.greenstone.gatherer.util.CheckList;
|
---|
50 | import org.greenstone.gatherer.util.CheckListEntry;
|
---|
51 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
52 | import org.greenstone.gatherer.util.XMLTools;
|
---|
53 | import org.w3c.dom.*;
|
---|
54 |
|
---|
55 | public class Preferences
|
---|
56 | extends ModalDialog
|
---|
57 | {
|
---|
58 | static final public String CONNECTION_PREFS = "connection";
|
---|
59 | static final public String GENERAL_PREFS = "general";
|
---|
60 |
|
---|
61 | static final private Dimension LABEL_SIZE = new Dimension(280, 25);
|
---|
62 | static final private Dimension ROW_SIZE = new Dimension(640, 25);
|
---|
63 | static final private Dimension SIZE = new Dimension(640, 345);
|
---|
64 | static final private String TRUE = "true";
|
---|
65 |
|
---|
66 | private CheckList warning_preferences_check_list;
|
---|
67 | private EmailField email_field;
|
---|
68 | private JButton apply_button;
|
---|
69 | private JButton cancel_button;
|
---|
70 | private JButton chdir_button;
|
---|
71 | private JButton ok_button;
|
---|
72 | private JCheckBox show_file_size_checkbox;
|
---|
73 | private JCheckBox no_check_certificate_checkbox; // Set no_check_certificate when retrieving https URLs that have no (valid) certificate
|
---|
74 | private JCheckBox use_proxy_checkbox;
|
---|
75 | private JCheckBox view_extracted_metadata_checkbox;
|
---|
76 | private JCheckBox workflow_download;
|
---|
77 | private JCheckBox workflow_gather;
|
---|
78 | private JCheckBox workflow_enrich;
|
---|
79 | private JCheckBox workflow_design;
|
---|
80 | private JCheckBox workflow_create;
|
---|
81 | private JCheckBox workflow_format;
|
---|
82 | private JComboBox language_combobox;
|
---|
83 | private JComboBox servlet_combobox; // GS3
|
---|
84 | private JComboBox site_combobox; // GS3
|
---|
85 | private JRadioButton assistant_mode_radio_button;
|
---|
86 | private JRadioButton expert_mode_radio_button;
|
---|
87 | private JRadioButton librarian_mode_radio_button;
|
---|
88 | private JSpinner proxy_port_field;
|
---|
89 | private JTabbedPane tab_pane;
|
---|
90 | private JTextArea mode_description_textarea;
|
---|
91 | private JTextField font_field;
|
---|
92 | private JTextField gliserver_url_field;
|
---|
93 | private JTextField library_path_field;
|
---|
94 | private JTextField program_field;
|
---|
95 | private JTextField proxy_host_field;
|
---|
96 | private JTextField collect_dir_field;
|
---|
97 |
|
---|
98 | private Preferences self;
|
---|
99 |
|
---|
100 | private String current_site_selection;
|
---|
101 |
|
---|
102 | public Preferences() {
|
---|
103 | this(GENERAL_PREFS);
|
---|
104 | }
|
---|
105 |
|
---|
106 | public Preferences(String initial_view) {
|
---|
107 | // Initialize
|
---|
108 | super(Gatherer.g_man, true);
|
---|
109 | this.self = this;
|
---|
110 | setSize(SIZE);
|
---|
111 | setTitle(Dictionary.get("Preferences"));
|
---|
112 | setJMenuBar(new SimpleMenuBar("preferences"));
|
---|
113 |
|
---|
114 | // Creation
|
---|
115 | JPanel content_pane = (JPanel) getContentPane();
|
---|
116 | content_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
117 | tab_pane = new JTabbedPane();
|
---|
118 | tab_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
119 | JPanel general_preferences = createGeneralPreferences();
|
---|
120 | general_preferences.setComponentOrientation(Dictionary.getOrientation());
|
---|
121 | tab_pane.addTab(Dictionary.get("Preferences.General"), null, general_preferences, Dictionary.get("Preferences.General_Tooltip"));
|
---|
122 | tab_pane.addTab(Dictionary.get("Preferences.Mode"), null, createModePreferences(), Dictionary.get("Preferences.Mode_Tooltip"));
|
---|
123 | // tab_pane.addTab(Dictionary.get("Preferences.Workflow"), null, createWorkflowPreferences(), Dictionary.get("Preferences.Workflow_Tooltip"));
|
---|
124 | JPanel connection_preferences = createConnectionPreferences();
|
---|
125 | connection_preferences.setComponentOrientation(Dictionary.getOrientation());
|
---|
126 | tab_pane.addTab(Dictionary.get("Preferences.Connection"), null, connection_preferences, Dictionary.get("Preferences.Connection_Tooltip"));
|
---|
127 | tab_pane.addTab(Dictionary.get("Preferences.Warnings"), null, createWarningPreferences(), Dictionary.get("Preferences.Warnings_Tooltip"));
|
---|
128 |
|
---|
129 | JPanel button_pane = new JPanel();
|
---|
130 | button_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
131 | ok_button = new GLIButton(Dictionary.get("General.OK"), Dictionary.get("General.OK_Tooltip"));
|
---|
132 |
|
---|
133 | apply_button = new GLIButton(Dictionary.get("General.Apply"), Dictionary.get("General.Apply_Tooltip"));
|
---|
134 |
|
---|
135 | cancel_button = new GLIButton(Dictionary.get("General.Cancel"), Dictionary.get("General.Cancel_Tooltip"));
|
---|
136 |
|
---|
137 | // Connection
|
---|
138 | ok_button.addActionListener(new OKButtonListener(true));
|
---|
139 | apply_button.addActionListener(new OKButtonListener(false));
|
---|
140 | cancel_button.addActionListener(new CancelButtonListener());
|
---|
141 |
|
---|
142 | // Layout
|
---|
143 | button_pane.setBorder(BorderFactory.createEmptyBorder(5,2,2,2));
|
---|
144 | button_pane.setLayout(new GridLayout(1,3,0,5));
|
---|
145 | button_pane.add(ok_button);
|
---|
146 | button_pane.add(apply_button);
|
---|
147 | button_pane.add(cancel_button);
|
---|
148 | button_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
149 |
|
---|
150 | content_pane.setLayout(new BorderLayout());
|
---|
151 | content_pane.add(tab_pane, BorderLayout.CENTER);
|
---|
152 | content_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
153 | content_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
154 |
|
---|
155 | Dimension frame_size = Gatherer.g_man.getSize();
|
---|
156 | Point frame_location = Gatherer.g_man.getLocation();
|
---|
157 | setLocation(((frame_size.width - SIZE.width) / 2), ((frame_size.height - SIZE.height)));
|
---|
158 |
|
---|
159 | // Bring the desired pane to the fore
|
---|
160 | if (initial_view.equals(CONNECTION_PREFS)) {
|
---|
161 | tab_pane.setSelectedComponent(connection_preferences);
|
---|
162 | }
|
---|
163 | else {
|
---|
164 | tab_pane.setSelectedComponent(general_preferences);
|
---|
165 | }
|
---|
166 |
|
---|
167 | // Clean up
|
---|
168 | general_preferences = null;
|
---|
169 | connection_preferences = null;
|
---|
170 | frame_location = null;
|
---|
171 | frame_size = null;
|
---|
172 | cancel_button = null;
|
---|
173 | ok_button = null;
|
---|
174 | button_pane = null;
|
---|
175 | tab_pane = null;
|
---|
176 | content_pane = null;
|
---|
177 |
|
---|
178 | setVisible(true);
|
---|
179 | }
|
---|
180 |
|
---|
181 | private JPanel createConnectionPreferences() {
|
---|
182 | JPanel program_pane = new JPanel();
|
---|
183 | program_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
184 | program_pane.setPreferredSize(ROW_SIZE);
|
---|
185 | JLabel program_label = new JLabel(Dictionary.get("Preferences.Connection.ProgramCommand"));
|
---|
186 | program_label.setPreferredSize(LABEL_SIZE);
|
---|
187 | program_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
188 |
|
---|
189 | program_field = new JTextField(Configuration.getPreviewCommand());
|
---|
190 | program_field.setCaretPosition(0);
|
---|
191 | program_field.setToolTipText(Dictionary.get("Preferences.Connection.ProgramCommand_Tooltip"));
|
---|
192 | program_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
193 |
|
---|
194 | JPanel library_path_pane = new JPanel();
|
---|
195 | library_path_pane.setPreferredSize(ROW_SIZE);
|
---|
196 | library_path_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
197 | JLabel library_path_label = new JLabel();
|
---|
198 | library_path_label.setPreferredSize(LABEL_SIZE);
|
---|
199 | library_path_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
200 | String library_url_string = "";
|
---|
201 | if (Configuration.library_url != null) {
|
---|
202 | library_url_string = Configuration.library_url.toString();
|
---|
203 | }
|
---|
204 | library_path_field = new JTextField(library_url_string);
|
---|
205 | library_path_field.setCaretPosition(0);
|
---|
206 | library_path_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
207 | if (Gatherer.GS3) {
|
---|
208 | library_path_label.setText(Dictionary.get("Preferences.Connection.Library_Path_GS3"));
|
---|
209 | library_path_field.setToolTipText(Dictionary.get("Preferences.Connection.Library_Path_Tooltip_GS3"));
|
---|
210 | } else {
|
---|
211 | library_path_label.setText(Dictionary.get("Preferences.Connection.Library_Path"));
|
---|
212 | library_path_field.setToolTipText(Dictionary.get("Preferences.Connection.Library_Path_Tooltip"));
|
---|
213 | }
|
---|
214 |
|
---|
215 | // Disable this field when using the applet, as it is automatically determined
|
---|
216 | library_path_label.setEnabled(!Gatherer.isApplet);
|
---|
217 | library_path_field.setEnabled(!Gatherer.isApplet);
|
---|
218 |
|
---|
219 | JPanel gliserver_url_pane = null;
|
---|
220 | JLabel gliserver_url_label = null;
|
---|
221 | if (Gatherer.isGsdlRemote && !Gatherer.GS3) {
|
---|
222 | gliserver_url_pane = new JPanel();
|
---|
223 | gliserver_url_pane.setPreferredSize(ROW_SIZE);
|
---|
224 | gliserver_url_label = new JLabel(Dictionary.get("Preferences.Connection.GLIServer_URL"));
|
---|
225 | gliserver_url_label.setPreferredSize(LABEL_SIZE);
|
---|
226 | gliserver_url_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
227 | String gliserver_url_string = "";
|
---|
228 | if (Configuration.gliserver_url != null) {
|
---|
229 | gliserver_url_string = Configuration.gliserver_url.toString();
|
---|
230 | }
|
---|
231 | gliserver_url_field = new JTextField(gliserver_url_string);
|
---|
232 | gliserver_url_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
233 | gliserver_url_field.setCaretPosition(0);
|
---|
234 | gliserver_url_field.setToolTipText(Dictionary.get("Preferences.Connection.GLIServer_URL_Tooltip"));
|
---|
235 |
|
---|
236 | // Disable this field when using the applet, as it is automatically determined
|
---|
237 | gliserver_url_label.setEnabled(!Gatherer.isApplet);
|
---|
238 | gliserver_url_field.setEnabled(!Gatherer.isApplet);
|
---|
239 | }
|
---|
240 |
|
---|
241 | JPanel site_pane = null;
|
---|
242 | JLabel site_label = null;
|
---|
243 | JPanel servlet_pane = null;
|
---|
244 | JLabel servlet_label = null;
|
---|
245 | if (Gatherer.GS3) {
|
---|
246 | site_pane = new JPanel();
|
---|
247 | site_pane.setPreferredSize(ROW_SIZE);
|
---|
248 | site_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
249 | site_label = new JLabel(Dictionary.get("Preferences.Connection.Site"));
|
---|
250 | site_label.setPreferredSize(LABEL_SIZE);
|
---|
251 | site_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
252 | // what should we do if Gatherer.servlet_config.getSites() is null?
|
---|
253 | site_combobox = new JComboBox(Gatherer.servlet_config.getSites().toArray());
|
---|
254 | site_combobox.setOpaque(false);
|
---|
255 | site_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Site_Tooltip"));
|
---|
256 | site_combobox.setComponentOrientation(Dictionary.getOrientation());
|
---|
257 |
|
---|
258 | servlet_pane = new JPanel();
|
---|
259 | servlet_pane.setPreferredSize(ROW_SIZE);
|
---|
260 | servlet_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
261 |
|
---|
262 | servlet_label = new JLabel(Dictionary.get("Preferences.Connection.Servlet"));
|
---|
263 | servlet_label.setPreferredSize(LABEL_SIZE);
|
---|
264 | servlet_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
265 | servlet_combobox = new JComboBox();
|
---|
266 | servlet_combobox.setOpaque(false);
|
---|
267 | servlet_combobox.setComponentOrientation(Dictionary.getOrientation());
|
---|
268 | // try to locate and select the current site
|
---|
269 | String this_site = Configuration.site_name;
|
---|
270 | for(int b = 0; b < site_combobox.getItemCount(); b++) {
|
---|
271 | String entry = (String) site_combobox.getItemAt(b);
|
---|
272 | if(this_site.equals(entry)) {
|
---|
273 | site_combobox.setSelectedIndex(b);
|
---|
274 | break;
|
---|
275 | }
|
---|
276 | }
|
---|
277 |
|
---|
278 | // just in case its not the current one?
|
---|
279 | current_site_selection = (String)site_combobox.getSelectedItem();
|
---|
280 |
|
---|
281 | ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection);
|
---|
282 | if (servlet_options == null) {
|
---|
283 | servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip2"));
|
---|
284 | //servlet_combobox.setModel(new DefaultComboBoxModel());
|
---|
285 | servlet_combobox.setEnabled(false);
|
---|
286 | } else {
|
---|
287 | ///ystem.err.println(ArrayTools.objectArrayToString(servlet_options.toArray()));
|
---|
288 |
|
---|
289 | servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray()));
|
---|
290 | servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip"));
|
---|
291 | servlet_combobox.setEnabled(true);
|
---|
292 | // try to locate and select the current servlet
|
---|
293 | String this_servlet = Configuration.getServletPath();
|
---|
294 | for(int b = 0; b < servlet_combobox.getItemCount(); b++) {
|
---|
295 | String entry = (String) servlet_combobox.getItemAt(b);
|
---|
296 | if(this_servlet.equals(entry)) {
|
---|
297 | servlet_combobox.setSelectedIndex(b);
|
---|
298 | break;
|
---|
299 | }
|
---|
300 | }
|
---|
301 |
|
---|
302 | }
|
---|
303 | }
|
---|
304 |
|
---|
305 | JPanel collect_dir_pane = new JPanel();
|
---|
306 | collect_dir_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
307 | collect_dir_pane.setPreferredSize(ROW_SIZE);
|
---|
308 | JLabel collect_dir_label = new JLabel(Dictionary.get("Preferences.Connection.CollectDirectory"));
|
---|
309 | collect_dir_label.setPreferredSize(LABEL_SIZE);
|
---|
310 | collect_dir_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
311 | collect_dir_field = new JTextField(Gatherer.getCollectDirectoryPath());
|
---|
312 | //collect_dir_field = new JTextField(Configuration.getString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true));
|
---|
313 | collect_dir_field.setCaretPosition(0);
|
---|
314 | collect_dir_field.setToolTipText(Dictionary.get("Preferences.Connection.CollectDirectory_Tooltip"));
|
---|
315 | collect_dir_field.setEditable(false);
|
---|
316 | JButton chdir_button = new GLIButton(Dictionary.get("General.CD"), Dictionary.get("General.CD_Tooltip"));
|
---|
317 | chdir_button.addActionListener(new ChangeDirListener());
|
---|
318 | if(Gatherer.isGsdlRemote) { // disable changing directories for client GLI
|
---|
319 | chdir_button.setEnabled(false);
|
---|
320 | }
|
---|
321 |
|
---|
322 | boolean no_check_cert_enabled = Configuration.get("general.no_check_certificate", true); // pass true to look in general rather than collection specific config file
|
---|
323 |
|
---|
324 | boolean currently_enabled = Configuration.get("general.use_proxy", true);
|
---|
325 | // Creation
|
---|
326 | JPanel connection_pane = new JPanel();
|
---|
327 | connection_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
328 | no_check_certificate_checkbox = new JCheckBox(Dictionary.get("Preferences.Connection.No_Check_Certificate"));
|
---|
329 | no_check_certificate_checkbox.setToolTipText(Dictionary.get("Preferences.Connection.No_Check_Certificate_Tooltip"));
|
---|
330 | no_check_certificate_checkbox.setSelected(no_check_cert_enabled);
|
---|
331 | no_check_certificate_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
332 | no_check_certificate_checkbox.setPreferredSize(ROW_SIZE);
|
---|
333 |
|
---|
334 | use_proxy_checkbox = new JCheckBox(Dictionary.get("Preferences.Connection.Use_Proxy"));
|
---|
335 | use_proxy_checkbox.setSelected(currently_enabled);
|
---|
336 | use_proxy_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
337 | use_proxy_checkbox.setPreferredSize(ROW_SIZE);
|
---|
338 |
|
---|
339 | JPanel proxy_host_pane = new JPanel();
|
---|
340 | proxy_host_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
341 | proxy_host_pane.setPreferredSize(ROW_SIZE);
|
---|
342 |
|
---|
343 | JLabel proxy_host_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Host"));
|
---|
344 | proxy_host_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
345 | proxy_host_label.setPreferredSize(LABEL_SIZE);
|
---|
346 |
|
---|
347 | proxy_host_field = new JTextField(Configuration.getString("general.proxy_host", true));
|
---|
348 | proxy_host_field.setEnabled(currently_enabled);
|
---|
349 | proxy_host_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Host_Tooltip"));
|
---|
350 | proxy_host_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
351 |
|
---|
352 | JPanel proxy_port_pane = new JPanel();
|
---|
353 | proxy_port_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
354 | proxy_port_pane.setPreferredSize(ROW_SIZE);
|
---|
355 |
|
---|
356 | JLabel proxy_port_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Port"));
|
---|
357 | proxy_port_label.setPreferredSize(LABEL_SIZE);
|
---|
358 | proxy_port_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
359 |
|
---|
360 | String port_value = Configuration.getString("general.proxy_port", true);
|
---|
361 | if(port_value.length() > 0) {
|
---|
362 | proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1));
|
---|
363 | }
|
---|
364 | else {
|
---|
365 | proxy_port_field = new JSpinner(new SpinnerNumberModel(0, 0, 65535, 1));
|
---|
366 | }
|
---|
367 | proxy_port_field.setEnabled(currently_enabled);
|
---|
368 | proxy_port_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Port_Tooltip"));
|
---|
369 |
|
---|
370 | // Connection
|
---|
371 | no_check_certificate_checkbox.addActionListener(new NoCheckCertificateListener());
|
---|
372 | use_proxy_checkbox.addActionListener(new UseProxyListener());
|
---|
373 | if (Gatherer.GS3) {
|
---|
374 | site_combobox.addActionListener(new SiteComboboxListener());
|
---|
375 | }
|
---|
376 |
|
---|
377 | // Layout
|
---|
378 | program_pane.setLayout(new BorderLayout());
|
---|
379 | program_pane.add(program_label, BorderLayout.LINE_START);
|
---|
380 | program_pane.add(program_field, BorderLayout.CENTER);
|
---|
381 |
|
---|
382 | library_path_pane.setLayout(new BorderLayout());
|
---|
383 | library_path_pane.add(library_path_label, BorderLayout.LINE_START);
|
---|
384 | library_path_pane.add(library_path_field, BorderLayout.CENTER);
|
---|
385 |
|
---|
386 | if (Gatherer.isGsdlRemote && !Gatherer.GS3) {
|
---|
387 | gliserver_url_pane.setLayout(new BorderLayout());
|
---|
388 | gliserver_url_pane.add(gliserver_url_label, BorderLayout.LINE_START);
|
---|
389 | gliserver_url_pane.add(gliserver_url_field, BorderLayout.CENTER);
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (Gatherer.GS3) {
|
---|
393 | site_pane.setLayout(new BorderLayout());
|
---|
394 | site_pane.add(site_label, BorderLayout.LINE_START);
|
---|
395 | site_pane.add(site_combobox, BorderLayout.CENTER);
|
---|
396 |
|
---|
397 | servlet_pane.setLayout(new BorderLayout());
|
---|
398 | servlet_pane.add(servlet_label, BorderLayout.LINE_START);
|
---|
399 | servlet_pane.add(servlet_combobox, BorderLayout.CENTER);
|
---|
400 | }
|
---|
401 |
|
---|
402 | collect_dir_pane.setLayout(new BorderLayout());
|
---|
403 | collect_dir_pane.add(collect_dir_label, BorderLayout.LINE_START);
|
---|
404 | collect_dir_pane.add(collect_dir_field, BorderLayout.CENTER);
|
---|
405 | collect_dir_pane.add(chdir_button, BorderLayout.LINE_END);
|
---|
406 |
|
---|
407 | proxy_host_pane.setLayout(new BorderLayout());
|
---|
408 | proxy_host_pane.add(proxy_host_label, BorderLayout.LINE_START);
|
---|
409 | proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER);
|
---|
410 |
|
---|
411 | proxy_port_pane.setLayout(new BorderLayout());
|
---|
412 | proxy_port_pane.add(proxy_port_label, BorderLayout.LINE_START);
|
---|
413 | proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER);
|
---|
414 |
|
---|
415 | connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
416 | connection_pane.setLayout(new GridLayout(9,1,0,2));
|
---|
417 | connection_pane.add(program_pane);
|
---|
418 | connection_pane.add(library_path_pane);
|
---|
419 | if (Gatherer.isGsdlRemote && !Gatherer.GS3) {
|
---|
420 | connection_pane.add(gliserver_url_pane);
|
---|
421 | }
|
---|
422 | if (Gatherer.GS3) {
|
---|
423 | connection_pane.add(site_pane);
|
---|
424 | connection_pane.add(servlet_pane);
|
---|
425 | }
|
---|
426 | connection_pane.add(collect_dir_pane);
|
---|
427 |
|
---|
428 | connection_pane.add(no_check_certificate_checkbox);
|
---|
429 | connection_pane.add(use_proxy_checkbox);
|
---|
430 | connection_pane.add(proxy_host_pane);
|
---|
431 | connection_pane.add(proxy_port_pane);
|
---|
432 |
|
---|
433 | return connection_pane;
|
---|
434 | }
|
---|
435 |
|
---|
436 | private JPanel createGeneralPreferences() {
|
---|
437 | JPanel general_pane = new JPanel();
|
---|
438 | general_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
439 | // Build the model of available languages
|
---|
440 | ArrayList dictionary_model = new ArrayList();
|
---|
441 |
|
---|
442 | // The new method makes use of the successor to the languages.dat file, classes/xml/languages.xml
|
---|
443 | NodeList language_elements = LanguageManager.LANGUAGES_DOCUMENT.getDocumentElement().getElementsByTagName(StaticStrings.LANGUAGE_ELEMENT);
|
---|
444 | for(int i = 0; i < language_elements.getLength(); i++) {
|
---|
445 | Element language_element = (Element) language_elements.item(i);
|
---|
446 | if((language_element.hasAttribute(StaticStrings.GLI_ATTRIBUTE)
|
---|
447 | && (language_element.getAttribute(StaticStrings.GLI_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR))
|
---|
448 | || (language_element.hasAttribute(StaticStrings.MDS_ATTRIBUTE)
|
---|
449 | && (language_element.getAttribute(StaticStrings.MDS_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR)))
|
---|
450 | {
|
---|
451 | Locale locale = new Locale(language_element.getAttribute(StaticStrings.CODE_ATTRIBUTE));
|
---|
452 | String description = language_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
|
---|
453 | DictionaryEntry entry = new DictionaryEntry(description, locale);
|
---|
454 | if(!dictionary_model.contains(entry)) {
|
---|
455 | dictionary_model.add(entry);
|
---|
456 | }
|
---|
457 | entry = null;
|
---|
458 | description = null;
|
---|
459 | locale = null;
|
---|
460 | }
|
---|
461 | language_element = null;
|
---|
462 | }
|
---|
463 | language_elements = null;
|
---|
464 |
|
---|
465 | // Users email
|
---|
466 | JPanel email_pane = new JPanel();
|
---|
467 | email_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
468 |
|
---|
469 | JLabel email_label = new JLabel(Dictionary.get("Preferences.General.Email"));
|
---|
470 | email_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
471 | email_label.setPreferredSize(LABEL_SIZE);
|
---|
472 |
|
---|
473 | email_field = new EmailField(Configuration.getColor("coloring.error_background", false));
|
---|
474 | email_field.setText(Configuration.getEmail());
|
---|
475 | email_field.setToolTipText(Dictionary.get("Preferences.General.Email_Tooltip"));
|
---|
476 | email_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
477 | // Font selection
|
---|
478 | JPanel font_pane = new JPanel();
|
---|
479 | font_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
480 |
|
---|
481 | JLabel font_label = new JLabel(Dictionary.get("Preferences.General.Font"));
|
---|
482 | font_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
483 | font_label.setPreferredSize(LABEL_SIZE);
|
---|
484 |
|
---|
485 | font_field = new JTextField(Configuration.getString("general.font", true));
|
---|
486 | font_field.setToolTipText(Dictionary.get("Preferences.General.Font_Tooltip"));
|
---|
487 | font_field.setComponentOrientation(Dictionary.getOrientation());
|
---|
488 |
|
---|
489 | // Extracted metadata
|
---|
490 | view_extracted_metadata_checkbox = new JCheckBox(Dictionary.get("Preferences.General.View_Extracted_Metadata"));
|
---|
491 | view_extracted_metadata_checkbox.setSelected(false);
|
---|
492 | view_extracted_metadata_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
493 |
|
---|
494 | if (Configuration.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC)) {
|
---|
495 | view_extracted_metadata_checkbox.setSelected(true);
|
---|
496 | }
|
---|
497 | view_extracted_metadata_checkbox.setToolTipText(Dictionary.get("Preferences.General.View_Extracted_Metadata_Tooltip"));
|
---|
498 | view_extracted_metadata_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
499 |
|
---|
500 | // Show file sizes
|
---|
501 | show_file_size_checkbox = new JCheckBox(Dictionary.get("Preferences.General.Show_File_Size"));
|
---|
502 | show_file_size_checkbox.setSelected(false);
|
---|
503 | show_file_size_checkbox.setComponentOrientation(Dictionary.getOrientation());
|
---|
504 |
|
---|
505 | if (Configuration.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC)) {
|
---|
506 | show_file_size_checkbox.setSelected(true);
|
---|
507 | }
|
---|
508 | show_file_size_checkbox.setToolTipText(Dictionary.get("Preferences.General.Show_File_Size_Tooltip"));
|
---|
509 |
|
---|
510 | // Language
|
---|
511 | JPanel language_pane = new JPanel();
|
---|
512 | language_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
513 |
|
---|
514 | JLabel language_label = new JLabel(Dictionary.get("Preferences.General.Interface_Language"));
|
---|
515 | language_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
516 | language_label.setPreferredSize(LABEL_SIZE);
|
---|
517 |
|
---|
518 | language_combobox = new JComboBox(dictionary_model.toArray());
|
---|
519 | language_combobox.setOpaque(false);
|
---|
520 | language_combobox.setToolTipText(Dictionary.get("Preferences.General.Interface_Language_Tooltip"));
|
---|
521 | language_combobox.setComponentOrientation(Dictionary.getOrientation());
|
---|
522 |
|
---|
523 | // Try to locate and select the current language
|
---|
524 | // Else default to English
|
---|
525 | String language_code = Configuration.getLanguage();
|
---|
526 | int defaultIndex = 0;
|
---|
527 | DictionaryEntry defaultEntry = null;
|
---|
528 |
|
---|
529 | int b = 0;
|
---|
530 | for (; b < language_combobox.getItemCount(); b++) {
|
---|
531 | DictionaryEntry entry = (DictionaryEntry) language_combobox.getItemAt(b);
|
---|
532 | if (language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) {
|
---|
533 | language_combobox.setSelectedIndex(b);
|
---|
534 | break;
|
---|
535 | } else if (entry.getLocale().getLanguage().equalsIgnoreCase("en")) { // store English as fallback
|
---|
536 | defaultIndex = b;
|
---|
537 | defaultEntry = entry;
|
---|
538 | }
|
---|
539 | }
|
---|
540 | // if we cycled through and couldn't find the chosen language to load,
|
---|
541 | // then we set the Preferences' and Configuration's language to English
|
---|
542 | if (b == language_combobox.getItemCount()) {
|
---|
543 | language_combobox.setSelectedIndex(defaultIndex);
|
---|
544 | Configuration.setLocale("general.locale", true, defaultEntry.getLocale());
|
---|
545 | System.err.println("*** GLI doesn't yet support the language: " + language_code
|
---|
546 | + " and has therefore defaulted to: " + Configuration.getLanguage());
|
---|
547 | }
|
---|
548 |
|
---|
549 | // Layout
|
---|
550 | email_pane.setLayout(new BorderLayout());
|
---|
551 | email_pane.add(email_label, BorderLayout.LINE_START);
|
---|
552 | email_pane.add(email_field, BorderLayout.CENTER);
|
---|
553 |
|
---|
554 | language_pane.setLayout(new BorderLayout());
|
---|
555 | language_pane.add(language_label, BorderLayout.LINE_START);
|
---|
556 | language_pane.add(language_combobox, BorderLayout.CENTER);
|
---|
557 |
|
---|
558 | font_pane.setLayout(new BorderLayout());
|
---|
559 | font_pane.add(font_label, BorderLayout.LINE_START);
|
---|
560 | font_pane.add(font_field, BorderLayout.CENTER);
|
---|
561 |
|
---|
562 | general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
563 | general_pane.setLayout(new GridLayout(5,1,0,5));
|
---|
564 | general_pane.add(email_pane);
|
---|
565 | general_pane.add(language_pane);
|
---|
566 | general_pane.add(font_pane);
|
---|
567 | general_pane.add(view_extracted_metadata_checkbox);
|
---|
568 | general_pane.add(show_file_size_checkbox);
|
---|
569 |
|
---|
570 | return general_pane;
|
---|
571 | }
|
---|
572 |
|
---|
573 | /** Generate the controls for altering the detail mode.
|
---|
574 | * @return a JPanel of controls
|
---|
575 | */
|
---|
576 | private JPanel createModePreferences() {
|
---|
577 | // Create Controls
|
---|
578 | JPanel mode_panel = new JPanel();
|
---|
579 | mode_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
580 |
|
---|
581 | JPanel button_panel = new JPanel();
|
---|
582 | button_panel.setComponentOrientation(Dictionary.getOrientation());
|
---|
583 |
|
---|
584 | ButtonGroup mode_button_group = new ButtonGroup();
|
---|
585 |
|
---|
586 | assistant_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Assistant"));
|
---|
587 | assistant_mode_radio_button.setOpaque(false);
|
---|
588 | assistant_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
|
---|
589 | mode_button_group.add(assistant_mode_radio_button);
|
---|
590 |
|
---|
591 | expert_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Expert"));
|
---|
592 | expert_mode_radio_button.setOpaque(false);
|
---|
593 | expert_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
|
---|
594 | mode_button_group.add(expert_mode_radio_button);
|
---|
595 |
|
---|
596 | librarian_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Librarian"));
|
---|
597 | librarian_mode_radio_button.setOpaque(false);
|
---|
598 | librarian_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
|
---|
599 | mode_button_group.add(librarian_mode_radio_button);
|
---|
600 |
|
---|
601 |
|
---|
602 | mode_description_textarea = new JTextArea();
|
---|
603 | mode_description_textarea.setComponentOrientation(Dictionary.getOrientation());
|
---|
604 | mode_description_textarea.setEditable(false);
|
---|
605 | mode_description_textarea.setLineWrap(true);
|
---|
606 | mode_description_textarea.setWrapStyleWord(true);
|
---|
607 | // Determine which value is already selected
|
---|
608 | switch(Configuration.getMode()) {
|
---|
609 | case Configuration.ASSISTANT_MODE:
|
---|
610 | assistant_mode_radio_button.setSelected(true);
|
---|
611 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
|
---|
612 | break;
|
---|
613 | case Configuration.EXPERT_MODE:
|
---|
614 | expert_mode_radio_button.setSelected(true);
|
---|
615 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
|
---|
616 | break;
|
---|
617 | default:
|
---|
618 | librarian_mode_radio_button.setSelected(true);
|
---|
619 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
|
---|
620 | }
|
---|
621 | // Connection - when a radio button is selected we have to change the description
|
---|
622 | ModeRadioButtonListener listener = new ModeRadioButtonListener();
|
---|
623 | assistant_mode_radio_button.addActionListener(listener);
|
---|
624 | expert_mode_radio_button.addActionListener(listener);
|
---|
625 | librarian_mode_radio_button.addActionListener(listener);
|
---|
626 | listener = null;
|
---|
627 | // Layout
|
---|
628 | button_panel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
|
---|
629 | button_panel.setLayout(new GridLayout(3,1,2,2));
|
---|
630 | button_panel.add(assistant_mode_radio_button);
|
---|
631 | button_panel.add(librarian_mode_radio_button);
|
---|
632 | button_panel.add(expert_mode_radio_button);
|
---|
633 |
|
---|
634 | mode_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
635 | mode_panel.setLayout(new BorderLayout());
|
---|
636 | mode_panel.add(button_panel, BorderLayout.NORTH);
|
---|
637 | mode_panel.add(new JScrollPane(mode_description_textarea), BorderLayout.CENTER);
|
---|
638 |
|
---|
639 | return mode_panel;
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 | /** The warning preferences are controlled through a checklist. */
|
---|
644 | private JPanel createWarningPreferences()
|
---|
645 | {
|
---|
646 | warning_preferences_check_list = new CheckList(false);
|
---|
647 | warning_preferences_check_list.setComponentOrientation(Dictionary.getOrientation());
|
---|
648 |
|
---|
649 | // Read all the warnings from the general xml/config.xml file, and their values from the user config.xml file
|
---|
650 | Document general_config_xml_file_document = XMLTools.parseXMLFile("xml/config.xml", true);
|
---|
651 | NodeList argument_elements_nodelist = general_config_xml_file_document.getDocumentElement().getElementsByTagName("Argument");
|
---|
652 | for (int i = 0; i < argument_elements_nodelist.getLength(); i++) {
|
---|
653 | Element argument_element = (Element) argument_elements_nodelist.item(i);
|
---|
654 | String argument_element_name = argument_element.getAttribute("name");
|
---|
655 | if (argument_element_name.startsWith("warning.")) {
|
---|
656 | String warning_title = Dictionary.get(argument_element_name.substring("warning.".length()) + ".Title");
|
---|
657 | boolean warning_enabled = Configuration.get(argument_element_name, true);
|
---|
658 | CheckListEntry warning_entry = new CheckListEntry(warning_title, warning_enabled);
|
---|
659 | warning_entry.setProperty(argument_element_name);
|
---|
660 | warning_preferences_check_list.addEntry(warning_entry);
|
---|
661 | }
|
---|
662 | }
|
---|
663 |
|
---|
664 | JPanel warning_preferences_pane = new JPanel();
|
---|
665 | warning_preferences_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
666 | warning_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
667 | warning_preferences_pane.setLayout(new BorderLayout());
|
---|
668 | JScrollPane scrol_tmp = new JScrollPane(warning_preferences_check_list);
|
---|
669 | scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
|
---|
670 | warning_preferences_pane.add(scrol_tmp, BorderLayout.CENTER);
|
---|
671 | return warning_preferences_pane;
|
---|
672 | }
|
---|
673 |
|
---|
674 |
|
---|
675 | private JPanel createWorkflowPreferences() {
|
---|
676 | // Read in the predefined configurations file
|
---|
677 | Vector predefined = new Vector();
|
---|
678 | Document predefined_document = XMLTools.parseXMLFile("xml/workflows.xml", true);
|
---|
679 | Element predefined_element = predefined_document.getDocumentElement();
|
---|
680 | NodeList workflow_elements = predefined_element.getElementsByTagName("Workflow");
|
---|
681 | for(int i = 0; i < workflow_elements.getLength(); i++) {
|
---|
682 | predefined.add(new WorkflowElementWrapper((Element)workflow_elements.item(i)));
|
---|
683 | }
|
---|
684 |
|
---|
685 | // Creation
|
---|
686 | JPanel workflow_preferences_pane = new JPanel();
|
---|
687 | workflow_preferences_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
688 |
|
---|
689 | JPanel checklist_pane = new JPanel();
|
---|
690 | checklist_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
691 |
|
---|
692 | JLabel title_label = new JLabel(Dictionary.get("Preferences.Workflow.Title"));
|
---|
693 | title_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
694 | title_label.setPreferredSize(ROW_SIZE);
|
---|
695 |
|
---|
696 | workflow_download = new JCheckBox(Dictionary.get("GUI.Download")+" - "+Dictionary.get("GUI.Download_Tooltip"));
|
---|
697 | workflow_download.setComponentOrientation(Dictionary.getOrientation());
|
---|
698 | workflow_download.setSelected(Configuration.get("workflow.download", false) && Gatherer.isDownloadEnabled);
|
---|
699 | workflow_download.setPreferredSize(ROW_SIZE);
|
---|
700 |
|
---|
701 | workflow_gather = new JCheckBox(Dictionary.get("GUI.Gather")+" - "+Dictionary.get("GUI.Gather_Tooltip"));
|
---|
702 | workflow_gather.setSelected(Configuration.get("workflow.gather", false));
|
---|
703 | workflow_gather.setPreferredSize(ROW_SIZE);
|
---|
704 | workflow_gather.setComponentOrientation(Dictionary.getOrientation());
|
---|
705 |
|
---|
706 | workflow_enrich = new JCheckBox(Dictionary.get("GUI.Enrich")+" - "+Dictionary.get("GUI.Enrich_Tooltip"));
|
---|
707 | workflow_enrich.setSelected(Configuration.get("workflow.enrich", false));
|
---|
708 | workflow_enrich.setPreferredSize(ROW_SIZE);
|
---|
709 | workflow_enrich.setComponentOrientation(Dictionary.getOrientation());
|
---|
710 |
|
---|
711 | workflow_design = new JCheckBox(Dictionary.get("GUI.Design")+" - "+Dictionary.get("GUI.Design_Tooltip"));
|
---|
712 | workflow_design.setSelected(Configuration.get("workflow.design", false));
|
---|
713 | workflow_design.setPreferredSize(ROW_SIZE);
|
---|
714 | workflow_design.setComponentOrientation(Dictionary.getOrientation());
|
---|
715 |
|
---|
716 | workflow_create = new JCheckBox(Dictionary.get("GUI.Create")+" - "+Dictionary.get("GUI.Create_Tooltip"));
|
---|
717 | workflow_create.setSelected(Configuration.get("workflow.create", false));
|
---|
718 | workflow_create.setPreferredSize(ROW_SIZE);
|
---|
719 | workflow_create.setComponentOrientation(Dictionary.getOrientation());
|
---|
720 |
|
---|
721 | workflow_format = new JCheckBox(Dictionary.get("GUI.Format")+" - "+Dictionary.get("GUI.Format_Tooltip"));
|
---|
722 | workflow_format.setSelected(Configuration.get("workflow.format", false));
|
---|
723 | workflow_format.setPreferredSize(ROW_SIZE);
|
---|
724 | workflow_format.setComponentOrientation(Dictionary.getOrientation());
|
---|
725 |
|
---|
726 | JPanel predefined_pane = new JPanel();
|
---|
727 | predefined_pane.setComponentOrientation(Dictionary.getOrientation());
|
---|
728 |
|
---|
729 | JLabel predefined_label = new JLabel(Dictionary.get("Preferences.Workflow.Predefined.Label"));
|
---|
730 | predefined_label.setComponentOrientation(Dictionary.getOrientation());
|
---|
731 |
|
---|
732 | JComboBox predefined_combobox = new JComboBox(predefined);
|
---|
733 | predefined_combobox.setOpaque(false);
|
---|
734 | // Connection
|
---|
735 | predefined_combobox.addActionListener(new PredefinedActionListener());
|
---|
736 |
|
---|
737 | // Layout
|
---|
738 | checklist_pane.setLayout(new BoxLayout(checklist_pane, BoxLayout.Y_AXIS));
|
---|
739 | checklist_pane.add(title_label);
|
---|
740 | if (Configuration.get("workflow.download", true)) {
|
---|
741 | checklist_pane.add(workflow_download);
|
---|
742 | }
|
---|
743 | if (Configuration.get("workflow.gather", true)) {
|
---|
744 | checklist_pane.add(workflow_gather);
|
---|
745 | }
|
---|
746 | if (Configuration.get("workflow.enrich", true)) {
|
---|
747 | checklist_pane.add(workflow_enrich);
|
---|
748 | }
|
---|
749 | if (Configuration.get("workflow.design", true)) {
|
---|
750 | checklist_pane.add(workflow_design);
|
---|
751 | }
|
---|
752 | if (Configuration.get("workflow.create", true)) {
|
---|
753 | checklist_pane.add(workflow_create);
|
---|
754 | }
|
---|
755 | if (Configuration.get("workflow.format", true)) {
|
---|
756 | checklist_pane.add(workflow_format);
|
---|
757 | }
|
---|
758 |
|
---|
759 | predefined_pane.setLayout(new BorderLayout(5,0));
|
---|
760 | predefined_pane.add(predefined_label, BorderLayout.LINE_START);
|
---|
761 | predefined_pane.add(predefined_combobox, BorderLayout.CENTER);
|
---|
762 |
|
---|
763 | workflow_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
764 | workflow_preferences_pane.setLayout(new BorderLayout());
|
---|
765 | workflow_preferences_pane.add(checklist_pane, BorderLayout.CENTER);
|
---|
766 | workflow_preferences_pane.add(predefined_pane, BorderLayout.SOUTH);
|
---|
767 |
|
---|
768 | return workflow_preferences_pane;
|
---|
769 | }
|
---|
770 |
|
---|
771 | private class ChangeDirListener implements ActionListener {
|
---|
772 | public void actionPerformed(ActionEvent event) {
|
---|
773 | JFileChooser chooser = new JFileChooser(collect_dir_field.getText());
|
---|
774 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
---|
775 | int returnVal = chooser.showOpenDialog(Preferences.this);
|
---|
776 | if(returnVal == JFileChooser.APPROVE_OPTION) {
|
---|
777 | collect_dir_field.setText(chooser.getSelectedFile().getAbsolutePath() + File.separator);
|
---|
778 | } // else collect_dir_field text remains as it is
|
---|
779 | }
|
---|
780 | }
|
---|
781 |
|
---|
782 | private class OKButtonListener
|
---|
783 | implements ActionListener {
|
---|
784 | private boolean close;
|
---|
785 | public OKButtonListener(boolean close) {
|
---|
786 | this.close = close;
|
---|
787 | }
|
---|
788 | public void actionPerformed(ActionEvent event)
|
---|
789 | {
|
---|
790 | // Several options requiring restarting the GLI to apply:
|
---|
791 | // interface font, interface language, changed gliserver url or library url
|
---|
792 | boolean restart_required = false;
|
---|
793 | boolean keep_collection_open = false;
|
---|
794 | String restart_message = "";
|
---|
795 |
|
---|
796 |
|
---|
797 | // Connection preferences
|
---|
798 | String program_str = program_field.getText();
|
---|
799 | if (program_str.length() > 0 && program_str.indexOf("%1") == -1) {
|
---|
800 | program_str = program_str + " %1";
|
---|
801 | }
|
---|
802 | Configuration.setPreviewCommand(program_str);
|
---|
803 |
|
---|
804 | String old_library_url = (Configuration.library_url == null) ? null : Configuration.library_url.toString();
|
---|
805 | String library_url_string = library_path_field.getText();
|
---|
806 | if(old_library_url != null && !old_library_url.equals(library_url_string)) {
|
---|
807 |
|
---|
808 | // If the server is remote and the library path's been changed, then GLI client needs restart
|
---|
809 | // If the server is local, GLI is going to work with the collection of GSDLPath anyway,
|
---|
810 | // even if the library path for previewing has changed
|
---|
811 | if (Gatherer.isGsdlRemote) {
|
---|
812 | restart_required = true;
|
---|
813 | restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required");
|
---|
814 |
|
---|
815 | }
|
---|
816 | if(Gatherer.c_man.getCollection() != null) {
|
---|
817 | // if the gliserver url has changed while a collection is open,
|
---|
818 | // close the open collection of the old library URL
|
---|
819 | Gatherer.g_man.saveThenCloseCurrentCollection();
|
---|
820 | Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, "");
|
---|
821 | }
|
---|
822 | }
|
---|
823 | if (library_url_string.equals("")) {
|
---|
824 | Configuration.library_url = null;
|
---|
825 | }
|
---|
826 | else {
|
---|
827 | try {
|
---|
828 | Configuration.library_url = new URL(library_url_string);
|
---|
829 | }
|
---|
830 | catch (MalformedURLException exception) {
|
---|
831 | DebugStream.printStackTrace(exception);
|
---|
832 | }
|
---|
833 | }
|
---|
834 |
|
---|
835 | Configuration.setString("general.library_url"+Configuration.gliPropertyNameSuffix(),
|
---|
836 | true, library_url_string);
|
---|
837 |
|
---|
838 | if (Gatherer.isGsdlRemote && !Gatherer.GS3) {
|
---|
839 | String old_gliserver_url = Configuration.gliserver_url.toString();
|
---|
840 | String gliserver_url_string = gliserver_url_field.getText();
|
---|
841 | if(!old_gliserver_url.equals(gliserver_url_string)) {
|
---|
842 | restart_required = true;
|
---|
843 | restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required");
|
---|
844 |
|
---|
845 | if(Gatherer.c_man.getCollection() != null) {
|
---|
846 | // if the gliserver url has changed while a collection is open,
|
---|
847 | // close the open collection of the old gliserver URL
|
---|
848 | Gatherer.g_man.saveThenCloseCurrentCollection();
|
---|
849 | Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, "");
|
---|
850 | }
|
---|
851 | }
|
---|
852 | if (gliserver_url_string.equals("")) {
|
---|
853 | Configuration.gliserver_url = null;
|
---|
854 | }
|
---|
855 | else {
|
---|
856 | try {
|
---|
857 | Configuration.gliserver_url = new URL(gliserver_url_string);
|
---|
858 | }
|
---|
859 | catch (MalformedURLException exception) {
|
---|
860 | DebugStream.printStackTrace(exception);
|
---|
861 | }
|
---|
862 | }
|
---|
863 | Configuration.setString("general.gliserver_url", true, gliserver_url_string);
|
---|
864 | }
|
---|
865 |
|
---|
866 |
|
---|
867 | boolean site_changed = false;
|
---|
868 | if (Gatherer.GS3) {
|
---|
869 | String current_site = Configuration.site_name;
|
---|
870 | String new_site =(String)site_combobox.getSelectedItem() ;
|
---|
871 | if (!new_site.equals(current_site)) {
|
---|
872 | site_changed = true;
|
---|
873 | }
|
---|
874 | Configuration.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem());
|
---|
875 | }
|
---|
876 |
|
---|
877 | Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected());
|
---|
878 | Configuration.setString("general.proxy_host", true, proxy_host_field.getText());
|
---|
879 | Configuration.setString("general.proxy_port", true, proxy_port_field.getValue() + "");
|
---|
880 | Gatherer.setProxy();
|
---|
881 |
|
---|
882 | // General preferences
|
---|
883 | Configuration.setEmail(email_field.getText());
|
---|
884 | Configuration.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected());
|
---|
885 | Configuration.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected());
|
---|
886 |
|
---|
887 |
|
---|
888 | // GLI interface font
|
---|
889 | String current_font = Configuration.getString("general.font", true);
|
---|
890 | if (!current_font.equals(font_field.getText())) {
|
---|
891 | Configuration.setString("general.font", true, font_field.getText());
|
---|
892 | restart_required = true;
|
---|
893 | restart_message = Dictionary.get("Preferences.General.Restart_Required");
|
---|
894 |
|
---|
895 | }
|
---|
896 |
|
---|
897 | // GLI interface language
|
---|
898 | String current_lang = Configuration.getLanguage();
|
---|
899 | if (!current_lang.equals(((DictionaryEntry) language_combobox.getSelectedItem()).getLocale().getLanguage())) {
|
---|
900 | // need to save the collection before changing the locale otherwise it stuffs the metadata names up
|
---|
901 | if(Gatherer.c_man.getCollection() != null) {
|
---|
902 | Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, Gatherer.c_man.getLoadedCollectionColFilePath());
|
---|
903 | Gatherer.g_man.saveThenCloseCurrentCollection();
|
---|
904 | keep_collection_open = true;
|
---|
905 | }
|
---|
906 |
|
---|
907 | Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry) language_combobox.getSelectedItem()).getLocale());
|
---|
908 | restart_required = true;
|
---|
909 | restart_message = Dictionary.get("Preferences.General.Restart_Required");
|
---|
910 | }
|
---|
911 |
|
---|
912 | // Inform the user that a restart is required, if necessary
|
---|
913 | if (restart_required) {
|
---|
914 | JOptionPane.showMessageDialog(Gatherer.g_man, restart_message, Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
|
---|
915 | }
|
---|
916 |
|
---|
917 | // Mode preferences
|
---|
918 | int current_mode = Configuration.getMode();
|
---|
919 | int new_mode;
|
---|
920 | if (assistant_mode_radio_button.isSelected()) {
|
---|
921 | new_mode = Configuration.ASSISTANT_MODE;
|
---|
922 | }
|
---|
923 | else if (expert_mode_radio_button.isSelected()) {
|
---|
924 | new_mode = Configuration.EXPERT_MODE;
|
---|
925 | }
|
---|
926 | else {
|
---|
927 | new_mode = Configuration.LIBRARIAN_MODE;
|
---|
928 | }
|
---|
929 |
|
---|
930 | // If there has been a change in modes, update the config, and also inform the persistant gui views that have a need to know
|
---|
931 | if (new_mode != current_mode) {
|
---|
932 | Configuration.setMode(new_mode);
|
---|
933 | Collection collection = Gatherer.c_man.getCollection();
|
---|
934 | if (collection != null) {
|
---|
935 | collection.cdm.modeChanged(new_mode);
|
---|
936 | }
|
---|
937 | Gatherer.g_man.modeChanged(new_mode);
|
---|
938 | }
|
---|
939 |
|
---|
940 | // Warning preferences
|
---|
941 | ListModel warning_preferences_check_list_model = warning_preferences_check_list.getModel();
|
---|
942 | for (int i = 0; i < warning_preferences_check_list_model.getSize(); i++) {
|
---|
943 | CheckListEntry entry = (CheckListEntry) warning_preferences_check_list_model.getElementAt(i);
|
---|
944 | Configuration.set(entry.getProperty(), true, entry.isSelected());
|
---|
945 | }
|
---|
946 |
|
---|
947 | if (Gatherer.GS3 && site_changed && Gatherer.c_man.getCollection() != null && !Gatherer.isGsdlRemote) {
|
---|
948 | // shut down the collection
|
---|
949 | System.err.println("shutting down the collection");
|
---|
950 | Gatherer.g_man.saveThenCloseCurrentCollection();
|
---|
951 | }
|
---|
952 |
|
---|
953 | // Workflow preferences
|
---|
954 | // Configuration.set("workflow.download", false, workflow_download.isSelected());
|
---|
955 | // Configuration.set("workflow.gather", false, workflow_gather.isSelected());
|
---|
956 | // Configuration.set("workflow.enrich", false, workflow_enrich.isSelected());
|
---|
957 | // Configuration.set("workflow.design", false, workflow_design.isSelected());
|
---|
958 | // Configuration.set("workflow.create", false, workflow_create.isSelected());
|
---|
959 | // Configuration.set("workflow.format", false, workflow_format.isSelected());
|
---|
960 |
|
---|
961 | // Gatherer.g_man.workflowUpdate("Download", workflow_download.isSelected());
|
---|
962 | // Gatherer.g_man.workflowUpdate("Gather", workflow_gather.isSelected());
|
---|
963 | // Gatherer.g_man.workflowUpdate("Enrich", workflow_enrich.isSelected());
|
---|
964 | // Gatherer.g_man.workflowUpdate("Design", (workflow_design.isSelected() && Configuration.getMode() > Configuration.ASSISTANT_MODE));
|
---|
965 | // Gatherer.g_man.workflowUpdate("Create", workflow_create.isSelected());
|
---|
966 | // Gatherer.g_man.workflowUpdate("Format", workflow_format.isSelected());
|
---|
967 |
|
---|
968 | // Always save configuration changes immediately (in case the GLI crashes)
|
---|
969 | Configuration.save();
|
---|
970 | if (Gatherer.isGsdlRemote && Gatherer.GS3 && site_changed ){
|
---|
971 | Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
|
---|
972 | }
|
---|
973 | // Refresh the GLI to account for the configuration changes
|
---|
974 | Gatherer.refresh(Gatherer.PREFERENCES_CHANGED);
|
---|
975 |
|
---|
976 | // If proxy is on but proxy details are incomplete, then can't continue
|
---|
977 | if (use_proxy_checkbox.isSelected() && proxy_host_field.getText().equals("")) {
|
---|
978 | JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.Connection.Proxy_Host_Missing"),
|
---|
979 | Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
|
---|
980 | } else {
|
---|
981 | // Hide dialog
|
---|
982 | if (close) {
|
---|
983 | self.dispose();
|
---|
984 | }
|
---|
985 | }
|
---|
986 |
|
---|
987 | // collect directory change
|
---|
988 | String newCollectPath = collect_dir_field.getText();
|
---|
989 | if(!newCollectPath.endsWith(File.separator)) {
|
---|
990 | newCollectPath += File.separator;
|
---|
991 | }
|
---|
992 | // wait cursor will display while changing the collect directory, need to work out what component to
|
---|
993 | // display it on: main GLI frame or Preferences window, depending on if OK or Apply was pressed
|
---|
994 | Container container = close ? Gatherer.g_man.getContentPane() : Preferences.this.getContentPane();
|
---|
995 | Gatherer.collectDirectoryHasChanged(Gatherer.getCollectDirectoryPath(),
|
---|
996 | newCollectPath, container);
|
---|
997 | // will tell the server that the collect directory has changed and that
|
---|
998 | // the workspace needs to be refreshed (Documents in Greenstone Collections)
|
---|
999 |
|
---|
1000 | if (restart_required) {
|
---|
1001 | if (keep_collection_open) {
|
---|
1002 | Gatherer.g_man.exitNoCollectionSave(Gatherer.EXIT_THEN_RESTART);
|
---|
1003 | } else {
|
---|
1004 | Gatherer.g_man.exit(Gatherer.EXIT_THEN_RESTART);
|
---|
1005 | }
|
---|
1006 | }
|
---|
1007 | }
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | private class CancelButtonListener
|
---|
1011 | implements ActionListener {
|
---|
1012 | public void actionPerformed(ActionEvent event) {
|
---|
1013 | self.dispose();
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 |
|
---|
1017 | private class DictionaryEntry
|
---|
1018 | implements Comparable {
|
---|
1019 | private Locale locale;
|
---|
1020 | private String description;
|
---|
1021 | public DictionaryEntry(Locale locale) {
|
---|
1022 | this.description = null;
|
---|
1023 | this.locale = locale;
|
---|
1024 | }
|
---|
1025 | public DictionaryEntry(String description, Locale locale) {
|
---|
1026 | this.description = description;
|
---|
1027 | this.locale = locale;
|
---|
1028 | }
|
---|
1029 | public int compareTo(Object object) {
|
---|
1030 | return toString().compareTo(object.toString());
|
---|
1031 | }
|
---|
1032 | public boolean equals(Object object) {
|
---|
1033 | return toString().equals(object.toString());
|
---|
1034 | }
|
---|
1035 | public Locale getLocale() {
|
---|
1036 | return locale;
|
---|
1037 | }
|
---|
1038 | public String toString() {
|
---|
1039 | if(description != null) {
|
---|
1040 | return description;
|
---|
1041 | }
|
---|
1042 | else {
|
---|
1043 | return locale.getDisplayName();
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | /** This listener updates the mode description depending on what mode is selected. */
|
---|
1049 | private class ModeRadioButtonListener
|
---|
1050 | implements ActionListener {
|
---|
1051 | public void actionPerformed(ActionEvent event) {
|
---|
1052 | Object source = event.getSource();
|
---|
1053 | if(source == assistant_mode_radio_button) {
|
---|
1054 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
|
---|
1055 | }
|
---|
1056 | else if(source == expert_mode_radio_button) {
|
---|
1057 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
|
---|
1058 | }
|
---|
1059 | else {
|
---|
1060 | mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
|
---|
1061 | }
|
---|
1062 | source = null;
|
---|
1063 | }
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | private class PredefinedActionListener
|
---|
1067 | implements ActionListener {
|
---|
1068 | public void actionPerformed(ActionEvent event) {
|
---|
1069 | JComboBox cb = (JComboBox) event.getSource();
|
---|
1070 | WorkflowElementWrapper element = (WorkflowElementWrapper) cb.getSelectedItem();
|
---|
1071 | CheckboxUpdater task = new CheckboxUpdater(element);
|
---|
1072 | SwingUtilities.invokeLater(task);
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | private class CheckboxUpdater
|
---|
1076 | implements Runnable {
|
---|
1077 | private WorkflowElementWrapper element;
|
---|
1078 | public CheckboxUpdater(WorkflowElementWrapper element) {
|
---|
1079 | this.element = element;
|
---|
1080 | }
|
---|
1081 | public void run() {
|
---|
1082 | workflow_download.setSelected(element.getEnabled("download"));
|
---|
1083 | workflow_gather.setSelected(element.getEnabled("gather"));
|
---|
1084 | workflow_enrich.setSelected(element.getEnabled("enrich"));
|
---|
1085 | workflow_design.setSelected(element.getEnabled("design"));
|
---|
1086 | workflow_create.setSelected(element.getEnabled("create"));
|
---|
1087 | workflow_format.setSelected(element.getEnabled("format"));
|
---|
1088 | }
|
---|
1089 | }
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 |
|
---|
1093 | private class SiteComboboxListener
|
---|
1094 | implements ActionListener {
|
---|
1095 | private boolean ignore_event=false;
|
---|
1096 | public void actionPerformed(ActionEvent event) {
|
---|
1097 | System.err.println("event occurred "+event.paramString());
|
---|
1098 | String site = (String) site_combobox.getSelectedItem();
|
---|
1099 | System.err.println("The site changed to = "+site);
|
---|
1100 | if (!site.equals(current_site_selection)) {
|
---|
1101 | current_site_selection = site;
|
---|
1102 | System.err.println("changed the current selection");
|
---|
1103 |
|
---|
1104 | ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection);
|
---|
1105 | if (servlet_options == null) {
|
---|
1106 | ///ystem.err.println("no servlets for this site");
|
---|
1107 | servlet_combobox.setModel(new DefaultComboBoxModel());
|
---|
1108 | servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip2"));
|
---|
1109 | servlet_combobox.setEnabled(false);
|
---|
1110 |
|
---|
1111 | } else {
|
---|
1112 | ///ystem.err.println(ArrayTools.objectArrayToString(servlet_options.toArray()));
|
---|
1113 | servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray()));
|
---|
1114 | servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip"));
|
---|
1115 | servlet_combobox.setEnabled(true);
|
---|
1116 | }
|
---|
1117 | if (Gatherer.isGsdlRemote){
|
---|
1118 | // Close the current collection, remove the lock on this file, ask to login to the new site, then download collection configurations of the site.
|
---|
1119 | if (Gatherer.c_man.getCollection()!=null){
|
---|
1120 | File lock_file = new File(Gatherer.c_man.getLoadedCollectionDirectoryPath() + "gli.lck");
|
---|
1121 | Gatherer.remoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file);
|
---|
1122 | Gatherer.g_man.closeCurrentCollection();
|
---|
1123 | }
|
---|
1124 | Configuration.site_name=site;
|
---|
1125 | Gatherer.remoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null();
|
---|
1126 | Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
|
---|
1127 | }
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | private class NoCheckCertificateListener implements ActionListener {
|
---|
1133 | public void actionPerformed(ActionEvent event) {
|
---|
1134 | boolean isEnabled = no_check_certificate_checkbox.isSelected();
|
---|
1135 | Configuration.set("general.no_check_certificate", true, isEnabled);
|
---|
1136 | boolean no_check_cert_enabled = Configuration.get("general.no_check_certificate", true);
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | private class UseProxyListener
|
---|
1141 | implements ActionListener {
|
---|
1142 | public void actionPerformed(ActionEvent event) {
|
---|
1143 | boolean enabled = use_proxy_checkbox.isSelected();
|
---|
1144 | Configuration.set("general.use_proxy", true, enabled);
|
---|
1145 | // Fortunately this is already driven by the event thread.
|
---|
1146 | proxy_host_field.setEnabled(enabled);
|
---|
1147 | proxy_port_field.setEnabled(enabled);
|
---|
1148 | }
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | private class WorkflowElementWrapper {
|
---|
1152 | private Element element;
|
---|
1153 | private String text;
|
---|
1154 | public WorkflowElementWrapper(Element element) {
|
---|
1155 | this.element = element;
|
---|
1156 | }
|
---|
1157 | public boolean getEnabled(String name) {
|
---|
1158 | boolean result = true;
|
---|
1159 | if(element.getAttribute(name).equalsIgnoreCase("false")) {
|
---|
1160 | result = false;
|
---|
1161 | }
|
---|
1162 | return result;
|
---|
1163 | }
|
---|
1164 | public String toString() {
|
---|
1165 | if (text == null) {
|
---|
1166 | text = Dictionary.get(element.getFirstChild().getNodeValue());
|
---|
1167 | }
|
---|
1168 | return text;
|
---|
1169 | }
|
---|
1170 | }
|
---|
1171 | }
|
---|