root / branches / v2_0_0_prep / libraries / libCorePlugin / src / org / gvsig / coreplugin / preferences / general / SkinPreferences.java @ 38608
History | View | Annotate | Download (4.05 KB)
1 | 29630 | jpiera | package org.gvsig.coreplugin.preferences.general; |
---|---|---|---|
2 | 16108 | vcaballero | |
3 | |||
4 | import java.awt.event.ActionEvent; |
||
5 | import java.awt.event.ActionListener; |
||
6 | import java.util.HashMap; |
||
7 | import java.util.Iterator; |
||
8 | import java.util.Vector; |
||
9 | import java.util.prefs.Preferences; |
||
10 | |||
11 | import javax.swing.ImageIcon; |
||
12 | import javax.swing.JLabel; |
||
13 | import javax.swing.JOptionPane; |
||
14 | import javax.swing.JPanel; |
||
15 | |||
16 | 29630 | jpiera | import org.gvsig.andami.Launcher; |
17 | import org.gvsig.andami.PluginServices; |
||
18 | import org.gvsig.andami.plugins.config.generate.PluginConfig; |
||
19 | import org.gvsig.andami.plugins.config.generate.SkinExtension; |
||
20 | import org.gvsig.andami.preferences.AbstractPreferencePage; |
||
21 | import org.gvsig.andami.preferences.StoreException; |
||
22 | import org.gvsig.andami.ui.mdiManager.MDIManagerFactory; |
||
23 | import org.gvsig.utils.XMLEntity; |
||
24 | import org.gvsig.utils.swing.JComboBox; |
||
25 | 38608 | jjdelcerro | import org.slf4j.Logger; |
26 | import org.slf4j.LoggerFactory; |
||
27 | 16108 | vcaballero | |
28 | 29630 | jpiera | |
29 | 16108 | vcaballero | public class SkinPreferences extends AbstractPreferencePage { |
30 | |||
31 | 38608 | jjdelcerro | private static final Logger logger = LoggerFactory.getLogger(SkinPreferences.class); |
32 | 16108 | vcaballero | private String id; |
33 | private ImageIcon icon; |
||
34 | 22960 | vcaballero | private Vector listSkinsPlugins; |
35 | 16108 | vcaballero | private JComboBox comboBox; |
36 | 29630 | jpiera | private String skinName = "org.gvsig.coreplugin.mdiManager.NewSkin"; |
37 | 16108 | vcaballero | private static Preferences prefs = Preferences.userRoot().node( |
38 | "gvsig.configuration.3D");
|
||
39 | |||
40 | public SkinPreferences() {
|
||
41 | super();
|
||
42 | // TODO Auto-generated constructor stub
|
||
43 | id = this.getClass().getName();
|
||
44 | setParentID(GeneralPage.id); |
||
45 | 38564 | jjdelcerro | icon = PluginServices.getIconTheme().get("edit-setup-skin");
|
46 | 16108 | vcaballero | } |
47 | |||
48 | public void setChangesApplied() { |
||
49 | // System.out.println("ESTOY LLAMANDO A setChangesApplied()");
|
||
50 | |||
51 | } |
||
52 | |||
53 | public void storeValues() throws StoreException { |
||
54 | // System.out.println("ESTOY LLAMANDO A storeValues()");
|
||
55 | 29630 | jpiera | PluginServices ps = PluginServices.getPluginServices("org.gvsig.coreplugin");
|
56 | 16108 | vcaballero | XMLEntity xml = ps.getPersistentXML(); |
57 | xml.putProperty("Skin-Selected", skinName);
|
||
58 | } |
||
59 | |||
60 | public String getID() { |
||
61 | return id;
|
||
62 | } |
||
63 | |||
64 | public ImageIcon getIcon() { |
||
65 | return icon;
|
||
66 | } |
||
67 | |||
68 | public JPanel getPanel() { |
||
69 | |||
70 | if (comboBox == null) { |
||
71 | comboBox = getComboBox(); |
||
72 | |||
73 | addComponent(new JLabel(PluginServices.getText(this, "skin_label"))); |
||
74 | |||
75 | addComponent(comboBox); |
||
76 | } |
||
77 | |||
78 | return this; |
||
79 | } |
||
80 | |||
81 | private JComboBox getComboBox() { |
||
82 | comboBox = new JComboBox(listSkinsPlugins); |
||
83 | |||
84 | comboBox.addActionListener(new ActionListener() { |
||
85 | public void actionPerformed(ActionEvent e) { |
||
86 | JComboBox cb = (JComboBox) e.getSource(); |
||
87 | String newSkinName = (String) cb.getSelectedItem(); |
||
88 | if (newSkinName != null) |
||
89 | if (!newSkinName.equals(skinName)) {
|
||
90 | skinName = newSkinName; |
||
91 | JOptionPane.showMessageDialog(null, PluginServices |
||
92 | .getText(this, "skin_message")); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | }); |
||
97 | |||
98 | comboBox.setSelectedItem(skinName); |
||
99 | return comboBox;
|
||
100 | } |
||
101 | |||
102 | public String getTitle() { |
||
103 | // TODO Auto-generated method stub
|
||
104 | 30543 | maquerol | return PluginServices.getText(this, "skin"); |
105 | 16108 | vcaballero | } |
106 | |||
107 | public void initializeDefaults() { |
||
108 | // TODO Auto-generated method stub
|
||
109 | // System.out.println("inicialize Defaults");
|
||
110 | |||
111 | } |
||
112 | |||
113 | public void initializeValues() { |
||
114 | 22960 | vcaballero | listSkinsPlugins = new Vector(); |
115 | 16108 | vcaballero | |
116 | HashMap pluginsConfig = Launcher.getPluginConfig();
|
||
117 | Iterator i = pluginsConfig.keySet().iterator();
|
||
118 | |||
119 | while (i.hasNext()) {
|
||
120 | String name = (String) i.next(); |
||
121 | PluginConfig pc = (PluginConfig) pluginsConfig.get(name); |
||
122 | |||
123 | if (pc.getExtensions().getSkinExtension() != null) { |
||
124 | SkinExtension[] se = pc.getExtensions().getSkinExtension();
|
||
125 | for (int j=0;j<se.length;j++){ |
||
126 | 38608 | jjdelcerro | String extensionName = se[j].getClassName();
|
127 | listSkinsPlugins.add(extensionName ); |
||
128 | logger.info("Skin plugin '"+name + "', extension '"+ extensionName +"."); |
||
129 | 16108 | vcaballero | } |
130 | } |
||
131 | } |
||
132 | |||
133 | |||
134 | 29630 | jpiera | PluginServices ps = PluginServices.getPluginServices("org.gvsig.coreplugin");
|
135 | 16108 | vcaballero | XMLEntity xml = ps.getPersistentXML(); |
136 | if (xml.contains("Skin-Selected")) { |
||
137 | skinName = xml.getStringProperty("Skin-Selected");
|
||
138 | |||
139 | } |
||
140 | |||
141 | |||
142 | |||
143 | } |
||
144 | |||
145 | public boolean isValueChanged() { |
||
146 | // TODO Auto-generated method stub
|
||
147 | // System.out.println("is value changed");
|
||
148 | return true; |
||
149 | } |
||
150 | |||
151 | } |