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 configuration
.setAttribute(
56 IJavaLaunchConfigurationConstants
.ATTR_WORKING_DIRECTORY
,
57 findWorkingDirectory());
58 OsgiLaunchHelper
.updateLaunchConfiguration(configuration
,
59 bundlesToStart
, systemPropertiesToAppend
, null);
60 } catch (CoreException e
) {
61 Shell shell
= Display
.getCurrent().getActiveShell();
62 ErrorDialog
.openError(shell
, "Error",
63 "Cannot execute initalize configuration", e
.getStatus());
68 protected String
findWorkingDirectory() {
69 // Choose working directory
70 Shell shell
= Display
.getCurrent().getActiveShell();
71 DirectoryDialog dirDialog
= new DirectoryDialog(shell
);
72 dirDialog
.setText("Working Directory");
73 dirDialog
.setMessage("Choose the working directory");
74 return dirDialog
.open();
77 protected void printVm(String prefix
, IVMInstall vmInstall
) {
78 System
.out
.println(prefix
+ " vmInstall: id=" + vmInstall
.getId()
79 + ", name=" + vmInstall
.getName() + ", installLocation="
80 + vmInstall
.getInstallLocation() + ", toString=" + vmInstall
);
81 if (vmInstall
instanceof IVMInstall2
) {
82 IVMInstall2 vmInstall2
= (IVMInstall2
) vmInstall
;
83 System
.out
.println(" vmInstall: javaVersion="
84 + vmInstall2
.getJavaVersion());
88 protected String
getName(ILaunchConfigurationType type
) {
89 if (name
!= null && !name
.toString().trim().equals(""))
90 return name
.toString();
96 protected boolean isGoodMatch(ILaunchConfiguration configuration
) {
98 return name
.toString().equals(configuration
.getName());
100 return super.isGoodMatch(configuration
);