001: /**
002: * L2FProd.com Common Components 7.3 License.
003: *
004: * Copyright 2005-2007 L2FProd.com
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package com.l2fprod.common.swing.plaf;
018:
019: import com.l2fprod.common.swing.JTaskPaneGroup;
020: import com.l2fprod.common.swing.plaf.windows.WindowsClassicLookAndFeelAddons;
021: import com.l2fprod.common.swing.plaf.windows.WindowsLookAndFeelAddons;
022: import com.l2fprod.common.util.JVM;
023: import com.l2fprod.common.util.OS;
024:
025: import java.awt.Color;
026: import java.awt.Font;
027: import java.awt.SystemColor;
028: import java.awt.Toolkit;
029: import java.lang.reflect.Method;
030: import java.util.Arrays;
031: import java.util.List;
032:
033: import javax.swing.UIDefaults;
034: import javax.swing.UIManager;
035: import javax.swing.plaf.ColorUIResource;
036: import javax.swing.plaf.FontUIResource;
037: import javax.swing.plaf.metal.MetalLookAndFeel;
038:
039: /**
040: * Addon for <code>JTaskPaneGroup</code>.<br>
041: *
042: * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
043: */
044: public class JTaskPaneGroupAddon extends AbstractComponentAddon {
045:
046: public JTaskPaneGroupAddon() {
047: super ("JTaskPaneGroup");
048: }
049:
050: protected void addBasicDefaults(LookAndFeelAddons addon,
051: List defaults) {
052: Font taskPaneFont = UIManager.getFont("Label.font");
053: if (taskPaneFont == null) {
054: taskPaneFont = new Font("Dialog", Font.PLAIN, 12);
055: }
056: taskPaneFont = taskPaneFont.deriveFont(Font.BOLD);
057:
058: Color menuBackground = new ColorUIResource(SystemColor.menu);
059: defaults
060: .addAll(Arrays
061: .asList(new Object[] {
062: JTaskPaneGroup.UI_CLASS_ID,
063: "com.l2fprod.common.swing.plaf.basic.BasicTaskPaneGroupUI",
064: "TaskPaneGroup.font",
065: new FontUIResource(taskPaneFont),
066: "TaskPaneGroup.background",
067: UIManager.getColor("List.background"),
068: "TaskPaneGroup.specialTitleBackground",
069: new ColorUIResource(menuBackground
070: .darker()),
071: "TaskPaneGroup.titleBackgroundGradientStart",
072: menuBackground,
073: "TaskPaneGroup.titleBackgroundGradientEnd",
074: menuBackground,
075: "TaskPaneGroup.titleForeground",
076: new ColorUIResource(
077: SystemColor.menuText),
078: "TaskPaneGroup.specialTitleForeground",
079: new ColorUIResource(
080: SystemColor.menuText)
081: .brighter(),
082: "TaskPaneGroup.animate",
083: Boolean.TRUE,
084: "TaskPaneGroup.focusInputMap",
085: new UIDefaults.LazyInputMap(
086: new Object[] { "ENTER",
087: "toggleExpanded",
088: "SPACE",
089: "toggleExpanded" }), }));
090: }
091:
092: protected void addMetalDefaults(LookAndFeelAddons addon,
093: List defaults) {
094: super .addMetalDefaults(addon, defaults);
095: // if using Ocean, use the Glossy l&f
096: String taskPaneGroupUI = "com.l2fprod.common.swing.plaf.metal.MetalTaskPaneGroupUI";
097: if (JVM.current().isOrLater(JVM.JDK1_5)) {
098: try {
099: Method method = MetalLookAndFeel.class.getMethod(
100: "getCurrentTheme", null);
101: Object currentTheme = method.invoke(null, null);
102: if (Class.forName("javax.swing.plaf.metal.OceanTheme")
103: .isInstance(currentTheme)) {
104: taskPaneGroupUI = "com.l2fprod.common.swing.plaf.misc.GlossyTaskPaneGroupUI";
105: }
106: } catch (Exception e) {
107: }
108: }
109: defaults.addAll(Arrays.asList(new Object[] {
110: JTaskPaneGroup.UI_CLASS_ID, taskPaneGroupUI,
111: "TaskPaneGroup.foreground",
112: UIManager.getColor("activeCaptionText"),
113: "TaskPaneGroup.background",
114: MetalLookAndFeel.getControl(),
115: "TaskPaneGroup.specialTitleBackground",
116: MetalLookAndFeel.getPrimaryControl(),
117: "TaskPaneGroup.titleBackgroundGradientStart",
118: MetalLookAndFeel.getPrimaryControl(),
119: "TaskPaneGroup.titleBackgroundGradientEnd",
120: MetalLookAndFeel.getPrimaryControlHighlight(),
121: "TaskPaneGroup.titleForeground",
122: MetalLookAndFeel.getControlTextColor(),
123: "TaskPaneGroup.specialTitleForeground",
124: MetalLookAndFeel.getControlTextColor(),
125: "TaskPaneGroup.borderColor",
126: MetalLookAndFeel.getPrimaryControl(),
127: "TaskPaneGroup.titleOver",
128: MetalLookAndFeel.getControl().darker(),
129: "TaskPaneGroup.specialTitleOver",
130: MetalLookAndFeel.getPrimaryControlHighlight() }));
131: }
132:
133: protected void addWindowsDefaults(LookAndFeelAddons addon,
134: List defaults) {
135: super .addWindowsDefaults(addon, defaults);
136:
137: if (addon instanceof WindowsLookAndFeelAddons) {
138: defaults
139: .addAll(Arrays
140: .asList(new Object[] {
141: JTaskPaneGroup.UI_CLASS_ID,
142: "com.l2fprod.common.swing.plaf.windows.WindowsTaskPaneGroupUI" }));
143:
144: String xpStyle = OS.getWindowsVisualStyle();
145: if (WindowsLookAndFeelAddons.HOMESTEAD_VISUAL_STYLE
146: .equalsIgnoreCase(xpStyle)) {
147: defaults.addAll(Arrays.asList(new Object[] {
148: "TaskPaneGroup.foreground",
149: new ColorUIResource(86, 102, 45),
150: "TaskPaneGroup.background",
151: new ColorUIResource(246, 246, 236),
152: "TaskPaneGroup.specialTitleBackground",
153: new ColorUIResource(224, 231, 184),
154: "TaskPaneGroup.titleBackgroundGradientStart",
155: new ColorUIResource(255, 255, 255),
156: "TaskPaneGroup.titleBackgroundGradientEnd",
157: new ColorUIResource(224, 231, 184),
158: "TaskPaneGroup.titleForeground",
159: new ColorUIResource(86, 102, 45),
160: "TaskPaneGroup.titleOver",
161: new ColorUIResource(114, 146, 29),
162: "TaskPaneGroup.specialTitleForeground",
163: new ColorUIResource(86, 102, 45),
164: "TaskPaneGroup.specialTitleOver",
165: new ColorUIResource(114, 146, 29),
166: "TaskPaneGroup.borderColor",
167: new ColorUIResource(255, 255, 255), }));
168: } else if (WindowsLookAndFeelAddons.SILVER_VISUAL_STYLE
169: .equalsIgnoreCase(xpStyle)) {
170: defaults.addAll(Arrays.asList(new Object[] {
171: "TaskPaneGroup.foreground",
172: new ColorUIResource(Color.black),
173: "TaskPaneGroup.background",
174: new ColorUIResource(240, 241, 245),
175: "TaskPaneGroup.specialTitleBackground",
176: new ColorUIResource(222, 222, 222),
177: "TaskPaneGroup.titleBackgroundGradientStart",
178: new ColorUIResource(Color.white),
179: "TaskPaneGroup.titleBackgroundGradientEnd",
180: new ColorUIResource(214, 215, 224),
181: "TaskPaneGroup.titleForeground",
182: new ColorUIResource(Color.black),
183: "TaskPaneGroup.titleOver",
184: new ColorUIResource(126, 124, 124),
185: "TaskPaneGroup.specialTitleForeground",
186: new ColorUIResource(Color.black),
187: "TaskPaneGroup.specialTitleOver",
188: new ColorUIResource(126, 124, 124),
189: "TaskPaneGroup.borderColor",
190: new ColorUIResource(Color.white), }));
191: } else if (OS.isWindowsVista()) {
192: final Toolkit toolkit = Toolkit.getDefaultToolkit();
193: defaults
194: .addAll(Arrays
195: .asList(new Object[] {
196: "TaskPaneGroup.foreground",
197: new ColorUIResource(Color.white),
198: "TaskPaneGroup.background",
199: new ColorUIResource(
200: (Color) toolkit
201: .getDesktopProperty("win.3d.backgroundColor")),
202: "TaskPaneGroup.specialTitleBackground",
203: new ColorUIResource(33, 89, 201),
204: "TaskPaneGroup.titleBackgroundGradientStart",
205: new ColorUIResource(Color.white),
206: "TaskPaneGroup.titleBackgroundGradientEnd",
207: new ColorUIResource(
208: (Color) toolkit
209: .getDesktopProperty("win.frame.inactiveCaptionColor")),
210: "TaskPaneGroup.titleForeground",
211: new ColorUIResource(
212: (Color) toolkit
213: .getDesktopProperty("win.frame.inactiveCaptionTextColor")),
214: "TaskPaneGroup.specialTitleForeground",
215: new ColorUIResource(Color.white),
216: "TaskPaneGroup.borderColor",
217: new ColorUIResource(Color.white), }));
218: } else {
219: defaults.addAll(Arrays.asList(new Object[] {
220: "TaskPaneGroup.foreground",
221: new ColorUIResource(Color.white),
222: "TaskPaneGroup.background",
223: new ColorUIResource(214, 223, 247),
224: "TaskPaneGroup.specialTitleBackground",
225: new ColorUIResource(33, 89, 201),
226: "TaskPaneGroup.titleBackgroundGradientStart",
227: new ColorUIResource(Color.white),
228: "TaskPaneGroup.titleBackgroundGradientEnd",
229: new ColorUIResource(199, 212, 247),
230: "TaskPaneGroup.titleForeground",
231: new ColorUIResource(33, 89, 201),
232: "TaskPaneGroup.specialTitleForeground",
233: new ColorUIResource(Color.white),
234: "TaskPaneGroup.borderColor",
235: new ColorUIResource(Color.white), }));
236: }
237: }
238:
239: if (addon instanceof WindowsClassicLookAndFeelAddons) {
240: defaults
241: .addAll(Arrays
242: .asList(new Object[] {
243: JTaskPaneGroup.UI_CLASS_ID,
244: "com.l2fprod.common.swing.plaf.windows.WindowsClassicTaskPaneGroupUI",
245: "TaskPaneGroup.foreground",
246: new ColorUIResource(Color.black),
247: "TaskPaneGroup.background",
248: new ColorUIResource(Color.white),
249: "TaskPaneGroup.specialTitleBackground",
250: new ColorUIResource(10, 36, 106),
251: "TaskPaneGroup.titleBackgroundGradientStart",
252: new ColorUIResource(212, 208, 200),
253: "TaskPaneGroup.titleBackgroundGradientEnd",
254: new ColorUIResource(212, 208, 200),
255: "TaskPaneGroup.titleForeground",
256: new ColorUIResource(Color.black),
257: "TaskPaneGroup.specialTitleForeground",
258: new ColorUIResource(Color.white),
259: "TaskPaneGroup.borderColor",
260: new ColorUIResource(212, 208, 200), }));
261: }
262: }
263:
264: protected void addMacDefaults(LookAndFeelAddons addon, List defaults) {
265: super .addMacDefaults(addon, defaults);
266: defaults
267: .addAll(Arrays
268: .asList(new Object[] {
269: JTaskPaneGroup.UI_CLASS_ID,
270: "com.l2fprod.common.swing.plaf.misc.GlossyTaskPaneGroupUI",
271: "TaskPaneGroup.background",
272: new ColorUIResource(245, 245, 245),
273: "TaskPaneGroup.titleForeground",
274: new ColorUIResource(Color.black),
275: "TaskPaneGroup.specialTitleBackground",
276: new ColorUIResource(188, 188, 188),
277: "TaskPaneGroup.specialTitleForeground",
278: new ColorUIResource(Color.black),
279: "TaskPaneGroup.titleBackgroundGradientStart",
280: new ColorUIResource(250, 250, 250),
281: "TaskPaneGroup.titleBackgroundGradientEnd",
282: new ColorUIResource(188, 188, 188),
283: "TaskPaneGroup.borderColor",
284: new ColorUIResource(97, 97, 97),
285: "TaskPaneGroup.titleOver",
286: new ColorUIResource(125, 125, 97),
287: "TaskPaneGroup.specialTitleOver",
288: new ColorUIResource(125, 125, 97), }));
289: }
290:
291: }
|