root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / impl / DefaultPluginsManager.java @ 38564
History | View | Annotate | Download (2.85 KB)
1 |
package org.gvsig.andami.impl; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
5 |
import java.util.Enumeration; |
6 |
import java.util.Iterator; |
7 |
import java.util.List; |
8 |
|
9 |
import org.gvsig.andami.Launcher; |
10 |
import org.gvsig.andami.PluginServices; |
11 |
import org.gvsig.andami.PluginsManager; |
12 |
import org.gvsig.andami.config.generate.AndamiConfig; |
13 |
import org.gvsig.andami.config.generate.Plugin; |
14 |
import org.gvsig.andami.plugins.ExclusiveUIExtension; |
15 |
import org.gvsig.andami.plugins.IExtension; |
16 |
import org.gvsig.andami.plugins.PluginClassLoader; |
17 |
|
18 |
public class DefaultPluginsManager implements PluginsManager{ |
19 |
|
20 |
private File pluginsFolder = null; |
21 |
|
22 |
public ExclusiveUIExtension getExclusiveUIExtension() {
|
23 |
return PluginServices.getExclusiveUIExtension();
|
24 |
} |
25 |
|
26 |
public IExtension getExtension(Class<? extends IExtension> extension) { |
27 |
return PluginServices.getExtension(extension);
|
28 |
} |
29 |
|
30 |
@SuppressWarnings("unchecked") |
31 |
public Iterator<IExtension> getExtensions() { |
32 |
return PluginServices.getExtensions();
|
33 |
} |
34 |
|
35 |
/**
|
36 |
* Return the associated pluginServices to the extension class passed as parameter.
|
37 |
*
|
38 |
*/
|
39 |
public PluginServices getPlugin(Class<? extends IExtension> extension) { |
40 |
String pluginName = ((PluginClassLoader)extension.getClassLoader()).getPluginName();
|
41 |
return this.getPlugin(pluginName); |
42 |
} |
43 |
|
44 |
public PluginServices getPlugin(String pluginName) { |
45 |
return Launcher.getPluginServices(pluginName);
|
46 |
} |
47 |
|
48 |
@SuppressWarnings("unchecked") |
49 |
public List<PluginServices> getPlugins() { |
50 |
List<PluginServices> pluginServices = new ArrayList<PluginServices>(); |
51 |
|
52 |
AndamiConfig config = Launcher.getAndamiConfig(); |
53 |
Enumeration<Plugin> plugins = config.enumeratePlugin();
|
54 |
while( plugins.hasMoreElements()) {
|
55 |
Plugin plugin = plugins.nextElement(); |
56 |
pluginServices.add(PluginServices.getPluginServices(plugin.getName())); |
57 |
} |
58 |
return pluginServices;
|
59 |
} |
60 |
|
61 |
public void setExclusiveUIExtension(ExclusiveUIExtension extension) { |
62 |
PluginServices.setExclusiveUIExtension(extension); |
63 |
} |
64 |
|
65 |
public String getText(Object obj, String msg) { |
66 |
return PluginServices.getText(obj, msg);
|
67 |
} |
68 |
|
69 |
public File getPluginsDirectory() { |
70 |
return getPluginsFolder();
|
71 |
} |
72 |
|
73 |
public File getApplicationFolder() { |
74 |
return Launcher.getApplicationFolder();
|
75 |
} |
76 |
|
77 |
public File getPluginsFolder() { |
78 |
if( this.pluginsFolder!=null ) { |
79 |
return this.pluginsFolder; |
80 |
} |
81 |
String folder = "gvSIG/extensiones"; |
82 |
if( !(Launcher.getAndamiConfig() == null || Launcher.getAndamiConfig().getPluginsDirectory()==null) ) { |
83 |
folder = Launcher.getAndamiConfig().getPluginsDirectory(); |
84 |
} |
85 |
this.pluginsFolder = new File(getApplicationFolder(), folder); |
86 |
return this.pluginsFolder; |
87 |
} |
88 |
|
89 |
public File getInstallFolder() { |
90 |
return new File(getApplicationFolder(), "install"); |
91 |
} |
92 |
|
93 |
public File getApplicationHomeFolder() { |
94 |
return Launcher.getApplicationHomeFolder();
|
95 |
} |
96 |
} |