source: trunk/gli/src/org/greenstone/gatherer/Configuration.java@ 5564

Last change on this file since 5564 was 5564, checked in by mdewsnip, 21 years ago

Many more small improvements and tooltips added. Still more to come!

  • Property svn:keywords set to Author Date Id Revision
File size: 28.5 KB
Line 
1package org.greenstone.gatherer;
2/**
3 *#########################################################################
4 *
5 * A component of the Gatherer application, part of the Greenstone digital
6 * library suite from the New Zealand Digital Library Project at the
7 * University of Waikato, New Zealand.
8 *
9 * <BR><BR>
10 *
11 * Author: John Thompson, Greenstone Digital Library, University of Waikato
12 *
13 * <BR><BR>
14 *
15 * Copyright (C) 1999 New Zealand Digital Library Project
16 *
17 * <BR><BR>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * <BR><BR>
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * <BR><BR>
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 *########################################################################
37 */
38import java.awt.*;
39import java.io.*;
40import java.lang.ref.*;
41import java.net.*;
42import java.util.*;
43import javax.swing.*;
44import javax.swing.plaf.*;
45import org.greenstone.gatherer.cdm.Language;
46import org.greenstone.gatherer.gui.Coloring;
47import org.greenstone.gatherer.msm.MSMUtils;
48import org.greenstone.gatherer.util.GURL;
49import org.greenstone.gatherer.util.Utility;
50import org.w3c.dom.*;
51/** This class stores the various configurable settings inside the Gatherer, both during a session, and between sessions in the form of XML. However not all data members are retained during xml serialization. To further improve efficiency, the property-name -> DOM Element pairs are stored in a SoftReferenced Hashtable.
52 * @author John Thompson, Greenstone Digital Library, University of Waikato
53 * @version 2.3
54 */
55public class Configuration
56 extends Hashtable {
57
58 static final public boolean COLLECTION_SPECIFIC = true;
59 static final public boolean GENERAL_SETTING = true;
60
61 /** The string identifying an argument's name attribute. */
62 static final private String ARGUMENT_NAME = "name";
63 /** The name of the general Gatherer configuration file. */
64 static final private String CONFIG_XML = "config.xml";
65 /** The name of the root element of the subtree containing gatherer configuration options. This is required as the document itself may contain several other subtrees of settings (such as in the case of a '.col' file). */
66 static final private String GATHERER_CONFIG = "GathererConfig";
67 /** The string identifying an argument element. */
68 static final private String GATHERER_CONFIG_ARGUMENT = "Argument";
69 /** The name of a Name Element. */
70 static final private String NAME = "Name";
71 /** The name of the other arguments element. */
72 static final private String OTHER = "Other";
73 /** The name of an information Element within the Other subtree. */
74 static final private String OTHER_INFO = "Info";
75 /** The name of the general Gatherer configuration template. */
76 static final private String TEMPLATE_CONFIG_XML = "xml/config.xml";
77 /** The first of two patterns used during tokenization, this pattern handles a comma separated list. */
78 static final private String TOKENIZER_PATTERN1 = " ,\n\t";
79 /** The second of two patterns used during tokenization, this pattern handles an underscore separated list. */
80 static final private String TOKENIZER_PATTERN2 = "_\n\t";
81
82 public File exec_file;
83 /** The path (or url) to the webserver which is serving the Greenstone collection. */
84 public String exec_path = null;
85 /** The path to the Greenstone Suite installation directory. */
86 public String gsdl_path = "";
87 /** The path to the PERL executable, up to and including Perl.exe. */
88 public String perl_path = "";
89 /** The password for the proxy server indicated above. */
90 public String proxy_pass = null;
91 /** The username for the proxy server indicated above. */
92 public String proxy_user = null;
93 /** The language selected for the interface. Currently hard-wired. */
94 public String interface_language = "en";
95 /** The screen size of the desktop the Gatherer will be displayed on. */
96 public Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
97 /** Collection level configuration (which in some cases overrides general configuration. */
98 private Document collection_config;
99 /** The general configuration settings. */
100 private Document general_config;
101 private int cache_hit = 0;
102 private int cache_miss = 0;
103 public URL exec_address = null;
104
105 /** Constructor.
106 * @param gsdl_path The path to the Greenstone directory as a <strong>String</strong>.
107 * @param exec_path A <strong>String</strong> containing the path or url to the webserver serving the greenstone collections.
108 * @param perl_path The path to the PERL executable, as a <strong>String</strong>.
109 */
110 public Configuration(String gsdl_path, String exec_path, String perl_path) {
111 super();
112 this.gsdl_path = gsdl_path;
113 this.exec_path = exec_path;
114 // The exec_path may contain an url address, in which case we blindly use that and leave it up to the user to worry about settings and resetting.
115 Gatherer.println("EXEC_PATH = " + exec_path);
116 if(exec_path != null && exec_path.length() > 0) {
117 try {
118 exec_address = new URL(exec_path);
119 }
120 catch (MalformedURLException error) {
121 ///ystem.err.println("Not an address.");
122 }
123 }
124 // If the above failed, then its up to us to try and figure out what to do.
125 if(exec_address == null) {
126 // Try building a file from the given exec_path
127 try {
128 File local_file = new File(exec_path);
129 if(local_file.exists()) {
130 // All good. I hope.
131 exec_file = local_file;
132 }
133 else {
134 ///ystem.err.println("No local library at given file path.");
135 }
136 }
137 // All sorts of errors might be thrown by a bogus file path.
138 catch (Exception error) {
139 Gatherer.println("Not a valid file.");
140 }
141 // We can generate the path to where the local library should be and use that if it is there.
142 if(exec_file == null) {
143 File server_exe = new File(gsdl_path + Utility.SERVER_EXE);
144 if(server_exe.exists()) {
145 exec_file = server_exe;
146 }
147 else {
148 ///ystem.err.println("No local library.");
149 }
150 }
151 // If we get to here with no exec_address nor an exec_file its just plain not going to work.
152 }
153 else {
154 ///ystem.err.println("exec_address != null -> " + exec_address);
155 }
156 ///ystem.err.println("Perl path.");
157 this.perl_path = perl_path;
158 // Ensure the perl path includes exe under windoze
159 if(Utility.isWindows() && !perl_path.toLowerCase().endsWith(".exe")) {
160 if(!perl_path.endsWith(File.separator)) {
161 perl_path = perl_path + File.separator;
162 }
163 perl_path = perl_path + "perl.exe";
164 }
165 // Try to reload the configuration.
166 File config_xml = new File(CONFIG_XML);
167 if(config_xml.exists()) {
168 general_config = Utility.parse(CONFIG_XML, false);
169 }
170 // If that fails retrieve the default configuration file from our xml library, which I'll personally guarantee to work.
171 if(general_config == null) {
172 general_config = Utility.parse(TEMPLATE_CONFIG_XML, true);
173 Gatherer.println("Loaded default Gatherer configuration template.");
174 }
175 else {
176 Gatherer.println("Loaded current Gatherer configuration.");
177 }
178 // Re-establish the color settings.
179 updateUI();
180
181 // If we have no exec_address, see if one was specified in the config file
182 if (exec_address == null) {
183 String exec_address_string = getString("general.exec_address", true);
184 if (!exec_address_string.equals("")) {
185 try {
186 exec_address = new URL(exec_address_string);
187 }
188 catch (MalformedURLException error) {
189 ///ystem.err.println("Error: Bad address: " + exec_address_string);
190 }
191 }
192 }
193
194 Gatherer.println("EXEC_FILE = " + exec_file);
195 Gatherer.println("EXEC_ADDRESS = " + exec_address);
196 }
197
198 /** The default get action retrieves the named property from the desired configuration, and returns a true or false. */
199 public boolean get(String property, boolean general) {
200 String raw = getString(property, general);
201 return (raw != null && raw.equalsIgnoreCase("true"));
202 }
203
204 /** Retrieve all of the configuration preferences which match a certain string. They are returned as a hash map of property names to String objects. */
205 public HashMap getAll(String property_pattern, boolean general) {
206 HashMap properties = new HashMap();
207 try {
208 // Locate the appropriate element
209 Element document_element = null;
210 if(general) {
211 document_element = general_config.getDocumentElement();
212 }
213 else if(collection_config != null) {
214 document_element = collection_config.getDocumentElement();
215 }
216 if(document_element != null) {
217 // Retrieve the Gatherer element
218 Element gatherer_element = (Element) MSMUtils.getNodeFromNamed(document_element, GATHERER_CONFIG);
219 NodeList arguments = gatherer_element.getElementsByTagName(GATHERER_CONFIG_ARGUMENT);
220 for(int i = 0; i < arguments.getLength(); i++) {
221 Element argument_element = (Element) arguments.item(i);
222 if(argument_element.getAttribute(ARGUMENT_NAME).matches(property_pattern)) {
223 String result = MSMUtils.getValue(argument_element);
224 // Store a mapping in the cache. Sometimes we will overwrite an existing value (say for collection and general level workflow options) but the processing overhead of detecting these clashes far exceeds any savings.
225 put(argument_element.getAttribute(ARGUMENT_NAME) + general, new SoftReference(argument_element));
226 // Add mapping to the properties we're going to return
227 properties.put(argument_element.getAttribute(ARGUMENT_NAME), result);
228 }
229 }
230 }
231 }
232 catch(Exception error) {
233 }
234 return properties;
235 }
236
237 /** Retrieve the information subtree containing the arguments for the desired external program. If the program has marked superclasses append their arguments as well. */
238 public Element getArguments(String filename) {
239 Element argument_element = null;
240 try {
241 // Retrieve the other information subtree.
242 Element document_element = general_config.getDocumentElement();
243 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER);
244 NodeList argument_elements = other_element.getElementsByTagName(OTHER_INFO);
245 for(int i = 0; argument_element == null && i < argument_elements.getLength(); i++) {
246 Element possible_element = (Element) argument_elements.item(i);
247 Element possible_name_element = (Element) MSMUtils.getNodeFromNamed(possible_element, NAME);
248 String possible_name = MSMUtils.getValue(possible_name_element);
249 ///ystem.err.println("Does " + possible_name + " equal " + filename);
250 if(possible_name.equalsIgnoreCase(filename)) {
251 argument_element = possible_element;
252 }
253 possible_name = null;
254 possible_name_element = null;
255 possible_element = null;
256 }
257 argument_elements = null;
258 other_element = null;
259 document_element = null;
260 }
261 catch(Exception error) {
262 }
263 return argument_element;
264 }
265
266 /** Retrieve the value of the named property as a Rectangle. */
267 public Rectangle getBounds(String property, boolean general) {
268 Rectangle result = null;
269 try {
270 String raw = getString(property, general);
271 // Rectangle is (x, y, width, height)
272 StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
273 int x = Integer.parseInt(tokenizer.nextToken());
274 int y = Integer.parseInt(tokenizer.nextToken());
275 int width = Integer.parseInt(tokenizer.nextToken());
276 int height = Integer.parseInt(tokenizer.nextToken());
277 result = new Rectangle(x, y, width, height);
278 }
279 catch(Exception error) {
280 Gatherer.printStackTrace(error);
281 }
282 return result;
283 }
284
285 /** Retrieve the value of the named property as a Color. */
286 public Color getColor(String property, boolean general) {
287 Color result = Color.white; // Default
288 try {
289 String raw = getString(property, general);
290 // Color is a RGB triplet list, comma separated (also remove whitespace)
291 StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
292 int red = Integer.parseInt(tokenizer.nextToken());
293 int green = Integer.parseInt(tokenizer.nextToken());
294 int blue = Integer.parseInt(tokenizer.nextToken());
295 result = new Color(red, green, blue);
296 }
297 catch(Exception error) {
298 Gatherer.printStackTrace(error);
299 }
300 return result;
301 }
302
303 /** Retrieve the value of the named property as a Dimension. */
304 public Dimension getDimension(String property, boolean general) {
305 Dimension result = new Dimension(100, 100); // Default
306 try {
307 String raw = getString(property, general);
308 // Dimension is a width by height pair, comma separated (also remove whitespace)
309 StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
310 int width = Integer.parseInt(tokenizer.nextToken());
311 int height = Integer.parseInt(tokenizer.nextToken());
312 result = new Dimension(width, height);
313 }
314 catch(Exception error) {
315 Gatherer.printStackTrace(error);
316 }
317 return result;
318 }
319
320 /** Retrieve the value of the named property as a FontUIResource. */
321 public FontUIResource getFont(String property, boolean general) {
322 FontUIResource result = new FontUIResource("Times New Roman", Font.PLAIN, 10);
323 try {
324 String raw = getString(property, general);
325 // Font is a face, style, size triplet.
326 StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN1);
327 String face = tokenizer.nextToken();
328 int style = Font.PLAIN;
329 String temp = tokenizer.nextToken().toUpperCase();
330 if(temp.equals("BOLD")) {
331 style = Font.BOLD;
332 }
333 else if(temp.equals("ITALIC")) {
334 style = Font.ITALIC;
335 }
336 int size = Integer.parseInt(tokenizer.nextToken());
337 result = new FontUIResource(face, style, size);
338 }
339 catch(Exception error) {
340 Gatherer.printStackTrace(error);
341 }
342 return result;
343 }
344
345 /** Retrieve the value of the named property as an integer. */
346 public int getInt(String property, boolean general) {
347 int result = -1;
348 try {
349 String raw = getString(property, general);
350 result = Integer.parseInt(raw);
351 }
352 catch(Exception error) {
353 Gatherer.printStackTrace(error);
354 }
355 return result;
356 }
357
358 /** Retrieve the value of the named property as a Locale. */
359 public Locale getLocale(String property, boolean general) {
360 Locale result = Locale.getDefault();
361 try {
362 String raw = getString(property, general);
363 // Locale is a underscore separated code.
364 StringTokenizer tokenizer = new StringTokenizer(raw, TOKENIZER_PATTERN2);
365 String language = tokenizer.nextToken();
366 if(tokenizer.hasMoreTokens()) {
367 String country = tokenizer.nextToken();
368 result = new Locale(language, country);
369 }
370 else {
371 result = new Locale(language);
372 }
373 }
374 catch(Exception error) {
375 Gatherer.printStackTrace(error);
376 }
377 return result;
378 }
379
380 /** Retrieve the value of the named property, and noting whether we consult the general or collection specific configuration. */
381 public String getString(String property, boolean general) {
382 // Its up to this method to find the appropriate node and retrieve the data itself.
383 String result = "";
384 try {
385 // First of all we look in the cache to see if we have a match.
386 SoftReference reference = (SoftReference) get(property + general);
387 if(reference != null) {
388 Element argument_element = (Element) reference.get();
389 if(argument_element != null) {
390 cache_hit++;
391 result = MSMUtils.getValue(argument_element);
392 }
393 }
394 // We may have missed in the cache, or the reference may have been consumed.
395 if(result.length() == 0) {
396 cache_miss++;
397 // Locate the appropriate element
398 Element document_element = null;
399 if(general) {
400 document_element = general_config.getDocumentElement();
401 }
402 else if(collection_config != null) {
403 document_element = collection_config.getDocumentElement();
404 }
405 if(document_element != null) {
406 // Retrieve the Gatherer element
407 Element gatherer_element = (Element) MSMUtils.getNodeFromNamed(document_element, GATHERER_CONFIG);
408 NodeList arguments = gatherer_element.getElementsByTagName(GATHERER_CONFIG_ARGUMENT);
409 for(int i = 0; result.length() == 0 && i < arguments.getLength(); i++) {
410 Element argument_element = (Element) arguments.item(i);
411 if(argument_element.getAttribute(ARGUMENT_NAME).equalsIgnoreCase(property)) {
412 result = MSMUtils.getValue(argument_element);
413 // Store a mapping in the cache. Sometimes we will overwrite an existing value (say for collection and general level workflow options) but the processing overhead of detecting these clashes far exceeds any savings.
414 put(property + general, new SoftReference(argument_element));
415 }
416 }
417 }
418 }
419 }
420 catch (Exception error) {
421 Gatherer.printStackTrace(error);
422 }
423 // If we still have no result, and the search was made in the collection configuration, retrieve the general one instead.
424 if(result.length() == 0 && !general) {
425 result = getString(property, true);
426 }
427 return result;
428 }
429
430 /** Retrieve the path to the PERL scripts within the Greenstone directory.
431 * @return A <strong>String</strong> containing the path.
432 */
433 public String getScriptPath() {
434 return gsdl_path + "bin" + File.separator + "script" + File.separator;
435 }
436
437 /** Export the general configuration to file. */
438 public void save() {
439 ///ystem.err.println("Hits " + cache_hit + " vs Misses " + cache_miss);
440 Utility.export(general_config, Utility.BASE_DIR + CONFIG_XML);
441 }
442
443 /** Set the named property, from the specified configuration, using the given boolean value. */
444 public void set(String property, boolean general, boolean value) {
445 if(property.startsWith("workflow")) {
446 System.err.println("Set property: " + property + ", general=" + general + ", value=" + value);
447 }
448 setString(property, general, (value ? "true" : "false"));
449 }
450
451 /** Add a subtree of argument information to the other arguments part of the general configuration. This overwrites any such existing subtree. */
452 public void setArguments(Element arguments_element) {
453 try {
454 Element document_element = general_config.getDocumentElement();
455 Element other_element = (Element) MSMUtils.getNodeFromNamed(document_element, OTHER);
456 // Retrieve the name of the information
457 Element arguments_name_element = (Element)MSMUtils.getNodeFromNamed(arguments_element, NAME);
458 String filename = MSMUtils.getValue(arguments_element);
459 // Find any argument information subtree starting with the same name
460 Element obsolete_arguments_element = getArguments(filename);
461 // Create a copy of the arguments_element within our tree (import).
462 Element our_arguments_element = (Element) general_config.importNode(arguments_element, true);
463 // Now we insert this new node into the tree. If a previous node exists we replace it instead.
464 if(obsolete_arguments_element == null) {
465 other_element.appendChild(our_arguments_element);
466 }
467 else {
468 other_element.replaceChild(our_arguments_element, obsolete_arguments_element);
469 }
470 our_arguments_element = null;
471 obsolete_arguments_element = null;
472 filename = null;
473 arguments_name_element = null;
474 other_element = null;
475 document_element = null;
476 }
477 catch (Exception error) {
478 Gatherer.println("Error in Configuration.setArguments(): " + error);
479 Gatherer.printStackTrace(error);
480 }
481 }
482
483 /** Set the collection configuration. */
484 public void setCollectionConfiguration(Document collection_config) {
485 this.collection_config = collection_config;
486 updateUI();
487 ///atherer.println("Collection configuration set.");
488 }
489
490 /** Set the named property, from the specified configuration, using the given Rectangle value. */
491 public void setBounds(String property, boolean general, Rectangle value) {
492 StringBuffer text = new StringBuffer("");
493 text.append(value.x);
494 text.append(", ");
495 text.append(value.y);
496 text.append(", ");
497 text.append(value.width);
498 text.append(", ");
499 text.append(value.height);
500 setString(property, general, text.toString());
501 }
502
503 /** Set the named property, from the specified configuration, using the given Color value. */
504 public void setColor(String property, boolean general, Color value) {
505 StringBuffer text = new StringBuffer("");
506 text.append(value.getRed());
507 text.append(", ");
508 text.append(value.getGreen());
509 text.append(", ");
510 text.append(value.getBlue());
511 setString(property, general, text.toString());
512 }
513
514 /** Set the named property, from the specified configuration, using the given Dimension value. */
515 public void setDimension(String property, boolean general, Dimension value) {
516 StringBuffer text = new StringBuffer("");
517 text.append(value.width);
518 text.append(", ");
519 text.append(value.height);
520 setString(property, general, text.toString());
521 }
522
523 /** Set the named property, from the specified configuration, using the given Font value. */
524 public void setFont(String property, boolean general, Font value) {
525 StringBuffer text = new StringBuffer("");
526 text.append(value.getName());
527 text.append(", ");
528 switch(value.getStyle()) {
529 case Font.BOLD:
530 text.append("BOLD");
531 break;
532 case Font.ITALIC:
533 text.append("ITALIC");
534 break;
535 default:
536 text.append("PLAIN");
537 }
538 text.append(", ");
539 text.append(value.getSize());
540 setString(property, general, text.toString());
541 }
542
543 /** Set the named property, from the specified configuration, using the given integer value. */
544 public void setInt(String property, boolean general, int value) {
545 setString(property, general, String.valueOf(value));
546 }
547
548 /** Set the named property, from the specified configuration, using the given Locale value. */
549 public void setLocale(String property, boolean general, Locale value) {
550 StringBuffer text = new StringBuffer("");
551 text.append(value.getLanguage());
552 String country = value.getCountry();
553 if(country != null && country.length() > 0) {
554 text.append("_");
555 text.append(country);
556 }
557 country = null;
558 setString(property, general, text.toString());
559 }
560
561 /** Sets the value of the named property argument using the given string. */
562 public void setString(String property, boolean general, String value) {
563 Gatherer.println("Set configuration property: " + property + " = " + value + (general ? "" : " [Collection]"));
564 try {
565 Document document = null;
566 if(general) {
567 document = general_config;
568 }
569 else if(collection_config != null) {
570 document = collection_config;
571 }
572 if(document != null) {
573 Element argument_element = null;
574 // Try to retrieve from cache
575 SoftReference reference = (SoftReference) get(property + general);
576 if(reference != null) {
577 argument_element = (Element) reference.get();
578 }
579 if(argument_element == null) {
580 Element document_element = document.getDocumentElement();
581 Element gatherer_element = (Element) MSMUtils.getNodeFromNamed(document_element, GATHERER_CONFIG);
582 NodeList arguments = document_element.getElementsByTagName(GATHERER_CONFIG_ARGUMENT);
583 boolean found = false;
584 for(int i = 0; argument_element == null && i < arguments.getLength(); i++) {
585 Element possible_element = (Element) arguments.item(i);
586 if(possible_element.getAttribute(ARGUMENT_NAME).equalsIgnoreCase(property)) {
587 argument_element = possible_element;
588 }
589 }
590 // If argument element is still null, create it in the target document.
591 if(argument_element == null) {
592 argument_element = document.createElement(GATHERER_CONFIG_ARGUMENT);
593 argument_element.setAttribute(ARGUMENT_NAME, property);
594 gatherer_element.appendChild(argument_element);
595 }
596 // Update cache
597 put(property + general, new SoftReference(argument_element));
598
599 }
600 if(value == null) {
601 value = "";
602 }
603 // Now remove any current text node children.
604 NodeList children = argument_element.getChildNodes();
605 for(int i = 0; i < children.getLength(); i++) {
606 argument_element.removeChild(children.item(i));
607 }
608 // Add a new text node child with the new value
609 argument_element.appendChild(document.createTextNode(value));
610 }
611 }
612 catch (Exception error) {
613 }
614 }
615
616 private void updateUI() {
617 // Buttons
618 UIManager.put("Button.select", new ColorUIResource(getColor("coloring.button_selected_background", false)));
619 UIManager.put("Button.background", new ColorUIResource(getColor("coloring.button_background", false)));
620 UIManager.put("Button.foreground", new ColorUIResource(getColor("coloring.button_foreground", false)));
621
622 UIManager.put("ToggleButton.background", new ColorUIResource(getColor("coloring.button_background", false)));
623 UIManager.put("ToggleButton.foreground", new ColorUIResource(getColor("coloring.button_foreground", false)));
624 UIManager.put("ToggleButton.select", new ColorUIResource(getColor("coloring.button_selected_background", false)));
625
626 // All the things with a lovely Collection green background
627 UIManager.put("OptionPane.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
628 UIManager.put("Panel.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
629 UIManager.put("Label.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
630 UIManager.put("TabbedPane.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
631 UIManager.put("SplitPane.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
632 UIManager.put("CheckBox.background", new ColorUIResource(getColor("coloring.collection_heading_background", false)));
633
634
635 // Editable coloring
636 UIManager.put("ComboBox.background", new ColorUIResource(getColor("coloring.collection_tree_background", false))); // Indicate clickable
637 UIManager.put("Tree.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
638 UIManager.put("Tree.textBackground", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
639 UIManager.put("ProgressBar.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
640 UIManager.put("TextArea.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
641 UIManager.put("TextField.background", new ColorUIResource(getColor("coloring.editable_background", false)));
642 UIManager.put("Table.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
643 UIManager.put("List.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
644 UIManager.put("RadioButton.background", new ColorUIResource(getColor("coloring.collection_tree_background", false)));
645
646 // Selection color
647 UIManager.put("TabbedPane.selected", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
648 UIManager.put("Tree.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
649 UIManager.put("ComboBox.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
650 UIManager.put("ProgressBar.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
651 UIManager.put("TextArea.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
652 UIManager.put("TextField.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
653 UIManager.put("List.selectionBackground", new ColorUIResource(getColor("coloring.collection_selection_background", false)));
654
655 // Scroll bar stuff
656 UIManager.put("ScrollBar.background", new ColorUIResource(getColor("coloring.scrollbar_background", false)));
657 UIManager.put("ScrollBar.thumb", new ColorUIResource(getColor("coloring.scrollbar_foreground", false)));
658 if(Gatherer.g_man != null) {
659 JPanel pane = (JPanel) Gatherer.g_man.getContentPane();
660 pane.updateUI();
661 // Also update all of the tabs according to workflow.
662 Gatherer.g_man.workflowUpdate("Hunt", get("workflow.browse", false));
663 Gatherer.g_man.workflowUpdate("Mirror", get("workflow.mirror", false));
664 Gatherer.g_man.workflowUpdate("Gather", get("workflow.gather", false));
665 Gatherer.g_man.workflowUpdate("Enrich", get("workflow.enrich", false));
666 Gatherer.g_man.workflowUpdate("Design", get("workflow.design", false));
667 Gatherer.g_man.workflowUpdate("Export", get("workflow.export", false));
668 Gatherer.g_man.workflowUpdate("Create", get("workflow.create", false));
669 Gatherer.g_man.workflowUpdate("Preview", get("workflow.preview", false));
670 }
671 }
672}
Note: See TracBrowser for help on using the repository browser.