|
1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.client.swing; |
|
27 |
|
28 import java.awt.Color; |
|
29 import java.io.IOException; |
|
30 import java.util.*; |
|
31 import javax.swing.UIManager; |
|
32 import com.oracle.solaris.vp.util.misc.TypedPropertiesWrapper; |
|
33 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
34 import com.oracle.solaris.vp.util.swing.*; |
|
35 |
|
36 @SuppressWarnings({"serial"}) |
|
37 public class AppProperties extends Properties { |
|
38 // |
|
39 // Static data |
|
40 // |
|
41 |
|
42 public static final String RESOURCE_NAME = "runtime.properties"; |
|
43 |
|
44 public static final AppProperties singleton = new AppProperties(); |
|
45 |
|
46 // |
|
47 // Instance data |
|
48 // |
|
49 |
|
50 private TypedPropertiesWrapper wrapper; |
|
51 |
|
52 // |
|
53 // Constructors |
|
54 // |
|
55 |
|
56 private AppProperties() { |
|
57 wrapper = new TypedPropertiesWrapper(this); |
|
58 |
|
59 try { |
|
60 load(Finder.getResource(RESOURCE_NAME).openStream()); |
|
61 |
|
62 // Load common defaults if available |
|
63 try { |
|
64 Color c = wrapper.getColor(HyperlinkLabel.KEY_UNVISITED); |
|
65 UIManager.put(HyperlinkLabel.KEY_UNVISITED, c); |
|
66 } catch (NoSuchElementException ignore) { |
|
67 } |
|
68 |
|
69 try { |
|
70 Color c = wrapper.getColor(HyperlinkLabel.KEY_VISITED); |
|
71 UIManager.put(HyperlinkLabel.KEY_VISITED, c); |
|
72 } catch (NoSuchElementException ignore) { |
|
73 } |
|
74 |
|
75 try { |
|
76 String value = getProperty(HyperlinkLabel.KEY_UNDERLINE_POLICY); |
|
77 HyperlinkLabel.UnderlinePolicy policy = |
|
78 HyperlinkLabel.UnderlinePolicy.valueOf(value); |
|
79 UIManager.put(HyperlinkLabel.KEY_UNDERLINE_POLICY, policy); |
|
80 } catch (Throwable ignore) { |
|
81 } |
|
82 } catch (IOException e) { |
|
83 // Unlikely -- the resource should always exist and be accessible |
|
84 } |
|
85 |
|
86 GUIUtil.setUIPreferences(this); |
|
87 } |
|
88 |
|
89 // |
|
90 // AppProperties methods |
|
91 // |
|
92 |
|
93 public TypedPropertiesWrapper getWrapper() { |
|
94 return wrapper; |
|
95 } |
|
96 } |