Revision 41218
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/impl/DefaultPluginsManager.java | ||
---|---|---|
29 | 29 |
import java.util.Iterator; |
30 | 30 |
import java.util.List; |
31 | 31 |
|
32 |
import javax.swing.SwingUtilities; |
|
33 |
|
|
32 | 34 |
import org.gvsig.andami.Launcher; |
33 | 35 |
import org.gvsig.andami.PluginServices; |
34 | 36 |
import org.gvsig.andami.PluginsManager; |
... | ... | |
49 | 51 |
LoggerFactory.getLogger(DefaultPluginsManager.class); |
50 | 52 |
|
51 | 53 |
private List<File> pluginsFolders = null; |
54 |
private List<Runnable> tasksAfterPlugins = new ArrayList<Runnable>(); |
|
52 | 55 |
|
53 | 56 |
public ExclusiveUIExtension getExclusiveUIExtension() { |
54 | 57 |
return PluginServices.getExclusiveUIExtension(); |
... | ... | |
186 | 189 |
public File getApplicationHomeFolder() { |
187 | 190 |
return Launcher.getApplicationHomeFolder(); |
188 | 191 |
} |
192 |
|
|
193 |
public void addAdditionalTask(Runnable task, boolean in_event_thread, int priority) { |
|
194 |
tasksAfterPlugins.add(task); |
|
195 |
} |
|
196 |
|
|
197 |
public void executeAdditionalTasks() { |
|
198 |
Thread th = new Thread(new Runnable() { |
|
199 |
public void run() { |
|
200 |
try { |
|
201 |
Thread.sleep(1000); |
|
202 |
} catch (Exception exc) { } |
|
203 |
executeTasksInEventThread(); |
|
204 |
} |
|
205 |
}); |
|
206 |
th.start(); |
|
207 |
|
|
208 |
} |
|
209 |
|
|
210 |
private void executeTasksInEventThread() { |
|
211 |
|
|
212 |
if (!SwingUtilities.isEventDispatchThread()) { |
|
213 |
try { |
|
214 |
SwingUtilities.invokeLater(new Runnable() { |
|
215 |
public void run() { |
|
216 |
doExecuteTasks(); |
|
217 |
} |
|
218 |
}); |
|
219 |
} catch (Throwable th) { |
|
220 |
logger.error("While running tasks", th); |
|
221 |
} |
|
222 |
} else { |
|
223 |
doExecuteTasks(); |
|
224 |
} |
|
225 |
|
|
226 |
} |
|
227 |
|
|
228 |
private void doExecuteTasks() { |
|
229 |
|
|
230 |
Runnable item = null; |
|
231 |
for (int i=0; i<tasksAfterPlugins.size(); i++) { |
|
232 |
item = tasksAfterPlugins.get(i); |
|
233 |
item.run(); |
|
234 |
} |
|
235 |
|
|
236 |
} |
|
237 |
|
|
238 |
|
|
189 | 239 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java | ||
---|---|---|
692 | 692 |
} |
693 | 693 |
org.apache.log4j.Logger.getRootLogger().addAppender( |
694 | 694 |
new NotificationAppender()); |
695 |
|
|
696 |
/* |
|
697 |
* Executes additional tasks required by plugins |
|
698 |
*/ |
|
699 |
PluginsLocator.getManager().executeAdditionalTasks(); |
|
695 | 700 |
|
696 | 701 |
} |
697 | 702 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/PluginsManager.java | ||
---|---|---|
163 | 163 |
* @deprecated @see {@link #getPluginsFolders()} |
164 | 164 |
*/ |
165 | 165 |
public File getPluginsDirectory(); |
166 |
|
|
167 |
/** |
|
168 |
* This method allows plugins to require the execution of |
|
169 |
* tasks |
|
170 |
* |
|
171 |
* @param task |
|
172 |
* @param in_event_thread |
|
173 |
* @param priority |
|
174 |
*/ |
|
175 |
public void addAdditionalTask(Runnable task, boolean in_event_thread, int priority); |
|
176 |
|
|
177 |
/** |
|
178 |
* This method executes the tasks required by the plugins. |
|
179 |
* |
|
180 |
* @return |
|
181 |
*/ |
|
182 |
public void executeAdditionalTasks(); |
|
166 | 183 |
|
167 | 184 |
} |
Also available in: Unified diff