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