1 package org
.argeo
.slc
.ide
.ui
.launch
.osgi
;
4 import java
.util
.ArrayList
;
5 import java
.util
.HashMap
;
8 import java
.util
.Properties
;
10 import org
.argeo
.slc
.ide
.ui
.SlcIdeUiPlugin
;
11 import org
.eclipse
.core
.resources
.IFile
;
12 import org
.eclipse
.core
.resources
.IResource
;
13 import org
.eclipse
.core
.runtime
.CoreException
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.debug
.core
.ILaunch
;
16 import org
.eclipse
.debug
.core
.ILaunchConfiguration
;
17 import org
.eclipse
.debug
.core
.ILaunchConfigurationWorkingCopy
;
18 import org
.eclipse
.jface
.dialogs
.ErrorDialog
;
19 import org
.eclipse
.pde
.ui
.launcher
.EquinoxLaunchConfiguration
;
20 import org
.eclipse
.pde
.ui
.launcher
.OSGiLaunchShortcut
;
21 import org
.eclipse
.swt
.widgets
.Display
;
23 public class OsgiBootEquinoxLaunchConfiguration
extends
24 EquinoxLaunchConfiguration
{
25 public final static String ID
= SlcIdeUiPlugin
.ID
26 + ".OsgiBootEquinoxLauncher";
29 public void launch(ILaunchConfiguration configuration
, String mode
,
30 ILaunch launch
, IProgressMonitor monitor
) throws CoreException
{
31 super.launch(configuration
, mode
, launch
, monitor
);
33 // TODO: add launch listener to be notified when is terminated and
36 IFile propertiesFile
= (IFile
) configuration
.getMappedResources()[0];
37 propertiesFile
.getProject().refreshLocal(IResource
.DEPTH_INFINITE
,
42 protected void preLaunchCheck(ILaunchConfiguration configuration
,
43 ILaunch launch
, IProgressMonitor monitor
) throws CoreException
{
44 // System.out.println("Launching... " + launch);
45 IFile propertiesFile
= (IFile
) configuration
.getMappedResources()[0];
47 Properties properties
= null;
49 properties
= OsgiLaunchHelper
.readProperties(propertiesFile
);
50 } catch (CoreException e
) {
51 ErrorDialog
.openError(Display
.getCurrent().getActiveShell(),
52 "Error", "Cannot execute launch shortcut", e
.getStatus());
56 List
<String
> bundlesToStart
= new ArrayList
<String
>();
57 Map
<String
, String
> systemPropertiesToAppend
= new HashMap
<String
, String
>();
58 OsgiLaunchHelper
.interpretProperties(properties
, bundlesToStart
,
59 systemPropertiesToAppend
);
61 File workingDir
= getWorkingDirectory(configuration
);
63 ILaunchConfigurationWorkingCopy wc
= configuration
.getWorkingCopy();
65 // Reinitialize using standard OSGi launch shortcut
66 // Kind of a hack but it lacks extension capabilities and it is still
67 // cleaner than forking the code (which would imply a lot of fork indeed
68 // because of all the internal classes)
69 new OSGiLaunchShortcut() {
71 public void initializeConfiguration(
72 ILaunchConfigurationWorkingCopy configuration
) {
73 // TODO Auto-generated method stub
74 super.initializeConfiguration(configuration
);
76 }.initializeConfiguration(wc
);
78 OsgiLaunchHelper
.updateLaunchConfiguration(wc
, bundlesToStart
,
79 systemPropertiesToAppend
, null, new File(workingDir
, "data")
83 super.preLaunchCheck(configuration
, launch
, monitor
);