Statistics
| Revision:

root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / impl / DefaultPluginsManager.java @ 38564

History | View | Annotate | Download (2.85 KB)

1 31413 jjdelcerro
package org.gvsig.andami.impl;
2
3 34114 fdiaz
import java.io.File;
4 31413 jjdelcerro
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 34114 fdiaz
import org.gvsig.andami.plugins.PluginClassLoader;
17 31413 jjdelcerro
18
public class DefaultPluginsManager implements PluginsManager{
19
20 37164 jjdelcerro
        private File pluginsFolder = null;
21
22 31413 jjdelcerro
        public ExclusiveUIExtension getExclusiveUIExtension() {
23
                return PluginServices.getExclusiveUIExtension();
24
        }
25
26 34318 cordinyana
        public IExtension getExtension(Class<? extends IExtension> extension) {
27 31413 jjdelcerro
                return PluginServices.getExtension(extension);
28
        }
29
30
        @SuppressWarnings("unchecked")
31
        public Iterator<IExtension> getExtensions() {
32
                return PluginServices.getExtensions();
33
        }
34
35 34114 fdiaz
        /**
36
         * Return the associated pluginServices to the extension class passed as parameter.
37
         *
38
         */
39 34318 cordinyana
        public PluginServices getPlugin(Class<? extends IExtension> extension) {
40 34114 fdiaz
            String pluginName = ((PluginClassLoader)extension.getClassLoader()).getPluginName();
41
                return  this.getPlugin(pluginName);
42 31413 jjdelcerro
        }
43
44
        public PluginServices getPlugin(String pluginName) {
45 34114 fdiaz
                return Launcher.getPluginServices(pluginName);
46 31413 jjdelcerro
        }
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 34818 nfrancisco
        public String getText(Object obj, String msg) {
66
            return PluginServices.getText(obj, msg);
67
        }
68
69 34114 fdiaz
    public File getPluginsDirectory() {
70 34485 cordinyana
        return getPluginsFolder();
71
    }
72
73
    public File getApplicationFolder() {
74 38564 jjdelcerro
            return Launcher.getApplicationFolder();
75 34485 cordinyana
    }
76
77
    public File getPluginsFolder() {
78 37164 jjdelcerro
            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 34114 fdiaz
    }
88
89 34485 cordinyana
    public File getInstallFolder() {
90
        return new File(getApplicationFolder(), "install");
91
    }
92 34946 jjdelcerro
93
    public File getApplicationHomeFolder() {
94 38564 jjdelcerro
        return Launcher.getApplicationHomeFolder();
95 34946 jjdelcerro
    }
96 31413 jjdelcerro
}