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