Permalink
Browse files

enhancements to the spatial toolbox - default libraries

  • Loading branch information...
1 parent 2ef371d commit 23c3cb8f574f75cace79d73710ef0acc0dc0bff6 @moovida committed Apr 18, 2012
View
6 plugins/eu.udig.omsbox/src/eu/udig/omsbox/OmsBoxPlugin.java
@@ -24,7 +24,9 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.geotools.data.DataUtilities;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -447,4 +449,8 @@ public File getConfigurationsFolder() {
return getStateLocation().toFile();
}
+ public static void log( String message ) {
+ getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
+ }
+
}
View
28 plugins/eu.udig.omsbox/src/eu/udig/omsbox/core/OmsModulesManager.java
@@ -18,6 +18,7 @@
package eu.udig.omsbox.core;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
@@ -31,6 +32,10 @@
import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.geotools.data.DataUtilities;
+
import oms3.Access;
import oms3.ComponentAccess;
import oms3.annotations.Description;
@@ -74,9 +79,30 @@ private OmsModulesManager() {
for( String jar : retrieveSavedJars ) {
addJar(jar);
}
+
+ /*
+ * and also search in a folder inside the installation
+ * folder for some library jars
+ */
+ Location installLocation = Platform.getInstallLocation();
+ File installFolder = DataUtilities.urlToFile(installLocation.getURL());
+ if (installFolder != null && installFolder.exists()) {
+ File omsboxLibsFolder = new File(installFolder, "omsbox");
+ OmsBoxPlugin.log("Searching module libraries in: " + omsboxLibsFolder.getAbsolutePath());
+ if (omsboxLibsFolder.exists()) {
+ File[] extraJars = omsboxLibsFolder.listFiles(new FilenameFilter(){
+ public boolean accept( File dir, String name ) {
+ return name.endsWith(".jar");
+ }
+ });
+ for( File extraJar : extraJars ) {
+ addJar(extraJar.getAbsolutePath());
+ }
+ }
+ }
}
- public static OmsModulesManager getInstance() {
+ public synchronized static OmsModulesManager getInstance() {
if (modulesManager == null) {
modulesManager = new OmsModulesManager();
}
View
18 plugins/eu.udig.omsbox/src/eu/udig/omsbox/view/OmsBoxView.java
@@ -364,13 +364,21 @@ public boolean select( Viewer arg0, Object arg1, Object arg2 ) {
* Resfresh the viewer.
*/
public void relayout() {
- Display.getDefault().syncExec(new Runnable(){
- public void run() {
+ IRunnableWithProgress operation = new IRunnableWithProgress(){
+ public void run( IProgressMonitor pm ) throws InvocationTargetException, InterruptedException {
+ pm.beginTask("", IProgressMonitor.UNKNOWN);
HashMap<String, List<ModuleDescription>> availableModules = OmsModulesManager.getInstance().browseModules(false);
- List<ViewerFolder> viewerFolders = ViewerFolder.hashmap2ViewerFolders(availableModules);
- modulesViewer.setInput(viewerFolders);
+ final List<ViewerFolder> viewerFolders = ViewerFolder.hashmap2ViewerFolders(availableModules);
+
+ Display.getDefault().syncExec(new Runnable(){
+ public void run() {
+ modulesViewer.setInput(viewerFolders);
+ }
+ });
+ pm.done();
}
- });
+ };
+ PlatformGIS.runInProgressDialog("Spatial Toolbox library gathering...", true, operation, true);
}
/**

0 comments on commit 23c3cb8

Please sign in to comment.