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

Last change on this file since 5983 was 5983, checked in by jmt12, 21 years ago

Fixed a bit of code where it was possible to assign configuration settings to a null document

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