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

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

Further along the tooltip highway. Hacked up the Dictionary code, and are updating the classes to use the new code.

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