1 package org
.argeo
.slc
.ide
.ui
;
5 import org
.eclipse
.core
.resources
.IResource
;
6 import org
.eclipse
.core
.runtime
.CoreException
;
7 import org
.eclipse
.debug
.core
.DebugEvent
;
8 import org
.eclipse
.debug
.core
.DebugPlugin
;
9 import org
.eclipse
.debug
.core
.IDebugEventSetListener
;
10 import org
.eclipse
.debug
.core
.ILaunch
;
11 import org
.eclipse
.debug
.core
.model
.IProcess
;
12 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
13 import org
.eclipse
.jface
.resource
.ImageRegistry
;
14 import org
.eclipse
.pde
.core
.plugin
.TargetPlatform
;
15 import org
.eclipse
.swt
.graphics
.Image
;
16 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
17 import org
.osgi
.framework
.BundleContext
;
20 * The activator class controls the plug-in life cycle
22 public class SlcIdeUiPlugin
extends AbstractUIPlugin
{
25 public static final String ID
= "org.argeo.slc.ide.ui";
27 // The shared instance
28 private static SlcIdeUiPlugin plugin
;
33 public SlcIdeUiPlugin() {
37 public void start(BundleContext context
) throws Exception
{
40 DebugPlugin
.getDefault()
41 .addDebugEventListener(new DebugEventListener());
43 String location
= TargetPlatform
.getLocation();
44 System
.out
.println(location
);
48 public void stop(BundleContext context
) throws Exception
{
54 * Returns the shared instance
56 * @return the shared instance
58 public static SlcIdeUiPlugin
getDefault() {
62 public Image
getImage(String relativeURL
) {
63 ImageRegistry imageRegistry
= getImageRegistry();
64 Image image
= imageRegistry
.get(relativeURL
);
66 URL imageURL
= getBundle().getEntry(relativeURL
);
67 ImageDescriptor descriptor
= ImageDescriptor
68 .createFromURL(imageURL
);
69 image
= descriptor
.createImage();
70 imageRegistry
.put(relativeURL
, image
);
75 protected static class DebugEventListener
implements IDebugEventSetListener
{
76 public void handleDebugEvents(DebugEvent
[] events
) {
80 for (int i
= 0; i
< events
.length
; i
++) {
81 DebugEvent event
= events
[i
];
84 Object source
= event
.getSource();
85 if (source
instanceof IProcess
86 && event
.getKind() == DebugEvent
.TERMINATE
) {
87 IProcess process
= (IProcess
) source
;
88 // if (process == null)
90 ILaunch launch
= process
.getLaunch();
92 refreshOsgiBootLaunch(launch
);
97 protected void refreshOsgiBootLaunch(ILaunch launch
) {
101 IResource
[] resources
= launch
.getLaunchConfiguration()
102 .getMappedResources();
103 if (resources
== null)
105 if (resources
.length
> 0) {
106 IResource propertiesFile
= resources
[0];
107 if (propertiesFile
.getParent() == null)
109 propertiesFile
.getParent().refreshLocal(
110 IResource
.DEPTH_INFINITE
, null);
111 // System.out.println("Refreshed "
112 // + propertiesFile.getParent());
114 } catch (CoreException e
) {