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