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;
52 protected void addSelectedProjects(List
<String
> bundlesToStart
) {
53 Assert
.isNotNull(selection
);
55 Map
<String
, IPluginModelBase
> bundleProjects
= new HashMap
<String
, IPluginModelBase
>();
56 for (IPluginModelBase modelBase
: PluginRegistry
.getWorkspaceModels()) {
57 IProject bundleProject
= modelBase
.getUnderlyingResource()
59 bundleProjects
.put(bundleProject
.getName(), modelBase
);
62 IStructuredSelection sSelection
= (IStructuredSelection
) selection
;
63 for (Iterator
<?
> it
= sSelection
.iterator(); it
.hasNext();) {
64 Object obj
= it
.next();
65 if (obj
instanceof IProject
) {
66 IProject project
= (IProject
) obj
;
67 if (bundleProjects
.containsKey(project
.getName())) {
68 IPluginModelBase modelBase
= bundleProjects
.get(project
71 BundleDescription bundleDescription
= null;
72 if (modelBase
.isFragmentModel()) {
73 BundleDescription
[] hosts
= modelBase
74 .getBundleDescription().getHost().getHosts();
75 for (BundleDescription bd
: hosts
) {
77 System
.out
.println("Host for "
78 + modelBase
.getBundleDescription()
79 .getSymbolicName() + ": "
80 + bd
.getSymbolicName());
81 bundleDescription
= bd
;
84 bundleDescription
= modelBase
.getBundleDescription();
87 if (bundleDescription
!= null) {
88 String symbolicName
= bundleDescription
90 String bundleName
= bundleDescription
.getName();
92 bundlesToStart
.add(symbolicName
);
94 if (name
.length() > 0)
96 if (bundleName
!= null)
97 name
.append(bundleName
);
99 name
.append(symbolicName
);