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

Last change on this file since 20789 was 20789, checked in by ak19, 15 years ago

If the proxy host is not set but Use Proxy Connection is turned on, we don't let the user store the preferences and close the dialog just yet. Shows up a message.

  • Property svn:keywords set to Author Date Id Revision
File size: 45.6 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.getAttribute(StaticStrings.GLI_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR) || (language_element.getAttribute(StaticStrings.MDS_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR)) {
409 Locale locale = new Locale(language_element.getAttribute(StaticStrings.CODE_ATTRIBUTE));
410 String description = language_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
411 DictionaryEntry entry = new DictionaryEntry(description, locale);
412 if(!dictionary_model.contains(entry)) {
413 dictionary_model.add(entry);
414 }
415 entry = null;
416 description = null;
417 locale = null;
418 }
419 language_element = null;
420 }
421 language_elements = null;
422
423 // Users email
424 JPanel email_pane = new JPanel();
425 email_pane.setComponentOrientation(Dictionary.getOrientation());
426
427 JLabel email_label = new JLabel(Dictionary.get("Preferences.General.Email"));
428 email_label.setComponentOrientation(Dictionary.getOrientation());
429 email_label.setPreferredSize(LABEL_SIZE);
430
431 email_field = new EmailField(Configuration.getColor("coloring.error_background", false));
432 email_field.setText(Configuration.getEmail());
433 email_field.setToolTipText(Dictionary.get("Preferences.General.Email_Tooltip"));
434 email_field.setComponentOrientation(Dictionary.getOrientation());
435 // Font selection
436 JPanel font_pane = new JPanel();
437 font_pane.setComponentOrientation(Dictionary.getOrientation());
438
439 JLabel font_label = new JLabel(Dictionary.get("Preferences.General.Font"));
440 font_label.setComponentOrientation(Dictionary.getOrientation());
441 font_label.setPreferredSize(LABEL_SIZE);
442
443 font_field = new JTextField(Configuration.getString("general.font", true));
444 font_field.setToolTipText(Dictionary.get("Preferences.General.Font_Tooltip"));
445 font_field.setComponentOrientation(Dictionary.getOrientation());
446
447 // Extracted metadata
448 view_extracted_metadata_checkbox = new JCheckBox(Dictionary.get("Preferences.General.View_Extracted_Metadata"));
449 view_extracted_metadata_checkbox.setSelected(false);
450 view_extracted_metadata_checkbox.setComponentOrientation(Dictionary.getOrientation());
451
452 if (Configuration.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC)) {
453 view_extracted_metadata_checkbox.setSelected(true);
454 }
455 view_extracted_metadata_checkbox.setToolTipText(Dictionary.get("Preferences.General.View_Extracted_Metadata_Tooltip"));
456 view_extracted_metadata_checkbox.setComponentOrientation(Dictionary.getOrientation());
457
458 // Show file sizes
459 show_file_size_checkbox = new JCheckBox(Dictionary.get("Preferences.General.Show_File_Size"));
460 show_file_size_checkbox.setSelected(false);
461 show_file_size_checkbox.setComponentOrientation(Dictionary.getOrientation());
462
463 if (Configuration.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC)) {
464 show_file_size_checkbox.setSelected(true);
465 }
466 show_file_size_checkbox.setToolTipText(Dictionary.get("Preferences.General.Show_File_Size_Tooltip"));
467
468 // Language
469 JPanel language_pane = new JPanel();
470 language_pane.setComponentOrientation(Dictionary.getOrientation());
471
472 JLabel language_label = new JLabel(Dictionary.get("Preferences.General.Interface_Language"));
473 language_label.setComponentOrientation(Dictionary.getOrientation());
474 language_label.setPreferredSize(LABEL_SIZE);
475
476 language_combobox = new JComboBox(dictionary_model.toArray());
477 language_combobox.setOpaque(false);
478 language_combobox.setToolTipText(Dictionary.get("Preferences.General.Interface_Language_Tooltip"));
479 language_combobox.setComponentOrientation(Dictionary.getOrientation());
480
481 // Try to locate and select the current language
482 String language_code = Configuration.getLanguage();
483 for (int b = 0; b < language_combobox.getItemCount(); b++) {
484 DictionaryEntry entry = (DictionaryEntry) language_combobox.getItemAt(b);
485 if (language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) {
486 language_combobox.setSelectedIndex(b);
487 break;
488 }
489 }
490
491 // Layout
492 email_pane.setLayout(new BorderLayout());
493 email_pane.add(email_label, BorderLayout.LINE_START);
494 email_pane.add(email_field, BorderLayout.CENTER);
495
496 language_pane.setLayout(new BorderLayout());
497 language_pane.add(language_label, BorderLayout.LINE_START);
498 language_pane.add(language_combobox, BorderLayout.CENTER);
499
500 font_pane.setLayout(new BorderLayout());
501 font_pane.add(font_label, BorderLayout.LINE_START);
502 font_pane.add(font_field, BorderLayout.CENTER);
503
504 general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
505 general_pane.setLayout(new GridLayout(5,1,0,5));
506 general_pane.add(email_pane);
507 general_pane.add(language_pane);
508 general_pane.add(font_pane);
509 general_pane.add(view_extracted_metadata_checkbox);
510 general_pane.add(show_file_size_checkbox);
511
512 return general_pane;
513 }
514
515 /** Generate the controls for altering the detail mode.
516 * @return a JPanel of controls
517 */
518 private JPanel createModePreferences() {
519 // Create Controls
520 JPanel mode_panel = new JPanel();
521 mode_panel.setComponentOrientation(Dictionary.getOrientation());
522
523 JPanel button_panel = new JPanel();
524 button_panel.setComponentOrientation(Dictionary.getOrientation());
525
526 ButtonGroup mode_button_group = new ButtonGroup();
527
528 assistant_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Assistant"));
529 assistant_mode_radio_button.setOpaque(false);
530 assistant_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
531 mode_button_group.add(assistant_mode_radio_button);
532
533 expert_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Expert"));
534 expert_mode_radio_button.setOpaque(false);
535 expert_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
536 mode_button_group.add(expert_mode_radio_button);
537
538 librarian_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Librarian"));
539 librarian_mode_radio_button.setOpaque(false);
540 librarian_mode_radio_button.setComponentOrientation(Dictionary.getOrientation());
541 mode_button_group.add(librarian_mode_radio_button);
542
543
544 mode_description_textarea = new JTextArea();
545 mode_description_textarea.setComponentOrientation(Dictionary.getOrientation());
546 mode_description_textarea.setEditable(false);
547 mode_description_textarea.setLineWrap(true);
548 mode_description_textarea.setWrapStyleWord(true);
549 // Determine which value is already selected
550 switch(Configuration.getMode()) {
551 case Configuration.ASSISTANT_MODE:
552 assistant_mode_radio_button.setSelected(true);
553 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
554 break;
555 case Configuration.EXPERT_MODE:
556 expert_mode_radio_button.setSelected(true);
557 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
558 break;
559 default:
560 librarian_mode_radio_button.setSelected(true);
561 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
562 }
563 // Connection - when a radio button is selected we have to change the description
564 ModeRadioButtonListener listener = new ModeRadioButtonListener();
565 assistant_mode_radio_button.addActionListener(listener);
566 expert_mode_radio_button.addActionListener(listener);
567 librarian_mode_radio_button.addActionListener(listener);
568 listener = null;
569 // Layout
570 button_panel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
571 button_panel.setLayout(new GridLayout(3,1,2,2));
572 button_panel.add(assistant_mode_radio_button);
573 button_panel.add(librarian_mode_radio_button);
574 button_panel.add(expert_mode_radio_button);
575
576 mode_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
577 mode_panel.setLayout(new BorderLayout());
578 mode_panel.add(button_panel, BorderLayout.NORTH);
579 mode_panel.add(new JScrollPane(mode_description_textarea), BorderLayout.CENTER);
580
581 return mode_panel;
582 }
583
584
585 /** The warning preferences are controlled through a checklist. */
586 private JPanel createWarningPreferences()
587 {
588 warning_preferences_check_list = new CheckList(false);
589 warning_preferences_check_list.setComponentOrientation(Dictionary.getOrientation());
590
591 // Read all the warnings from the general xml/config.xml file, and their values from the user config.xml file
592 Document general_config_xml_file_document = XMLTools.parseXMLFile("xml/config.xml", true);
593 NodeList argument_elements_nodelist = general_config_xml_file_document.getDocumentElement().getElementsByTagName("Argument");
594 for (int i = 0; i < argument_elements_nodelist.getLength(); i++) {
595 Element argument_element = (Element) argument_elements_nodelist.item(i);
596 String argument_element_name = argument_element.getAttribute("name");
597 if (argument_element_name.startsWith("warning.")) {
598 String warning_title = Dictionary.get(argument_element_name.substring("warning.".length()) + ".Title");
599 boolean warning_enabled = Configuration.get(argument_element_name, true);
600 CheckListEntry warning_entry = new CheckListEntry(warning_title, warning_enabled);
601 warning_entry.setProperty(argument_element_name);
602 warning_preferences_check_list.addEntry(warning_entry);
603 }
604 }
605
606 JPanel warning_preferences_pane = new JPanel();
607 warning_preferences_pane.setComponentOrientation(Dictionary.getOrientation());
608 warning_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
609 warning_preferences_pane.setLayout(new BorderLayout());
610 JScrollPane scrol_tmp = new JScrollPane(warning_preferences_check_list);
611 scrol_tmp.setComponentOrientation(Dictionary.getOrientation());
612 warning_preferences_pane.add(scrol_tmp, BorderLayout.CENTER);
613 return warning_preferences_pane;
614 }
615
616
617 private JPanel createWorkflowPreferences() {
618 // Read in the predefined configurations file
619 Vector predefined = new Vector();
620 Document predefined_document = XMLTools.parseXMLFile("xml/workflows.xml", true);
621 Element predefined_element = predefined_document.getDocumentElement();
622 NodeList workflow_elements = predefined_element.getElementsByTagName("Workflow");
623 for(int i = 0; i < workflow_elements.getLength(); i++) {
624 predefined.add(new WorkflowElementWrapper((Element)workflow_elements.item(i)));
625 }
626
627 // Creation
628 JPanel workflow_preferences_pane = new JPanel();
629 workflow_preferences_pane.setComponentOrientation(Dictionary.getOrientation());
630
631 JPanel checklist_pane = new JPanel();
632 checklist_pane.setComponentOrientation(Dictionary.getOrientation());
633
634 JLabel title_label = new JLabel(Dictionary.get("Preferences.Workflow.Title"));
635 title_label.setComponentOrientation(Dictionary.getOrientation());
636 title_label.setPreferredSize(ROW_SIZE);
637
638 workflow_download = new JCheckBox(Dictionary.get("GUI.Download")+" - "+Dictionary.get("GUI.Download_Tooltip"));
639 workflow_download.setComponentOrientation(Dictionary.getOrientation());
640 workflow_download.setSelected(Configuration.get("workflow.download", false) && Gatherer.isDownloadEnabled);
641 workflow_download.setPreferredSize(ROW_SIZE);
642
643 workflow_gather = new JCheckBox(Dictionary.get("GUI.Gather")+" - "+Dictionary.get("GUI.Gather_Tooltip"));
644 workflow_gather.setSelected(Configuration.get("workflow.gather", false));
645 workflow_gather.setPreferredSize(ROW_SIZE);
646 workflow_gather.setComponentOrientation(Dictionary.getOrientation());
647
648 workflow_enrich = new JCheckBox(Dictionary.get("GUI.Enrich")+" - "+Dictionary.get("GUI.Enrich_Tooltip"));
649 workflow_enrich.setSelected(Configuration.get("workflow.enrich", false));
650 workflow_enrich.setPreferredSize(ROW_SIZE);
651 workflow_enrich.setComponentOrientation(Dictionary.getOrientation());
652
653 workflow_design = new JCheckBox(Dictionary.get("GUI.Design")+" - "+Dictionary.get("GUI.Design_Tooltip"));
654 workflow_design.setSelected(Configuration.get("workflow.design", false));
655 workflow_design.setPreferredSize(ROW_SIZE);
656 workflow_design.setComponentOrientation(Dictionary.getOrientation());
657
658 workflow_create = new JCheckBox(Dictionary.get("GUI.Create")+" - "+Dictionary.get("GUI.Create_Tooltip"));
659 workflow_create.setSelected(Configuration.get("workflow.create", false));
660 workflow_create.setPreferredSize(ROW_SIZE);
661 workflow_create.setComponentOrientation(Dictionary.getOrientation());
662
663 workflow_format = new JCheckBox(Dictionary.get("GUI.Format")+" - "+Dictionary.get("GUI.Format_Tooltip"));
664 workflow_format.setSelected(Configuration.get("workflow.format", false));
665 workflow_format.setPreferredSize(ROW_SIZE);
666 workflow_format.setComponentOrientation(Dictionary.getOrientation());
667
668 JPanel predefined_pane = new JPanel();
669 predefined_pane.setComponentOrientation(Dictionary.getOrientation());
670
671 JLabel predefined_label = new JLabel(Dictionary.get("Preferences.Workflow.Predefined.Label"));
672 predefined_label.setComponentOrientation(Dictionary.getOrientation());
673
674 JComboBox predefined_combobox = new JComboBox(predefined);
675 predefined_combobox.setOpaque(false);
676 // Connection
677 predefined_combobox.addActionListener(new PredefinedActionListener());
678
679 // Layout
680 checklist_pane.setLayout(new BoxLayout(checklist_pane, BoxLayout.Y_AXIS));
681 checklist_pane.add(title_label);
682 if (Configuration.get("workflow.download", true)) {
683 checklist_pane.add(workflow_download);
684 }
685 if (Configuration.get("workflow.gather", true)) {
686 checklist_pane.add(workflow_gather);
687 }
688 if (Configuration.get("workflow.enrich", true)) {
689 checklist_pane.add(workflow_enrich);
690 }
691 if (Configuration.get("workflow.design", true)) {
692 checklist_pane.add(workflow_design);
693 }
694 if (Configuration.get("workflow.create", true)) {
695 checklist_pane.add(workflow_create);
696 }
697 if (Configuration.get("workflow.format", true)) {
698 checklist_pane.add(workflow_format);
699 }
700
701 predefined_pane.setLayout(new BorderLayout(5,0));
702 predefined_pane.add(predefined_label, BorderLayout.LINE_START);
703 predefined_pane.add(predefined_combobox, BorderLayout.CENTER);
704
705 workflow_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
706 workflow_preferences_pane.setLayout(new BorderLayout());
707 workflow_preferences_pane.add(checklist_pane, BorderLayout.CENTER);
708 workflow_preferences_pane.add(predefined_pane, BorderLayout.SOUTH);
709
710 return workflow_preferences_pane;
711 }
712
713
714 private class OKButtonListener
715 implements ActionListener {
716 private boolean close;
717 public OKButtonListener(boolean close) {
718 this.close = close;
719 }
720 public void actionPerformed(ActionEvent event)
721 {
722 // Several options requiring restarting the GLI to apply:
723 // interface font, interface language, changed gliserver url or library url
724 boolean restart_required = false;
725 boolean keep_collection_open = false;
726 String restart_message = "";
727
728
729 // Connection preferences
730 String program_str = program_field.getText();
731 if (program_str.length() > 0 && program_str.indexOf("%1") == -1) {
732 program_str = program_str + " %1";
733 }
734 Configuration.setPreviewCommand(program_str);
735
736 String old_library_url = (Configuration.library_url == null) ? null : Configuration.library_url.toString();
737 String library_url_string = library_path_field.getText();
738 if(old_library_url != null && !old_library_url.equals(library_url_string)) {
739
740 // If the server is remote and the library path's been changed, then GLI client needs restart
741 // If the server is local, GLI is going to work with the collection of GSDLPath anyway,
742 // even if the library path for previewing has changed
743 if (Gatherer.isGsdlRemote) {
744 restart_required = true;
745 restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required");
746
747 }
748 if(Gatherer.c_man.getCollection() != null) {
749 // if the gliserver url has changed while a collection is open,
750 // close the open collection of the old library URL
751 Gatherer.g_man.saveThenCloseCurrentCollection();
752 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, "");
753 }
754 }
755 if (library_url_string.equals("")) {
756 Configuration.library_url = null;
757 }
758 else {
759 try {
760 Configuration.library_url = new URL(library_url_string);
761 }
762 catch (MalformedURLException exception) {
763 DebugStream.printStackTrace(exception);
764 }
765 }
766
767 Configuration.setString("general.library_url"+Configuration.gliPropertyNameSuffix(),
768 true, library_url_string);
769
770 if (Gatherer.isGsdlRemote && !Gatherer.GS3) {
771 String old_gliserver_url = Configuration.gliserver_url.toString();
772 String gliserver_url_string = gliserver_url_field.getText();
773 if(!old_gliserver_url.equals(gliserver_url_string)) {
774 restart_required = true;
775 restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required");
776
777 if(Gatherer.c_man.getCollection() != null) {
778 // if the gliserver url has changed while a collection is open,
779 // close the open collection of the old gliserver URL
780 Gatherer.g_man.saveThenCloseCurrentCollection();
781 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, "");
782 }
783 }
784 if (gliserver_url_string.equals("")) {
785 Configuration.gliserver_url = null;
786 }
787 else {
788 try {
789 Configuration.gliserver_url = new URL(gliserver_url_string);
790 }
791 catch (MalformedURLException exception) {
792 DebugStream.printStackTrace(exception);
793 }
794 }
795 Configuration.setString("general.gliserver_url", true, gliserver_url_string);
796 }
797
798
799 boolean site_changed = false;
800 if (Gatherer.GS3) {
801 String current_site = Configuration.site_name;
802 String new_site =(String)site_combobox.getSelectedItem() ;
803 if (!new_site.equals(current_site)) {
804 site_changed = true;
805 }
806 Configuration.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem());
807 }
808
809 Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected());
810 Configuration.setString("general.proxy_host", true, proxy_host_field.getText());
811 Configuration.setString("general.proxy_port", true, proxy_port_field.getValue() + "");
812 Gatherer.setProxy();
813
814 // General preferences
815 Configuration.setEmail(email_field.getText());
816 Configuration.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected());
817 Configuration.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected());
818
819
820 // GLI interface font
821 String current_font = Configuration.getString("general.font", true);
822 if (!current_font.equals(font_field.getText())) {
823 Configuration.setString("general.font", true, font_field.getText());
824 restart_required = true;
825 restart_message = Dictionary.get("Preferences.General.Restart_Required");
826
827 }
828
829 // GLI interface language
830 String current_lang = Configuration.getLanguage();
831 if (!current_lang.equals(((DictionaryEntry) language_combobox.getSelectedItem()).getLocale().getLanguage())) {
832 // need to save the collection before changing the locale otherwise it stuffs the metadata names up
833 if(Gatherer.c_man.getCollection() != null) {
834 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, Gatherer.c_man.getLoadedCollectionColFilePath());
835 Gatherer.g_man.saveThenCloseCurrentCollection();
836 keep_collection_open = true;
837 }
838
839 Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry) language_combobox.getSelectedItem()).getLocale());
840 restart_required = true;
841 restart_message = Dictionary.get("Preferences.General.Restart_Required");
842 }
843
844 // Inform the user that a restart is required, if necessary
845 if (restart_required) {
846 JOptionPane.showMessageDialog(Gatherer.g_man, restart_message, Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);
847 }
848
849 // Mode preferences
850 int current_mode = Configuration.getMode();
851 int new_mode;
852 if (assistant_mode_radio_button.isSelected()) {
853 new_mode = Configuration.ASSISTANT_MODE;
854 }
855 else if (expert_mode_radio_button.isSelected()) {
856 new_mode = Configuration.EXPERT_MODE;
857 }
858 else {
859 new_mode = Configuration.LIBRARIAN_MODE;
860 }
861
862 // If there has been a change in modes, update the config, and also inform the persistant gui views that have a need to know
863 if (new_mode != current_mode) {
864 Configuration.setMode(new_mode);
865 Collection collection = Gatherer.c_man.getCollection();
866 if (collection != null) {
867 collection.cdm.modeChanged(new_mode);
868 }
869 Gatherer.g_man.modeChanged(new_mode);
870 }
871
872 // Warning preferences
873 ListModel warning_preferences_check_list_model = warning_preferences_check_list.getModel();
874 for (int i = 0; i < warning_preferences_check_list_model.getSize(); i++) {
875 CheckListEntry entry = (CheckListEntry) warning_preferences_check_list_model.getElementAt(i);
876 Configuration.set(entry.getProperty(), true, entry.isSelected());
877 }
878
879 if (Gatherer.GS3 && site_changed && Gatherer.c_man.getCollection() != null && !Gatherer.isGsdlRemote) {
880 // shut down the collection
881 System.err.println("shutting down the collection");
882 Gatherer.g_man.saveThenCloseCurrentCollection();
883 }
884
885 // Workflow preferences
886// Configuration.set("workflow.download", false, workflow_download.isSelected());
887// Configuration.set("workflow.gather", false, workflow_gather.isSelected());
888// Configuration.set("workflow.enrich", false, workflow_enrich.isSelected());
889// Configuration.set("workflow.design", false, workflow_design.isSelected());
890// Configuration.set("workflow.create", false, workflow_create.isSelected());
891// Configuration.set("workflow.format", false, workflow_format.isSelected());
892
893// Gatherer.g_man.workflowUpdate("Download", workflow_download.isSelected());
894// Gatherer.g_man.workflowUpdate("Gather", workflow_gather.isSelected());
895// Gatherer.g_man.workflowUpdate("Enrich", workflow_enrich.isSelected());
896// Gatherer.g_man.workflowUpdate("Design", (workflow_design.isSelected() && Configuration.getMode() > Configuration.ASSISTANT_MODE));
897// Gatherer.g_man.workflowUpdate("Create", workflow_create.isSelected());
898// Gatherer.g_man.workflowUpdate("Format", workflow_format.isSelected());
899
900 // Always save configuration changes immediately (in case the GLI crashes)
901 Configuration.save();
902 if (Gatherer.isGsdlRemote && Gatherer.GS3 && site_changed ){
903 Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
904 }
905 // Refresh the GLI to account for the configuration changes
906 Gatherer.refresh(Gatherer.PREFERENCES_CHANGED);
907
908 // If proxy is on but proxy details are incomplete, then can't continue
909 if (use_proxy_checkbox.isSelected() && proxy_host_field.getText().equals("")) {
910 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.Connection.Proxy_Host_Missing"),
911 Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
912 } else {
913 // Hide dialog
914 if (close) {
915 self.dispose();
916 }
917 }
918
919 if (restart_required) {
920 if (keep_collection_open) {
921 Gatherer.g_man.exitNoCollectionSave(Gatherer.EXIT_THEN_RESTART);
922 } else {
923 Gatherer.g_man.exit(Gatherer.EXIT_THEN_RESTART);
924 }
925 }
926 }
927 }
928
929 private class CancelButtonListener
930 implements ActionListener {
931 public void actionPerformed(ActionEvent event) {
932 self.dispose();
933 }
934 }
935
936 private class DictionaryEntry
937 implements Comparable {
938 private Locale locale;
939 private String description;
940 public DictionaryEntry(Locale locale) {
941 this.description = null;
942 this.locale = locale;
943 }
944 public DictionaryEntry(String description, Locale locale) {
945 this.description = description;
946 this.locale = locale;
947 }
948 public int compareTo(Object object) {
949 return toString().compareTo(object.toString());
950 }
951 public boolean equals(Object object) {
952 return toString().equals(object.toString());
953 }
954 public Locale getLocale() {
955 return locale;
956 }
957 public String toString() {
958 if(description != null) {
959 return description;
960 }
961 else {
962 return locale.getDisplayName();
963 }
964 }
965 }
966
967 /** This listener updates the mode description depending on what mode is selected. */
968 private class ModeRadioButtonListener
969 implements ActionListener {
970 public void actionPerformed(ActionEvent event) {
971 Object source = event.getSource();
972 if(source == assistant_mode_radio_button) {
973 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
974 }
975 else if(source == expert_mode_radio_button) {
976 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
977 }
978 else {
979 mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
980 }
981 source = null;
982 }
983 }
984
985 private class PredefinedActionListener
986 implements ActionListener {
987 public void actionPerformed(ActionEvent event) {
988 JComboBox cb = (JComboBox) event.getSource();
989 WorkflowElementWrapper element = (WorkflowElementWrapper) cb.getSelectedItem();
990 CheckboxUpdater task = new CheckboxUpdater(element);
991 SwingUtilities.invokeLater(task);
992 }
993
994 private class CheckboxUpdater
995 implements Runnable {
996 private WorkflowElementWrapper element;
997 public CheckboxUpdater(WorkflowElementWrapper element) {
998 this.element = element;
999 }
1000 public void run() {
1001 workflow_download.setSelected(element.getEnabled("download"));
1002 workflow_gather.setSelected(element.getEnabled("gather"));
1003 workflow_enrich.setSelected(element.getEnabled("enrich"));
1004 workflow_design.setSelected(element.getEnabled("design"));
1005 workflow_create.setSelected(element.getEnabled("create"));
1006 workflow_format.setSelected(element.getEnabled("format"));
1007 }
1008 }
1009 }
1010
1011
1012 private class SiteComboboxListener
1013 implements ActionListener {
1014 private boolean ignore_event=false;
1015 public void actionPerformed(ActionEvent event) {
1016 System.err.println("event occurred "+event.paramString());
1017 String site = (String) site_combobox.getSelectedItem();
1018 System.err.println("The site changed to = "+site);
1019 if (!site.equals(current_site_selection)) {
1020 current_site_selection = site;
1021 System.err.println("changed the current selection");
1022
1023 ArrayList servlet_options = Gatherer.servlet_config.getServletsForSite(current_site_selection);
1024 if (servlet_options == null) {
1025 ///ystem.err.println("no servlets for this site");
1026 servlet_combobox.setModel(new DefaultComboBoxModel());
1027 servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip2"));
1028 servlet_combobox.setEnabled(false);
1029
1030 } else {
1031 ///ystem.err.println(ArrayTools.objectArrayToString(servlet_options.toArray()));
1032 servlet_combobox.setModel(new DefaultComboBoxModel(servlet_options.toArray()));
1033 servlet_combobox.setToolTipText(Dictionary.get("Preferences.Connection.Servlet_Tooltip"));
1034 servlet_combobox.setEnabled(true);
1035 }
1036 if (Gatherer.isGsdlRemote){
1037 // Close the current collection, remove the lock on this file, ask to login to the new site, then download collection configurations of the site.
1038 if (Gatherer.c_man.getCollection()!=null){
1039 File lock_file = new File(Gatherer.c_man.getLoadedCollectionDirectoryPath() + "gli.lck");
1040 Gatherer.remoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file);
1041 Gatherer.g_man.closeCurrentCollection();
1042 }
1043 Configuration.site_name=site;
1044 Gatherer.remoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null();
1045 Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations();
1046 }
1047 }
1048 }
1049 }
1050
1051 private class UseProxyListener
1052 implements ActionListener {
1053 public void actionPerformed(ActionEvent event) {
1054 boolean enabled = use_proxy_checkbox.isSelected();
1055 Configuration.set("general.use_proxy", true, enabled);
1056 // Fortunately this is already driven by the event thread.
1057 proxy_host_field.setEnabled(enabled);
1058 proxy_port_field.setEnabled(enabled);
1059 }
1060 }
1061
1062 private class WorkflowElementWrapper {
1063 private Element element;
1064 private String text;
1065 public WorkflowElementWrapper(Element element) {
1066 this.element = element;
1067 }
1068 public boolean getEnabled(String name) {
1069 boolean result = true;
1070 if(element.getAttribute(name).equalsIgnoreCase("false")) {
1071 result = false;
1072 }
1073 return result;
1074 }
1075 public String toString() {
1076 if (text == null) {
1077 text = Dictionary.get(element.getFirstChild().getNodeValue());
1078 }
1079 return text;
1080 }
1081 }
1082}
Note: See TracBrowser for help on using the repository browser.