svn-gvsig-desktop / trunk / libraries / libCorePlugin / src / com / iver / core / PreferencesExtension.java @ 6880
History | View | Annotate | Download (4.04 KB)
1 |
package com.iver.core; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.HashMap; |
5 |
import java.util.Iterator; |
6 |
|
7 |
import com.iver.andami.Launcher; |
8 |
import com.iver.andami.PluginServices; |
9 |
import com.iver.andami.plugins.Extension; |
10 |
import com.iver.andami.plugins.ExtensionDecorator; |
11 |
import com.iver.andami.plugins.config.generate.Extensions; |
12 |
import com.iver.andami.plugins.config.generate.PluginConfig; |
13 |
import com.iver.andami.preferences.IPreference; |
14 |
import com.iver.andami.preferences.IPreferenceExtension; |
15 |
import com.iver.core.preferences.general.AppearancePage; |
16 |
import com.iver.core.preferences.general.DirExtensionsPage; |
17 |
import com.iver.core.preferences.general.ExtensionPage; |
18 |
import com.iver.core.preferences.general.ExtensionsPage; |
19 |
import com.iver.core.preferences.general.GeneralPage; |
20 |
import com.iver.core.preferences.general.LanguagePage; |
21 |
import com.iver.core.preferences.network.FirewallPage; |
22 |
import com.iver.core.preferences.network.NetworkPage; |
23 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
24 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
25 |
|
26 |
public class PreferencesExtension extends Extension{ |
27 |
private ExtensionPoints extensionPoints =
|
28 |
ExtensionPointsSingleton.getInstance(); |
29 |
|
30 |
private boolean initilizedExtensions=false; |
31 |
|
32 |
public void initialize() { |
33 |
initializeCoreExtensions(); |
34 |
} |
35 |
|
36 |
public void execute(String actionCommand) { |
37 |
if (!this.initilizedExtensions) { |
38 |
initializeExtensions(); |
39 |
initializeExtensionsConfig(); |
40 |
this.initilizedExtensions = true; |
41 |
} |
42 |
|
43 |
PluginServices.getMDIManager().addWindow(PluginServices.getDlgPreferences()); |
44 |
} |
45 |
public boolean isEnabled() { |
46 |
return true; |
47 |
} |
48 |
|
49 |
public boolean isVisible() { |
50 |
return true; |
51 |
} |
52 |
|
53 |
private void initializeCoreExtensions() { |
54 |
//dlgPrefs.addPreferencePage(new GeneralPage());
|
55 |
this.extensionPoints.add("AplicationPreferences","GeneralPage", new GeneralPage()); |
56 |
|
57 |
//dlgPrefs.addPreferencePage(new NetworkPage());
|
58 |
this.extensionPoints.add("AplicationPreferences","NetworkPage", new NetworkPage()); |
59 |
|
60 |
//dlgPrefs.addPreferencePage(new FirewallPage());
|
61 |
this.extensionPoints.add("AplicationPreferences","FirewallPage", new FirewallPage()); |
62 |
|
63 |
//dlgPrefs.addPreferencePage(new DirExtensionsPage());
|
64 |
this.extensionPoints.add("AplicationPreferences","DirExtensionsPage", new DirExtensionsPage()); |
65 |
|
66 |
//dlgPrefs.addPreferencePage(new LanguagePage());
|
67 |
this.extensionPoints.add("AplicationPreferences","LanguagePage", new LanguagePage()); |
68 |
|
69 |
//dlgPrefs.addPreferencePage(new ExtensionsPage());
|
70 |
this.extensionPoints.add("AplicationPreferences","ExtensionsPage", new ExtensionsPage()); |
71 |
|
72 |
//dlgPrefs.addPreferencePage(new AppearancePage());
|
73 |
this.extensionPoints.add("AplicationPreferences","AppearancePage", new AppearancePage()); |
74 |
|
75 |
//Falta los plugin
|
76 |
} |
77 |
|
78 |
private void initializeExtensionsConfig() { |
79 |
HashMap pc = Launcher.getPluginConfig();
|
80 |
ArrayList array = new ArrayList(); |
81 |
Iterator iter = pc.values().iterator();
|
82 |
|
83 |
while (iter.hasNext()) {
|
84 |
array.add(((PluginConfig) iter.next()).getExtensions()); |
85 |
} |
86 |
|
87 |
Extensions[] exts = (Extensions[]) array.toArray(new Extensions[0]); |
88 |
for (int i = 0; i < exts.length; i++) { |
89 |
for (int j = 0; j < exts[i].getExtensionCount(); j++) { |
90 |
com.iver.andami.plugins.config.generate.Extension ext = exts[i] |
91 |
.getExtension(j); |
92 |
String pn = null; |
93 |
String sExt = ext.getClassName().toString();
|
94 |
pn = sExt.substring(0, sExt.lastIndexOf(".")); |
95 |
//dlgPrefs.addPreferencePage(new PluginsPage(pn));
|
96 |
//dlgPrefs.addPreferencePage(new ExtensionPage(ext));
|
97 |
this.extensionPoints.add("AplicationPreferences",sExt, new ExtensionPage(ext)); |
98 |
} |
99 |
} |
100 |
} |
101 |
/**
|
102 |
*
|
103 |
*/
|
104 |
private void initializeExtensions() { |
105 |
|
106 |
Iterator i =PluginServices.getExtensions();
|
107 |
while (i.hasNext()) {
|
108 |
ExtensionDecorator extension = (ExtensionDecorator) i.next(); |
109 |
|
110 |
if (extension.getExtension() instanceof IPreferenceExtension) { |
111 |
IPreferenceExtension pe=(IPreferenceExtension)extension.getExtension(); |
112 |
IPreference pp=pe.getPreferencesPage(); |
113 |
//dlgPrefs.addPreferencePage(pe.getPreferencesPage());
|
114 |
this.extensionPoints.add("AplicationPreferences",pp.getID(), pp); |
115 |
} |
116 |
} |
117 |
} |
118 |
} |