root / branches / v2_0_0_prep / libraries / libCorePlugin / src / org / gvsig / coreplugin / preferences / general / SkinPreferences.java @ 29630
History | View | Annotate | Download (3.89 KB)
1 |
package org.gvsig.coreplugin.preferences.general; |
---|---|
2 |
|
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 |
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 |
|
26 |
|
27 |
public class SkinPreferences extends AbstractPreferencePage { |
28 |
|
29 |
private String id; |
30 |
private ImageIcon icon; |
31 |
private Vector listSkinsPlugins; |
32 |
private JComboBox comboBox; |
33 |
private String skinName = "org.gvsig.coreplugin.mdiManager.NewSkin"; |
34 |
private static Preferences prefs = Preferences.userRoot().node( |
35 |
"gvsig.configuration.3D");
|
36 |
|
37 |
public SkinPreferences() {
|
38 |
super();
|
39 |
// TODO Auto-generated constructor stub
|
40 |
id = this.getClass().getName();
|
41 |
setParentID(GeneralPage.id); |
42 |
icon = PluginServices.getIconTheme().get("gnome-settings-theme");
|
43 |
} |
44 |
|
45 |
public void setChangesApplied() { |
46 |
// System.out.println("ESTOY LLAMANDO A setChangesApplied()");
|
47 |
|
48 |
} |
49 |
|
50 |
public void storeValues() throws StoreException { |
51 |
// System.out.println("ESTOY LLAMANDO A storeValues()");
|
52 |
PluginServices ps = PluginServices.getPluginServices("org.gvsig.coreplugin");
|
53 |
XMLEntity xml = ps.getPersistentXML(); |
54 |
xml.putProperty("Skin-Selected", skinName);
|
55 |
} |
56 |
|
57 |
public String getID() { |
58 |
return id;
|
59 |
} |
60 |
|
61 |
public ImageIcon getIcon() { |
62 |
return icon;
|
63 |
} |
64 |
|
65 |
public JPanel getPanel() { |
66 |
|
67 |
if (comboBox == null) { |
68 |
comboBox = getComboBox(); |
69 |
|
70 |
addComponent(new JLabel(PluginServices.getText(this, "skin_label"))); |
71 |
|
72 |
addComponent(comboBox); |
73 |
} |
74 |
|
75 |
return this; |
76 |
} |
77 |
|
78 |
private JComboBox getComboBox() { |
79 |
comboBox = new JComboBox(listSkinsPlugins); |
80 |
|
81 |
comboBox.addActionListener(new ActionListener() { |
82 |
public void actionPerformed(ActionEvent e) { |
83 |
JComboBox cb = (JComboBox) e.getSource(); |
84 |
String newSkinName = (String) cb.getSelectedItem(); |
85 |
if (newSkinName != null) |
86 |
if (!newSkinName.equals(skinName)) {
|
87 |
skinName = newSkinName; |
88 |
JOptionPane.showMessageDialog(null, PluginServices |
89 |
.getText(this, "skin_message")); |
90 |
} |
91 |
} |
92 |
|
93 |
}); |
94 |
|
95 |
comboBox.setSelectedItem(skinName); |
96 |
return comboBox;
|
97 |
} |
98 |
|
99 |
public String getTitle() { |
100 |
// TODO Auto-generated method stub
|
101 |
return "Skin"; |
102 |
} |
103 |
|
104 |
public void initializeDefaults() { |
105 |
// TODO Auto-generated method stub
|
106 |
// System.out.println("inicialize Defaults");
|
107 |
|
108 |
} |
109 |
|
110 |
public void initializeValues() { |
111 |
// TODO Auto-generated method stub
|
112 |
// System.out.println("inicialize values");
|
113 |
|
114 |
listSkinsPlugins = new Vector(); |
115 |
|
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 |
|
127 |
listSkinsPlugins.add(se[j].getClassName()); |
128 |
System.out.println("plugin de skin + name"); |
129 |
} |
130 |
} |
131 |
} |
132 |
|
133 |
|
134 |
PluginServices ps = PluginServices.getPluginServices("org.gvsig.coreplugin");
|
135 |
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 |
} |