1 package org
.argeo
.slc
.ide
.ui
.launch
.osgi
;
3 import java
.util
.Iterator
;
5 import org
.eclipse
.core
.resources
.IFile
;
6 import org
.eclipse
.core
.resources
.IResource
;
7 import org
.eclipse
.debug
.core
.DebugPlugin
;
8 import org
.eclipse
.debug
.core
.ILaunchConfiguration
;
9 import org
.eclipse
.debug
.core
.ILaunchConfigurationType
;
10 import org
.eclipse
.debug
.core
.ILaunchConfigurationWorkingCopy
;
11 import org
.eclipse
.jdt
.launching
.IJavaLaunchConfigurationConstants
;
12 import org
.eclipse
.jface
.viewers
.ISelection
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.pde
.ui
.launcher
.OSGiLaunchShortcut
;
16 /** Launch shortcut simplifying the launch of a pure OSGi runtime */
17 public class OsgiBootLaunchShortcut
extends OSGiLaunchShortcut
implements
18 OsgiLauncherConstants
{
19 private StringBuffer name
= null;
20 private IFile propertiesFile
= null;
23 protected String
getLaunchConfigurationTypeName() {
24 return OsgiBootEquinoxLaunchConfiguration
.ID
;
28 public void launch(ISelection selection
, String mode
) {
29 // we assume that only one file is selected
30 IStructuredSelection sSelection
= (IStructuredSelection
) selection
;
31 Iterator
<?
> it
= sSelection
.iterator();
32 propertiesFile
= (IFile
) it
.next();
34 name
= new StringBuffer(OsgiLaunchHelper
.extractName(propertiesFile
));
36 super.launch(selection
, mode
);
40 protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc
) {
41 IResource
[] resources
= { propertiesFile
};
42 wc
.setMappedResources(resources
);
43 super.initializeConfiguration(wc
);
45 OsgiLaunchHelper
.setDefaults(wc
, true);
48 IJavaLaunchConfigurationConstants
.ATTR_WORKING_DIRECTORY
,
49 OsgiLaunchHelper
.findWorkingDirectory(propertiesFile
));
51 OsgiLaunchHelper
.updateLaunchConfiguration(wc
, false);
54 protected String
getName(ILaunchConfigurationType type
) {
55 if (name
!= null && !name
.toString().trim().equals(""))
56 return DebugPlugin
.getDefault().getLaunchManager()
57 .generateLaunchConfigurationName(name
.toString());
59 return DebugPlugin
.getDefault().getLaunchManager()
60 .generateLaunchConfigurationName("SLC");
64 protected boolean isGoodMatch(ILaunchConfiguration configuration
) {
66 return name
.toString().equals(configuration
.getName());
68 return super.isGoodMatch(configuration
);