]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - eclipse/plugins/org.argeo.slc.ide.ui/src/main/java/org/argeo/slc/ide/ui/launch/osgi/OsgiBootEquinoxLaunchConfiguration.java
NEW - bug 11: Introduce a simplified launch for RCP
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.ide.ui / src / main / java / org / argeo / slc / ide / ui / launch / osgi / OsgiBootEquinoxLaunchConfiguration.java
index ab2db16d2543da00053d9c76a6ad0db194e5deb3..19cdee12b8b1896f839293499d8fd66f208f9e3b 100644 (file)
@@ -1,22 +1,16 @@
 package org.argeo.slc.ide.ui.launch.osgi;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.pde.ui.launcher.EquinoxLaunchConfiguration;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.pde.launching.EquinoxLaunchConfiguration;
 
+/** OSGiBoot launch configuration. */
 public class OsgiBootEquinoxLaunchConfiguration extends
                EquinoxLaunchConfiguration {
        public final static String ID = SlcIdeUiPlugin.ID
@@ -27,39 +21,35 @@ public class OsgiBootEquinoxLaunchConfiguration extends
                        ILaunch launch, IProgressMonitor monitor) throws CoreException {
                super.launch(configuration, mode, launch, monitor);
 
-               // TODO: add launch listener to be notified when is terminated and
-               // refresh resources
-               
-               // IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
-               // propertiesFile.getProject().refreshLocal(IResource.DEPTH_INFINITE,
-               // monitor);
+//             System.out.println("targetBundles="
+//                             + configuration.getAttribute(
+//                                             IPDELauncherConstants.TARGET_BUNDLES, ""));
+//             System.out.println("workspaceBundles="
+//                             + configuration.getAttribute(
+//                                             IPDELauncherConstants.WORKSPACE_BUNDLES, ""));
+
+               // Refresh resources before launching
+               final IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
+               propertiesFile.getParent().refreshLocal(IResource.DEPTH_INFINITE,
+                               monitor);
        }
 
        @Override
        protected void preLaunchCheck(ILaunchConfiguration configuration,
                        ILaunch launch, IProgressMonitor monitor) throws CoreException {
-               System.out.println("Launching... " + launch);
-               IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
-
-               Properties properties = null;
-               try {
-                       properties = OsgiLaunchHelper.readProperties(propertiesFile);
-               } catch (CoreException e) {
-                       ErrorDialog.openError(Display.getCurrent().getActiveShell(),
-                                       "Error", "Cannot execute launch shortcut", e.getStatus());
-                       return;
-               }
-
-               List<String> bundlesToStart = new ArrayList<String>();
-               Map<String, String> systemPropertiesToAppend = new HashMap<String, String>();
-               OsgiLaunchHelper.interpretProperties(properties, bundlesToStart,
-                               systemPropertiesToAppend);
+               // System.out.println("Launching... " + launch);
                ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
-               OsgiLaunchHelper.updateLaunchConfiguration(wc, bundlesToStart,
-                               systemPropertiesToAppend, null);
+               OsgiLaunchHelper.updateLaunchConfiguration(wc, false);
                wc.doSave();
-
                super.preLaunchCheck(configuration, launch, monitor);
+
+               // Note that if a Java project contains a build.properties it has to
+               // declare the sources otherwise it will be skipped in the generation of
+               // the dev.properties file!
+
+               // for(Object bundleId:fAllBundles.keySet()){
+               // System.out.println(bundleId+"="+fAllBundles.get(bundleId));
+               // }
        }
 
 }