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