]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.ide.ui/src/main/java/org/argeo/slc/ide/ui/launch/osgi/OsgiBootLaunchShortcut.java
Catch all exception types
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.ide.ui / src / main / java / org / argeo / slc / ide / ui / launch / osgi / OsgiBootLaunchShortcut.java
1 package org.argeo.slc.ide.ui.launch.osgi;
2
3 import java.util.Iterator;
4
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;
15
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;
21
22 @Override
23 protected String getLaunchConfigurationTypeName() {
24 return OsgiBootEquinoxLaunchConfiguration.ID;
25 }
26
27 @Override
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();
33
34 name = new StringBuffer(OsgiLaunchHelper.extractName(propertiesFile));
35
36 super.launch(selection, mode);
37 }
38
39 @Override
40 protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) {
41 IResource[] resources = { propertiesFile };
42 wc.setMappedResources(resources);
43 super.initializeConfiguration(wc);
44
45 OsgiLaunchHelper.setDefaults(wc, true);
46
47 wc.setAttribute(
48 IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
49 OsgiLaunchHelper.findWorkingDirectory(propertiesFile));
50
51 OsgiLaunchHelper.updateLaunchConfiguration(wc, false);
52 }
53
54 protected String getName(ILaunchConfigurationType type) {
55 if (name != null && !name.toString().trim().equals(""))
56 return DebugPlugin.getDefault().getLaunchManager()
57 .generateLaunchConfigurationName(name.toString());
58 else
59 return DebugPlugin.getDefault().getLaunchManager()
60 .generateLaunchConfigurationName("SLC");
61 }
62
63 @Override
64 protected boolean isGoodMatch(ILaunchConfiguration configuration) {
65 if (name != null) {
66 return name.toString().equals(configuration.getName());
67 }
68 return super.isGoodMatch(configuration);
69 }
70
71 }