1 package org
.argeo
.slc
.ide
.ui
.launch
.osgi
;
3 import java
.util
.ArrayList
;
4 import java
.util
.HashMap
;
5 import java
.util
.Iterator
;
9 import org
.eclipse
.core
.resources
.IProject
;
10 import org
.eclipse
.core
.runtime
.Assert
;
11 import org
.eclipse
.jface
.viewers
.ISelection
;
12 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
13 import org
.eclipse
.osgi
.service
.resolver
.BundleDescription
;
14 import org
.eclipse
.pde
.core
.plugin
.IPluginModelBase
;
15 import org
.eclipse
.pde
.core
.plugin
.PluginRegistry
;
17 public class SlcLaunchShortcut
extends AbstractOsgiLaunchShortcut
{
18 private Boolean debug
= false;
20 private String springOsgiExtenderId
= "org.springframework.osgi.extender";
21 private String slcSupportEquinoxId
= "org.argeo.slc.support.equinox";
22 // private String slcAgentId = "org.argeo.slc.agent";
23 // private String osgiBootId = "org.argeo.slc.osgiboot";
25 private ISelection selection
= null;
27 private final List
<String
> defaultBundlesToStart
= new ArrayList
<String
>();
28 public SlcLaunchShortcut() {
30 defaultBundlesToStart
.add(springOsgiExtenderId
);
31 defaultBundlesToStart
.add(slcSupportEquinoxId
);
32 // defaultBundlesToStart.add(slcAgentId);
35 public void launch(ISelection selection
, String mode
) {
36 this.selection
= selection
;
37 this.name
= new StringBuffer();
39 bundlesToStart
= new ArrayList
<String
>();
40 bundlesToStart
.addAll(defaultBundlesToStart
);
42 if (selection
!= null) {
43 addSelectedProjects(bundlesToStart
);
46 super.launch(selection
, mode
);
49 this.selection
= null;
51 bundlesToStart
= null;
54 protected void addSelectedProjects(List
<String
> bundlesToStart
) {
55 Assert
.isNotNull(selection
);
57 Map
<String
, IPluginModelBase
> bundleProjects
= new HashMap
<String
, IPluginModelBase
>();
58 for (IPluginModelBase modelBase
: PluginRegistry
.getWorkspaceModels()) {
59 IProject bundleProject
= modelBase
.getUnderlyingResource()
61 bundleProjects
.put(bundleProject
.getName(), modelBase
);
64 IStructuredSelection sSelection
= (IStructuredSelection
) selection
;
65 for (Iterator
<?
> it
= sSelection
.iterator(); it
.hasNext();) {
66 Object obj
= it
.next();
67 if (obj
instanceof IProject
) {
68 IProject project
= (IProject
) obj
;
69 if (bundleProjects
.containsKey(project
.getName())) {
70 IPluginModelBase modelBase
= bundleProjects
.get(project
73 BundleDescription bundleDescription
= null;
74 if (modelBase
.isFragmentModel()) {
75 BundleDescription
[] hosts
= modelBase
76 .getBundleDescription().getHost().getHosts();
77 for (BundleDescription bd
: hosts
) {
79 System
.out
.println("Host for "
80 + modelBase
.getBundleDescription()
81 .getSymbolicName() + ": "
82 + bd
.getSymbolicName());
83 bundleDescription
= bd
;
86 bundleDescription
= modelBase
.getBundleDescription();
89 if (bundleDescription
!= null) {
90 String symbolicName
= bundleDescription
92 String bundleName
= bundleDescription
.getName();
94 bundlesToStart
.add(symbolicName
);
96 if (name
.length() > 0)
98 if (bundleName
!= null)
99 name
.append(bundleName
);
101 name
.append(symbolicName
);