root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / impl / DefaultPluginsManager.java @ 34946
History | View | Annotate | Download (2.56 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 |
public ExclusiveUIExtension getExclusiveUIExtension() {
|
21 |
return PluginServices.getExclusiveUIExtension();
|
22 |
} |
23 |
|
24 |
public IExtension getExtension(Class<? extends IExtension> extension) { |
25 |
return PluginServices.getExtension(extension);
|
26 |
} |
27 |
|
28 |
@SuppressWarnings("unchecked") |
29 |
public Iterator<IExtension> getExtensions() { |
30 |
return PluginServices.getExtensions();
|
31 |
} |
32 |
|
33 |
/**
|
34 |
* Return the associated pluginServices to the extension class passed as parameter.
|
35 |
*
|
36 |
*/
|
37 |
public PluginServices getPlugin(Class<? extends IExtension> extension) { |
38 |
String pluginName = ((PluginClassLoader)extension.getClassLoader()).getPluginName();
|
39 |
return this.getPlugin(pluginName); |
40 |
} |
41 |
|
42 |
public PluginServices getPlugin(String pluginName) { |
43 |
return Launcher.getPluginServices(pluginName);
|
44 |
} |
45 |
|
46 |
@SuppressWarnings("unchecked") |
47 |
public List<PluginServices> getPlugins() { |
48 |
List<PluginServices> pluginServices = new ArrayList<PluginServices>(); |
49 |
|
50 |
AndamiConfig config = Launcher.getAndamiConfig(); |
51 |
Enumeration<Plugin> plugins = config.enumeratePlugin();
|
52 |
while( plugins.hasMoreElements()) {
|
53 |
Plugin plugin = plugins.nextElement(); |
54 |
pluginServices.add(PluginServices.getPluginServices(plugin.getName())); |
55 |
} |
56 |
return pluginServices;
|
57 |
} |
58 |
|
59 |
public void setExclusiveUIExtension(ExclusiveUIExtension extension) { |
60 |
PluginServices.setExclusiveUIExtension(extension); |
61 |
} |
62 |
|
63 |
public String getText(Object obj, String msg) { |
64 |
return PluginServices.getText(obj, msg);
|
65 |
} |
66 |
|
67 |
public File getPluginsDirectory() { |
68 |
return getPluginsFolder();
|
69 |
} |
70 |
|
71 |
public File getApplicationFolder() { |
72 |
// TODO: check if there is a better way to handle this
|
73 |
return new File(System.getProperty("user.dir")); |
74 |
} |
75 |
|
76 |
public File getPluginsFolder() { |
77 |
return new File(Launcher.getAndamiConfig().getPluginsDirectory()); |
78 |
} |
79 |
|
80 |
public File getInstallFolder() { |
81 |
return new File(getApplicationFolder(), "install"); |
82 |
} |
83 |
|
84 |
public File getApplicationHomeFolder() { |
85 |
return new File(Launcher.getAppHomeDir()); |
86 |
} |
87 |
} |