Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 243441 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java (-23 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
public class ConfigurationAttributeAdapter extends ParentAdapter {
14
15
	public ConfigurationAttributeAdapter(Object object) {
16
		super(object);
17
	}
18
19
	protected Object[] createChildren() {
20
		return null;
21
	}
22
23
}
(-)src/org/eclipse/pde/internal/runtime/registry/PluginAdapter.java (-39 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.BundleFolder;
14
import org.osgi.framework.Bundle;
15
16
/**
17
 * Adapter for bundle objects.
18
 *
19
 */
20
public class PluginAdapter extends ParentAdapter {
21
22
	public PluginAdapter(Bundle object) {
23
		super(object);
24
	}
25
26
	protected Object[] createChildren() {
27
		Bundle bundle = (Bundle) getObject();
28
29
		Object[] array = new Object[7];
30
		array[0] = new BundleFolder(bundle, IBundleFolder.F_LOCATION);
31
		array[1] = new BundleFolder(bundle, IBundleFolder.F_IMPORTS);
32
		array[2] = new BundleFolder(bundle, IBundleFolder.F_LIBRARIES);
33
		array[3] = new BundleFolder(bundle, IBundleFolder.F_EXTENSION_POINTS);
34
		array[4] = new BundleFolder(bundle, IBundleFolder.F_EXTENSIONS);
35
		array[5] = new BundleFolder(bundle, IBundleFolder.F_REGISTERED_SERVICES);
36
		array[6] = new BundleFolder(bundle, IBundleFolder.F_SERVICES_IN_USE);
37
		return array;
38
	}
39
}
(-)src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java (-15 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
public interface IConfigurationAttribute {
14
	public String getLabel();
15
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java (-206 / +26 lines)
Lines 10-117 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
11
package org.eclipse.pde.internal.runtime.registry;
12
12
13
import java.util.*;
13
import java.util.ArrayList;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.jface.viewers.ITreeContentProvider;
14
import org.eclipse.jface.viewers.ITreeContentProvider;
16
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.jface.viewers.Viewer;
17
import org.eclipse.osgi.util.ManifestElement;
16
import org.eclipse.pde.internal.runtime.registry.model.*;
18
import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
17
import org.eclipse.pde.internal.runtime.registry.model.impl.generic.*;
19
import org.osgi.framework.*;
18
import org.eclipse.pde.internal.runtime.registry.model.impl.local.ExtensionPointAdapter;
20
19
21
public class RegistryBrowserContentProvider implements ITreeContentProvider {
20
public class RegistryBrowserContentProvider implements ITreeContentProvider {
22
	private Hashtable fExtensionPointMap = new Hashtable();
23
	public boolean isInExtensionSet;
21
	public boolean isInExtensionSet;
24
22
25
	static class BundleFolder implements IBundleFolder {
26
		private int id;
27
		private Bundle bundle;
28
		private Object[] children;
29
30
		public BundleFolder(Bundle pd, int id) {
31
			this.bundle = pd;
32
			this.id = id;
33
		}
34
35
		public Bundle getBundle() {
36
			return bundle;
37
		}
38
39
		public Object[] getChildren() {
40
			if (children == null) {
41
				children = getFolderChildren(bundle, id);
42
			}
43
			return children;
44
		}
45
46
		/**
47
		 * Resets folder's previously cached knowledge about it's children. 
48
		 */
49
		public void refresh() {
50
			children = null;
51
		}
52
53
		public int getFolderId() {
54
			return id;
55
		}
56
57
		public Object getAdapter(Class key) {
58
			return null;
59
		}
60
	}
61
62
	static class BundlePrerequisite implements IBundlePrerequisite {
63
		private ManifestElement underlyingElement;
64
65
		public BundlePrerequisite(ManifestElement element) {
66
			underlyingElement = element;
67
		}
68
69
		public ManifestElement getPrerequisite() {
70
			return underlyingElement;
71
		}
72
73
		public boolean isExported() {
74
			String visibility = underlyingElement.getDirective(Constants.VISIBILITY_DIRECTIVE);
75
			return Constants.VISIBILITY_REEXPORT.equals(visibility);
76
		}
77
78
		public String getLabel() {
79
			String version = underlyingElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
80
			String value = underlyingElement.getValue();
81
			if (version == null)
82
				return value;
83
			if (Character.isDigit(version.charAt(0)))
84
				version = '(' + version + ')';
85
			return value + ' ' + version;
86
		}
87
	}
88
89
	static class BundleLibrary implements IBundleLibrary {
90
		private ManifestElement underlyingElement;
91
92
		public BundleLibrary(ManifestElement element) {
93
			underlyingElement = element;
94
		}
95
96
		public String getLibrary() {
97
			return underlyingElement.getValue();
98
		}
99
	}
100
101
	/**
102
	 * Creates contents adapter for given folder id.
103
	 * @param object Folder contents to be wrapped in adapter
104
	 * @param id Type of folder
105
	 * @return Adapter 
106
	 */
107
	static protected PluginObjectAdapter createAdapter(Object object, int id) {
108
		if (id == IBundleFolder.F_EXTENSIONS)
109
			return new ExtensionAdapter(object);
110
		if (id == IBundleFolder.F_EXTENSION_POINTS)
111
			return new ExtensionPointAdapter(object);
112
		return new PluginObjectAdapter(object);
113
	}
114
115
	public void dispose() { // nothing to dispose
23
	public void dispose() { // nothing to dispose
116
	}
24
	}
117
25
Lines 123-147 Link Here
123
		if (element == null)
31
		if (element == null)
124
			return null;
32
			return null;
125
33
126
		if (element instanceof ExtensionAdapter)
34
		if (element instanceof IExtensionAdapter)
127
			return ((ExtensionAdapter) element).getChildren();
35
			return ((IExtensionAdapter) element).getConfigurationElements();
128
36
129
		isInExtensionSet = false;
37
		isInExtensionSet = false;
130
		if (element instanceof ExtensionPointAdapter)
38
		if (element instanceof ExtensionPointAdapter)
131
			return ((ExtensionPointAdapter) element).getChildren();
39
			return ((ExtensionPointAdapter) element).getExtensions();
132
40
133
		if (element instanceof ConfigurationElementAdapter)
41
		if (element instanceof IElement)
134
			return ((ConfigurationElementAdapter) element).getChildren();
42
			return ((IElement) element).getElements();
135
43
136
		if (element instanceof PluginAdapter) {
44
		if (element instanceof IBundle) {
137
			PluginAdapter bundle = (PluginAdapter) element;
45
			IBundle bundle = (IBundle) element;
138
46
139
			Object[] folders = bundle.getChildren();
47
			Object[] folders = new Object[7];
48
			folders[0] = new ConfigurationAttribute(IAttribute.F_LOCATION, bundle.getLocation());
49
			folders[1] = new BundleFolder(bundle, IBundleFolder.F_IMPORTS);
50
			folders[2] = new BundleFolder(bundle, IBundleFolder.F_LIBRARIES);
51
			folders[3] = new BundleFolder(bundle, IBundleFolder.F_EXTENSION_POINTS);
52
			folders[4] = new BundleFolder(bundle, IBundleFolder.F_EXTENSIONS);
53
			folders[5] = new BundleFolder(bundle, IBundleFolder.F_REGISTERED_SERVICES);
54
			folders[6] = new BundleFolder(bundle, IBundleFolder.F_SERVICES_IN_USE);
140
55
141
			// filter out empty folders
56
			// filter out empty folders
142
			ArrayList folderList = new ArrayList();
57
			ArrayList folderList = new ArrayList();
143
			for (int i = 0; i < folders.length; i++) {
58
			for (int i = 1; i < folders.length; i++) {
144
				if (folders[i] != null && ((IBundleFolder) folders[i]).getChildren() != null || ((IBundleFolder) folders[i]).getFolderId() == IBundleFolder.F_LOCATION)
59
				if (((IBundleFolder) folders[i]).getChildren() != null)
145
					folderList.add(folders[i]);
60
					folderList.add(folders[i]);
146
			}
61
			}
147
			folders = folderList.toArray(new Object[folderList.size()]);
62
			folders = folderList.toArray(new Object[folderList.size()]);
Lines 157-249 Link Here
157
			isInExtensionSet = folder.getFolderId() == IBundleFolder.F_EXTENSIONS;
72
			isInExtensionSet = folder.getFolderId() == IBundleFolder.F_EXTENSIONS;
158
			return ((IBundleFolder) element).getChildren();
73
			return ((IBundleFolder) element).getChildren();
159
		}
74
		}
160
		if (element instanceof IConfigurationElement) {
75
		if (element instanceof IElement) {
161
			return ((IConfigurationElement) element).getChildren();
76
			return ((IElement) element).getElements();
162
		}
77
		}
163
		if (element instanceof Object[]) {
78
		if (element instanceof Object[]) {
164
			return (Object[]) element;
79
			return (Object[]) element;
165
		}
80
		}
166
		if (element instanceof IExtensionPoint) {
81
		if (element instanceof IExtensionPointAdapter) {
167
			IExtensionPoint extensionPoint = (IExtensionPoint) element;
82
			IExtensionPointAdapter extensionPoint = (IExtensionPointAdapter) element;
168
			String id = extensionPoint.getUniqueIdentifier();
83
			String id = extensionPoint.getUniqueIdentifier();
169
84
			return extensionPoint.getExtensions();
170
			Object[] children = (Object[]) fExtensionPointMap.get(id);
171
			if (children == null) {
172
				Object[] array = extensionPoint.getExtensions();
173
				if (array != null && array.length > 0) {
174
					children = new Object[array.length];
175
					for (int i = 0; i < array.length; i++) {
176
						children[i] = createAdapter(array[i], IBundleFolder.F_EXTENSIONS);
177
					}
178
179
					fExtensionPointMap.put(id, children);
180
				}
181
			}
182
183
			return children;
184
		}
85
		}
185
		return null;
86
		return null;
186
	}
87
	}
187
88
188
	protected static Object[] getFolderChildren(Bundle bundle, int id) {
189
		Object[] array = null;
190
		String bundleId = bundle.getSymbolicName();
191
		switch (id) {
192
			case IBundleFolder.F_EXTENSIONS :
193
				array = Platform.getExtensionRegistry().getExtensions(bundleId);
194
				break;
195
			case IBundleFolder.F_EXTENSION_POINTS :
196
				array = Platform.getExtensionRegistry().getExtensionPoints(bundleId);
197
				break;
198
			case IBundleFolder.F_IMPORTS :
199
				array = getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE);
200
				break;
201
			case IBundleFolder.F_LIBRARIES :
202
				array = getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH);
203
				break;
204
			case IBundleFolder.F_REGISTERED_SERVICES :
205
				return getServices(bundle, IBundleFolder.F_REGISTERED_SERVICES);
206
			case IBundleFolder.F_SERVICES_IN_USE :
207
				return getServices(bundle, IBundleFolder.F_SERVICES_IN_USE);
208
		}
209
		Object[] result = null;
210
		if (array != null && array.length > 0) {
211
			result = new Object[array.length];
212
			for (int i = 0; i < array.length; i++) {
213
				result[i] = createAdapter(array[i], id);
214
			}
215
		}
216
		return result;
217
	}
218
219
	protected static Object[] getServices(Bundle bundle, int type) {
220
		Set result = new HashSet();
221
222
		try {
223
			ServiceReference[] references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null);
224
225
			for (int i = 0; i < references.length; i++) {
226
				ServiceReference ref = references[i];
227
228
				if ((type == IBundleFolder.F_REGISTERED_SERVICES) && (bundle.equals(ref.getBundle()))) {
229
					result.add(new ServiceReferenceAdapter(ref));
230
				}
231
232
				Bundle[] usingBundles = ref.getUsingBundles();
233
				if ((type == IBundleFolder.F_SERVICES_IN_USE) && (usingBundles != null && Arrays.asList(usingBundles).contains(bundle))) {
234
					result.add(new ServiceReferenceAdapter(ref));
235
				}
236
			}
237
238
		} catch (InvalidSyntaxException e) { // nothing
239
		}
240
241
		if (result.size() == 0)
242
			return null;
243
244
		return result.toArray(new ServiceReferenceAdapter[result.size()]);
245
	}
246
247
	public Object getParent(Object element) {
89
	public Object getParent(Object element) {
248
		return null;
90
		return null;
249
	}
91
	}
Lines 256-281 Link Here
256
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // do nothing
98
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // do nothing
257
	}
