source: gli/trunk/src/org/greenstone/gatherer/gui/Preferences.java@ 20961

Last change on this file since 20961 was 20961, checked in by ak19, 14 years ago

Now when GLI starts up and finds a language in the config file which GLI does not yet support, and when Preferences is opened and a property changed, it no longer defaults to the first available language in the list (Arabic), but defaults to English instead. The Configuration file is also updated to English, so it doesn't force a restart on the GLI user.

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