Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / PluginsManager.java @ 42959

History | View | Annotate | Download (8.23 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami;
25

    
26
import java.io.File;
27
import java.net.URI;
28
import java.util.Iterator;
29
import java.util.List;
30
import static org.gvsig.andami.Launcher.appName;
31

    
32
import org.gvsig.andami.firewall.FirewallConfiguration;
33
import org.gvsig.andami.impl.UnsavedDataException;
34
import org.gvsig.andami.plugins.ExclusiveUIExtension;
35
import org.gvsig.andami.plugins.IExtension;
36
import org.gvsig.andami.plugins.status.IUnsavedData;
37
import org.gvsig.installer.lib.api.PackageInfo;
38
import org.gvsig.installer.lib.api.Version;
39

    
40
public interface PluginsManager {
41

    
42
    public String getApplicationName();
43

    
44
    /**
45
     * Return the associated pluginServices to the extension class passed as
46
     * parameter.
47
     *
48
     * @param extension
49
     * @return plugin services
50
     */
51
    public PluginServices getPlugin(Class<? extends IExtension> extension);
52

    
53
    /**
54
     * Return the associated pluginServices to the object passed as parameter.
55
     *
56
     * @param object
57
     * @return plugin services
58
     */
59
    public PluginServices getPlugin(Object obj);
60

    
61
    /**
62
     * Return the associated pluginServices to the extension plugin.
63
     *
64
     * @param pluginName, name of the plugin
65
     * @return plugin services
66
     */
67
    public PluginServices getPlugin(String pluginName);
68

    
69
    /**
70
     * Get the package info associated to the plugin of the extension.
71
     *
72
     * @param extension extension of the plugin
73
     * @return plugin package info
74
     */
75
    public PackageInfo getPackageInfo(Class<? extends IExtension> extension);
76

    
77
    /**
78
     * Get the package info associated to the plugin with the specified name.
79
     *
80
     * @param pluginName, name of the plugin
81
     * @return plugin package info
82
     */
83
    public PackageInfo getPackageInfo(String pluginName);
84

    
85
    /**
86
     * Get the package info associated to the application.
87
     *
88
     * @return application package info
89
     */
90
    public PackageInfo getPackageInfo();
91

    
92
    /**
93
     * Return the list of plugins loaded in the application
94
     *
95
     * @return list of plugins
96
     */
97
    public List<PluginServices> getPlugins();
98

    
99
    /**
100
     * Gets the instance of the extension whose class is provided.
101
     *
102
     * @param extension, class of the extension to retrieve
103
     *
104
     * @return The instance of the extension, or null if the instance does
105
     * not exist.
106
     */
107
    public IExtension getExtension(Class<? extends IExtension> extension);
108

    
109
    /**
110
     * Return an iterator over al extensions loaded in the application.
111
     *
112
     * @return iterator over extensions
113
     */
114
    public Iterator<IExtension> getExtensions();
115

    
116
    /**
117
     * Set an extension to control the visivility of all the extensions
118
     * of the application.
119
     *
120
     * @param extension
121
     */
122
    public void setExclusiveUIExtension(ExclusiveUIExtension extension);
123

    
124
    /**
125
     * Return the ExclusiveUIExtension installed in the application or
126
     * null.
127
     *
128
     * @return
129
     */
130
    public ExclusiveUIExtension getExclusiveUIExtension();
131

    
132
    /**
133
     * @deprecated use {@link #translate(String)}
134
     * @see {@link #translate(String)}
135
     */
136
    public String getText(Object obj, String msg);
137

    
138
    /**
139
     * Translate the message key to the current language used
140
     * in the application.
141
     *
142
     * @param msg key to translate
143
     * @return message traslated or the key
144
     */
145
    public String translate(String msg);
146

    
147
    /**
148
     * Returns the main application folder, where the application is installed.
149
     *
150
     * @return the main application folder
151
     */
152
    public File getApplicationFolder();
153

    
154
    /**
155
     * Returns the default folder with the installable package bundles.
156
     *
157
     * @return the default folder with the installable package bundles
158
     */
159
    public File getInstallFolder();
160

    
161
    /**
162
     * Returns the application folder in the home of user.
163
     *
164
     * @return the main application folder
165
     */
166
    public File getApplicationHomeFolder();
167

    
168

    
169
    /**
170
     * Returns the default folder where the internationalization files are installed.
171
     *
172
     * @return the default folder where the internationalization files are installed.
173
     */
174
    public File getApplicationI18nFolder();
175

    
176
    /**
177
     * Returns the plugins folder.
178
     *
179
     * @return the plugins folder
180
     * @deprecated use {@link #getPluginsFolders()}
181
     */
182
    public File getPluginsFolder();
183

    
184
    /**
185
     * Returns a list of folder on the plugins are instaleds.
186
     *
187
     * @return list of folders File of the plugins.
188
     */
189
    public List<File> getPluginsFolders();
190

    
191
    /**
192
     * @deprecated @see {@link #getPluginsFolders()}
193
     */
194
    public File getPluginsDirectory();
195

    
196
    /**
197
     * This method allows plugins register task to do before initializacion of
198
     * all gvSIG plugins.
199
     *
200
     * Task with higher priority value are executed after.
201
     *
202
     * @param name of the task
203
     * @param task runnable with the code of the task
204
     * @param in_event_thread, true if the task shoul run in the AWT event thread.
205
     * @param priority of the task.
206
     */
207
    public void addStartupTask(String name, Runnable task, boolean in_event_thread, int priority);
208

    
209
    /**
210
     * This method allows plugins register task to do after close the application.
211
     *
212
     * Task with higher priority value are executed after.
213
     *
214
     * @param name of the task
215
     * @param task runnable with the code of the task
216
     * @param in_event_thread, true if the task shoul run in the AWT event thread.
217
     * @param priority of the task.
218
     */
219
    public void addShutdownTask(String name, Runnable task, boolean in_event_thread, int priority);
220

    
221
    /**
222
     * This method executes registered task to run before the initialization of
223
     * all plugins.
224
     * The tasks are sorted according to the priority and executed in a separated
225
     * thread.
226
     *
227
     */
228
    public void executeStartupTasks();
229

    
230
    /**
231
     * This method executes registered task to run after the close of the application.
232
     * The tasks are sorted according to the priority and executed in a separated
233
     * thread.
234
     *
235
     */
236
    public void executeShutdownTasks();
237

    
238

    
239
    public FirewallConfiguration getFirewallConfiguration();
240

    
241
    public Version getApplicationVersion();
242

    
243
    /**
244
     * Return a list of unsaved data
245
     *
246
     * @return
247
     */
248
    public List<IUnsavedData> getUnsavedData();
249

    
250
    /**
251
     * Save the provided unsaved data as parameter
252
     *
253
     * @param unsavedData
254
     * @throws UnsavedDataException
255
     */
256
    public void saveUnsavedData(List<IUnsavedData> unsavedData) throws UnsavedDataException;
257

    
258
    /**
259
     * Gets the temporary folder of the plugins framework.
260
     *
261
     * @return the temp folder
262
     */
263
    public File getTempFolder();
264

    
265
    /**
266
     * Get the file name in the temporary folder of the plugins framework.
267
     * @param name
268
     * @return
269
     */
270
    public File getTempFile(String name);
271

    
272
    /**
273
     * Create a unique file name in the temporary folder of the plugins framework.
274
     *
275
     * @param name base name used for create the unique file name
276
     * @param sufix to add the the unique file name
277
     * @return
278
     */
279
    public File getTempFile(String name, String sufix);
280

    
281
    /**
282
     * Browses to a given URI
283
     * @param uri
284
     * @return
285
     */
286
    public boolean desktopBrowse(URI uri);
287

    
288
    /**
289
     * Open a given file
290
     * @param file
291
     * @return
292
     */
293
    public boolean desktopOpen(File file);
294

    
295

    
296
}