99
	}
258
100
259
	static private Object[] getManifestHeaderArray(Bundle bundle, String headerKey) {
260
		String libraries = (String) bundle.getHeaders().get(headerKey);
261
		try {
262
			ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries);
263
			if (elements == null)
264
				return null;
265
			if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) {
266
				IBundleLibrary[] array = new IBundleLibrary[elements.length];
267
				for (int i = 0; i < elements.length; i++)
268
					array[i] = new BundleLibrary(elements[i]);
269
				return array;
270
			} else if (headerKey.equals(Constants.REQUIRE_BUNDLE)) {
271
				IBundlePrerequisite[] array = new IBundlePrerequisite[elements.length];
272
				for (int i = 0; i < elements.length; i++)
273
					array[i] = new BundlePrerequisite(elements[i]);
274
				return array;
275
			}
276
		} catch (BundleException e) { // do nothing
277
		}
278
		return null;
279
	}
280
281
}
101
}
(-)src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java (-21 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.osgi.util.ManifestElement;
14
15
public interface IBundlePrerequisite {
16
	public ManifestElement getPrerequisite();
17
18
	public boolean isExported();
19
20
	public String getLabel();
21
}
(-)src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java (-27 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
public abstract class ParentAdapter extends PluginObjectAdapter {
14
	Object[] fChildren;
15
16
	public ParentAdapter(Object object) {
17
		super(object);
18
	}
19
20
	protected abstract Object[] createChildren();
21
22
	public Object[] getChildren() {
23
		if (fChildren == null)
24
			fChildren = createChildren();
25
		return fChildren;
26
	}
27
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java (-111 / +62 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.runtime.registry;
12
package org.eclipse.pde.internal.runtime.registry;
13
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
14
import java.util.*;
16
import java.util.*;
15
import java.util.List;
17
import java.util.List;
16
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.runtime.*;
Lines 18-26 Link Here
18
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.viewers.*;
22
import org.eclipse.jface.viewers.*;
21
import org.eclipse.osgi.service.resolver.*;
22
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.pde.internal.runtime.*;
24
import org.eclipse.pde.internal.runtime.*;
25
import org.eclipse.pde.internal.runtime.registry.model.*;
26
import org.eclipse.pde.internal.runtime.registry.model.impl.generic.PluginObjectAdapter;
24
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.BusyIndicator;
28
import org.eclipse.swt.custom.BusyIndicator;
26
import org.eclipse.swt.dnd.*;
29
import org.eclipse.swt.dnd.*;
Lines 33-39 Link Here
33
import org.eclipse.ui.dialogs.PatternFilter;
36
import org.eclipse.ui.dialogs.PatternFilter;
34
import org.eclipse.ui.part.DrillDownAdapter;
37
import org.eclipse.ui.part.DrillDownAdapter;
35
import org.eclipse.ui.part.ViewPart;
38
import org.eclipse.ui.part.ViewPart;
36
import org.osgi.framework.*;
39
import org.osgi.framework.Bundle;
40
import org.osgi.framework.BundleException;
37
import org.osgi.service.packageadmin.PackageAdmin;
41
import org.osgi.service.packageadmin.PackageAdmin;
38
42
39
public class RegistryBrowser extends ViewPart {
43
public class RegistryBrowser extends ViewPart {
Lines 43-54 Link Here
43
	public static final String SHOW_EXTENSIONS_ONLY = "RegistryView.showExtensions.label"; //$NON-NLS-1$ 
47
	public static final String SHOW_EXTENSIONS_ONLY = "RegistryView.showExtensions.label"; //$NON-NLS-1$ 
44
	public static final String SHOW_DISABLED_MODE = "RegistryView.showDisabledMode.label"; //$NON-NLS-1$
48
	public static final String SHOW_DISABLED_MODE = "RegistryView.showDisabledMode.label"; //$NON-NLS-1$
45
49
46
	private RegistryBrowserListener fListener;
47
	private FilteredTree fFilteredTree;
50
	private FilteredTree fFilteredTree;
48
	private TreeViewer fTreeViewer;
51
	private TreeViewer fTreeViewer;
49
	private IMemento fMemento;
52
	private IMemento fMemento;
50
	private int fTotalItems = 0;
53
	private int fTotalItems = 0;
51
54
55
	private IRegistryModel model;
56
	private IModelChangeListener listener;
57
52
	// menus and action items
58
	// menus and action items
53
	private Action fRefreshAction;
59
	private Action fRefreshAction;
54
	private Action fShowPluginsAction;
60
	private Action fShowPluginsAction;
Lines 70-99 Link Here
70
	private DrillDownAdapter fDrillDownAdapter;
76
	private DrillDownAdapter fDrillDownAdapter;
71
	private ViewerFilter fActiveFilter = new ViewerFilter() {
77
	private ViewerFilter fActiveFilter = new ViewerFilter() {
72
		public boolean select(Viewer viewer, Object parentElement, Object element) {
78
		public boolean select(Viewer viewer, Object parentElement, Object element) {
73
			if (element instanceof PluginObjectAdapter)
79
			if (element instanceof IExtensionPointAdapter)
74
				element = ((PluginObjectAdapter) element).getObject();
80
				element = Platform.getBundle(((IExtensionPointAdapter) element).getNamespaceIdentifier());
75
			if (element instanceof IExtensionPoint)
81
			else if (element instanceof IExtensionAdapter)
76
				element = Platform.getBundle(((IExtensionPoint) element).getNamespaceIdentifier());
82
				element = Platform.getBundle(((IExtensionAdapter) element).getNamespaceIdentifier());
77
			else if (element instanceof IExtension)
83
			if (element instanceof IBundle)
78
				element = Platform.getBundle(((IExtension) element).getNamespaceIdentifier());
84
				return ((IBundle) element).getState() == Bundle.ACTIVE;
79
			if (element instanceof Bundle)
80
				return ((Bundle) element).getState() == Bundle.ACTIVE;
81
			return true;
85
			return true;
82
		}
86
		}
83
	};
87
	};
84
88
85
	private ViewerFilter fDisabledFilter = new ViewerFilter() {
89
	private ViewerFilter fDisabledFilter = new ViewerFilter() {
86
		PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
87
		State state = plaformAdmin.getState(false);
88
89
		public boolean select(Viewer viewer, Object parentElement, Object element) {
90
		public boolean select(Viewer viewer, Object parentElement, Object element) {
90
			if (element instanceof PluginObjectAdapter)
91
			if (element instanceof IBundle) {
91
				element = ((PluginObjectAdapter) element).getObject();
92
				return !((IBundle) element).isEnabled();
92
93
			if (element instanceof Bundle) {
94
				Bundle bundle = (Bundle) element;
95
				BundleDescription description = state.getBundle(bundle.getBundleId());
96
				return ((state.getDisabledInfos(description)).length > 0);
97
			}
93
			}
98
			return false;
94
			return false;
99
		}
95
		}
Lines 133-138 Link Here
133
		}
129
		}
134
	}
130
	}
135
131
132
	public RegistryBrowser() {
133
		try {
134
			model = RegistryModelFactory.getRegistryModel(new URI("local"));
135
		} catch (URISyntaxException e) {
136
			PDERuntimePlugin.log(e);
137
		}
138
		model.connect();
139
140
		listener = new RegistryBrowserModelChangeListener(this);
141
		model.addModelChangeListener(listener);
142
	}
143
136
	public void init(IViewSite site, IMemento memento) throws PartInitException {
144
	public void init(IViewSite site, IMemento memento) throws PartInitException {
137
		super.init(site, memento);
145
		super.init(site, memento);
138
		if (memento == null)
146
		if (memento == null)
Lines 140-147 Link Here
140
		else
148
		else
141
			this.fMemento = memento;
149
			this.fMemento = memento;
142
		initializeMemento();
150
		initializeMemento();
143
144
		fListener = new RegistryBrowserListener(this);
145
	}
151
	}
146
152
147
	private void initializeMemento() {
153
	private void initializeMemento() {
Lines 159-169 Link Here
159
	}
165
	}
160
166
161
	public void dispose() {
167
	public void dispose() {
162
		if (fListener != null) {
168
		model.disconnect();
163
			Platform.getExtensionRegistry().removeRegistryChangeListener(fListener);
169
		model.removeModelChangeListener(listener);
164
			PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(fListener);
165
			PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener(fListener);
166
		}
167
		fClipboard.dispose();
170
		fClipboard.dispose();
168
		super.dispose();
171
		super.dispose();
169
	}
172
	}
Lines 179-188 Link Here
179
		createTreeViewer(composite);
182
		createTreeViewer(composite);
180
		fClipboard = new Clipboard(fTreeViewer.getTree().getDisplay());
183
		fClipboard = new Clipboard(fTreeViewer.getTree().getDisplay());
181
		fillToolBar();
184
		fillToolBar();
182
183
		PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(fListener);
184
		Platform.getExtensionRegistry().addRegistryChangeListener(fListener);
185
		PDERuntimePlugin.getDefault().getBundleContext().addServiceListener(fListener);
186
	}
185
	}
187
186
188
	private void createTreeViewer(Composite parent) {
187
	private void createTreeViewer(Composite parent) {
Lines 203-217 Link Here
203
		fTreeViewer.setUseHashlookup(true);
202
		fTreeViewer.setUseHashlookup(true);
204
		fTreeViewer.setComparator(new ViewerComparator() {
203
		fTreeViewer.setComparator(new ViewerComparator() {
205
			public int compare(Viewer viewer, Object e1, Object e2) {
204
			public int compare(Viewer viewer, Object e1, Object e2) {
206
				if (e1 instanceof PluginObjectAdapter)
207
					e1 = ((PluginObjectAdapter) e1).getObject();
208
				if (e2 instanceof PluginObjectAdapter)
209
					e2 = ((PluginObjectAdapter) e2).getObject();
210
				if (e1 instanceof IBundleFolder && e2 instanceof IBundleFolder)
205
				if (e1 instanceof IBundleFolder && e2 instanceof IBundleFolder)
211
					return ((IBundleFolder) e1).getFolderId() - ((IBundleFolder) e2).getFolderId();
206
					return ((IBundleFolder) e1).getFolderId() - ((IBundleFolder) e2).getFolderId();
212
				if (e1 instanceof Bundle && e2 instanceof Bundle) {
207
				if (e1 instanceof IBundle && e2 instanceof IBundle) {
213
					e1 = ((Bundle) e1).getSymbolicName();
208
					e1 = ((IBundle) e1).getSymbolicName();
214
					e2 = ((Bundle) e2).getSymbolicName();
209
					e2 = ((IBundle) e2).getSymbolicName();
215
				}
210
				}
216
				return super.compare(viewer, e1, e2);
211
				return super.compare(viewer, e1, e2);
217
			}
212
			}
Lines 240-254 Link Here
240
		tree.setMenu(menu);
235
		tree.setMenu(menu);
241
	}
236
	}
242
237
243
	private PluginObjectAdapter[] getBundles() {
244
		Bundle[] bundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles();
245
		ArrayList list = new ArrayList();
246
		for (int i = 0; i < bundles.length; i++)
247
			if (bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) == null)
248
				list.add(new PluginAdapter(bundles[i]));
249
		return (PluginObjectAdapter[]) list.toArray(new PluginObjectAdapter[list.size()]);
250
	}
251
252
	private void fillToolBar() {
238
	private void fillToolBar() {
253
		fDrillDownAdapter = new RegistryDrillDownAdapter(fTreeViewer);
239
		fDrillDownAdapter = new RegistryDrillDownAdapter(fTreeViewer);
254
		IActionBars bars = getViewSite().getActionBars();
240
		IActionBars bars = getViewSite().getActionBars();
Lines 398-404 Link Here
398
				try {
384
				try {
399
					List bundles = getSelectedBundles();
385
					List bundles = getSelectedBundles();
400
					for (Iterator it = bundles.iterator(); it.hasNext();) {
386
					for (Iterator it = bundles.iterator(); it.hasNext();) {
401
						Bundle bundle = (Bundle) it.next();
387
						IBundle bundle = (IBundle) it.next();
402
						bundle.start();
388
						bundle.start();
403
					}
389
					}
404
				} catch (BundleException e) {
390
				} catch (BundleException e) {
Lines 412-418 Link Here
412
				try {
398
				try {
413
					List bundles = getSelectedBundles();
399
					List bundles = getSelectedBundles();
414
					for (Iterator it = bundles.iterator(); it.hasNext();) {
400
					for (Iterator it = bundles.iterator(); it.hasNext();) {
415
						Bundle bundle = (Bundle) it.next();
401
						IBundle bundle = (IBundle) it.next();
416
						bundle.stop();
402
						bundle.stop();
417
					}
403
					}
418
				} catch (BundleException e) {
404
				} catch (BundleException e) {
Lines 424-438 Link Here
424
		fEnableAction = new Action(PDERuntimeMessages.RegistryView_enableAction_label) {
410
		fEnableAction = new Action(PDERuntimeMessages.RegistryView_enableAction_label) {
425
			public void run() {
411
			public void run() {
426
				List bundles = getSelectedBundles();
412
				List bundles = getSelectedBundles();
427
				State state = PDERuntimePlugin.getDefault().getState();
428
				for (Iterator it = bundles.iterator(); it.hasNext();) {
413
				for (Iterator it = bundles.iterator(); it.hasNext();) {
429
					Bundle bundle = (Bundle) it.next();
414
					IBundle bundle = (IBundle) it.next();
430
					BundleDescription desc = state.getBundle(bundle.getBundleId());
415
					bundle.setEnabled(true);
431
					DisabledInfo[] infos = state.getDisabledInfos(desc);
432
					for (int i = 0; i < infos.length; i++) {
433
						PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
434
						platformAdmin.removeDisabledInfo(infos[i]);
435
					}
436
				}
416
				}
437
				PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
417
				PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
438
				packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()]));
418
				packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()]));
Lines 442-454 Link Here
442
		fDisableAction = new Action(PDERuntimeMessages.RegistryView_disableAction_label) {
422
		fDisableAction = new Action(PDERuntimeMessages.RegistryView_disableAction_label) {
443
			public void run() {
423
			public void run() {
444
				List bundles = getSelectedBundles();
424
				List bundles = getSelectedBundles();
445
				State state = PDERuntimePlugin.getDefault().getState();
446
				for (Iterator it = bundles.iterator(); it.hasNext();) {
425
				for (Iterator it = bundles.iterator(); it.hasNext();) {
447
					Bundle bundle = (Bundle) it.next();
426
					IBundle bundle = (IBundle) it.next();
448
					BundleDescription desc = state.getBundle(bundle.getBundleId());
427
					bundle.setEnabled(false);
449
					DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$
450
					PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
451
					platformAdmin.addDisabledInfo(info);
452
				}
428
				}
453
				PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
429
				PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
454
				packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()]));
430
				packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()]));
Lines 458-484 Link Here
458
		fDiagnoseAction = new Action(PDERuntimeMessages.RegistryView_diagnoseAction_label) {
434
		fDiagnoseAction = new Action(PDERuntimeMessages.RegistryView_diagnoseAction_label) {
459
			public void run() {
435
			public void run() {
460
				List bundles = getSelectedBundles();
436
				List bundles = getSelectedBundles();
461
				State state = PDERuntimePlugin.getDefault().getState();
462
				for (Iterator it = bundles.iterator(); it.hasNext();) {
437
				for (Iterator it = bundles.iterator(); it.hasNext();) {
463
					Bundle bundle = (Bundle) it.next();
438
					IBundle bundle = (IBundle) it.next();
464
					BundleDescription desc = state.getBundle(bundle.getBundleId());
439
					MultiStatus problems = bundle.diagnose();
465
					PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
466
					VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(desc);
467
					ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc);
468
					MultiStatus problems = new MultiStatus(PDERuntimePlugin.ID, IStatus.INFO, PDERuntimeMessages.RegistryView_found_problems, null);
469
					for (int i = 0; i < resolverErrors.length; i++) {
470
						if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST | ResolverError.MISSING_GENERIC_CAPABILITY | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0)
471
							continue;
472
						IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, resolverErrors[i].toString());
473
						problems.add(status);
474
					}
475
440
476
					for (int i = 0; i < unsatisfied.length; i++) {
477
						IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, MessageHelper.getResolutionFailureMessage(unsatisfied[i]));
478
						problems.add(status);
479
					}
480
					Dialog dialog;
441
					Dialog dialog;
481
					if (unsatisfied.length != 0 || resolverErrors.length != 0) {
442
					if (problems.getChildren().length > 0) {
482
						dialog = new DiagnosticsDialog(getSite().getShell(), PDERuntimeMessages.RegistryView_diag_dialog_title, null, problems, IStatus.WARNING);
443
						dialog = new DiagnosticsDialog(getSite().getShell(), PDERuntimeMessages.RegistryView_diag_dialog_title, null, problems, IStatus.WARNING);
483
						dialog.open();
444
						dialog.open();
484
					} else {
445
					} else {
Lines 499-512 Link Here
499
		fCollapseAllAction.setToolTipText(PDERuntimeMessages.RegistryView_collapseAll_tooltip);
460
		fCollapseAllAction.setToolTipText(PDERuntimeMessages.RegistryView_collapseAll_tooltip);
500
	}
461
	}
501
462
502
	protected void updateItems(boolean resetInput) {
463
	public/* was protected */void updateItems(boolean resetInput) {
503
		Object[] input = null;
464
		Object[] input = null;
504
		boolean extOnly = fShowExtensionsOnlyAction.isChecked();
465
		boolean extOnly = fShowExtensionsOnlyAction.isChecked();
505
		if (extOnly)
466
		if (extOnly)
506
			input = Platform.getExtensionRegistry().getExtensionPoints();
467
			input = model.getExtensionPoints();
507
		else
468
		else
508
			input = getBundles();
469
			input = model.getBundles();
509
		fListener.fExtOnly = extOnly;
510
		fTotalItems = input.length;
470
		fTotalItems = input.length;
511
		if (resetInput)
471
		if (resetInput)
512
			fTreeViewer.setInput(new PluginObjectAdapter(input));
472
			fTreeViewer.setInput(new PluginObjectAdapter(input));
Lines 517-523 Link Here
517
		setContentDescription(getTitleSummary());
477
		setContentDescription(getTitleSummary());
518
	}
478
	}
519
479
520
	protected Tree getUndisposedTree() {
480
	public/* was protected */Tree getUndisposedTree() {
521
		if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed())
481
		if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed())
522
			return null;
482
			return null;
523
		return fTreeViewer.getTree();
483
		return fTreeViewer.getTree();
Lines 556-566 Link Here
556
		if (selection != null) {
516
		if (selection != null) {
557
			Object[] elements = selection.toArray();
517
			Object[] elements = selection.toArray();
558
			for (int i = 0; i < elements.length; i++) {
518
			for (int i = 0; i < elements.length; i++) {
559
				if (elements[i] instanceof PluginObjectAdapter) {
519
				if (elements[i] instanceof IBundle) {
560
					PluginObjectAdapter adapter = (PluginObjectAdapter) elements[i];
520
					bundles.add(elements[i]);
561
					Object object = adapter.getObject();
562
					if (object instanceof Bundle)
563
						bundles.add(object);
564
				}
521
				}
565
			}
522
			}
566
		}
523
		}
Lines 570-576 Link Here
570
	private boolean selectedBundlesStarted() {
527
	private boolean selectedBundlesStarted() {
571
		List bundles = getSelectedBundles();
528
		List bundles = getSelectedBundles();
572
		for (Iterator it = bundles.iterator(); it.hasNext();) {
529
		for (Iterator it = bundles.iterator(); it.hasNext();) {
573
			Bundle bundle = (Bundle) it.next();
530
			IBundle bundle = (IBundle) it.next();
574
			if (bundle.getState() != Bundle.ACTIVE)
531
			if (bundle.getState() != Bundle.ACTIVE)
575
				return false;
532
				return false;
576
		}
533
		}
Lines 580-586 Link Here
580
	private boolean selectedBundlesStopped() {
537
	private boolean selectedBundlesStopped() {
581
		List bundles = getSelectedBundles();
538
		List bundles = getSelectedBundles();
582
		for (Iterator it = bundles.iterator(); it.hasNext();) {
539
		for (Iterator it = bundles.iterator(); it.hasNext();) {
583
			Bundle bundle = (Bundle) it.next();
540
			IBundle bundle = (IBundle) it.next();
584
			if (bundle.getState() == Bundle.ACTIVE)
541
			if (bundle.getState() == Bundle.ACTIVE)
585
				return false;
542
				return false;
586
		}
543
		}
Lines 590-600 Link Here
590
	private boolean selectedBundlesDisabled() {
547
	private boolean selectedBundlesDisabled() {
591
		List bundles = getSelectedBundles();
548
		List bundles = getSelectedBundles();
592
		for (Iterator it = bundles.iterator(); it.hasNext();) {
549
		for (Iterator it = bundles.iterator(); it.hasNext();) {
593
			Bundle bundle = (Bundle) it.next();
550
			IBundle bundle = (IBundle) it.next();
594
			State state = PDERuntimePlugin.getDefault().getState();
551
			if (!bundle.isEnabled())
595
			BundleDescription desc = state.getBundle(bundle.getBundleId());
596
			DisabledInfo[] infos = state.getDisabledInfos(desc);
597
			if (infos.length == 0)
598
				return false;
552
				return false;
599
		}
553
		}
600
		return true;
554
		return true;
Lines 603-623 Link Here
603
	private boolean selectedBundlesEnabled() {
557
	private boolean selectedBundlesEnabled() {
604
		List bundles = getSelectedBundles();
558
		List bundles = getSelectedBundles();
605
		for (Iterator it = bundles.iterator(); it.hasNext();) {
559
		for (Iterator it = bundles.iterator(); it.hasNext();) {
606
			Bundle bundle = (Bundle) it.next();
560
			IBundle bundle = (IBundle) it.next();
607
			State state = PDERuntimePlugin.getDefault().getState();
561
			if (bundle.isEnabled())
608
			BundleDescription desc = state.getBundle(bundle.getBundleId());
562
				return true;
609
			DisabledInfo[] infos = state.getDisabledInfos(desc);
610
			if (infos.length > 0)
611
				return false;
612
		}
563
		}
613
		return true;
564
		return true;
614
	}
565
	}
615
566
616
	protected void add(Object object) {
567
	public/* was protected */void add(Object object) {
617
		add(fTreeViewer.getInput(), object);
568
		add(fTreeViewer.getInput(), object);
618
	}
569
	}
619
570
620
	protected void add(Object parent, Object object) {
571
	public/* was protected */void add(Object parent, Object object) {
621
		if (fDrillDownAdapter.canGoHome())
572
		if (fDrillDownAdapter.canGoHome())
622
			return;
573
			return;
623
		fTotalItems += 1;
574
		fTotalItems += 1;
Lines 625-631 Link Here
625
		updateTitle();
576
		updateTitle();
626
	}
577
	}
627
578
628
	protected void remove(Object object) {
579
	public/* was protected */void remove(Object object) {
629
		if (fDrillDownAdapter.canGoHome())
580
		if (fDrillDownAdapter.canGoHome())
630
			return;
581
			return;
631
		fTotalItems -= 1;
582
		fTotalItems -= 1;
Lines 633-647 Link Here
633
		updateTitle();
584
		updateTitle();
634
	}
585
	}
635
586
636
	protected void update(Object object) {
587
	public/* was protected */void update(Object object) {
637
		fTreeViewer.update(object, null);
588
		fTreeViewer.update(object, null);
638
	}
589
	}
639
590
640
	protected void refresh(Object object) {
591
	public/* was protected */void refresh(Object object) {
641
		fTreeViewer.refresh(object);
592
		fTreeViewer.refresh(object);
642
	}
593
	}
643
594
644
	protected TreeItem[] getTreeItems() {
595
	public/* was protected */TreeItem[] getTreeItems() {
645
		return fTreeViewer.getTree().getItems();
596
		return fTreeViewer.getTree().getItems();
646
	}
597
	}
647
}
598
}
(-)src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.core.runtime.IExtension;
15
16
public class ExtensionAdapter extends ParentAdapter {
17
18
	public ExtensionAdapter(Object object) {
19
		super(object);
20
	}
21
22
	protected Object[] createChildren() {
23
		IExtension extension = (IExtension) getObject();
24
25
		IConfigurationElement[] elements = extension.getConfigurationElements();
26
		Object[] result = new ConfigurationElementAdapter[elements.length];
27
		for (int i = 0; i < elements.length; i++) {
28
			IConfigurationElement config = elements[i];
29
			result[i] = new ConfigurationElementAdapter(config);
30
		}
31
		return result;
32
	}
33
}
(-)src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.IExtension;
14
import org.eclipse.core.runtime.IExtensionPoint;
15
16
public class ExtensionPointAdapter extends ParentAdapter {
17
18
	public ExtensionPointAdapter(Object object) {
19
		super(object);
20
	}
21
22
	protected Object[] createChildren() {
23
		IExtensionPoint extensionPoint = (IExtensionPoint) getObject();
24
25
		IExtension[] extensions = extensionPoint.getExtensions();
26
		Object[] result = new Object[extensions.length];
27
		for (int i = 0; i < extensions.length; i++) {
28
			IExtension extension = extensions[i];
29
			result[i] = new ExtensionAdapter(extension);
30
		}
31
		return result;
32
	}
33
}
(-)src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.PlatformObject;
14
15
public class PluginObjectAdapter extends PlatformObject {
16
	private Object fObject;
17
18
	public PluginObjectAdapter(Object object) {
19
		this.fObject = object;
20
	}
21
22
	public Object getObject() {
23
		return fObject;
24
	}
25
}
(-)src/org/eclipse/pde/internal/runtime/registry/ServiceReferenceAdapter.java (-35 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.osgi.framework.ServiceReference;
14
15
public class ServiceReferenceAdapter extends ParentAdapter {
16
17
	public ServiceReferenceAdapter(ServiceReference object) {
18
		super(object);
19
	}
20
21
	protected Object[] createChildren() {
22
		// TODO pluggable support for different services
23
		return null;
24
	}
25
26
	public boolean equals(Object obj) {
27
		// imitate ServiceReference behavior, that multiple ServiceReference instances are equal
28
		return (obj instanceof ServiceReferenceAdapter) ? getObject().equals(((ServiceReferenceAdapter) obj).getObject()) : false;
29
	}
30
31
	public int hashCode() {
32
		// imitate ServiceReference behavior, that multiple ServiceReference instances return the same hashCode
33
		return getObject().hashCode();
34
	}
35
}
(-)src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java (-51 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
15
public class ConfigurationElementAdapter extends ParentAdapter {
16
17
	class ConfigurationAttribute implements IConfigurationAttribute {
18
		private String fLabel;
19
20
		public ConfigurationAttribute(String name, String value) {
21
			fLabel = name + " = " + value; //$NON-NLS-1$
22
		}
23
24
		public String getLabel() {
25
			return fLabel;
26
		}
27
	}
28
29
	public ConfigurationElementAdapter(Object object) {
30
		super(object);
31
	}
32
33
	protected Object[] createChildren() {
34
		IConfigurationElement config = (IConfigurationElement) getObject();
35
		String[] atts = config.getAttributeNames();
36
		IConfigurationAttribute[] catts = new IConfigurationAttribute[atts.length];
37
		for (int i = 0; i < atts.length; i++)
38
			catts[i] = new ConfigurationAttribute(atts[i], config.getAttribute(atts[i]));
39
		IConfigurationElement[] children = config.getChildren();
40
		Object[] result = new Object[children.length + catts.length];
41
		for (int i = 0; i < children.length; i++) {
42
			IConfigurationElement child = children[i];
43
			result[i] = new ConfigurationElementAdapter(child);
44
		}
45
		for (int i = 0; i < catts.length; i++) {
46
			IConfigurationAttribute child = catts[i];
47
			result[children.length + i] = new ConfigurationAttributeAdapter(child);
48
		}
49
		return result;
50
	}
51
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java (-388 lines)
Removed Link Here
1
/******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.*;
14
import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.BundleFolder;
15
import org.eclipse.swt.widgets.Tree;
16
import org.eclipse.swt.widgets.TreeItem;
17
import org.osgi.framework.*;
18
19
public class RegistryBrowserListener implements IRegistryChangeListener, BundleListener, ServiceListener {
20
21
	protected RegistryBrowser fBrowser;
22
	protected boolean fExtOnly;
23
24
	protected RegistryBrowserListener(RegistryBrowser browser) {
25
		fBrowser = browser;
26
	}
27
28
	public void registryChanged(final IRegistryChangeEvent event) {
29
		final Tree tree = fBrowser.getUndisposedTree();
30
		if (tree == null)
31
			return;
32
33
		tree.getDisplay().asyncExec(new Runnable() {
34
			public void run() {
35
				IExtensionDelta[] deltas = event.getExtensionDeltas();
36
				for (int i = 0; i < deltas.length; i++) {
37
					if (fExtOnly)
38
						handleExtOnlyEvent(deltas[i]);
39
					else
40
						handleEvent(deltas[i]);
41
				}
42
			}
43
		});
44
	}
45
46
	public void bundleChanged(final BundleEvent event) {
47
		final Tree tree = fBrowser.getUndisposedTree();
48
		if (tree == null)
49
			return;
50
51
		tree.getDisplay().asyncExec(new Runnable() {
52
			public void run() {
53
				if (fExtOnly)
54
					handleExtOnlyEvent(event.getType(), event.getBundle());
55
				else
56
					handleEvent(event.getType(), event.getBundle());
57
			}
58
		});
59
	}
60
61
	void handleEvent(IExtensionDelta delta) {
62
		handleDelta(delta, false);
63
	}
64
65
	void handleExtOnlyEvent(IExtensionDelta delta) {
66
		handleDelta(delta, true);
67
	}
68
69
	private void handleDelta(IExtensionDelta delta, boolean extOnly) {
70
		IExtension ext = delta.getExtension();
71
		IExtensionPoint extPoint = delta.getExtensionPoint();
72
		// TODO fix this method (and addToTree/removeFromTree)
73
		// bug 130655
74
		if (delta.getKind() == IExtensionDelta.ADDED) {
75
			System.out.println("adding "); //$NON-NLS-1$
76
			if (ext != null)
77
				System.out.println("ext: " + ext.getUniqueIdentifier() + "/" + ext.getLabel() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
78
			if (extPoint != null)
79
				System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$
80
			addExtensionObjectToTree(ext, extOnly);
81
			addExtensionObjectToTree(extPoint, extOnly);
82
			//			addToTree(ext);
83
			//			addToTree(extPoint);
84
		} else if (delta.getKind() == IExtensionDelta.REMOVED) {
85
			System.out.println("removing "); //$NON-NLS-1$
86
			if (ext != null)
87
				System.out.println("ext: " + ext.getUniqueIdentifier() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
88
			if (extPoint != null)
89
				System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$
90
			removeFromTree(ext);
91
			removeFromTree(extPoint);
92
		}
93
	}
94
95
	//	private void addToTree(Object object) {
96
	//		String namespace = getNamespaceIdentifier(object);
97
	//		if (namespace == null)
98
	//			return;
99
	//		TreeItem[] items = fTreeViewer.getTree().getItems();
100
	//		for (int i = 0; i < items.length; i++) {
101
	//			Object data = items[i].getData();
102
	//			Object adapted = null;
103
	//			if (data instanceof PluginObjectAdapter)
104
	//				adapted = ((PluginObjectAdapter)data).getObject();
105
	//			if (adapted instanceof Bundle && ((Bundle)adapted).getSymbolicName().equals(namespace)) {
106
	//				addBundleToTree(items[i], data, object);
107
	//			}
108
	//		}
109
	//	}
110
111
	private void addExtensionObjectToTree(Object child, boolean extOnly) {
112
		Object parent = null;
113
		if (!extOnly)
114
			parent = getAdoptingBundleParent(child);
115
		else if (child instanceof IExtensionPoint) {
116
			// add to root
117
			fBrowser.add(child);
118
			return;
119
		} else if (child instanceof IExtension) {
120
			// search all extensionPoints and return the correct one
121
			String extPoint = ((IExtension) child).getExtensionPointUniqueIdentifier();
122
			TreeItem[] items = fBrowser.getTreeItems();
123
			for (int i = 0; i < items.length; i++) {
124
				Object data = items[i].getData();
125
				if (data instanceof PluginObjectAdapter)
126
					data = ((PluginObjectAdapter) data).getObject();
127
				if (data instanceof IExtensionPoint && ((IExtensionPoint) data).getUniqueIdentifier().equals(extPoint)) {
128
					parent = items[i].getData();
129
					break;
130
				}
131
			}
132
		}
133
		if (parent != null)
134
			fBrowser.add(parent, child);
135
	}
136
137
	private Object getAdoptingBundleParent(Object child) {
138
		TreeItem bundleItem = findBundleItem(getNamespaceIdentifier(child));
139
		if (bundleItem != null) {
140
			// TODO fix this
141
			// remove this if (true) clause and return the proper parent
142
			if (true) {
143
				fBrowser.refresh(bundleItem.getData());
144
				fBrowser.updateItems(false);
145
				return null;
146
			}
147
			TreeItem[] folders = bundleItem.getItems();
148
			for (int j = 0; j < folders.length; j++) {
149
				// make sure to check extensionsOnlyMode()
150
				// and add to root/proper extension if true
151
				IBundleFolder folder = (IBundleFolder) folders[j].getData();
152
				if (correctFolder(folder, child))
153
					return folder;
154
			}
155
			// folder not found - 1st extension - refresh bundle item
156
			// to rebuild folders
157
			fBrowser.refresh(bundleItem.getData());
158
		}
159
		return null;
160
	}
161
162
	private TreeItem findBundleItem(String namespace) {
163
		if (namespace == null)
164
			return null;
165
		TreeItem[] items = fBrowser.getTreeItems();
166
		for (int i = 0; i < items.length; i++) {
167
			Object data = items[i].getData();
168
			if (data instanceof PluginObjectAdapter)
169
				data = ((PluginObjectAdapter) data).getObject();
170
			if (data instanceof Bundle && ((Bundle) data).getSymbolicName().equals(namespace))
171
				return items[i];
172
		}
173
		return null;
174
	}
175
176
	//	private void addBundleToTree(TreeItem item, Object data, Object object) {
177
	//		// TODO fix this method
178
	//		if (true) {
179
	//			fTreeViewer.refresh(data);
180
	//			updateItems(false);
181
	//			return;
182
	//		}
183
	//		TreeItem[] folders = item.getItems();
184
	//		for (int j = 0; j < folders.length; j++) {
185
	//			// make sure to check extensionsOnlyMode()
186
	//			// and add to root/proper extension if true
187
	//			IBundleFolder folder = (IBundleFolder)folders[j].getData();
188
	//			if (correctFolder(folder, object)) {
189
	//				fTreeViewer.add(folder, object);
190
	//				return;
191
	//			}
192
	//		}
193
	//		// folder not found - 1st extension - refresh bundle item
194
	//		fTreeViewer.refresh(data);
195
	//	}
196
197
	private String getNamespaceIdentifier(Object object) {
198
		if (object instanceof IExtensionPoint)
199
			return ((IExtensionPoint) object).getNamespaceIdentifier();
200
		if (object instanceof IExtension)
201
			return ((IExtension) object).getContributor().getName();
202
		return null;
203
	}
204
205
	private boolean correctFolder(IBundleFolder folder, Object child) {
206
		if (folder == null)
207
			return false;
208
		if (child instanceof IExtensionPoint)
209
			return folder.getFolderId() == IBundleFolder.F_EXTENSION_POINTS;
210
		if (child instanceof IExtension)
211
			return folder.getFolderId() == IBundleFolder.F_EXTENSIONS;
212
		return false;
213
	}
214
215
	private void removeFromTree(Object object) {
216
		String namespace = getNamespaceIdentifier(object);
217
		if (namespace == null)
218
			return;
219
		TreeItem[] bundles = fBrowser.getTreeItems();
220
		for (int i = 0; i < bundles.length; i++) {
221
			Object data = bundles[i].getData();
222
			Object adapted = null;
223
			if (data instanceof PluginObjectAdapter)
224
				adapted = ((PluginObjectAdapter) data).getObject();
225
			if (adapted instanceof Bundle && ((Bundle) adapted).getSymbolicName().equals(namespace)) {
226
				TreeItem[] folders = bundles[i].getItems();
227
				// TODO fix this method
228
				if (true) {
229
					fBrowser.refresh(data);
230
					fBrowser.updateItems(false);
231
					return;
232
				}
233
				for (int j = 0; j < folders.length; j++) {
234
					IBundleFolder folder = (IBundleFolder) folders[j].getData();
235
					if (correctFolder(folder, object)) {
236
						fBrowser.remove(object);
237
						return;
238
					}
239
				}
240
				// folder not found - 1st extension - refresh bundle item
241
				fBrowser.refresh(data);
242
			}
243
		}
244
	}
245
246
	protected Object findTreeBundleData(Object searchData) {
247
		final Tree tree = fBrowser.getUndisposedTree();
248
		if (tree == null)
249
			return null;
250
251
		Object data = null;
252
		TreeItem[] items = fBrowser.getTreeItems();
253
		if (items == null)
254
			return null;
255
		for (int i = 0; i < items.length; i++) {
256
			Object object = items[i].getData();
257
			data = object;
258
			if (object instanceof PluginObjectAdapter)
259
				object = ((PluginObjectAdapter) object).getObject();
260
			if (searchData.equals(object))
261
				return data;
262
		}
263
		return null;
264
	}
265
266
	void handleEvent(int changeType, Bundle bundle) {
267
		Object data = findTreeBundleData(bundle);
268
		switch (changeType) {
269
			case BundleEvent.INSTALLED :
270
				if (data == null)
271
					fBrowser.add(new PluginAdapter(bundle));
272
				break;
273
			case BundleEvent.UNINSTALLED :
274
				if (data != null)
275
					fBrowser.remove(data);
276
				break;
277
			case BundleEvent.STARTED :
278
			case BundleEvent.STOPPED :
279
			case BundleEvent.UPDATED :
280
			case BundleEvent.RESOLVED :
281
			case BundleEvent.STARTING :
282
			case BundleEvent.STOPPING :
283
			case BundleEvent.UNRESOLVED :
284
			case BundleEvent.LAZY_ACTIVATION :
285
				if (data != null)
286
					fBrowser.update(data);
287
				break;
288
		}
289
	}
290
291
	void handleExtOnlyEvent(int changeType, Bundle bundle) {
292
		switch (changeType) {
293
			case BundleEvent.INSTALLED :
294
			case BundleEvent.UNINSTALLED :
295
				// add/remove all extension points contributed by new bundle
296
				IExtensionPoint[] points = Platform.getExtensionRegistry().getExtensionPoints(bundle.getSymbolicName());
297
				for (int i = 0; i < points.length; i++) {
298
					Object pointData = findTreeBundleData(points[i]);
299
					if (pointData == null) {
300
						if (changeType == BundleEvent.INSTALLED)
301
							fBrowser.add(new ExtensionPointAdapter(points[i]));
302
						else
303
							// changeType == BundleEvent.UNINSTALLED
304
							fBrowser.remove(pointData);
305
					}
306
				}
307
				// add/remove all extensions contributed by new bundle
308
				IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(bundle.getSymbolicName());
309
				for (int i = 0; i < extensions.length; i++) {
310
					String pointId = extensions[i].getExtensionPointUniqueIdentifier();
311
					if (changeType == BundleEvent.INSTALLED) {
312
						IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pointId);
313
						Object pointData = findTreeBundleData(point);
314
						if (pointData != null)
315
							fBrowser.add(pointData, new ExtensionAdapter(extensions[i]));
316
					} else { // changeType == BundleEvent.UNINSTALLED
317
						Object extensionData = findTreeBundleData(extensions[i]);
318
						if (extensionData != null)
319
							fBrowser.remove(extensionData);
320
					}
321
				}
322
				break;
323
			case BundleEvent.STARTED :
324
			case BundleEvent.STOPPED :
325
			case BundleEvent.UPDATED :
326
			case BundleEvent.RESOLVED :
327
			case BundleEvent.STARTING :
328
			case BundleEvent.STOPPING :
329
			case BundleEvent.UNRESOLVED :
330
			case BundleEvent.LAZY_ACTIVATION :
331
				// nothing needs to be done for any other cases
332
				break;
333
		}
334
	}
335
336
	public void serviceChanged(final ServiceEvent event) {
337
		final Tree tree = fBrowser.getUndisposedTree();
338
		if (tree == null)
339
			return;
340
341
		tree.getDisplay().asyncExec(new Runnable() {
342
			public void run() {
343
				handleServiceChangedEvent(event);
344
			}
345
		});
346
347
	}
348
349
	protected void handleServiceChangedEvent(ServiceEvent event) {
350
		ServiceReference ref = event.getServiceReference();
351
		switch (event.getType()) {
352
			case ServiceEvent.REGISTERED :
353
			case ServiceEvent.UNREGISTERING :
354
				Bundle bundle = ref.getBundle();
355
				if (bundle == null)
356
					return;
357
				String name = bundle.getSymbolicName();
358
				if (name == null)
359
					return;
360
				TreeItem bundleItem = findBundleItem(name);
361
				if (bundleItem == null)
362
					return;
363
				PluginAdapter bundleAdapter = ((PluginAdapter) bundleItem.getData());
364
				Object[] folders = bundleAdapter.getChildren();
365
366
				for (int j = 0; j < folders.length; j++) {
367
					if (folders[j] instanceof IBundleFolder) {
368
						IBundleFolder folder = (IBundleFolder) folders[j];
369
370
						if (folder.getFolderId() == IBundleFolder.F_REGISTERED_SERVICES) {
371
							if ((event.getType() == ServiceEvent.REGISTERED) || (event.getType() == ServiceEvent.UNREGISTERING)) {
372
								((BundleFolder) folder).refresh(); // refresh model
373
								fBrowser.refresh(folder); // refresh view
374
375
								// refresh whole bundle in case there were folders added - they might have not existed if bundle had no service before
376
								fBrowser.refresh(bundleAdapter);
377
							}
378
						}
379
					}
380
				}
381
382
				break;
383
			case ServiceEvent.MODIFIED :
384
				break;
385
		}
386
	}
387
388
}
(-)src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java (-32 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.osgi.framework.Bundle;
15
16
public interface IBundleFolder extends IAdaptable {
17
	public static final int F_LOCATION = 0;
18
	public static final int F_EXTENSIONS = 1;
19
	public static final int F_EXTENSION_POINTS = 2;
20
	public static final int F_IMPORTS = 3;
21
	public static final int F_LIBRARIES = 4;
22
	public static final int F_REGISTERED_SERVICES = 5;
23
	public static final int F_SERVICES_IN_USE = 6;
24
25
	public Object[] getChildren();
26
27
	public void refresh();
28
29
	int getFolderId();
30
31
	public Bundle getBundle();
32
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java (-65 / +34 lines)
Lines 10-28 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
11
package org.eclipse.pde.internal.runtime.registry;
12
12
13
import java.io.IOException;
14
import java.net.URL;
15
import java.util.Arrays;
13
import java.util.Arrays;
16
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.jface.viewers.LabelProvider;
19
import org.eclipse.jface.viewers.TreeViewer;
17
import org.eclipse.jface.viewers.TreeViewer;
20
import org.eclipse.osgi.service.resolver.*;
21
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.pde.internal.runtime.*;
19
import org.eclipse.pde.internal.runtime.*;
20
import org.eclipse.pde.internal.runtime.registry.model.*;
21
import org.eclipse.pde.internal.runtime.registry.model.impl.generic.PluginObjectAdapter;
23
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.graphics.Image;
24
import org.osgi.framework.Bundle;
23
import org.osgi.framework.Bundle;
25
import org.osgi.framework.ServiceReference;
26
24
27
public class RegistryBrowserLabelProvider extends LabelProvider {
25
public class RegistryBrowserLabelProvider extends LabelProvider {
28
26
Lines 105-119 Link Here
105
		if (element instanceof PluginObjectAdapter)
103
		if (element instanceof PluginObjectAdapter)
106
			element = ((PluginObjectAdapter) element).getObject();
104
			element = ((PluginObjectAdapter) element).getObject();
107
105
108
		if (element instanceof Bundle) {
106
		if (element instanceof IBundle) {
109
			Bundle bundle = (Bundle) element;
107
			IBundle bundle = (IBundle) element;
110
108
111
			// check if bundle is disabled
109
			if (!bundle.isEnabled())
112
			PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
113
			State state = plaformAdmin.getState(false);
114
115
			BundleDescription description = state.getBundle(bundle.getBundleId());
116
			if ((state.getDisabledInfos(description)).length > 0)
117
				return fDisabledImage;
110
				return fDisabledImage;
118
111
119
			switch (bundle.getState()) {
112
			switch (bundle.getState()) {
Lines 122-135 Link Here
122
				case Bundle.UNINSTALLED :
115
				case Bundle.UNINSTALLED :
123
					return fUnresolvedPluginImage;
116
					return fUnresolvedPluginImage;
124
				case Bundle.INSTALLED :
117
				case Bundle.INSTALLED :
125
					if ((state.getDisabledInfos(description)).length > 0)
118
					if (!bundle.isEnabled())
126
						return fUnresolvedPluginImage;
119
						return fUnresolvedPluginImage;
127
				default :
120
				default :
128
					return fPluginImage;
121
					return fPluginImage;
129
			}
122
			}
130
		}
123
		}
131
124
132
		if (element instanceof ServiceReference) {
125
		if (element instanceof IService) {
133
			return fServiceImage;
126
			return fServiceImage;
134
		}
127
		}
135
128
Lines 144-151 Link Here
144
					return fRequiresImage;
137
					return fRequiresImage;
145
				case IBundleFolder.F_LIBRARIES :
138
				case IBundleFolder.F_LIBRARIES :
146
					return fRuntimeImage;
139
					return fRuntimeImage;
147
				case IBundleFolder.F_LOCATION :
148
					return fLocationImage;
149
				case IBundleFolder.F_REGISTERED_SERVICES :
140
				case IBundleFolder.F_REGISTERED_SERVICES :
150
					return fExporterImage;
141
					return fExporterImage;
151
				case IBundleFolder.F_SERVICES_IN_USE :
142
				case IBundleFolder.F_SERVICES_IN_USE :
Lines 153-162 Link Here
153
			}
144
			}
154
			return null;
145
			return null;
155
		}
146
		}
156
		if (element instanceof IExtension)
147
		if (element instanceof IExtensionAdapter)
157
			return fExtensionImage;
148
			return fExtensionImage;
158
149
159
		if (element instanceof IExtensionPoint)
150
		if (element instanceof IExtensionPointAdapter)
160
			return fExtensionPointImage;
151
			return fExtensionPointImage;
161
152
162
		if (element instanceof IBundlePrerequisite)
153
		if (element instanceof IBundlePrerequisite)
Lines 168-193 Link Here
168
		if (element instanceof IConfigurationElement)
159
		if (element instanceof IConfigurationElement)
169
			return fGenericTagImage;
160
			return fGenericTagImage;
170
161
171
		if (element instanceof IConfigurationAttribute)
162
		if (element instanceof IAttribute) {
163
			IAttribute attr = (IAttribute) element;
164
			if (IAttribute.F_LOCATION.equals(attr.getName())) {
165
				return fLocationImage;
166
			}
172
			return fGenericAttrImage;
167
			return fGenericAttrImage;
168
		}
173
169
174
		return null;
170
		return null;
175
	}
171
	}
176
172
177
	public String getText(Object element) {
173
	public String getText(Object element) {
178
		if (element instanceof PluginObjectAdapter)
174
		if (element instanceof IBundle) {
179
			element = ((PluginObjectAdapter) element).getObject();
175
			String id = ((IBundle) element).getSymbolicName();
180
		if (element instanceof Bundle) {
176
			String version = ((IBundle) element).getVersion();
181
			String id = ((Bundle) element).getSymbolicName();
182
			String version = (String) ((Bundle) element).getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
183
			if (version == null)
177
			if (version == null)
184
				return id;
178
				return id;
185
			return id + " (" + version + ")"; //$NON-NLS-1$ //$NON-NLS-2$
179
			return id + " (" + version + ")"; //$NON-NLS-1$ //$NON-NLS-2$
186
		}
180
		}
187
		if (element instanceof ServiceReference) {
181
		if (element instanceof IService) {
188
			ServiceReference ref = (ServiceReference) element;
182
			IService ref = (IService) element;
189
			String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
183
			String[] classes = ref.getClasses();
190
			Long id = (Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
184
			Long id = ref.getId();
191
			String identifier = " (id=" + id.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
185
			String identifier = " (id=" + id.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
192
			return Arrays.asList(classes).toString().concat(identifier);
186
			return Arrays.asList(classes).toString().concat(identifier);
193
		}
187
		}
Lines 205-242 Link Here
205
					return PDERuntimeMessages.RegistryBrowserLabelProvider_registeredServices;
199
					return PDERuntimeMessages.RegistryBrowserLabelProvider_registeredServices;
206
				case IBundleFolder.F_SERVICES_IN_USE :
200
				case IBundleFolder.F_SERVICES_IN_USE :
207
					return PDERuntimeMessages.RegistryBrowserLabelProvider_usedServices;
201
					return PDERuntimeMessages.RegistryBrowserLabelProvider_usedServices;
208
				case IBundleFolder.F_LOCATION :
209
					Bundle bundle = ((IBundleFolder) element).getBundle();
210
					URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$
211
					try {
212
						bundleEntry = FileLocator.resolve(bundleEntry);
213
					} catch (IOException e) { // do nothing
214
					}
215
					IPath path = new Path(bundleEntry.getFile());
216
					String pathString = path.removeTrailingSeparator().toOSString();
217
					if (pathString.startsWith("file:")) //$NON-NLS-1$
218
						pathString = pathString.substring(5);
219
					if (pathString.endsWith("!")) //$NON-NLS-1$
220
						pathString = pathString.substring(0, pathString.length() - 1);
221
					return pathString;
222
			}
202
			}
223
		}
203
		}
224
		if (element instanceof IExtension) {
204
		if (element instanceof IExtensionAdapter) {
225
			if (((RegistryBrowserContentProvider) fViewer.getContentProvider()).isInExtensionSet) {
205
			if (((RegistryBrowserContentProvider) fViewer.getContentProvider()).isInExtensionSet) {
226
				String name = ((IExtension) element).getLabel();
206
				String name = ((IExtensionAdapter) element).getLabel();
227
				String id = ((IExtension) element).getExtensionPointUniqueIdentifier();
207
				String id = ((IExtensionAdapter) element).getExtensionPointUniqueIdentifier();
228
				if (name != null && name.length() > 0)
208
				if (name != null && name.length() > 0)
229
					return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name);
209
					return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name);
230
				return id;
210
				return id;
231
			}
211
			}
232
212
233
			String contributor = ((IExtension) element).getNamespaceIdentifier();
213
			String contributor = ((IExtensionAdapter) element).getNamespaceIdentifier();
234
			return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_contributedBy, contributor);
214
			return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_contributedBy, contributor);
235
215
236
		}
216
		}
237
		if (element instanceof IExtensionPoint) {
217
		if (element instanceof IExtensionPointAdapter) {
238
			String id = ((IExtensionPoint) element).getUniqueIdentifier();
218
			String id = ((IExtensionPointAdapter) element).getUniqueIdentifier();
239
			String name = ((IExtensionPoint) element).getLabel();
219
			String name = ((IExtensionPointAdapter) element).getLabel();
240
			if (name != null && name.length() > 0)
220
			if (name != null && name.length() > 0)
241
				return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name);
221
				return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name);
242
			return id;
222
			return id;
Lines 247-268 Link Here
247
		if (element instanceof IBundleLibrary)
227
		if (element instanceof IBundleLibrary)
248
			return ((IBundleLibrary) element).getLibrary();
228
			return ((IBundleLibrary) element).getLibrary();
249
229
250
		if (element instanceof IConfigurationElement) {
230
		if (element instanceof IElement) {
251
			String label = ((IConfigurationElement) element).getAttribute("label"); //$NON-NLS-1$
231
			return ((IElement) element).getLabel();
252
			if (label == null)
253
				label = ((IConfigurationElement) element).getName();
254
255
			if (label == null)
256
				label = ((IConfigurationElement) element).getAttribute("name"); //$NON-NLS-1$
257
258
			if (label == null && ((IConfigurationElement) element).getAttribute("id") != null) { //$NON-NLS-1$
259
				String[] labelSplit = ((IConfigurationElement) element).getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$
260
				label = labelSplit.length == 0 ? null : labelSplit[labelSplit.length - 1];
261
			}
262
			return label;
263
		}
232
		}
264
		if (element instanceof IConfigurationAttribute)
233
		if (element instanceof IAttribute)
265
			return ((IConfigurationAttribute) element).getLabel();
234
			return ((IAttribute) element).getLabel();
266
235
267
		return super.getText(element);
236
		return super.getText(element);
268
	}
237
	}
(-)src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java (-15 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry;
12
13
public interface IBundleLibrary {
14
	public String getLibrary();
15
}
(-)META-INF/MANIFEST.MF (+3 lines)
Lines 17-22 Link Here
17
Eclipse-LazyStart: true
17
Eclipse-LazyStart: true
18
Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true,
18
Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true,
19
 org.eclipse.pde.internal.runtime.registry;x-internal:=true,
19
 org.eclipse.pde.internal.runtime.registry;x-internal:=true,
20
 org.eclipse.pde.internal.runtime.registry.model;x-internal:=true,
21
 org.eclipse.pde.internal.runtime.registry.model.impl.generic;x-internal:=true,
22
 org.eclipse.pde.internal.runtime.registry.model.impl.local;x-internal:=true,
20
 org.eclipse.pde.internal.runtime.spy;x-internal:=true,
23
 org.eclipse.pde.internal.runtime.spy;x-internal:=true,
21
 org.eclipse.pde.internal.runtime.spy.dialogs;x-internal:=true,
24
 org.eclipse.pde.internal.runtime.spy.dialogs;x-internal:=true,
22
 org.eclipse.pde.internal.runtime.spy.handlers;x-internal:=true,
25
 org.eclipse.pde.internal.runtime.spy.handlers;x-internal:=true,
(-)src/org/eclipse/pde/internal/runtime/registry/model/IRegistryModel.java (+20 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
import org.eclipse.core.runtime.IExtensionPoint;
4
5
public interface IRegistryModel {
6
7
	void connect();
8
9
	IBundle[] getBundles();
10
11
	IService[] getServices();
12
13
	IExtensionPoint[] getExtensionPoints();
14
15
	void addModelChangeListener(IModelChangeListener listener);
16
17
	void removeModelChangeListener(IModelChangeListener listener);
18
19
	void disconnect();
20
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IBundle.java (+38 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
import org.eclipse.core.runtime.MultiStatus;
4
import org.osgi.framework.BundleException;
5
6
public interface IBundle extends IModelObject {
7
8
	String getSymbolicName();
9
10
	String getVersion();
11
12
	boolean isEnabled();
13
14
	void setEnabled(boolean enabled);
15
16
	public IExtensionAdapter[] getExtensions();
17
18
	public IExtensionPointAdapter[] getExtensionPoints();
19
20
	public IBundlePrerequisite[] getImports();
21
22
	public IBundleLibrary[] getLibraries();
23
24
	public Object[] getRegisteredServices();
25
26
	public Object[] getServicesInUse();
27
28
	public String getLocation();
29
30
	int getState();
31
32
	void start() throws BundleException; // XXX Create custom Exception
33
34
	void stop() throws BundleException;
35
36
	MultiStatus diagnose();
37
38
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IBundleFolder.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model;
12
13
public interface IBundleFolder extends IModelObject {
14
	public static final int F_EXTENSIONS = 1;
15
	public static final int F_EXTENSION_POINTS = 2;
16
	public static final int F_IMPORTS = 3;
17
	public static final int F_LIBRARIES = 4;
18
	public static final int F_REGISTERED_SERVICES = 5;
19
	public static final int F_SERVICES_IN_USE = 6;
20
21
	public Object[] getChildren();
22
23
	public void refresh();
24
25
	int getFolderId();
26
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IBundleLibrary.java (+15 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model;
12
13
public interface IBundleLibrary extends IModelObject {
14
	public String getLibrary();
15
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ServiceReferenceAdapter.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
12
13
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
14
import org.eclipse.pde.internal.runtime.registry.model.IService;
15
import org.osgi.framework.ServiceReference;
16
17
public class ServiceReferenceAdapter implements IService {
18
19
	private ServiceReference ref;
20
21
	public ServiceReferenceAdapter(ServiceReference object) {
22
		this.ref = object;
23
	}
24
25
	public boolean equals(Object obj) {
26
		// imitate ServiceReference behavior, that multiple ServiceReference instances are equal
27
		return (obj instanceof ServiceReferenceAdapter) && ref.equals(((ServiceReferenceAdapter) obj).ref);
28
	}
29
30
	public int hashCode() {
31
		// imitate ServiceReference behavior, that multiple ServiceReference instances return the same hashCode
32
		return ref.hashCode();
33
	}
34
35
	public IModelObject getParent() {
36
		// TODO Auto-generated method stub
37
		return null;
38
	}
39
40
	public String[] getClasses() {
41
		return (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
42
	}
43
44
	public Long getId() {
45
		return (Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
46
	}
47
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionAdapter.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.pde.internal.runtime.registry.model.*;
15
16
public class ExtensionAdapter implements IExtensionAdapter {
17
18
	org.eclipse.core.runtime.IExtension extension;
19
20
	public ExtensionAdapter(org.eclipse.core.runtime.IExtension extension) {
21
		this.extension = extension;
22
	}
23
24
	public IElement[] getConfigurationElements() {
25
26
		IConfigurationElement[] elements = extension.getConfigurationElements();
27
		IElement[] result = new IElement[elements.length];
28
		for (int i = 0; i < elements.length; i++) {
29
			IConfigurationElement config = elements[i];
30
			result[i] = new ConfigurationElementAdapter(config);
31
		}
32
		return result;
33
	}
34
35
	public IModelObject getParent() {
36
		// TODO Auto-generated method stub
37
		return null;
38
	}
39
40
	public String getExtensionPointUniqueIdentifier() {
41
		return extension.getExtensionPointUniqueIdentifier();
42
	}
43
44
	public String getLabel() {
45
		return extension.getLabel();
46
	}
47
48
	public String getNamespaceIdentifier() {
49
		return extension.getNamespaceIdentifier();
50
	}
51
52
	public boolean equals(Object o) {
53
		return (o instanceof ExtensionAdapter) && (extension.equals(((ExtensionAdapter) o).extension));
54
	}
55
56
	public int hashCode() {
57
		return extension.hashCode();
58
	}
59
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/RegistryBrowserListener.java (+83 lines)
Added Link Here
1
/******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
12
13
import org.eclipse.core.runtime.*;
14
import org.eclipse.pde.internal.runtime.registry.model.IModelChangeDelta;
15
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
16
import org.eclipse.pde.internal.runtime.registry.model.impl.generic.ModelChangeDelta;
17
import org.osgi.framework.*;
18
19
public class RegistryBrowserListener implements IRegistryChangeListener, BundleListener, ServiceListener {
20
21
	protected LocalModel fModel;
22
23
	public RegistryBrowserListener(LocalModel localModel) {
24
		fModel = localModel;
25
	}
26
27
	public void registryChanged(IRegistryChangeEvent event) {
28
		IExtensionDelta[] deltas = event.getExtensionDeltas();
29
		if (deltas.length == 0) {
30
			return;
31
		}
32
33
		IModelChangeDelta[] delta = new IModelChangeDelta[deltas.length];
34
		for (int i = 0; i < deltas.length; i++) {
35
			IModelObject adapter = fModel.createAdapter(deltas[i].getExtension());
36
			int flag = deltas[i].getKind() == IExtensionDelta.ADDED ? IModelChangeDelta.ADDED : IModelChangeDelta.REMOVED;
37
			delta[i] = new ModelChangeDelta(adapter, flag);
38
		}
39
40
		fModel.fireModelChangeEvent(delta);
41
	}
42
43
	public void bundleChanged(BundleEvent event) {
44
		Bundle bundle = event.getBundle();
45
46
		IModelObject adapter = fModel.createAdapter(bundle);
47
		int flag;
48
		switch (event.getType()) {
49
			case BundleEvent.INSTALLED :
50
				flag = IModelChangeDelta.ADDED;
51
				break;
52
			case BundleEvent.UNINSTALLED :
53
				flag = IModelChangeDelta.REMOVED;
54
				break;
55
			default :
56
				flag = IModelChangeDelta.CHANGED;
57
		}
58
		IModelChangeDelta delta = new ModelChangeDelta(adapter, flag);
59
60
		fModel.fireModelChangeEvent(new IModelChangeDelta[] {delta});
61
	}
62
63
	public void serviceChanged(ServiceEvent event) {
64
		ServiceReference ref = event.getServiceReference();
65
		IModelObject adapter = fModel.createAdapter(ref);
66
		int flag;
67
68
		switch (event.getType()) {
69
			case ServiceEvent.REGISTERED :
70
				flag = IModelChangeDelta.ADDED;
71
				break;
72
			case ServiceEvent.UNREGISTERING :
73
				flag = IModelChangeDelta.REMOVED;
74
				break;
75
			default :
76
				flag = IModelChangeDelta.CHANGED;
77
				break;
78
		}
79
		IModelChangeDelta delta = new ModelChangeDelta(adapter, flag);
80
81
		fModel.fireModelChangeEvent(new IModelChangeDelta[] {delta});
82
	}
83
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IBundlePrerequisite.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model;
12
13
import org.eclipse.osgi.util.ManifestElement;
14
15
public interface IBundlePrerequisite extends IModelObject {
16
	public ManifestElement getPrerequisite();
17
18
	public boolean isExported();
19
20
	public String getLabel();
21
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ConfigurationElementAdapter.java (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.pde.internal.runtime.registry.model.*;
15
import org.eclipse.pde.internal.runtime.registry.model.impl.generic.ConfigurationAttribute;
16
17
public class ConfigurationElementAdapter implements IElement {
18
19
	private IConfigurationElement config;
20
	private IAttribute[] elements;
21
22
	public ConfigurationElementAdapter(IConfigurationElement config) {
23
		this.config = config;
24
	}
25
26
	protected void createChildren() {
27
		String[] atts = config.getAttributeNames();
28
		IAttribute[] catts = new IAttribute[atts.length];
29
		for (int i = 0; i < atts.length; i++)
30
			catts[i] = new ConfigurationAttribute(atts[i], config.getAttribute(atts[i]));
31
		IConfigurationElement[] children = config.getChildren();
32
		IAttribute[] result = new IAttribute[children.length + catts.length];
33
		for (int i = 0; i < children.length; i++) {
34
			IConfigurationElement child = children[i];
35
			result[i] = new ConfigurationElementAdapter(child);
36
		}
37
		for (int i = 0; i < catts.length; i++) {
38
			result[children.length + i] = catts[i];
39
		}
40
		elements = result;
41
	}
42
43
	public IAttribute[] getElements() {
44
		if (elements == null) {
45
			createChildren();
46
		}
47
48
		return elements;
49
	}
50
51
	public IModelObject getParent() {
52
		// TODO Auto-generated method stub
53
		return null;
54
	}
55
56
	public String getLabel() {
57
		String label = config.getAttribute("label"); //$NON-NLS-1$
58
		if (label == null)
59
			label = config.getName();
60
61
		if (label == null)
62
			label = config.getAttribute("name"); //$NON-NLS-1$
63
64
		if (label == null && config.getAttribute("id") != null) { //$NON-NLS-1$
65
			String[] labelSplit = config.getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$
66
			label = labelSplit.length == 0 ? null : labelSplit[labelSplit.length - 1];
67
		}
68
		return label;
69
	}
70
71
	public String getName() {
72
		// TODO Auto-generated method stub
73
		return null;
74
	}
75
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IExtensionAdapter.java (+12 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
public interface IExtensionAdapter extends IModelObject {
4
5
	IElement[] getConfigurationElements();
6
7
	String getLabel();
8
9
	String getExtensionPointUniqueIdentifier();
10
11
	String getNamespaceIdentifier();
12
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/LocalModel.java (+80 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
2
3
import java.util.*;
4
import org.eclipse.core.runtime.*;
5
import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
6
import org.eclipse.pde.internal.runtime.registry.model.*;
7
import org.osgi.framework.*;
8
9
public class LocalModel implements IRegistryModel {
10
11
	private List listeners = new ArrayList();
12
13
	RegistryBrowserListener fListener;
14
15
	public void connect() {
16
		fListener = new RegistryBrowserListener(this);
17
		PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(fListener);
18
		Platform.getExtensionRegistry().addRegistryChangeListener(fListener);
19
		PDERuntimePlugin.getDefault().getBundleContext().addServiceListener(fListener);
20
	}
21
22
	public void disconnect() {
23
		Platform.getExtensionRegistry().removeRegistryChangeListener(fListener);
24
		PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(fListener);
25
		PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener(fListener);
26
	}
27
28
	public IBundle[] getBundles() {
29
		Bundle[] bundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles();
30
		ArrayList list = new ArrayList();
31
		for (int i = 0; i < bundles.length; i++)
32
			if (bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) == null)
33
				list.add(new BundleAdapter(bundles[i]));
34
		return (BundleAdapter[]) list.toArray(new BundleAdapter[list.size()]);
35
	}
36
37
	public IExtensionPoint[] getExtensionPoints() {
38
		return Platform.getExtensionRegistry().getExtensionPoints();
39
	}
40
41
	public IService[] getServices() {
42
		// TODO Auto-generated method stub
43
		return null;
44
	}
45
46
	public void addModelChangeListener(IModelChangeListener listener) {
47
		listeners.add(listener);
48
	}
49
50
	public void removeModelChangeListener(IModelChangeListener listener) {
51
		listeners.remove(listener);
52
	}
53
54
	/**
55
	 * For received domain types: Bundle, IExtension, IExtensionPoint, ServiceReference,
56
	 * generates delta with model types: IBundle, IExtensionAdapter, IExtensionPointAdapter, IService
57
	 *  
58
	 * @param objects
59
	 */
60
	protected void fireModelChangeEvent(IModelChangeDelta[] delta) {
61
		for (Iterator i = listeners.iterator(); i.hasNext();) {
62
			IModelChangeListener listener = (IModelChangeListener) i.next();
63
			listener.modelChanged(delta);
64
		}
65
	}
66
67
	protected IModelObject createAdapter(Object o) {
68
		if (o instanceof Bundle) {
69
			return new BundleAdapter((Bundle) o);
70
		} else if (o instanceof IExtension) {
71
			return new ExtensionAdapter((IExtension) o);
72
		} else if (o instanceof IExtensionAdapter) {
73
			return new ExtensionPointAdapter((IExtensionPoint) o);
74
		} else if (o instanceof ServiceReference) {
75
			return new ServiceReferenceAdapter((ServiceReference) o);
76
		}
77
78
		return null;
79
	}
80
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IExtensionPointAdapter.java (+13 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
public interface IExtensionPointAdapter extends IModelObject {
4
5
	String getUniqueIdentifier();
6
7
	IExtensionAdapter[] getExtensions();
8
9
	String getLabel();
10
11
	String getNamespaceIdentifier();
12
13
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/BundleFolder.java (+62 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.pde.internal.runtime.registry.model.impl.generic;
5
6
import org.eclipse.pde.internal.runtime.registry.model.*;
7
8
public class BundleFolder implements IBundleFolder {
9
	private int id;
10
	private IModelObject parent;
11
	private Object[] children;
12
13
	public BundleFolder(IModelObject parent, int id) {
14
		this.parent = parent;
15
		this.id = id;
16
	}
17
18
	protected void createChildren() {
19
		switch (id) {
20
			case F_EXTENSION_POINTS :
21
				children = ((IBundle) parent).getExtensionPoints();
22
				return;
23
			case F_EXTENSIONS :
24
				children = ((IBundle) parent).getExtensions();
25
				return;
26
			case F_IMPORTS :
27
				children = ((IBundle) parent).getImports();
28
				return;
29
			case F_LIBRARIES :
30
				children = ((IBundle) parent).getLibraries();
31
				return;
32
			case F_REGISTERED_SERVICES :
33
				children = ((IBundle) parent).getRegisteredServices();
34
				return;
35
			case F_SERVICES_IN_USE :
36
				children = ((IBundle) parent).getServicesInUse();
37
				return;
38
		}
39
	}
40
41
	public Object[] getChildren() {
42
		if (children == null) {
43
			createChildren();
44
		}
45
		return children;
46
	}
47
48
	/**
49
	 * Resets folder's previously cached knowledge about it's children. 
50
	 */
51
	public void refresh() {
52
		children = null;
53
	}
54
55
	public int getFolderId() {
56
		return id;
57
	}
58
59
	public IModelObject getParent() {
60
		return parent;
61
	}
62
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeDelta.java (+16 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
/**
4
 * 
5
 * Delta model objects are of type IBundle, IService, IExtension, IExtensionPoint
6
 */
7
public interface IModelChangeDelta {
8
9
	public static final int ADDED = 0;
10
	public static final int CHANGED = 1;
11
	public static final int REMOVED = 2;
12
13
	public IModelObject getModelObject();
14
15
	public int getFlag();
16
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeListener.java (+14 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
/**
4
 * Event provides a list of objects that have changed.
5
 * Possible objects on the list are IBundle, IService, IExtension, IExtensionPoint.
6
 * This is temporary solution and is subject to future changes.
7
 * 
8
 * @author jpospychala
9
 *
10
 */
11
public interface IModelChangeListener {
12
13
	void modelChanged(IModelChangeDelta[] deltas);
14
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ModelChangeDelta.java (+24 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model.impl.generic;
2
3
import org.eclipse.pde.internal.runtime.registry.model.IModelChangeDelta;
4
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
5
6
public class ModelChangeDelta implements IModelChangeDelta {
7
8
	private IModelObject fObject;
9
	private int fFlag;
10
11
	public ModelChangeDelta(IModelObject object, int flag) {
12
		fObject = object;
13
		fFlag = flag;
14
	}
15
16
	public IModelObject getModelObject() {
17
		return fObject;
18
	}
19
20
	public int getFlag() {
21
		return fFlag;
22
	}
23
24
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ConfigurationAttribute.java (+30 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.pde.internal.runtime.registry.model.impl.generic;
5
6
import org.eclipse.pde.internal.runtime.registry.model.IAttribute;
7
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
8
9
public class ConfigurationAttribute implements IAttribute {
10
	private String fLabel;
11
	private String name;
12
13
	public ConfigurationAttribute(String name, String value) {
14
		fLabel = name + " = " + value; //$NON-NLS-1$
15
		this.name = name;
16
	}
17
18
	public String getLabel() {
19
		return fLabel;
20
	}
21
22
	public IModelObject getParent() {
23
		// TODO Auto-generated method stub
24
		return null;
25
	}
26
27
	public String getName() {
28
		return name;
29
	}
30
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IModelObject.java (+6 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
public interface IModelObject {
4
5
	IModelObject getParent();
6
}
(-)src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java (+36 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry;
2
3
import org.eclipse.pde.internal.runtime.registry.model.*;
4
5
public class RegistryBrowserModelChangeListener implements IModelChangeListener {
6
7
	private RegistryBrowser fRegistryBrowser;
8
9
	public RegistryBrowserModelChangeListener(RegistryBrowser registryBrowser) {
10
		fRegistryBrowser = registryBrowser;
11
	}
12
13
	public void modelChanged(final IModelChangeDelta[] delta) {
14
		fRegistryBrowser.getSite().getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() {
15
			public void run() {
16
				update(delta);
17
			}
18
		});
19
	}
20
21
	protected void update(IModelChangeDelta[] deltas) {
22
		for (int i = 0; i < deltas.length; i++) {
23
			IModelObject object = deltas[i].getModelObject();
24
25
			switch (deltas[i].getFlag()) {
26
				case IModelChangeDelta.ADDED : // TODO This doesn't work
27
					fRegistryBrowser.add(object);
28
				case IModelChangeDelta.REMOVED :
29
					fRegistryBrowser.remove(object);
30
				case IModelChangeDelta.CHANGED :
31
					fRegistryBrowser.refresh(object);
32
			}
33
		}
34
	}
35
36
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleAdapter.java (+231 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
2
3
import java.io.IOException;
4
import java.net.URL;
5
import java.util.*;
6
import org.eclipse.core.runtime.*;
7
import org.eclipse.osgi.service.resolver.*;
8
import org.eclipse.osgi.util.ManifestElement;
9
import org.eclipse.pde.internal.runtime.*;
10
import org.eclipse.pde.internal.runtime.registry.model.*;
11
import org.osgi.framework.*;
12
13
public class BundleAdapter implements IBundle {
14
15
	private Bundle bundle;
16
17
	private IExtensionAdapter[] fExtensions;
18
19
	private IExtensionPointAdapter[] fExtensionPoints;
20
21
	public BundleAdapter(Bundle bundle) {
22
		this.bundle = bundle;
23
	}
24
25
	public String getSymbolicName() {
26
		return bundle.getSymbolicName();
27
	}
28
29
	public boolean isEnabled() {
30
		PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
31
		State state = plaformAdmin.getState(false);
32
33
		BundleDescription description = state.getBundle(bundle.getBundleId());
34
		return ((state.getDisabledInfos(description)).length == 0);
35
	}
36
37
	public void setEnabled(boolean enabled) {
38
		PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
39
		State state = plaformAdmin.getState(false);
40
41
		BundleDescription desc = state.getBundle(bundle.getBundleId());
42
43
		if (enabled) {
44
			DisabledInfo[] infos = state.getDisabledInfos(desc);
45
			for (int i = 0; i < infos.length; i++) {
46
				PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
47
				platformAdmin.removeDisabledInfo(infos[i]);
48
			}
49
		} else {
50
			DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$
51
			PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
52
			platformAdmin.addDisabledInfo(info);
53
		}
54
		// TODO Auto-generated method stub
55
56
	}
57
58
	public IModelObject getParent() {
59
		// TODO Auto-generated method stub
60
		return null;
61
	}
62
63
	public IExtensionAdapter[] getExtensions() {
64
		if (fExtensions == null) {
65
			IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(getSymbolicName());
66
			IExtensionAdapter[] tmp = new IExtensionAdapter[extensions.length];
67
			for (int i = 0; i < extensions.length; i++) {
68
				tmp[i] = new ExtensionAdapter(extensions[i]);
69
			}
70
			fExtensions = tmp;
71
		}
72
		return fExtensions;
73
	}
74
75
	public IExtensionPointAdapter[] getExtensionPoints() {
76
		if (fExtensionPoints == null) {
77
			IExtensionPoint[] extensions = Platform.getExtensionRegistry().getExtensionPoints(getSymbolicName());
78
			IExtensionPointAdapter[] tmp = new IExtensionPointAdapter[extensions.length];
79
			for (int i = 0; i < extensions.length; i++) {
80
				tmp[i] = new ExtensionPointAdapter(extensions[i]);
81
			}
82
			fExtensionPoints = tmp;
83
		}
84
		return fExtensionPoints;
85
	}
86
87
	public IBundlePrerequisite[] getImports() {
88
		return (IBundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE);
89
	}
90
91
	public IBundleLibrary[] getLibraries() {
92
		return (IBundleLibrary[]) getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH);
93
	}
94
95
	public Object[] getRegisteredServices() {
96
		return getServices(bundle, IBundleFolder.F_REGISTERED_SERVICES);
97
	}
98
99
	public Object[] getServicesInUse() {
100
		return getServices(bundle, IBundleFolder.F_SERVICES_IN_USE);
101
	}
102
103
	public static Object[] getServices(Bundle bundle, int type) {
104
		Set result = new HashSet();
105
106
		try {
107
			ServiceReference[] references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null);
108
109
			for (int i = 0; i < references.length; i++) {
110
				ServiceReference ref = references[i];
111
112
				if ((type == IBundleFolder.F_REGISTERED_SERVICES) && (bundle.equals(ref.getBundle()))) {
113
					result.add(new ServiceReferenceAdapter(ref));
114
				}
115
116
				Bundle[] usingBundles = ref.getUsingBundles();
117
				if ((type == IBundleFolder.F_SERVICES_IN_USE) && (usingBundles != null && Arrays.asList(usingBundles).contains(bundle))) {
118
					result.add(new ServiceReferenceAdapter(ref));
119
				}
120
			}
121
122
		} catch (InvalidSyntaxException e) { // nothing
123
		}
124
125
		if (result.size() == 0)
126
			return null;
127
128
		return result.toArray(new ServiceReferenceAdapter[result.size()]);
129
	}
130
131
	/*	public static Object[] getFolderChildren(int id) {
132
			Object[] array = null;
133
134
			Object[] result = null;
135
			if (array != null && array.length > 0) {
136
				result = new Object[array.length];
137
				for (int i = 0; i < array.length; i++) {
138
					result[i] = createAdapter(array[i], id);
139
				}
140
			}
141
			return result;
142
		}*/
143
144
	public static Object[] getManifestHeaderArray(Bundle bundle, String headerKey) {
145
		String libraries = (String) bundle.getHeaders().get(headerKey);
146
		try {
147
			ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries);
148
			if (elements == null)
149
				return null;
150
			if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) {
151
				IBundleLibrary[] array = new IBundleLibrary[elements.length];
152
				for (int i = 0; i < elements.length; i++)
153
					array[i] = new BundleLibrary(elements[i]);
154
				return array;
155
			} else if (headerKey.equals(Constants.REQUIRE_BUNDLE)) {
156
				IBundlePrerequisite[] array = new IBundlePrerequisite[elements.length];
157
				for (int i = 0; i < elements.length; i++)
158
					array[i] = new BundlePrerequisite(elements[i]);
159
				return array;
160
			}
161
		} catch (BundleException e) { // do nothing
162
		}
163
		return null;
164
	}
165
166
	public String getLocation() {
167
		URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$
168
		try {
169
			bundleEntry = FileLocator.resolve(bundleEntry);
170
		} catch (IOException e) { // do nothing
171
		}
172
		IPath path = new Path(bundleEntry.getFile());
173
		String pathString = path.removeTrailingSeparator().toOSString();
174
		if (pathString.startsWith("file:")) //$NON-NLS-1$
175
			pathString = pathString.substring(5);
176
		if (pathString.endsWith("!")) //$NON-NLS-1$
177
			pathString = pathString.substring(0, pathString.length() - 1);
178
		return pathString;
179
	}
180
181
	public String getVersion() {
182
		return (String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
183
	}
184
185
	public int getState() {
186
		return bundle.getState();
187
	}
188
189
	public void start() throws BundleException {
190
		bundle.start();
191
	}
192
193
	public void stop() throws BundleException {
194
		bundle.stop();
195
	}
196
197
	public MultiStatus diagnose() {
198
		PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
199
		State state = plaformAdmin.getState(false);
200
201
		BundleDescription desc = state.getBundle(bundle.getBundleId());
202
203
		PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
204
		VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(desc);
205
		ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc);
206
207
		MultiStatus problems = new MultiStatus(PDERuntimePlugin.ID, IStatus.INFO, PDERuntimeMessages.RegistryView_found_problems, null);
208
		for (int i = 0; i < resolverErrors.length; i++) {
209
			if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST | ResolverError.MISSING_GENERIC_CAPABILITY | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0)
210
				continue;
211
			IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, resolverErrors[i].toString());
212
			problems.add(status);
213
		}
214
215
		for (int i = 0; i < unsatisfied.length; i++) {
216
			IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, MessageHelper.getResolutionFailureMessage(unsatisfied[i]));
217
			problems.add(status);
218
		}
219
220
		return problems;
221
	}
222
223
	public boolean equals(Object object) {
224
		return (object instanceof BundleAdapter) && bundle.equals(((BundleAdapter) object).bundle);
225
	}
226
227
	public int hashCode() {
228
		return bundle.hashCode();
229
	}
230
231
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionPointAdapter.java (+68 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
12
13
import org.eclipse.core.runtime.IExtension;
14
import org.eclipse.core.runtime.IExtensionPoint;
15
import org.eclipse.pde.internal.runtime.registry.model.*;
16
17
public class ExtensionPointAdapter implements IExtensionPointAdapter {
18
19
	private IExtensionPoint extensionPoint;
20
21
	private IExtensionAdapter[] extensions;
22
23
	public ExtensionPointAdapter(IExtensionPoint extensionPoint) {
24
		this.extensionPoint = extensionPoint;
25
	}
26
27
	protected void createChildren() {
28
		IExtension[] exts = extensionPoint.getExtensions();
29
		IExtensionAdapter[] result = new IExtensionAdapter[exts.length];
30
		for (int i = 0; i < exts.length; i++) {
31
			result[i] = new ExtensionAdapter(exts[i]);
32
		}
33
		extensions = result;
34
	}
35
36
	public IExtensionAdapter[] getExtensions() {
37
		if (extensions == null) {
38
			createChildren();
39
		}
40
41
		return extensions;
42
	}
43
44
	public IModelObject getParent() {
45
		// TODO Auto-generated method stub
46
		return null;
47
	}
48
49
	public String getLabel() {
50
		return extensionPoint.getLabel();
51
	}
52
53
	public String getUniqueIdentifier() {
54
		return extensionPoint.getUniqueIdentifier();
55
	}
56
57
	public String getNamespaceIdentifier() {
58
		return extensionPoint.getNamespaceIdentifier();
59
	}
60
61
	public boolean equals(Object o) {
62
		return (o instanceof ExtensionPointAdapter) && (extensionPoint.equals(((ExtensionPointAdapter) o).extensionPoint));
63
	}
64
65
	public int hashCode() {
66
		return extensionPoint.hashCode();
67
	}
68
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundlePrerequisite.java (+41 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
5
6
import org.eclipse.osgi.util.ManifestElement;
7
import org.eclipse.pde.internal.runtime.registry.model.IBundlePrerequisite;
8
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
9
import org.osgi.framework.Constants;
10
11
public class BundlePrerequisite implements IBundlePrerequisite {
12
	private ManifestElement underlyingElement;
13
14
	public BundlePrerequisite(ManifestElement element) {
15
		underlyingElement = element;
16
	}
17
18
	public ManifestElement getPrerequisite() {
19
		return underlyingElement;
20
	}
21
22
	public boolean isExported() {
23
		String visibility = underlyingElement.getDirective(Constants.VISIBILITY_DIRECTIVE);
24
		return Constants.VISIBILITY_REEXPORT.equals(visibility);
25
	}
26
27
	public String getLabel() {
28
		String version = underlyingElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
29
		String value = underlyingElement.getValue();
30
		if (version == null)
31
			return value;
32
		if (Character.isDigit(version.charAt(0)))
33
			version = '(' + version + ')';
34
		return value + ' ' + version;
35
	}
36
37
	public IModelObject getParent() {
38
		// TODO Auto-generated method stub
39
		return null;
40
	}
41
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IAttribute.java (+19 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model;
12
13
public interface IAttribute extends IModelObject {
14
	String F_LOCATION = "Location";
15
16
	public String getLabel();
17
18
	String getName();
19
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IElement.java (+7 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
public interface IElement extends IAttribute {
4
5
	IAttribute[] getElements();
6
7
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java (+23 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
import java.net.URI;
4
import org.eclipse.pde.internal.runtime.registry.model.impl.local.LocalModel;
5
6
/**
7
 * Produces RegistryModels for URLs. Valid URLs:
8
 * local
9
 * target
10
 * remote://host:port
11
 *
12
 */
13
public class RegistryModelFactory {
14
15
	/**
16
	 * 
17
	 * @param codename
18
	 * @return never returns null
19
	 */
20
	public static IRegistryModel getRegistryModel(URI codename) {
21
		return new LocalModel();
22
	}
23
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/PluginObjectAdapter.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.runtime.registry.model.impl.generic;
12
13
import org.eclipse.core.runtime.PlatformObject;
14
15
public class PluginObjectAdapter extends PlatformObject {
16
	private Object fObject;
17
18
	public PluginObjectAdapter(Object object) {
19
		this.fObject = object;
20
	}
21
22
	public Object getObject() {
23
		return fObject;
24
	}
25
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/IService.java (+9 lines)
Added Link Here
1
package org.eclipse.pde.internal.runtime.registry.model;
2
3
public interface IService extends IModelObject {
4
5
	String[] getClasses();
6
7
	Long getId();
8
9
}
(-)src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleLibrary.java (+25 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.pde.internal.runtime.registry.model.impl.local;
5
6
import org.eclipse.osgi.util.ManifestElement;
7
import org.eclipse.pde.internal.runtime.registry.model.IBundleLibrary;
8
import org.eclipse.pde.internal.runtime.registry.model.IModelObject;
9
10
public class BundleLibrary implements IBundleLibrary {
11
	private ManifestElement underlyingElement;
12
13
	public BundleLibrary(ManifestElement element) {
14
		underlyingElement = element;
15
	}
16
17
	public String getLibrary() {
18
		return underlyingElement.getValue();
19
	}
20
21
	public IModelObject getParent() {
22
		// TODO Auto-generated method stub
23
		return null;
24
	}
25
}

Return to bug 243441