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