1 package org
.argeo
.slc
.ide
.ui
.launch
.osgi
;
3 import java
.util
.ArrayList
;
4 import java
.util
.HashMap
;
8 import org
.eclipse
.core
.runtime
.CoreException
;
9 import org
.eclipse
.debug
.core
.ILaunchConfiguration
;
10 import org
.eclipse
.debug
.core
.ILaunchConfigurationType
;
11 import org
.eclipse
.debug
.core
.ILaunchConfigurationWorkingCopy
;
12 import org
.eclipse
.jdt
.launching
.IJavaLaunchConfigurationConstants
;
13 import org
.eclipse
.jdt
.launching
.IVMInstall
;
14 import org
.eclipse
.jdt
.launching
.IVMInstall2
;
15 import org
.eclipse
.jface
.dialogs
.ErrorDialog
;
16 import org
.eclipse
.jface
.viewers
.ISelection
;
17 import org
.eclipse
.pde
.ui
.launcher
.OSGiLaunchShortcut
;
18 import org
.eclipse
.swt
.widgets
.DirectoryDialog
;
19 import org
.eclipse
.swt
.widgets
.Display
;
20 import org
.eclipse
.swt
.widgets
.Shell
;
22 public abstract class AbstractOsgiLaunchShortcut
extends OSGiLaunchShortcut
{
23 protected StringBuffer name
= null;
25 protected List
<String
> bundlesToStart
= new ArrayList
<String
>();
26 protected Map
<String
, String
> systemPropertiesToAppend
= new HashMap
<String
, String
>();
29 public void launch(ISelection selection
, String mode
) {
30 super.launch(selection
, mode
);
32 bundlesToStart
.clear();
33 systemPropertiesToAppend
.clear();
36 protected void initializeConfiguration(
37 ILaunchConfigurationWorkingCopy configuration
) {
39 super.initializeConfiguration(configuration
);
43 OsgiLauncherConstants
.ATTR_DEFAULT_VM_ARGS
,
46 IJavaLaunchConfigurationConstants
.ATTR_VM_ARGUMENTS
,
48 String defaultProgArgs
= configuration
.getAttribute(
49 IJavaLaunchConfigurationConstants
.ATTR_PROGRAM_ARGUMENTS
,
51 configuration
.setAttribute(
52 OsgiLauncherConstants
.ATTR_DEFAULT_PROGRAM_ARGS
,
55 OsgiLaunchHelper
.updateLaunchConfiguration(configuration
,
56 bundlesToStart
, systemPropertiesToAppend
,
57 findWorkingDirectory(), null);
58 } catch (CoreException e
) {
59 Shell shell
= Display
.getCurrent().getActiveShell();
60 ErrorDialog
.openError(shell
, "Error",
61 "Cannot execute initalize configuration", e
.getStatus());
66 protected String
findWorkingDirectory() {
67 // Choose working directory
68 Shell shell
= Display
.getCurrent().getActiveShell();
69 DirectoryDialog dirDialog
= new DirectoryDialog(shell
);
70 dirDialog
.setText("Working Directory");
71 dirDialog
.setMessage("Choose the working directory");
72 return dirDialog
.open();
75 protected void printVm(String prefix
, IVMInstall vmInstall
) {
76 System
.out
.println(prefix
+ " vmInstall: id=" + vmInstall
.getId()
77 + ", name=" + vmInstall
.getName() + ", installLocation="
78 + vmInstall
.getInstallLocation() + ", toString=" + vmInstall
);
79 if (vmInstall
instanceof IVMInstall2
) {
80 IVMInstall2 vmInstall2
= (IVMInstall2
) vmInstall
;
81 System
.out
.println(" vmInstall: javaVersion="
82 + vmInstall2
.getJavaVersion());
86 protected String
getName(ILaunchConfigurationType type
) {
87 if (name
!= null && !name
.toString().trim().equals(""))
88 return name
.toString();
94 protected boolean isGoodMatch(ILaunchConfiguration configuration
) {
96 return name
.toString().equals(configuration
.getName());
98 return super.isGoodMatch(configuration
);