01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.gui.themes.plugin;
17:
18: import java.awt.Dimension;
19: import java.util.List;
20:
21: import org.columba.core.config.Config;
22: import org.columba.core.xml.XmlElement;
23:
24: import com.jgoodies.looks.LookUtils;
25: import com.jgoodies.looks.Options;
26: import com.jgoodies.looks.plastic.PlasticLookAndFeel;
27: import com.jgoodies.looks.plastic.PlasticTheme;
28: import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
29:
30: /**
31: * JGoodies Looks L&F plugin
32: * @author frd
33: */
34: public class PlasticLookAndFeelPlugin extends AbstractThemePlugin {
35: /**
36: *
37: */
38: public PlasticLookAndFeelPlugin() {
39: super ();
40: }
41:
42: /**
43: * @see org.columba.core.gui.themes.plugin.AbstractThemePlugin#setLookAndFeel()
44: */
45: public void setLookAndFeel() throws Exception {
46:
47: Options.setDefaultIconSize(new Dimension(16, 16));
48: Options.setUseNarrowButtons(false);
49: Options.setPopupDropShadowEnabled(true);
50:
51: XmlElement options = Config.getInstance().get("options")
52: .getElement("/options");
53: XmlElement gui = options.getElement("gui");
54: XmlElement themeElement = gui.getElement("theme");
55:
56: try {
57: // UIManager.setLookAndFeel(lafName);
58: String theme = themeElement.getAttribute("theme");
59:
60: if (theme != null) {
61: PlasticTheme t = getTheme(theme);
62: LookUtils
63: .setLookAndTheme(new PlasticXPLookAndFeel(), t);
64: } else {
65: PlasticTheme t = PlasticLookAndFeel
66: .createMyDefaultTheme();
67: LookUtils
68: .setLookAndTheme(new PlasticXPLookAndFeel(), t);
69: }
70:
71: } catch (Exception e) {
72: System.err.println("Can't set look & feel:" + e);
73: }
74:
75: ;
76: }
77:
78: protected PlasticTheme[] computeThemes() {
79: List themes = PlasticLookAndFeel.getInstalledThemes();
80:
81: return (PlasticTheme[]) themes.toArray(new PlasticTheme[themes
82: .size()]);
83: }
84:
85: protected PlasticTheme getTheme(String name) {
86: PlasticTheme[] themes = computeThemes();
87:
88: for (int i = 0; i < themes.length; i++) {
89: String str = themes[i].getName();
90:
91: if (name.equals(str)) {
92: return themes[i];
93: }
94: }
95:
96: return null;
97: }
98: }
|