KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > themes > plugin > PlasticLookAndFeelPlugin


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
19 import java.util.List JavaDoc;
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 JavaDoc {
46
47         Options.setDefaultIconSize(new Dimension JavaDoc(16, 16));
48         Options.setUseNarrowButtons(false);
49         Options.setPopupDropShadowEnabled(true);
50         
51         XmlElement options = Config.getInstance().get("options").getElement(
52                 "/options");
53         XmlElement gui = options.getElement("gui");
54         XmlElement themeElement = gui.getElement("theme");
55
56         try {
57             // UIManager.setLookAndFeel(lafName);
58
String JavaDoc theme = themeElement.getAttribute("theme");
59
60             if (theme != null) {
61                 PlasticTheme t = getTheme(theme);
62                 LookUtils.setLookAndTheme(new PlasticXPLookAndFeel(), t);
63             } else {
64                 PlasticTheme t = PlasticLookAndFeel.createMyDefaultTheme();
65                 LookUtils.setLookAndTheme(new PlasticXPLookAndFeel(), t);
66             }
67
68         } catch (Exception JavaDoc e) {
69             System.err.println("Can't set look & feel:" + e);
70         }
71
72         ;
73     }
74
75     protected PlasticTheme[] computeThemes() {
76         List JavaDoc themes = PlasticLookAndFeel.getInstalledThemes();
77
78         return (PlasticTheme[]) themes.toArray(new PlasticTheme[themes.size()]);
79     }
80
81     protected PlasticTheme getTheme(String JavaDoc name) {
82         PlasticTheme[] themes = computeThemes();
83
84         for (int i = 0; i < themes.length; i++) {
85             String JavaDoc str = themes[i].getName();
86
87             if (name.equals(str)) {
88                 return themes[i];
89             }
90         }
91
92         return null;
93     }
94 }
95
Popular Tags