1 | package org.greenstone.gatherer.gui;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.*;
|
---|
5 | import java.io.*;
|
---|
6 | import java.net.*;
|
---|
7 | import java.util.*;
|
---|
8 | import javax.swing.*;
|
---|
9 | import javax.swing.event.*;
|
---|
10 | import org.greenstone.gatherer.Configuration;
|
---|
11 | import org.greenstone.gatherer.Dictionary;
|
---|
12 | import org.greenstone.gatherer.Gatherer;
|
---|
13 | import org.greenstone.gatherer.checklist.CheckList;
|
---|
14 | import org.greenstone.gatherer.checklist.Entry;
|
---|
15 | import org.greenstone.gatherer.gui.ModalDialog;
|
---|
16 | import org.greenstone.gatherer.gui.SimpleMenuBar;
|
---|
17 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
18 | import org.greenstone.gatherer.util.Utility;
|
---|
19 | import org.w3c.dom.*;
|
---|
20 |
|
---|
21 | public class Preferences
|
---|
22 | extends ModalDialog {
|
---|
23 |
|
---|
24 | private CheckList warning_preferences_check_list;
|
---|
25 | private JButton apply_button;
|
---|
26 | private JButton cancel_button;
|
---|
27 | private JButton ok_button;
|
---|
28 | private JCheckBox show_file_size_checkbox;
|
---|
29 | private JCheckBox use_proxy_checkbox;
|
---|
30 | private JCheckBox view_extracted_metadata_checkbox;
|
---|
31 | private JCheckBox workflow_browse;
|
---|
32 | private JCheckBox workflow_create;
|
---|
33 | private JCheckBox workflow_mirror;
|
---|
34 | private JCheckBox workflow_gather;
|
---|
35 | private JCheckBox workflow_enrich;
|
---|
36 | private JCheckBox workflow_design;
|
---|
37 | private JCheckBox workflow_export;
|
---|
38 | private JCheckBox workflow_preview;
|
---|
39 | private JComboBox language_combobox;
|
---|
40 | private JLabel language_label;
|
---|
41 | private JLabel library_path_label;
|
---|
42 | private JLabel predefined_label;
|
---|
43 | private JLabel proxy_host_label;
|
---|
44 | private JLabel proxy_port_label;
|
---|
45 | private JLabel title_label;
|
---|
46 | private JTabbedPane tab_pane;
|
---|
47 | private JTextField library_path_field;
|
---|
48 | private JTextField proxy_host_field;
|
---|
49 | private JSpinner proxy_port_field;
|
---|
50 | private Preferences self;
|
---|
51 |
|
---|
52 | static final Dimension LABEL_SIZE = new Dimension(150, 25);
|
---|
53 | static final Dimension ROW_SIZE = new Dimension(640, 25);
|
---|
54 | static final Dimension SIZE = new Dimension(640, 345);
|
---|
55 | static final String TRUE = "true";
|
---|
56 |
|
---|
57 | public Preferences() {
|
---|
58 | // Initialize
|
---|
59 | super(Gatherer.g_man, true);
|
---|
60 | this.self = this;
|
---|
61 | setSize(SIZE);
|
---|
62 | Dictionary.registerText(this, "Preferences");
|
---|
63 | setJMenuBar(new SimpleMenuBar("preferences"));
|
---|
64 |
|
---|
65 | // Creation
|
---|
66 | JPanel content_pane = (JPanel) getContentPane();
|
---|
67 | tab_pane = new JTabbedPane();
|
---|
68 | JPanel general_preferences = createGeneralPreferences();
|
---|
69 | tab_pane.add("Preferences.General", general_preferences);
|
---|
70 | tab_pane.add("Preferences.Workflow", createWorkflowPreferences());
|
---|
71 | tab_pane.add("Preferences.Connection", createConnectionPreferences());
|
---|
72 | tab_pane.add("Preferences.Warnings", createWarningPreferences());
|
---|
73 | Dictionary.register(tab_pane);
|
---|
74 |
|
---|
75 | JPanel button_pane = new JPanel();
|
---|
76 | ok_button = new JButton();
|
---|
77 | Dictionary.registerBoth(ok_button, "General.OK", "General.OK_Tooltip");
|
---|
78 | apply_button = new JButton();
|
---|
79 | Dictionary.registerBoth(apply_button, "General.Apply", "General.Apply_Tooltip");
|
---|
80 | cancel_button = new JButton();
|
---|
81 | Dictionary.registerBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
|
---|
82 |
|
---|
83 | // Connection
|
---|
84 | ok_button.addActionListener(new OKButtonListener(true));
|
---|
85 | apply_button.addActionListener(new OKButtonListener(false));
|
---|
86 | cancel_button.addActionListener(new CancelButtonListener());
|
---|
87 |
|
---|
88 | // Layout
|
---|
89 | button_pane.setBorder(BorderFactory.createEmptyBorder(5,2,2,2));
|
---|
90 | button_pane.setLayout(new GridLayout(1,3,0,5));
|
---|
91 | button_pane.add(ok_button);
|
---|
92 | button_pane.add(apply_button);
|
---|
93 | button_pane.add(cancel_button);
|
---|
94 |
|
---|
95 | content_pane.setLayout(new BorderLayout());
|
---|
96 | content_pane.add(tab_pane, BorderLayout.CENTER);
|
---|
97 | content_pane.add(button_pane, BorderLayout.SOUTH);
|
---|
98 |
|
---|
99 | Dimension frame_size = Gatherer.g_man.getSize();
|
---|
100 | Point frame_location = Gatherer.g_man.getLocation();
|
---|
101 | //setLocation(frame_location.x + ((frame_size.width - SIZE.width) / 2), frame_location.y + ((frame_size.height - SIZE.height)));
|
---|
102 | setLocation(((frame_size.width - SIZE.width) / 2), ((frame_size.height - SIZE.height)));
|
---|
103 |
|
---|
104 | // Clean up
|
---|
105 | frame_location = null;
|
---|
106 | frame_size = null;
|
---|
107 | cancel_button = null;
|
---|
108 | ok_button = null;
|
---|
109 | button_pane = null;
|
---|
110 | tab_pane = null;
|
---|
111 | content_pane = null;
|
---|
112 | setVisible(true);
|
---|
113 | }
|
---|
114 |
|
---|
115 | private JPanel createConnectionPreferences() {
|
---|
116 | JPanel library_path_pane = new JPanel();
|
---|
117 | library_path_pane.setPreferredSize(ROW_SIZE);
|
---|
118 | library_path_label = new JLabel();
|
---|
119 | library_path_label.setPreferredSize(LABEL_SIZE);
|
---|
120 | Dictionary.registerText(library_path_label, "Preferences.Connection.Library_Path");
|
---|
121 | library_path_field = new JTextField(Gatherer.config.getString("general.exec_address", true));
|
---|
122 | library_path_field.setCaretPosition(0);
|
---|
123 | Dictionary.registerTooltip(library_path_field, "Preferences.Connection.Library_Path_Tooltip");
|
---|
124 |
|
---|
125 | boolean currently_enabled = Gatherer.config.get("general.use_proxy", true);
|
---|
126 | // Creation
|
---|
127 | JPanel connection_pane = new JPanel();
|
---|
128 | use_proxy_checkbox = new JCheckBox();
|
---|
129 | use_proxy_checkbox.setSelected(currently_enabled);
|
---|
130 | Dictionary.registerText(use_proxy_checkbox, "Preferences.Connection.Use_Proxy");
|
---|
131 |
|
---|
132 | use_proxy_checkbox.setPreferredSize(ROW_SIZE);
|
---|
133 | JPanel proxy_host_pane = new JPanel();
|
---|
134 | proxy_host_pane.setPreferredSize(ROW_SIZE);
|
---|
135 | proxy_host_label = new JLabel();
|
---|
136 | proxy_host_label.setPreferredSize(LABEL_SIZE);
|
---|
137 | Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host");
|
---|
138 | proxy_host_field = new JTextField(Gatherer.config.getString("general.proxy_host", true));
|
---|
139 | proxy_host_field.setEnabled(currently_enabled);
|
---|
140 | Dictionary.registerTooltip(proxy_host_field, "Preferences.Connection.Proxy_Host_Tooltip");
|
---|
141 | JPanel proxy_port_pane = new JPanel();
|
---|
142 | proxy_port_pane.setPreferredSize(ROW_SIZE);
|
---|
143 | proxy_port_label = new JLabel();
|
---|
144 | proxy_port_label.setPreferredSize(LABEL_SIZE);
|
---|
145 | Dictionary.registerText(proxy_port_label, "Preferences.Connection.Proxy_Port");
|
---|
146 | String port_value = Gatherer.config.getString("general.proxy_port", true);
|
---|
147 | proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1));
|
---|
148 | proxy_port_field.setEnabled(currently_enabled);
|
---|
149 | Dictionary.registerTooltip(proxy_port_field, "Preferences.Connection.Proxy_Port_Tooltip");
|
---|
150 |
|
---|
151 | // Connection
|
---|
152 | use_proxy_checkbox.addActionListener(new UseProxyListener());
|
---|
153 |
|
---|
154 | // Layout
|
---|
155 | library_path_pane.setLayout(new BorderLayout());
|
---|
156 | library_path_pane.add(library_path_label, BorderLayout.WEST);
|
---|
157 | library_path_pane.add(library_path_field, BorderLayout.CENTER);
|
---|
158 |
|
---|
159 | proxy_host_pane.setLayout(new BorderLayout());
|
---|
160 | proxy_host_pane.add(proxy_host_label, BorderLayout.WEST);
|
---|
161 | proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER);
|
---|
162 |
|
---|
163 | proxy_port_pane.setLayout(new BorderLayout());
|
---|
164 | proxy_port_pane.add(proxy_port_label, BorderLayout.WEST);
|
---|
165 | proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER);
|
---|
166 |
|
---|
167 | connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
168 | connection_pane.setLayout(new GridLayout(8,1,0,2));
|
---|
169 | connection_pane.add(library_path_pane);
|
---|
170 | connection_pane.add(use_proxy_checkbox);
|
---|
171 | connection_pane.add(proxy_host_pane);
|
---|
172 | connection_pane.add(proxy_port_pane);
|
---|
173 |
|
---|
174 | return connection_pane;
|
---|
175 | }
|
---|
176 |
|
---|
177 | private JPanel createGeneralPreferences() {
|
---|
178 | JPanel general_pane = new JPanel();
|
---|
179 |
|
---|
180 | // Build the model of available languages
|
---|
181 | ArrayList dictionary_model = new ArrayList();
|
---|
182 |
|
---|
183 | dictionary_model.add(new DictionaryEntry(Locale.ENGLISH));
|
---|
184 | File classes_folder = new File(Utility.BASE_DIR + StaticStrings.CLASSES_FOLDER);
|
---|
185 | File[] possible_dictionaries = classes_folder.listFiles();
|
---|
186 | for(int i = 0; i < possible_dictionaries.length; i++) {
|
---|
187 | String filename = possible_dictionaries[i].getName();
|
---|
188 | if(filename.endsWith(StaticStrings.PROPERTIES_FILE_EXTENSION) && filename.indexOf(StaticStrings.UNDERSCORE_CHARACTER) != -1) {
|
---|
189 | StringTokenizer tokenizer = new StringTokenizer(filename.substring(filename.indexOf(StaticStrings.UNDERSCORE_CHARACTER) + 1, filename.indexOf(StaticStrings.STOP_CHARACTER)), StaticStrings.UNDERSCORE_CHARACTER);
|
---|
190 | Locale locale = null;
|
---|
191 | switch(tokenizer.countTokens()) {
|
---|
192 | case 1:
|
---|
193 | locale = new Locale(tokenizer.nextToken().toLowerCase());
|
---|
194 | break;
|
---|
195 | case 2:
|
---|
196 | locale = new Locale(tokenizer.nextToken().toLowerCase(), tokenizer.nextToken().toUpperCase());
|
---|
197 | break;
|
---|
198 | }
|
---|
199 | tokenizer = null;
|
---|
200 | // Open the file and read the first line
|
---|
201 | String description = null;
|
---|
202 | try {
|
---|
203 | BufferedReader br = new BufferedReader(new FileReader(possible_dictionaries[i]));
|
---|
204 | String first_line = br.readLine();
|
---|
205 | br.close();
|
---|
206 | description = first_line.substring(first_line.indexOf(StaticStrings.COLON_CHARACTER) + 1);
|
---|
207 | }
|
---|
208 | catch(Exception error) {
|
---|
209 | }
|
---|
210 | DictionaryEntry entry = new DictionaryEntry(description, locale);
|
---|
211 | description = null;
|
---|
212 | locale = null;
|
---|
213 | if(!dictionary_model.contains(entry)) {
|
---|
214 | dictionary_model.add(entry);
|
---|
215 | }
|
---|
216 | entry = null;
|
---|
217 | }
|
---|
218 | filename = null;
|
---|
219 | }
|
---|
220 | possible_dictionaries = null;
|
---|
221 | classes_folder = null;
|
---|
222 |
|
---|
223 | // Extracted metadata
|
---|
224 | view_extracted_metadata_checkbox = new JCheckBox();
|
---|
225 | view_extracted_metadata_checkbox.setSelected(false);
|
---|
226 | Dictionary.registerText(view_extracted_metadata_checkbox, "Preferences.General.View_Extracted_Metadata");
|
---|
227 | if (Gatherer.config.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC)) {
|
---|
228 | view_extracted_metadata_checkbox.setSelected(true);
|
---|
229 | }
|
---|
230 |
|
---|
231 | // Show file sizes
|
---|
232 | show_file_size_checkbox = new JCheckBox();
|
---|
233 | show_file_size_checkbox.setSelected(false);
|
---|
234 | Dictionary.registerText(show_file_size_checkbox, "Preferences.General.Show_File_Size");
|
---|
235 | if (Gatherer.config.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC)) {
|
---|
236 | show_file_size_checkbox.setSelected(true);
|
---|
237 | }
|
---|
238 |
|
---|
239 | // Language
|
---|
240 | JPanel language_pane = new JPanel();
|
---|
241 | language_label = new JLabel();
|
---|
242 | language_label.setPreferredSize(LABEL_SIZE);
|
---|
243 | Dictionary.registerText(language_label, "Preferences.General.Interface_Language");
|
---|
244 | language_combobox = new JComboBox(dictionary_model.toArray());
|
---|
245 |
|
---|
246 | // Connect
|
---|
247 | language_combobox.addActionListener(new LanguageComboboxListener());
|
---|
248 |
|
---|
249 | // Layout
|
---|
250 | language_pane.setLayout(new BorderLayout());
|
---|
251 | language_pane.add(language_label, BorderLayout.WEST);
|
---|
252 | language_pane.add(language_combobox, BorderLayout.CENTER);
|
---|
253 |
|
---|
254 | general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
255 | general_pane.setLayout(new GridLayout(5,1,0,5));
|
---|
256 | general_pane.add(view_extracted_metadata_checkbox);
|
---|
257 | general_pane.add(show_file_size_checkbox);
|
---|
258 | general_pane.add(language_pane);
|
---|
259 |
|
---|
260 | return general_pane;
|
---|
261 | }
|
---|
262 |
|
---|
263 | /** The warning preferences are controlled through a checklist. */
|
---|
264 | private JPanel createWarningPreferences() {
|
---|
265 | // Retrieve all of the warning preferences settings.
|
---|
266 | HashMap warning_preferences = Gatherer.config.getAll("warning\\..*", true);
|
---|
267 | warning_preferences_check_list = new CheckList(false);
|
---|
268 | for(Iterator keys = warning_preferences.keySet().iterator(); keys.hasNext(); ) {
|
---|
269 | String property = (String) keys.next();
|
---|
270 | String value = (String) warning_preferences.get(property);
|
---|
271 | // Remove 'warning.'
|
---|
272 | String title = Dictionary.newget(property.substring(8) + ".Title");
|
---|
273 | Entry entry = new Entry(title, value.equalsIgnoreCase(TRUE));
|
---|
274 | entry.setProperty(property);
|
---|
275 | warning_preferences_check_list.addEntry(entry);
|
---|
276 | }
|
---|
277 | // Creation
|
---|
278 | JPanel warning_preferences_pane = new JPanel();
|
---|
279 | // Connection
|
---|
280 | // Layout
|
---|
281 | warning_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
282 | warning_preferences_pane.setLayout(new BorderLayout());
|
---|
283 | warning_preferences_pane.add(new JScrollPane(warning_preferences_check_list), BorderLayout.CENTER);
|
---|
284 |
|
---|
285 | return warning_preferences_pane;
|
---|
286 | }
|
---|
287 |
|
---|
288 | private JPanel createWorkflowPreferences() {
|
---|
289 | // Read in the predefined configurations file
|
---|
290 | Vector predefined = new Vector();
|
---|
291 | Document predefined_document = Utility.parse("xml/workflows.xml", true);
|
---|
292 | Element predefined_element = predefined_document.getDocumentElement();
|
---|
293 | NodeList workflow_elements = predefined_element.getElementsByTagName("Workflow");
|
---|
294 | for(int i = 0; i < workflow_elements.getLength(); i++) {
|
---|
295 | predefined.add(new WorkflowElementWrapper((Element)workflow_elements.item(i)));
|
---|
296 | }
|
---|
297 |
|
---|
298 | // Creation
|
---|
299 | JPanel workflow_preferences_pane = new JPanel();
|
---|
300 | JPanel checklist_pane = new JPanel();
|
---|
301 | title_label = new JLabel();
|
---|
302 | title_label.setPreferredSize(ROW_SIZE);
|
---|
303 | Dictionary.registerText(title_label, "Preferences.Workflow.Title");
|
---|
304 |
|
---|
305 | workflow_browse = new JCheckBox();
|
---|
306 | workflow_browse.setSelected(Gatherer.config.get("workflow.browse", false));
|
---|
307 | workflow_browse.setPreferredSize(ROW_SIZE);
|
---|
308 | Dictionary.registerText(workflow_browse, "Preferences.Workflow.Browse");
|
---|
309 |
|
---|
310 | workflow_mirror = new JCheckBox();
|
---|
311 | workflow_mirror.setSelected(Gatherer.config.get("workflow.mirror", false));
|
---|
312 | workflow_mirror.setPreferredSize(ROW_SIZE);
|
---|
313 | Dictionary.registerText(workflow_mirror, "Preferences.Workflow.Mirror");
|
---|
314 |
|
---|
315 | workflow_gather = new JCheckBox();
|
---|
316 | workflow_gather.setSelected(Gatherer.config.get("workflow.gather", false));
|
---|
317 | workflow_gather.setPreferredSize(ROW_SIZE);
|
---|
318 | Dictionary.registerText(workflow_gather, "Preferences.Workflow.Gather");
|
---|
319 |
|
---|
320 | workflow_enrich = new JCheckBox();
|
---|
321 | workflow_enrich.setSelected(Gatherer.config.get("workflow.enrich", false));
|
---|
322 | workflow_enrich.setPreferredSize(ROW_SIZE);
|
---|
323 | Dictionary.registerText(workflow_enrich, "Preferences.Workflow.Enrich");
|
---|
324 |
|
---|
325 | workflow_design = new JCheckBox();
|
---|
326 | workflow_design.setSelected(Gatherer.config.get("workflow.design", false));
|
---|
327 | workflow_design.setPreferredSize(ROW_SIZE);
|
---|
328 | Dictionary.registerText(workflow_design, "Preferences.Workflow.Design");
|
---|
329 |
|
---|
330 | workflow_export = new JCheckBox();
|
---|
331 | workflow_export.setSelected(Gatherer.config.get("workflow.export", false));
|
---|
332 | workflow_export.setPreferredSize(ROW_SIZE);
|
---|
333 | Dictionary.registerText(workflow_export, "Preferences.Workflow.Export");
|
---|
334 |
|
---|
335 | workflow_create = new JCheckBox();
|
---|
336 | workflow_create.setSelected(Gatherer.config.get("workflow.create", false));
|
---|
337 | workflow_create.setPreferredSize(ROW_SIZE);
|
---|
338 | Dictionary.registerText(workflow_create, "Preferences.Workflow.Create");
|
---|
339 |
|
---|
340 | workflow_preview = new JCheckBox();
|
---|
341 | workflow_preview.setSelected(Gatherer.config.get("workflow.preview", false));
|
---|
342 | workflow_preview.setPreferredSize(ROW_SIZE);
|
---|
343 | Dictionary.registerText(workflow_preview, "Preferences.Workflow.Preview");
|
---|
344 |
|
---|
345 | JPanel predefined_pane = new JPanel();
|
---|
346 | predefined_label = new JLabel();
|
---|
347 | predefined_label.setPreferredSize(new Dimension(150,25));
|
---|
348 | Dictionary.registerText(predefined_label, "Preferences.Workflow.Predefined.Label");
|
---|
349 | JComboBox predefined_combobox = new JComboBox(predefined);
|
---|
350 |
|
---|
351 | // Connection
|
---|
352 | predefined_combobox.addActionListener(new PredefinedActionListener());
|
---|
353 |
|
---|
354 | // Layout
|
---|
355 | checklist_pane.setLayout(new BoxLayout(checklist_pane, BoxLayout.Y_AXIS));
|
---|
356 | checklist_pane.add(title_label);
|
---|
357 | if (Gatherer.config.get("workflow.browse", true)) {
|
---|
358 | checklist_pane.add(workflow_browse);
|
---|
359 | }
|
---|
360 | if (Gatherer.config.get("workflow.mirror", true)) {
|
---|
361 | checklist_pane.add(workflow_mirror);
|
---|
362 | }
|
---|
363 | if (Gatherer.config.get("workflow.gather", true)) {
|
---|
364 | checklist_pane.add(workflow_gather);
|
---|
365 | }
|
---|
366 | if (Gatherer.config.get("workflow.enrich", true)) {
|
---|
367 | checklist_pane.add(workflow_enrich);
|
---|
368 | }
|
---|
369 | if (Gatherer.config.get("workflow.design", true)) {
|
---|
370 | checklist_pane.add(workflow_design);
|
---|
371 | }
|
---|
372 | if (Gatherer.config.get("workflow.export", true)) {
|
---|
373 | checklist_pane.add(workflow_export);
|
---|
374 | }
|
---|
375 | if (Gatherer.config.get("workflow.create", true)) {
|
---|
376 | checklist_pane.add(workflow_create);
|
---|
377 | }
|
---|
378 | if (Gatherer.config.get("workflow.preview", true)) {
|
---|
379 | checklist_pane.add(workflow_preview);
|
---|
380 | }
|
---|
381 | predefined_pane.setLayout(new BorderLayout());
|
---|
382 | predefined_pane.add(predefined_label, BorderLayout.WEST);
|
---|
383 | predefined_pane.add(predefined_combobox, BorderLayout.CENTER);
|
---|
384 |
|
---|
385 | workflow_preferences_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
386 | workflow_preferences_pane.setLayout(new BorderLayout());
|
---|
387 | workflow_preferences_pane.add(checklist_pane, BorderLayout.CENTER);
|
---|
388 | workflow_preferences_pane.add(predefined_pane, BorderLayout.SOUTH);
|
---|
389 |
|
---|
390 | return workflow_preferences_pane;
|
---|
391 | }
|
---|
392 |
|
---|
393 | public void dispose() {
|
---|
394 | // Dispose
|
---|
395 | super.dispose();
|
---|
396 | }
|
---|
397 |
|
---|
398 | private class OKButtonListener
|
---|
399 | implements ActionListener {
|
---|
400 | private boolean close;
|
---|
401 | public OKButtonListener(boolean close) {
|
---|
402 | this.close = close;
|
---|
403 | }
|
---|
404 | public void actionPerformed(ActionEvent event) {
|
---|
405 | // Submit the various changes.
|
---|
406 | // Connection preferences
|
---|
407 | String library_path_string = library_path_field.getText();
|
---|
408 | Gatherer.config.setString("general.exec_address", true, library_path_string);
|
---|
409 | if (!library_path_string.equals("")) {
|
---|
410 | try {
|
---|
411 | Gatherer.config.exec_address = new URL(library_path_string);
|
---|
412 | }
|
---|
413 | catch (MalformedURLException error) {
|
---|
414 | ///ystem.err.println("Error: Bad address: " + exec_address_string);
|
---|
415 | }
|
---|
416 | }
|
---|
417 | Gatherer.config.set("general.use_proxy", true, use_proxy_checkbox.isSelected());
|
---|
418 | Gatherer.config.setString("general.proxy_host", true, proxy_host_field.getText());
|
---|
419 | Gatherer.config.setString("general.proxy_port", true, proxy_port_field.getValue() + "");
|
---|
420 | Gatherer.setProxy();
|
---|
421 |
|
---|
422 | // General preferences
|
---|
423 | Gatherer.config.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected());
|
---|
424 | Gatherer.g_man.collection_pane.refreshTrees();
|
---|
425 | Gatherer.g_man.metaedit_pane.refreshTrees();
|
---|
426 |
|
---|
427 | Gatherer.config.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected());
|
---|
428 | Gatherer.g_man.metaedit_pane.valueChanged((TreeSelectionEvent) null); // Refresh metadata table
|
---|
429 |
|
---|
430 | Gatherer.config.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry)language_combobox.getSelectedItem()).getLocale());
|
---|
431 |
|
---|
432 | // Warning preferences
|
---|
433 | for(int i = 0; i < warning_preferences_check_list.getEntryCount(); i++) {
|
---|
434 | Entry entry = warning_preferences_check_list.get(i);
|
---|
435 | Gatherer.config.set(entry.getProperty(), true, entry.isSelected());
|
---|
436 | }
|
---|
437 | // Workflow preferences
|
---|
438 | Gatherer.config.set("workflow.browse", false, workflow_browse.isSelected());
|
---|
439 | Gatherer.config.set("workflow.mirror", false, workflow_mirror.isSelected());
|
---|
440 | Gatherer.config.set("workflow.gather", false, workflow_gather.isSelected());
|
---|
441 | Gatherer.config.set("workflow.enrich", false, workflow_enrich.isSelected());
|
---|
442 | Gatherer.config.set("workflow.design", false, workflow_design.isSelected());
|
---|
443 | Gatherer.config.set("workflow.export", false, workflow_export.isSelected());
|
---|
444 | Gatherer.config.set("workflow.create", false, workflow_create.isSelected());
|
---|
445 | Gatherer.config.set("workflow.preview", false, workflow_preview.isSelected());
|
---|
446 | Gatherer.g_man.workflowUpdate("Browser", workflow_browse.isSelected());
|
---|
447 | Gatherer.g_man.workflowUpdate("Mirroring", workflow_mirror.isSelected());
|
---|
448 | Gatherer.g_man.workflowUpdate("Collection", workflow_gather.isSelected());
|
---|
449 | Gatherer.g_man.workflowUpdate("MetaEdit", workflow_enrich.isSelected());
|
---|
450 | Gatherer.g_man.workflowUpdate("Build", workflow_design.isSelected());
|
---|
451 | Gatherer.g_man.workflowUpdate("Export", workflow_export.isSelected());
|
---|
452 | Gatherer.g_man.workflowUpdate("Create", workflow_create.isSelected());
|
---|
453 | Gatherer.g_man.workflowUpdate("Preview", workflow_preview.isSelected());
|
---|
454 | // Hide dialog
|
---|
455 | if(close) {
|
---|
456 | self.dispose();
|
---|
457 | }
|
---|
458 | }
|
---|
459 | }
|
---|
460 |
|
---|
461 | private class CancelButtonListener
|
---|
462 | implements ActionListener {
|
---|
463 | public void actionPerformed(ActionEvent event) {
|
---|
464 | self.dispose();
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | private class DictionaryEntry
|
---|
469 | implements Comparable {
|
---|
470 | private Locale locale;
|
---|
471 | private String description;
|
---|
472 | public DictionaryEntry(Locale locale) {
|
---|
473 | this.description = null;
|
---|
474 | this.locale = locale;
|
---|
475 | }
|
---|
476 | public DictionaryEntry(String description, Locale locale) {
|
---|
477 | this.description = description;
|
---|
478 | this.locale = locale;
|
---|
479 | }
|
---|
480 | public int compareTo(Object object) {
|
---|
481 | return toString().compareTo(object.toString());
|
---|
482 | }
|
---|
483 | public boolean equals(Object object) {
|
---|
484 | return toString().equals(object.toString());
|
---|
485 | }
|
---|
486 | public Locale getLocale() {
|
---|
487 | return locale;
|
---|
488 | }
|
---|
489 | public String toString() {
|
---|
490 | if(description != null) {
|
---|
491 | return description;
|
---|
492 | }
|
---|
493 | else {
|
---|
494 | return locale.getDisplayName();
|
---|
495 | }
|
---|
496 | }
|
---|
497 | }
|
---|
498 |
|
---|
499 | private class PredefinedActionListener
|
---|
500 | implements ActionListener {
|
---|
501 | public void actionPerformed(ActionEvent event) {
|
---|
502 | JComboBox cb = (JComboBox) event.getSource();
|
---|
503 | WorkflowElementWrapper element = (WorkflowElementWrapper) cb.getSelectedItem();
|
---|
504 | CheckboxUpdater task = new CheckboxUpdater(element);
|
---|
505 | SwingUtilities.invokeLater(task);
|
---|
506 | }
|
---|
507 |
|
---|
508 | private class CheckboxUpdater
|
---|
509 | implements Runnable {
|
---|
510 | private WorkflowElementWrapper element;
|
---|
511 | public CheckboxUpdater(WorkflowElementWrapper element) {
|
---|
512 | this.element = element;
|
---|
513 | }
|
---|
514 | public void run() {
|
---|
515 | workflow_browse.setSelected(element.getEnabled("browse"));
|
---|
516 | workflow_create.setSelected(element.getEnabled("create"));
|
---|
517 | workflow_mirror.setSelected(element.getEnabled("mirror"));
|
---|
518 | workflow_gather.setSelected(element.getEnabled("gather"));
|
---|
519 | workflow_enrich.setSelected(element.getEnabled("enrich"));
|
---|
520 | workflow_design.setSelected(element.getEnabled("design"));
|
---|
521 | workflow_export.setSelected(element.getEnabled("export"));
|
---|
522 | workflow_preview.setSelected(element.getEnabled("preview"));
|
---|
523 | }
|
---|
524 | }
|
---|
525 | }
|
---|
526 |
|
---|
527 | private class LanguageComboboxListener
|
---|
528 | implements ActionListener {
|
---|
529 | public void actionPerformed(ActionEvent event) {
|
---|
530 | // Retrieve the entry
|
---|
531 | DictionaryEntry entry = (DictionaryEntry) language_combobox.getSelectedItem();
|
---|
532 | if(entry != null) {
|
---|
533 | Gatherer.dictionary.changeDictionary(entry.getLocale());
|
---|
534 | // Display message
|
---|
535 | JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("Preferences.General.Restart_Required"), Dictionary.newget("Preferences.General.Restart_Required"), JOptionPane.WARNING_MESSAGE);
|
---|
536 | }
|
---|
537 | }
|
---|
538 | }
|
---|
539 |
|
---|
540 | private class UseProxyListener
|
---|
541 | implements ActionListener {
|
---|
542 | public void actionPerformed(ActionEvent event) {
|
---|
543 | boolean enabled = use_proxy_checkbox.isSelected();
|
---|
544 | Gatherer.config.set("general.use_proxy", true, enabled);
|
---|
545 | // Fortunately this is already driven by the event thread.
|
---|
546 | proxy_host_field.setEnabled(enabled);
|
---|
547 | proxy_port_field.setEnabled(enabled);
|
---|
548 | }
|
---|
549 | }
|
---|
550 |
|
---|
551 | private class WorkflowElementWrapper {
|
---|
552 | private Element element;
|
---|
553 | private String text;
|
---|
554 | public WorkflowElementWrapper(Element element) {
|
---|
555 | this.element = element;
|
---|
556 | }
|
---|
557 | public boolean getEnabled(String name) {
|
---|
558 | boolean result = true;
|
---|
559 | if(element.getAttribute(name).equalsIgnoreCase("false")) {
|
---|
560 | result = false;
|
---|
561 | }
|
---|
562 | return result;
|
---|
563 | }
|
---|
564 | public String toString() {
|
---|
565 | if(text == null) {
|
---|
566 | text = element.getFirstChild().getNodeValue();
|
---|
567 | }
|
---|
568 | return text;
|
---|
569 | }
|
---|
570 | }
|
---|
571 | }
|
---|