Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115415 Details for
Bug 243441
[selfhosting] refactor registry view model
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch v4
patch.txt (text/plain), 122.20 KB, created by
Jacek Pospychala
on 2008-10-17 12:01:34 EDT
(
hide
)
Description:
patch v4
Filename:
MIME Type:
Creator:
Jacek Pospychala
Created:
2008-10-17 12:01:34 EDT
Size:
122.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.runtime >Index: src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java 6 Mar 2006 14:50:59 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,23 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-public class ConfigurationAttributeAdapter extends ParentAdapter { >- >- public ConfigurationAttributeAdapter(Object object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- return null; >- } >- >-} >Index: src/org/eclipse/pde/internal/runtime/registry/PluginAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/PluginAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/PluginAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/PluginAdapter.java 24 Apr 2008 08:57:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,39 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.BundleFolder; >-import org.osgi.framework.Bundle; >- >-/** >- * Adapter for bundle objects. >- * >- */ >-public class PluginAdapter extends ParentAdapter { >- >- public PluginAdapter(Bundle object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- Bundle bundle = (Bundle) getObject(); >- >- Object[] array = new Object[7]; >- array[0] = new BundleFolder(bundle, IBundleFolder.F_LOCATION); >- array[1] = new BundleFolder(bundle, IBundleFolder.F_IMPORTS); >- array[2] = new BundleFolder(bundle, IBundleFolder.F_LIBRARIES); >- array[3] = new BundleFolder(bundle, IBundleFolder.F_EXTENSION_POINTS); >- array[4] = new BundleFolder(bundle, IBundleFolder.F_EXTENSIONS); >- array[5] = new BundleFolder(bundle, IBundleFolder.F_REGISTERED_SERVICES); >- array[6] = new BundleFolder(bundle, IBundleFolder.F_SERVICES_IN_USE); >- return array; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java >diff -N src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java >--- src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java 6 Mar 2006 14:50:59 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,15 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-public interface IConfigurationAttribute { >- public String getLabel(); >-} >Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java,v >retrieving revision 1.29 >diff -u -r1.29 RegistryBrowserContentProvider.java >--- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java 24 Apr 2008 08:57:27 -0000 1.29 >+++ src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java 17 Oct 2008 15:42:28 -0000 >@@ -10,106 +10,17 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.runtime.registry; > >-import java.util.*; >-import org.eclipse.core.runtime.*; >+import java.util.ArrayList; > import org.eclipse.jface.viewers.ITreeContentProvider; > import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.osgi.util.ManifestElement; >-import org.eclipse.pde.internal.runtime.PDERuntimePlugin; >-import org.osgi.framework.*; >+import org.eclipse.pde.internal.runtime.registry.model.*; > > public class RegistryBrowserContentProvider implements ITreeContentProvider { >- private Hashtable fExtensionPointMap = new Hashtable(); > public boolean isInExtensionSet; >+ private RegistryBrowser fRegistryBrowser; > >- static class BundleFolder implements IBundleFolder { >- private int id; >- private Bundle bundle; >- private Object[] children; >- >- public BundleFolder(Bundle pd, int id) { >- this.bundle = pd; >- this.id = id; >- } >- >- public Bundle getBundle() { >- return bundle; >- } >- >- public Object[] getChildren() { >- if (children == null) { >- children = getFolderChildren(bundle, id); >- } >- return children; >- } >- >- /** >- * Resets folder's previously cached knowledge about it's children. >- */ >- public void refresh() { >- children = null; >- } >- >- public int getFolderId() { >- return id; >- } >- >- public Object getAdapter(Class key) { >- return null; >- } >- } >- >- static class BundlePrerequisite implements IBundlePrerequisite { >- private ManifestElement underlyingElement; >- >- public BundlePrerequisite(ManifestElement element) { >- underlyingElement = element; >- } >- >- public ManifestElement getPrerequisite() { >- return underlyingElement; >- } >- >- public boolean isExported() { >- String visibility = underlyingElement.getDirective(Constants.VISIBILITY_DIRECTIVE); >- return Constants.VISIBILITY_REEXPORT.equals(visibility); >- } >- >- public String getLabel() { >- String version = underlyingElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); >- String value = underlyingElement.getValue(); >- if (version == null) >- return value; >- if (Character.isDigit(version.charAt(0))) >- version = '(' + version + ')'; >- return value + ' ' + version; >- } >- } >- >- static class BundleLibrary implements IBundleLibrary { >- private ManifestElement underlyingElement; >- >- public BundleLibrary(ManifestElement element) { >- underlyingElement = element; >- } >- >- public String getLibrary() { >- return underlyingElement.getValue(); >- } >- } >- >- /** >- * Creates contents adapter for given folder id. >- * @param object Folder contents to be wrapped in adapter >- * @param id Type of folder >- * @return Adapter >- */ >- static protected PluginObjectAdapter createAdapter(Object object, int id) { >- if (id == IBundleFolder.F_EXTENSIONS) >- return new ExtensionAdapter(object); >- if (id == IBundleFolder.F_EXTENSION_POINTS) >- return new ExtensionPointAdapter(object); >- return new PluginObjectAdapter(object); >+ public RegistryBrowserContentProvider(RegistryBrowser registryBrowser) { >+ fRegistryBrowser = registryBrowser; > } > > public void dispose() { // nothing to dispose >@@ -123,128 +34,74 @@ > if (element == null) > return null; > >- if (element instanceof ExtensionAdapter) >- return ((ExtensionAdapter) element).getChildren(); >+ if (element instanceof Extension) >+ return ((Extension) element).getConfigurationElements(); > > isInExtensionSet = false; >- if (element instanceof ExtensionPointAdapter) >- return ((ExtensionPointAdapter) element).getChildren(); >+ if (element instanceof ExtensionPoint) >+ return ((ExtensionPoint) element).getExtensions().toArray(); > >- if (element instanceof ConfigurationElementAdapter) >- return ((ConfigurationElementAdapter) element).getChildren(); >+ if (element instanceof ConfigurationElement) >+ return ((ConfigurationElement) element).getElements(); > >- if (element instanceof PluginAdapter) { >- PluginAdapter bundle = (PluginAdapter) element; >+ if (element instanceof Bundle) { >+ Bundle bundle = (Bundle) element; > >- Object[] folders = bundle.getChildren(); >+ Folder[] folders = new Folder[6]; >+ folders[0] = new Folder(Folder.F_IMPORTS, bundle); >+ folders[1] = new Folder(Folder.F_LIBRARIES, bundle); >+ folders[2] = new Folder(Folder.F_EXTENSION_POINTS, bundle); >+ folders[3] = new Folder(Folder.F_EXTENSIONS, bundle); >+ folders[4] = new Folder(Folder.F_REGISTERED_SERVICES, bundle); >+ folders[5] = new Folder(Folder.F_SERVICES_IN_USE, bundle); > > // filter out empty folders > ArrayList folderList = new ArrayList(); >+ folderList.add(new Attribute(bundle.getModel(), Attribute.F_LOCATION, bundle.getLocation())); >+ > for (int i = 0; i < folders.length; i++) { >- if (folders[i] != null && ((IBundleFolder) folders[i]).getChildren() != null || ((IBundleFolder) folders[i]).getFolderId() == IBundleFolder.F_LOCATION) >+ if ((folders[i].getChildren() != null) && (folders[i].getChildren().length > 0)) > folderList.add(folders[i]); > } >- folders = folderList.toArray(new Object[folderList.size()]); >- >- return folders; >+ return folderList.toArray(); > } > >- if (element instanceof PluginObjectAdapter) >- element = ((PluginObjectAdapter) element).getObject(); >- >- if (element instanceof IBundleFolder) { >- IBundleFolder folder = (IBundleFolder) element; >- isInExtensionSet = folder.getFolderId() == IBundleFolder.F_EXTENSIONS; >- return ((IBundleFolder) element).getChildren(); >+ if (element instanceof Folder) { >+ Folder folder = (Folder) element; >+ isInExtensionSet = folder.getId() == Folder.F_EXTENSIONS; >+ Object[] objs = ((Folder) element).getChildren(); >+ return objs; >+ } >+ if (element instanceof ConfigurationElement) { >+ return ((ConfigurationElement) element).getElements(); > } >- if (element instanceof IConfigurationElement) { >- return ((IConfigurationElement) element).getChildren(); >+ >+ if (element instanceof ExtensionPoint) { >+ ExtensionPoint extensionPoint = (ExtensionPoint) element; >+ Object[] objs = extensionPoint.getExtensions().toArray(); >+ return objs; > } >+ > if (element instanceof Object[]) { > return (Object[]) element; > } >- if (element instanceof IExtensionPoint) { >- IExtensionPoint extensionPoint = (IExtensionPoint) element; >- String id = extensionPoint.getUniqueIdentifier(); >- >- Object[] children = (Object[]) fExtensionPointMap.get(id); >- if (children == null) { >- Object[] array = extensionPoint.getExtensions(); >- if (array != null && array.length > 0) { >- children = new Object[array.length]; >- for (int i = 0; i < array.length; i++) { >- children[i] = createAdapter(array[i], IBundleFolder.F_EXTENSIONS); >- } > >- fExtensionPointMap.put(id, children); >- } >- } >- >- return children; >- } > return null; > } > >- protected static Object[] getFolderChildren(Bundle bundle, int id) { >- Object[] array = null; >- String bundleId = bundle.getSymbolicName(); >- switch (id) { >- case IBundleFolder.F_EXTENSIONS : >- array = Platform.getExtensionRegistry().getExtensions(bundleId); >- break; >- case IBundleFolder.F_EXTENSION_POINTS : >- array = Platform.getExtensionRegistry().getExtensionPoints(bundleId); >- break; >- case IBundleFolder.F_IMPORTS : >- array = getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE); >- break; >- case IBundleFolder.F_LIBRARIES : >- array = getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH); >- break; >- case IBundleFolder.F_REGISTERED_SERVICES : >- return getServices(bundle, IBundleFolder.F_REGISTERED_SERVICES); >- case IBundleFolder.F_SERVICES_IN_USE : >- return getServices(bundle, IBundleFolder.F_SERVICES_IN_USE); >- } >- Object[] result = null; >- if (array != null && array.length > 0) { >- result = new Object[array.length]; >- for (int i = 0; i < array.length; i++) { >- result[i] = createAdapter(array[i], id); >- } >+ public Object getParent(Object element) { >+ if (!(element instanceof ModelObject)) { >+ return null; > } >- return result; >- } >- >- protected static Object[] getServices(Bundle bundle, int type) { >- Set result = new HashSet(); > >- try { >- ServiceReference[] references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null); >+ ModelObject object = (ModelObject) element; > >- for (int i = 0; i < references.length; i++) { >- ServiceReference ref = references[i]; >- >- if ((type == IBundleFolder.F_REGISTERED_SERVICES) && (bundle.equals(ref.getBundle()))) { >- result.add(new ServiceReferenceAdapter(ref)); >- } >- >- Bundle[] usingBundles = ref.getUsingBundles(); >- if ((type == IBundleFolder.F_SERVICES_IN_USE) && (usingBundles != null && Arrays.asList(usingBundles).contains(bundle))) { >- result.add(new ServiceReferenceAdapter(ref)); >- } >- } >+ boolean extOnly = fRegistryBrowser.showExtensionsOnly(); > >- } catch (InvalidSyntaxException e) { // nothing >+ if (element instanceof Folder) { >+ return ((Folder) element).getParent(); > } > >- if (result.size() == 0) >- return null; >- >- return result.toArray(new ServiceReferenceAdapter[result.size()]); >- } >- >- public Object getParent(Object element) { > return null; > } > >@@ -256,26 +113,4 @@ > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // do nothing > } > >- static private Object[] getManifestHeaderArray(Bundle bundle, String headerKey) { >- String libraries = (String) bundle.getHeaders().get(headerKey); >- try { >- ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries); >- if (elements == null) >- return null; >- if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) { >- IBundleLibrary[] array = new IBundleLibrary[elements.length]; >- for (int i = 0; i < elements.length; i++) >- array[i] = new BundleLibrary(elements[i]); >- return array; >- } else if (headerKey.equals(Constants.REQUIRE_BUNDLE)) { >- IBundlePrerequisite[] array = new IBundlePrerequisite[elements.length]; >- for (int i = 0; i < elements.length; i++) >- array[i] = new BundlePrerequisite(elements[i]); >- return array; >- } >- } catch (BundleException e) { // do nothing >- } >- return null; >- } >- > } >Index: src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java >diff -N src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java >--- src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java 2 Jan 2008 16:06:15 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,21 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.osgi.util.ManifestElement; >- >-public interface IBundlePrerequisite { >- public ManifestElement getPrerequisite(); >- >- public boolean isExported(); >- >- public String getLabel(); >-} >Index: src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java 29 Oct 2007 19:17:17 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,27 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-public abstract class ParentAdapter extends PluginObjectAdapter { >- Object[] fChildren; >- >- public ParentAdapter(Object object) { >- super(object); >- } >- >- protected abstract Object[] createChildren(); >- >- public Object[] getChildren() { >- if (fChildren == null) >- fChildren = createChildren(); >- return fChildren; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java,v >retrieving revision 1.63 >diff -u -r1.63 RegistryBrowser.java >--- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java 9 Jul 2008 18:11:28 -0000 1.63 >+++ src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java 17 Oct 2008 15:42:28 -0000 >@@ -11,6 +11,8 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.runtime.registry; > >+import java.net.URI; >+import java.net.URISyntaxException; > import java.util.*; > import java.util.List; > import org.eclipse.core.runtime.*; >@@ -18,9 +20,9 @@ > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.*; >-import org.eclipse.osgi.service.resolver.*; > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.internal.runtime.*; >+import org.eclipse.pde.internal.runtime.registry.model.*; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.dnd.*; >@@ -33,8 +35,7 @@ > import org.eclipse.ui.dialogs.PatternFilter; > import org.eclipse.ui.part.DrillDownAdapter; > import org.eclipse.ui.part.ViewPart; >-import org.osgi.framework.*; >-import org.osgi.service.packageadmin.PackageAdmin; >+import org.osgi.framework.BundleException; > > public class RegistryBrowser extends ViewPart { > >@@ -43,12 +44,16 @@ > public static final String SHOW_EXTENSIONS_ONLY = "RegistryView.showExtensions.label"; //$NON-NLS-1$ > public static final String SHOW_DISABLED_MODE = "RegistryView.showDisabledMode.label"; //$NON-NLS-1$ > >- private RegistryBrowserListener fListener; > private FilteredTree fFilteredTree; > private TreeViewer fTreeViewer; > private IMemento fMemento; > private int fTotalItems = 0; > >+ private RegistryModel model; >+ private ModelChangeListener listener; >+ >+ private RegistryBrowserContentProvider fContentProvider; >+ > // menus and action items > private Action fRefreshAction; > private Action fShowPluginsAction; >@@ -70,12 +75,10 @@ > private DrillDownAdapter fDrillDownAdapter; > private ViewerFilter fActiveFilter = new ViewerFilter() { > public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof PluginObjectAdapter) >- element = ((PluginObjectAdapter) element).getObject(); >- if (element instanceof IExtensionPoint) >- element = Platform.getBundle(((IExtensionPoint) element).getNamespaceIdentifier()); >- else if (element instanceof IExtension) >- element = Platform.getBundle(((IExtension) element).getNamespaceIdentifier()); >+ if (element instanceof ExtensionPoint) >+ element = Platform.getBundle(((ExtensionPoint) element).getNamespaceIdentifier()); >+ else if (element instanceof Extension) >+ element = Platform.getBundle(((Extension) element).getNamespaceIdentifier()); > if (element instanceof Bundle) > return ((Bundle) element).getState() == Bundle.ACTIVE; > return true; >@@ -83,17 +86,9 @@ > }; > > private ViewerFilter fDisabledFilter = new ViewerFilter() { >- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >- State state = plaformAdmin.getState(false); >- > public boolean select(Viewer viewer, Object parentElement, Object element) { >- if (element instanceof PluginObjectAdapter) >- element = ((PluginObjectAdapter) element).getObject(); >- > if (element instanceof Bundle) { >- Bundle bundle = (Bundle) element; >- BundleDescription description = state.getBundle(bundle.getBundleId()); >- return ((state.getDisabledInfos(description)).length > 0); >+ return !((Bundle) element).isEnabled(); > } > return false; > } >@@ -133,6 +128,18 @@ > } > } > >+ public RegistryBrowser() { >+ try { >+ model = RegistryModelFactory.getRegistryModel(new URI("local")); >+ } catch (URISyntaxException e) { >+ PDERuntimePlugin.log(e); >+ } >+ model.connect(); >+ >+ listener = new RegistryBrowserModelChangeListener(this); >+ model.addModelChangeListener(listener); >+ } >+ > public void init(IViewSite site, IMemento memento) throws PartInitException { > super.init(site, memento); > if (memento == null) >@@ -140,8 +147,6 @@ > else > this.fMemento = memento; > initializeMemento(); >- >- fListener = new RegistryBrowserListener(this); > } > > private void initializeMemento() { >@@ -159,12 +164,11 @@ > } > > public void dispose() { >- if (fListener != null) { >- Platform.getExtensionRegistry().removeRegistryChangeListener(fListener); >- PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(fListener); >- PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener(fListener); >+ model.disconnect(); >+ model.removeModelChangeListener(listener); >+ if (fClipboard != null) { >+ fClipboard.dispose(); > } >- fClipboard.dispose(); > super.dispose(); > } > >@@ -179,10 +183,6 @@ > createTreeViewer(composite); > fClipboard = new Clipboard(fTreeViewer.getTree().getDisplay()); > fillToolBar(); >- >- PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(fListener); >- Platform.getExtensionRegistry().addRegistryChangeListener(fListener); >- PDERuntimePlugin.getDefault().getBundleContext().addServiceListener(fListener); > } > > private void createTreeViewer(Composite parent) { >@@ -198,17 +198,14 @@ > GridData gd = new GridData(GridData.FILL_BOTH); > fFilteredTree.setLayoutData(gd); > fTreeViewer = fFilteredTree.getViewer(); >- fTreeViewer.setContentProvider(new RegistryBrowserContentProvider()); >+ fContentProvider = new RegistryBrowserContentProvider(this); >+ fTreeViewer.setContentProvider(fContentProvider); > fTreeViewer.setLabelProvider(new RegistryBrowserLabelProvider(fTreeViewer)); > fTreeViewer.setUseHashlookup(true); > fTreeViewer.setComparator(new ViewerComparator() { > public int compare(Viewer viewer, Object e1, Object e2) { >- if (e1 instanceof PluginObjectAdapter) >- e1 = ((PluginObjectAdapter) e1).getObject(); >- if (e2 instanceof PluginObjectAdapter) >- e2 = ((PluginObjectAdapter) e2).getObject(); >- if (e1 instanceof IBundleFolder && e2 instanceof IBundleFolder) >- return ((IBundleFolder) e1).getFolderId() - ((IBundleFolder) e2).getFolderId(); >+ if (e1 instanceof Folder && e2 instanceof Folder) >+ return ((Folder) e1).getId() - ((Folder) e2).getId(); > if (e1 instanceof Bundle && e2 instanceof Bundle) { > e1 = ((Bundle) e1).getSymbolicName(); > e2 = ((Bundle) e2).getSymbolicName(); >@@ -240,15 +237,6 @@ > tree.setMenu(menu); > } > >- private PluginObjectAdapter[] getBundles() { >- Bundle[] bundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles(); >- ArrayList list = new ArrayList(); >- for (int i = 0; i < bundles.length; i++) >- if (bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) == null) >- list.add(new PluginAdapter(bundles[i])); >- return (PluginObjectAdapter[]) list.toArray(new PluginObjectAdapter[list.size()]); >- } >- > private void fillToolBar() { > fDrillDownAdapter = new RegistryDrillDownAdapter(fTreeViewer); > IActionBars bars = getViewSite().getActionBars(); >@@ -424,61 +412,32 @@ > fEnableAction = new Action(PDERuntimeMessages.RegistryView_enableAction_label) { > public void run() { > List bundles = getSelectedBundles(); >- State state = PDERuntimePlugin.getDefault().getState(); > for (Iterator it = bundles.iterator(); it.hasNext();) { > Bundle bundle = (Bundle) it.next(); >- BundleDescription desc = state.getBundle(bundle.getBundleId()); >- DisabledInfo[] infos = state.getDisabledInfos(desc); >- for (int i = 0; i < infos.length; i++) { >- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >- platformAdmin.removeDisabledInfo(infos[i]); >- } >+ bundle.setEnabled(true); > } >- PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); >- packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()])); > } > }; > > fDisableAction = new Action(PDERuntimeMessages.RegistryView_disableAction_label) { > public void run() { > List bundles = getSelectedBundles(); >- State state = PDERuntimePlugin.getDefault().getState(); > for (Iterator it = bundles.iterator(); it.hasNext();) { > Bundle bundle = (Bundle) it.next(); >- BundleDescription desc = state.getBundle(bundle.getBundleId()); >- DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$ >- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >- platformAdmin.addDisabledInfo(info); >+ bundle.setEnabled(false); > } >- PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); >- packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()])); > } > }; > > fDiagnoseAction = new Action(PDERuntimeMessages.RegistryView_diagnoseAction_label) { > public void run() { > List bundles = getSelectedBundles(); >- State state = PDERuntimePlugin.getDefault().getState(); > for (Iterator it = bundles.iterator(); it.hasNext();) { > Bundle bundle = (Bundle) it.next(); >- BundleDescription desc = state.getBundle(bundle.getBundleId()); >- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >- VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(desc); >- ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc); >- MultiStatus problems = new MultiStatus(PDERuntimePlugin.ID, IStatus.INFO, PDERuntimeMessages.RegistryView_found_problems, null); >- for (int i = 0; i < resolverErrors.length; i++) { >- if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST | ResolverError.MISSING_GENERIC_CAPABILITY | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0) >- continue; >- IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, resolverErrors[i].toString()); >- problems.add(status); >- } >+ MultiStatus problems = bundle.diagnose(); > >- for (int i = 0; i < unsatisfied.length; i++) { >- IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, MessageHelper.getResolutionFailureMessage(unsatisfied[i])); >- problems.add(status); >- } > Dialog dialog; >- if (unsatisfied.length != 0 || resolverErrors.length != 0) { >+ if (problems.getChildren().length > 0) { > dialog = new DiagnosticsDialog(getSite().getShell(), PDERuntimeMessages.RegistryView_diag_dialog_title, null, problems, IStatus.WARNING); > dialog.open(); > } else { >@@ -499,17 +458,19 @@ > fCollapseAllAction.setToolTipText(PDERuntimeMessages.RegistryView_collapseAll_tooltip); > } > >+ public boolean showExtensionsOnly() { >+ return fShowExtensionsOnlyAction.isChecked(); >+ } >+ > protected void updateItems(boolean resetInput) { > Object[] input = null; >- boolean extOnly = fShowExtensionsOnlyAction.isChecked(); >- if (extOnly) >- input = Platform.getExtensionRegistry().getExtensionPoints(); >+ if (showExtensionsOnly()) >+ input = model.getExtensionPoints(); > else >- input = getBundles(); >- fListener.fExtOnly = extOnly; >+ input = model.getBundles(); > fTotalItems = input.length; > if (resetInput) >- fTreeViewer.setInput(new PluginObjectAdapter(input)); >+ fTreeViewer.setInput(input); > updateTitle(); > } > >@@ -531,22 +492,17 @@ > return NLS.bind(PDERuntimeMessages.RegistryView_titleSummary, (new String[] {Integer.toString(tree.getItemCount()), Integer.toString(fTotalItems), type})); > } > >- // TODO hackish, should rewrite > private boolean isBundleSelected() { > IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); > if (selection != null) { > Object[] elements = selection.toArray(); > for (int i = 0; i < elements.length; i++) { >- if (elements[i] instanceof PluginObjectAdapter) { >- PluginObjectAdapter adapter = (PluginObjectAdapter) elements[i]; >- Object object = adapter.getObject(); >- if (!(object instanceof Bundle)) >- return false; >- } else { >+ if (!(elements[i] instanceof Bundle)) { > return false; > } > } > } >+ > return true; > } > >@@ -556,17 +512,17 @@ > if (selection != null) { > Object[] elements = selection.toArray(); > for (int i = 0; i < elements.length; i++) { >- if (elements[i] instanceof PluginObjectAdapter) { >- PluginObjectAdapter adapter = (PluginObjectAdapter) elements[i]; >- Object object = adapter.getObject(); >- if (object instanceof Bundle) >- bundles.add(object); >+ if (elements[i] instanceof Bundle) { >+ bundles.add(elements[i]); > } > } > } > return bundles; > } > >+ /** >+ * @return true if none is stopped, false if at least one is stopped >+ */ > private boolean selectedBundlesStarted() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >@@ -577,6 +533,9 @@ > return true; > } > >+ /** >+ * @return true if none is active, false if at least one is active >+ */ > private boolean selectedBundlesStopped() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >@@ -587,34 +546,39 @@ > return true; > } > >+ /** >+ * @return true if none is enabled, false if at least one is enabled >+ */ > private boolean selectedBundlesDisabled() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { > Bundle bundle = (Bundle) it.next(); >- State state = PDERuntimePlugin.getDefault().getState(); >- BundleDescription desc = state.getBundle(bundle.getBundleId()); >- DisabledInfo[] infos = state.getDisabledInfos(desc); >- if (infos.length == 0) >+ if (bundle.isEnabled()) > return false; > } > return true; > } > >+ /** >+ * @return true if none is disabled, false if at least one is disabled >+ */ > private boolean selectedBundlesEnabled() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { > Bundle bundle = (Bundle) it.next(); >- State state = PDERuntimePlugin.getDefault().getState(); >- BundleDescription desc = state.getBundle(bundle.getBundleId()); >- DisabledInfo[] infos = state.getDisabledInfos(desc); >- if (infos.length > 0) >+ if (!bundle.isEnabled()) > return false; > } > return true; > } > >- protected void add(Object object) { >- add(fTreeViewer.getInput(), object); >+ public void add(Object object) { >+ Object parent = fContentProvider.getParent(object); >+ if (parent == null) { >+ add(fTreeViewer.getInput(), object); >+ } else { >+ refresh(parent); >+ } > } > > protected void add(Object parent, Object object) { >@@ -625,7 +589,7 @@ > updateTitle(); > } > >- protected void remove(Object object) { >+ public void remove(Object object) { > if (fDrillDownAdapter.canGoHome()) > return; > fTotalItems -= 1; >@@ -633,15 +597,11 @@ > updateTitle(); > } > >- protected void update(Object object) { >+ public void update(Object object) { > fTreeViewer.update(object, null); > } > >- protected void refresh(Object object) { >+ public void refresh(Object object) { > fTreeViewer.refresh(object); > } >- >- protected TreeItem[] getTreeItems() { >- return fTreeViewer.getTree().getItems(); >- } > } >Index: src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java 29 Oct 2007 19:17:17 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,33 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IExtension; >- >-public class ExtensionAdapter extends ParentAdapter { >- >- public ExtensionAdapter(Object object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- IExtension extension = (IExtension) getObject(); >- >- IConfigurationElement[] elements = extension.getConfigurationElements(); >- Object[] result = new ConfigurationElementAdapter[elements.length]; >- for (int i = 0; i < elements.length; i++) { >- IConfigurationElement config = elements[i]; >- result[i] = new ConfigurationElementAdapter(config); >- } >- return result; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java 29 Oct 2007 19:17:18 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,33 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IExtensionPoint; >- >-public class ExtensionPointAdapter extends ParentAdapter { >- >- public ExtensionPointAdapter(Object object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- IExtensionPoint extensionPoint = (IExtensionPoint) getObject(); >- >- IExtension[] extensions = extensionPoint.getExtensions(); >- Object[] result = new Object[extensions.length]; >- for (int i = 0; i < extensions.length; i++) { >- IExtension extension = extensions[i]; >- result[i] = new ExtensionAdapter(extension); >- } >- return result; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/ServiceReferenceAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ServiceReferenceAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ServiceReferenceAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ServiceReferenceAdapter.java 24 Apr 2008 08:57:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,35 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.osgi.framework.ServiceReference; >- >-public class ServiceReferenceAdapter extends ParentAdapter { >- >- public ServiceReferenceAdapter(ServiceReference object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- // TODO pluggable support for different services >- return null; >- } >- >- public boolean equals(Object obj) { >- // imitate ServiceReference behavior, that multiple ServiceReference instances are equal >- return (obj instanceof ServiceReferenceAdapter) ? getObject().equals(((ServiceReferenceAdapter) obj).getObject()) : false; >- } >- >- public int hashCode() { >- // imitate ServiceReference behavior, that multiple ServiceReference instances return the same hashCode >- return getObject().hashCode(); >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java 29 Oct 2007 19:17:18 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,25 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.PlatformObject; >- >-public class PluginObjectAdapter extends PlatformObject { >- private Object fObject; >- >- public PluginObjectAdapter(Object object) { >- this.fObject = object; >- } >- >- public Object getObject() { >- return fObject; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java >--- src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java 2 Jan 2008 16:06:15 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,51 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.IConfigurationElement; >- >-public class ConfigurationElementAdapter extends ParentAdapter { >- >- class ConfigurationAttribute implements IConfigurationAttribute { >- private String fLabel; >- >- public ConfigurationAttribute(String name, String value) { >- fLabel = name + " = " + value; //$NON-NLS-1$ >- } >- >- public String getLabel() { >- return fLabel; >- } >- } >- >- public ConfigurationElementAdapter(Object object) { >- super(object); >- } >- >- protected Object[] createChildren() { >- IConfigurationElement config = (IConfigurationElement) getObject(); >- String[] atts = config.getAttributeNames(); >- IConfigurationAttribute[] catts = new IConfigurationAttribute[atts.length]; >- for (int i = 0; i < atts.length; i++) >- catts[i] = new ConfigurationAttribute(atts[i], config.getAttribute(atts[i])); >- IConfigurationElement[] children = config.getChildren(); >- Object[] result = new Object[children.length + catts.length]; >- for (int i = 0; i < children.length; i++) { >- IConfigurationElement child = children[i]; >- result[i] = new ConfigurationElementAdapter(child); >- } >- for (int i = 0; i < catts.length; i++) { >- IConfigurationAttribute child = catts[i]; >- result[children.length + i] = new ConfigurationAttributeAdapter(child); >- } >- return result; >- } >-} >Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java >--- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java 17 Aug 2008 17:47:24 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,376 +0,0 @@ >-/****************************************************************************** >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.*; >-import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.BundleFolder; >-import org.eclipse.swt.widgets.Tree; >-import org.eclipse.swt.widgets.TreeItem; >-import org.osgi.framework.*; >- >-public class RegistryBrowserListener implements IRegistryChangeListener, BundleListener, ServiceListener { >- >- protected RegistryBrowser fBrowser; >- protected boolean fExtOnly; >- >- protected RegistryBrowserListener(RegistryBrowser browser) { >- fBrowser = browser; >- } >- >- public void registryChanged(final IRegistryChangeEvent event) { >- final Tree tree = fBrowser.getUndisposedTree(); >- if (tree == null) >- return; >- >- tree.getDisplay().asyncExec(new Runnable() { >- public void run() { >- IExtensionDelta[] deltas = event.getExtensionDeltas(); >- for (int i = 0; i < deltas.length; i++) { >- if (fExtOnly) >- handleExtOnlyEvent(deltas[i]); >- else >- handleEvent(deltas[i]); >- } >- } >- }); >- } >- >- public void bundleChanged(final BundleEvent event) { >- final Tree tree = fBrowser.getUndisposedTree(); >- if (tree == null) >- return; >- >- tree.getDisplay().asyncExec(new Runnable() { >- public void run() { >- if (fExtOnly) >- handleExtOnlyEvent(event.getType(), event.getBundle()); >- else >- handleEvent(event.getType(), event.getBundle()); >- } >- }); >- } >- >- void handleEvent(IExtensionDelta delta) { >- handleDelta(delta, false); >- } >- >- void handleExtOnlyEvent(IExtensionDelta delta) { >- handleDelta(delta, true); >- } >- >- private void handleDelta(IExtensionDelta delta, boolean extOnly) { >- IExtension ext = delta.getExtension(); >- IExtensionPoint extPoint = delta.getExtensionPoint(); >- // TODO fix this method (and addToTree/removeFromTree) >- // bug 130655 >- if (delta.getKind() == IExtensionDelta.ADDED) { >- addExtensionObjectToTree(ext, extOnly); >- addExtensionObjectToTree(extPoint, extOnly); >- } else if (delta.getKind() == IExtensionDelta.REMOVED) { >- removeFromTree(ext); >- removeFromTree(extPoint); >- } >- } >- >- // private void addToTree(Object object) { >- // String namespace = getNamespaceIdentifier(object); >- // if (namespace == null) >- // return; >- // TreeItem[] items = fTreeViewer.getTree().getItems(); >- // for (int i = 0; i < items.length; i++) { >- // Object data = items[i].getData(); >- // Object adapted = null; >- // if (data instanceof PluginObjectAdapter) >- // adapted = ((PluginObjectAdapter)data).getObject(); >- // if (adapted instanceof Bundle && ((Bundle)adapted).getSymbolicName().equals(namespace)) { >- // addBundleToTree(items[i], data, object); >- // } >- // } >- // } >- >- private void addExtensionObjectToTree(Object child, boolean extOnly) { >- Object parent = null; >- if (!extOnly) >- parent = getAdoptingBundleParent(child); >- else if (child instanceof IExtensionPoint) { >- // add to root >- fBrowser.add(child); >- return; >- } else if (child instanceof IExtension) { >- // search all extensionPoints and return the correct one >- String extPoint = ((IExtension) child).getExtensionPointUniqueIdentifier(); >- TreeItem[] items = fBrowser.getTreeItems(); >- for (int i = 0; i < items.length; i++) { >- Object data = items[i].getData(); >- if (data instanceof PluginObjectAdapter) >- data = ((PluginObjectAdapter) data).getObject(); >- if (data instanceof IExtensionPoint && ((IExtensionPoint) data).getUniqueIdentifier().equals(extPoint)) { >- parent = items[i].getData(); >- break; >- } >- } >- } >- if (parent != null) >- fBrowser.add(parent, child); >- } >- >- private Object getAdoptingBundleParent(Object child) { >- TreeItem bundleItem = findBundleItem(getNamespaceIdentifier(child)); >- if (bundleItem != null) { >- // TODO fix this >- // remove this if (true) clause and return the proper parent >- if (true) { >- fBrowser.refresh(bundleItem.getData()); >- fBrowser.updateItems(false); >- return null; >- } >- TreeItem[] folders = bundleItem.getItems(); >- for (int j = 0; j < folders.length; j++) { >- // make sure to check extensionsOnlyMode() >- // and add to root/proper extension if true >- IBundleFolder folder = (IBundleFolder) folders[j].getData(); >- if (correctFolder(folder, child)) >- return folder; >- } >- // folder not found - 1st extension - refresh bundle item >- // to rebuild folders >- fBrowser.refresh(bundleItem.getData()); >- } >- return null; >- } >- >- private TreeItem findBundleItem(String namespace) { >- if (namespace == null) >- return null; >- TreeItem[] items = fBrowser.getTreeItems(); >- for (int i = 0; i < items.length; i++) { >- Object data = items[i].getData(); >- if (data instanceof PluginObjectAdapter) >- data = ((PluginObjectAdapter) data).getObject(); >- if (data instanceof Bundle && ((Bundle) data).getSymbolicName().equals(namespace)) >- return items[i]; >- } >- return null; >- } >- >- // private void addBundleToTree(TreeItem item, Object data, Object object) { >- // // TODO fix this method >- // if (true) { >- // fTreeViewer.refresh(data); >- // updateItems(false); >- // return; >- // } >- // TreeItem[] folders = item.getItems(); >- // for (int j = 0; j < folders.length; j++) { >- // // make sure to check extensionsOnlyMode() >- // // and add to root/proper extension if true >- // IBundleFolder folder = (IBundleFolder)folders[j].getData(); >- // if (correctFolder(folder, object)) { >- // fTreeViewer.add(folder, object); >- // return; >- // } >- // } >- // // folder not found - 1st extension - refresh bundle item >- // fTreeViewer.refresh(data); >- // } >- >- private String getNamespaceIdentifier(Object object) { >- if (object instanceof IExtensionPoint) >- return ((IExtensionPoint) object).getNamespaceIdentifier(); >- if (object instanceof IExtension) >- return ((IExtension) object).getContributor().getName(); >- return null; >- } >- >- private boolean correctFolder(IBundleFolder folder, Object child) { >- if (folder == null) >- return false; >- if (child instanceof IExtensionPoint) >- return folder.getFolderId() == IBundleFolder.F_EXTENSION_POINTS; >- if (child instanceof IExtension) >- return folder.getFolderId() == IBundleFolder.F_EXTENSIONS; >- return false; >- } >- >- private void removeFromTree(Object object) { >- String namespace = getNamespaceIdentifier(object); >- if (namespace == null) >- return; >- TreeItem[] bundles = fBrowser.getTreeItems(); >- for (int i = 0; i < bundles.length; i++) { >- Object data = bundles[i].getData(); >- Object adapted = null; >- if (data instanceof PluginObjectAdapter) >- adapted = ((PluginObjectAdapter) data).getObject(); >- if (adapted instanceof Bundle && ((Bundle) adapted).getSymbolicName().equals(namespace)) { >- TreeItem[] folders = bundles[i].getItems(); >- // TODO fix this method >- if (true) { >- fBrowser.refresh(data); >- fBrowser.updateItems(false); >- return; >- } >- for (int j = 0; j < folders.length; j++) { >- IBundleFolder folder = (IBundleFolder) folders[j].getData(); >- if (correctFolder(folder, object)) { >- fBrowser.remove(object); >- return; >- } >- } >- // folder not found - 1st extension - refresh bundle item >- fBrowser.refresh(data); >- } >- } >- } >- >- protected Object findTreeBundleData(Object searchData) { >- final Tree tree = fBrowser.getUndisposedTree(); >- if (tree == null) >- return null; >- >- Object data = null; >- TreeItem[] items = fBrowser.getTreeItems(); >- if (items == null) >- return null; >- for (int i = 0; i < items.length; i++) { >- Object object = items[i].getData(); >- data = object; >- if (object instanceof PluginObjectAdapter) >- object = ((PluginObjectAdapter) object).getObject(); >- if (searchData.equals(object)) >- return data; >- } >- return null; >- } >- >- void handleEvent(int changeType, Bundle bundle) { >- Object data = findTreeBundleData(bundle); >- switch (changeType) { >- case BundleEvent.INSTALLED : >- if (data == null) >- fBrowser.add(new PluginAdapter(bundle)); >- break; >- case BundleEvent.UNINSTALLED : >- if (data != null) >- fBrowser.remove(data); >- break; >- case BundleEvent.STARTED : >- case BundleEvent.STOPPED : >- case BundleEvent.UPDATED : >- case BundleEvent.RESOLVED : >- case BundleEvent.STARTING : >- case BundleEvent.STOPPING : >- case BundleEvent.UNRESOLVED : >- case BundleEvent.LAZY_ACTIVATION : >- if (data != null) >- fBrowser.update(data); >- break; >- } >- } >- >- void handleExtOnlyEvent(int changeType, Bundle bundle) { >- switch (changeType) { >- case BundleEvent.INSTALLED : >- case BundleEvent.UNINSTALLED : >- // add/remove all extension points contributed by new bundle >- IExtensionPoint[] points = Platform.getExtensionRegistry().getExtensionPoints(bundle.getSymbolicName()); >- for (int i = 0; i < points.length; i++) { >- Object pointData = findTreeBundleData(points[i]); >- if (pointData == null) { >- if (changeType == BundleEvent.INSTALLED) >- fBrowser.add(new ExtensionPointAdapter(points[i])); >- else >- // changeType == BundleEvent.UNINSTALLED >- fBrowser.remove(pointData); >- } >- } >- // add/remove all extensions contributed by new bundle >- IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(bundle.getSymbolicName()); >- for (int i = 0; i < extensions.length; i++) { >- String pointId = extensions[i].getExtensionPointUniqueIdentifier(); >- if (changeType == BundleEvent.INSTALLED) { >- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pointId); >- Object pointData = findTreeBundleData(point); >- if (pointData != null) >- fBrowser.add(pointData, new ExtensionAdapter(extensions[i])); >- } else { // changeType == BundleEvent.UNINSTALLED >- Object extensionData = findTreeBundleData(extensions[i]); >- if (extensionData != null) >- fBrowser.remove(extensionData); >- } >- } >- break; >- case BundleEvent.STARTED : >- case BundleEvent.STOPPED : >- case BundleEvent.UPDATED : >- case BundleEvent.RESOLVED : >- case BundleEvent.STARTING : >- case BundleEvent.STOPPING : >- case BundleEvent.UNRESOLVED : >- case BundleEvent.LAZY_ACTIVATION : >- // nothing needs to be done for any other cases >- break; >- } >- } >- >- public void serviceChanged(final ServiceEvent event) { >- final Tree tree = fBrowser.getUndisposedTree(); >- if (tree == null) >- return; >- >- tree.getDisplay().asyncExec(new Runnable() { >- public void run() { >- handleServiceChangedEvent(event); >- } >- }); >- >- } >- >- protected void handleServiceChangedEvent(ServiceEvent event) { >- ServiceReference ref = event.getServiceReference(); >- switch (event.getType()) { >- case ServiceEvent.REGISTERED : >- case ServiceEvent.UNREGISTERING : >- Bundle bundle = ref.getBundle(); >- if (bundle == null) >- return; >- String name = bundle.getSymbolicName(); >- if (name == null) >- return; >- TreeItem bundleItem = findBundleItem(name); >- if (bundleItem == null) >- return; >- PluginAdapter bundleAdapter = ((PluginAdapter) bundleItem.getData()); >- Object[] folders = bundleAdapter.getChildren(); >- >- for (int j = 0; j < folders.length; j++) { >- if (folders[j] instanceof IBundleFolder) { >- IBundleFolder folder = (IBundleFolder) folders[j]; >- >- if (folder.getFolderId() == IBundleFolder.F_REGISTERED_SERVICES) { >- if ((event.getType() == ServiceEvent.REGISTERED) || (event.getType() == ServiceEvent.UNREGISTERING)) { >- ((BundleFolder) folder).refresh(); // refresh model >- fBrowser.refresh(folder); // refresh view >- >- // refresh whole bundle in case there were folders added - they might have not existed if bundle had no service before >- fBrowser.refresh(bundleAdapter); >- } >- } >- } >- } >- >- break; >- case ServiceEvent.MODIFIED : >- break; >- } >- } >- >-} >Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java,v >retrieving revision 1.33 >diff -u -r1.33 RegistryBrowserLabelProvider.java >--- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java 24 Apr 2008 08:57:27 -0000 1.33 >+++ src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java 17 Oct 2008 15:42:28 -0000 >@@ -10,19 +10,14 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.runtime.registry; > >-import java.io.IOException; >-import java.net.URL; > import java.util.Arrays; >-import org.eclipse.core.runtime.*; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.LabelProvider; > import org.eclipse.jface.viewers.TreeViewer; >-import org.eclipse.osgi.service.resolver.*; > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.internal.runtime.*; >+import org.eclipse.pde.internal.runtime.registry.model.*; > import org.eclipse.swt.graphics.Image; >-import org.osgi.framework.Bundle; >-import org.osgi.framework.ServiceReference; > > public class RegistryBrowserLabelProvider extends LabelProvider { > >@@ -102,18 +97,10 @@ > } > > public Image getImage(Object element) { >- if (element instanceof PluginObjectAdapter) >- element = ((PluginObjectAdapter) element).getObject(); >- > if (element instanceof Bundle) { > Bundle bundle = (Bundle) element; > >- // check if bundle is disabled >- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >- State state = plaformAdmin.getState(false); >- >- BundleDescription description = state.getBundle(bundle.getBundleId()); >- if ((state.getDisabledInfos(description)).length > 0) >+ if (!bundle.isEnabled()) > return fDisabledImage; > > switch (bundle.getState()) { >@@ -122,147 +109,125 @@ > case Bundle.UNINSTALLED : > return fUnresolvedPluginImage; > case Bundle.INSTALLED : >- if ((state.getDisabledInfos(description)).length > 0) >+ if (!bundle.isEnabled()) > return fUnresolvedPluginImage; > default : > return fPluginImage; > } > } > >- if (element instanceof ServiceReference) { >+ if (element instanceof ServiceRegistration) { > return fServiceImage; > } > >- if (element instanceof IBundleFolder) { >- int id = ((IBundleFolder) element).getFolderId(); >+ if (element instanceof Folder) { >+ int id = ((Folder) element).getId(); > switch (id) { >- case IBundleFolder.F_EXTENSIONS : >+ case Folder.F_EXTENSIONS : > return fExtensionsImage; >- case IBundleFolder.F_EXTENSION_POINTS : >+ case Folder.F_EXTENSION_POINTS : > return fExtensionPointsImage; >- case IBundleFolder.F_IMPORTS : >+ case Folder.F_IMPORTS : > return fRequiresImage; >- case IBundleFolder.F_LIBRARIES : >+ case Folder.F_LIBRARIES : > return fRuntimeImage; >- case IBundleFolder.F_LOCATION : >- return fLocationImage; >- case IBundleFolder.F_REGISTERED_SERVICES : >+ case Folder.F_REGISTERED_SERVICES : > return fExporterImage; >- case IBundleFolder.F_SERVICES_IN_USE : >+ case Folder.F_SERVICES_IN_USE : > return fImporterImage; > } > return null; > } >- if (element instanceof IExtension) >+ if (element instanceof Extension) > return fExtensionImage; > >- if (element instanceof IExtensionPoint) >+ if (element instanceof ExtensionPoint) > return fExtensionPointImage; > >- if (element instanceof IBundlePrerequisite) >- return ((IBundlePrerequisite) element).isExported() ? fExpReqPluginImage : fReqPluginImage; >+ if (element instanceof BundlePrerequisite) >+ return ((BundlePrerequisite) element).isExported() ? fExpReqPluginImage : fReqPluginImage; > >- if (element instanceof IBundleLibrary) >+ if (element instanceof BundleLibrary) > return fLibraryImage; > >- if (element instanceof IConfigurationElement) >+ if (element instanceof ConfigurationElement) > return fGenericTagImage; > >- if (element instanceof IConfigurationAttribute) >+ if (element instanceof Attribute) { >+ Attribute attr = (Attribute) element; >+ if (Attribute.F_LOCATION.equals(attr.getName())) { >+ return fLocationImage; >+ } > return fGenericAttrImage; >+ } > > return null; > } > > public String getText(Object element) { >- if (element instanceof PluginObjectAdapter) >- element = ((PluginObjectAdapter) element).getObject(); > if (element instanceof Bundle) { > String id = ((Bundle) element).getSymbolicName(); >- String version = (String) ((Bundle) element).getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); >+ String version = ((Bundle) element).getVersion(); > if (version == null) > return id; > return id + " (" + version + ")"; //$NON-NLS-1$ //$NON-NLS-2$ > } >- if (element instanceof ServiceReference) { >- ServiceReference ref = (ServiceReference) element; >- String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS); >- Long id = (Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID); >+ if (element instanceof ServiceRegistration) { >+ ServiceRegistration ref = (ServiceRegistration) element; >+ String[] classes = ref.getClasses(); >+ Long id = ref.getId(); > String identifier = " (id=" + id.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ > return Arrays.asList(classes).toString().concat(identifier); > } >- if (element instanceof IBundleFolder) { >- switch (((IBundleFolder) element).getFolderId()) { >- case IBundleFolder.F_IMPORTS : >+ if (element instanceof Folder) { >+ switch (((Folder) element).getId()) { >+ case Folder.F_IMPORTS : > return PDERuntimeMessages.RegistryView_folders_imports; >- case IBundleFolder.F_LIBRARIES : >+ case Folder.F_LIBRARIES : > return PDERuntimeMessages.RegistryView_folders_libraries; >- case IBundleFolder.F_EXTENSION_POINTS : >+ case Folder.F_EXTENSION_POINTS : > return PDERuntimeMessages.RegistryView_folders_extensionPoints; >- case IBundleFolder.F_EXTENSIONS : >+ case Folder.F_EXTENSIONS : > return PDERuntimeMessages.RegistryView_folders_extensions; >- case IBundleFolder.F_REGISTERED_SERVICES : >+ case Folder.F_REGISTERED_SERVICES : > return PDERuntimeMessages.RegistryBrowserLabelProvider_registeredServices; >- case IBundleFolder.F_SERVICES_IN_USE : >+ case Folder.F_SERVICES_IN_USE : > return PDERuntimeMessages.RegistryBrowserLabelProvider_usedServices; >- case IBundleFolder.F_LOCATION : >- Bundle bundle = ((IBundleFolder) element).getBundle(); >- URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$ >- try { >- bundleEntry = FileLocator.resolve(bundleEntry); >- } catch (IOException e) { // do nothing >- } >- IPath path = new Path(bundleEntry.getFile()); >- String pathString = path.removeTrailingSeparator().toOSString(); >- if (pathString.startsWith("file:")) //$NON-NLS-1$ >- pathString = pathString.substring(5); >- if (pathString.endsWith("!")) //$NON-NLS-1$ >- pathString = pathString.substring(0, pathString.length() - 1); >- return pathString; > } > } >- if (element instanceof IExtension) { >+ if (element instanceof Extension) { > if (((RegistryBrowserContentProvider) fViewer.getContentProvider()).isInExtensionSet) { >- String name = ((IExtension) element).getLabel(); >- String id = ((IExtension) element).getExtensionPointUniqueIdentifier(); >+ String name = ((Extension) element).getLabel(); >+ String id = ((Extension) element).getExtensionPointUniqueIdentifier(); > if (name != null && name.length() > 0) > return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name); > return id; > } > >- String contributor = ((IExtension) element).getNamespaceIdentifier(); >+ String contributor = ((Extension) element).getNamespaceIdentifier(); > return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_contributedBy, contributor); > > } >- if (element instanceof IExtensionPoint) { >- String id = ((IExtensionPoint) element).getUniqueIdentifier(); >- String name = ((IExtensionPoint) element).getLabel(); >+ if (element instanceof ExtensionPoint) { >+ String id = ((ExtensionPoint) element).getUniqueIdentifier(); >+ String name = ((ExtensionPoint) element).getLabel(); > if (name != null && name.length() > 0) > return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name); > return id; > } >- if (element instanceof IBundlePrerequisite) >- return ((IBundlePrerequisite) element).getLabel(); >+ if (element instanceof BundlePrerequisite) >+ return ((BundlePrerequisite) element).getName(); > >- if (element instanceof IBundleLibrary) >- return ((IBundleLibrary) element).getLibrary(); >+ if (element instanceof BundleLibrary) >+ return ((BundleLibrary) element).getLibrary(); > >- if (element instanceof IConfigurationElement) { >- String label = ((IConfigurationElement) element).getAttribute("label"); //$NON-NLS-1$ >- if (label == null) >- label = ((IConfigurationElement) element).getName(); >- >- if (label == null) >- label = ((IConfigurationElement) element).getAttribute("name"); //$NON-NLS-1$ >- >- if (label == null && ((IConfigurationElement) element).getAttribute("id") != null) { //$NON-NLS-1$ >- String[] labelSplit = ((IConfigurationElement) element).getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$ >- label = labelSplit.length == 0 ? null : labelSplit[labelSplit.length - 1]; >- } >- return label; >+ if (element instanceof ConfigurationElement) { >+ return ((ConfigurationElement) element).getName(); >+ } >+ if (element instanceof Attribute) { >+ Attribute attribute = (Attribute) element; >+ return attribute.getName() + " = " + attribute.getValue(); //$NON-NLS-1$ > } >- if (element instanceof IConfigurationAttribute) >- return ((IConfigurationAttribute) element).getLabel(); > > return super.getText(element); > } >Index: src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java >diff -N src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java >--- src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java 24 Apr 2008 08:57:27 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,32 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-import org.eclipse.core.runtime.IAdaptable; >-import org.osgi.framework.Bundle; >- >-public interface IBundleFolder extends IAdaptable { >- public static final int F_LOCATION = 0; >- public static final int F_EXTENSIONS = 1; >- public static final int F_EXTENSION_POINTS = 2; >- public static final int F_IMPORTS = 3; >- public static final int F_LIBRARIES = 4; >- public static final int F_REGISTERED_SERVICES = 5; >- public static final int F_SERVICES_IN_USE = 6; >- >- public Object[] getChildren(); >- >- public void refresh(); >- >- int getFolderId(); >- >- public Bundle getBundle(); >-} >Index: src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java >diff -N src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java >--- src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java 6 Mar 2006 14:50:59 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,15 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.runtime.registry; >- >-public interface IBundleLibrary { >- public String getLibrary(); >-} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/META-INF/MANIFEST.MF,v >retrieving revision 1.26 >diff -u -r1.26 MANIFEST.MF >--- META-INF/MANIFEST.MF 17 Aug 2008 18:39:55 -0000 1.26 >+++ META-INF/MANIFEST.MF 17 Oct 2008 15:42:28 -0000 >@@ -17,6 +17,7 @@ > Eclipse-LazyStart: true > Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true, > org.eclipse.pde.internal.runtime.registry;x-internal:=true, >+ org.eclipse.pde.internal.runtime.registry.model;x-internal:=true, > org.eclipse.pde.internal.runtime.spy;x-internal:=true, > org.eclipse.pde.internal.runtime.spy.dialogs;x-internal:=true, > org.eclipse.pde.internal.runtime.spy.handlers;x-internal:=true, >Index: src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java,v >retrieving revision 1.27 >diff -u -r1.27 PDERuntimePlugin.java >--- src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java 2 Jan 2008 16:06:15 -0000 1.27 >+++ src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java 17 Oct 2008 15:42:28 -0000 >@@ -32,6 +32,10 @@ > private ServiceTracker packageAdminTracker; > private ServiceTracker platformAdminTracker; > >+ public PDERuntimePlugin() { >+ inst = this; >+ } >+ > private static boolean isBundleAvailable(String bundleID) { > Bundle bundle = Platform.getBundle(bundleID); > return bundle != null && (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0; >@@ -86,10 +90,6 @@ > return getDefault().getBundle().getSymbolicName(); > } > >- public PDERuntimePlugin() { >- inst = this; >- } >- > private IWorkbenchPage internalGetActivePage() { > return getWorkbench().getActiveWorkbenchWindow().getActivePage(); > } >@@ -142,7 +142,6 @@ > platformAdminTracker.close(); > platformAdminTracker = null; > } >- inst = null; > } > > } >Index: src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,423 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.io.IOException; >+import java.net.URL; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.osgi.service.resolver.*; >+import org.eclipse.osgi.util.ManifestElement; >+import org.eclipse.pde.internal.runtime.*; >+import org.osgi.framework.*; >+import org.osgi.service.packageadmin.PackageAdmin; >+ >+public class LocalRegistryBackend implements IRegistryEventListener, BundleListener, ServiceListener, RegistryBackend { >+ >+ private BackendChangeListener listener; >+ private RegistryModel model; >+ >+ public void setRegistryModel(RegistryModel model) { >+ this.model = model; >+ } >+ >+ public void setRegistryListener(BackendChangeListener listener) { >+ this.listener = listener; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#connect() >+ */ >+ public void connect() { >+ PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(this); >+ Platform.getExtensionRegistry().addListener(this); >+ PDERuntimePlugin.getDefault().getBundleContext().addServiceListener(this); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#disconnect() >+ */ >+ public void disconnect() { >+ Platform.getExtensionRegistry().removeListener(this); >+ PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(this); >+ PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener(this); >+ } >+ >+ protected static boolean isRegisteredService(org.osgi.framework.Bundle bundle, ServiceReference ref) { >+ return bundle.equals(ref.getBundle()); >+ } >+ >+ protected static boolean isServiceInUse(org.osgi.framework.Bundle bundle, ServiceReference ref) { >+ org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles(); >+ return (usingBundles != null && Arrays.asList(usingBundles).contains(bundle)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#start(org.osgi.framework.Bundle) >+ */ >+ public void start(Bundle bundle) throws BundleException { >+ PDERuntimePlugin.getDefault().getBundleContext().getBundle(bundle.getId().longValue()).start(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#stop(org.osgi.framework.Bundle) >+ */ >+ public void stop(Bundle bundle) throws BundleException { >+ PDERuntimePlugin.getDefault().getBundleContext().getBundle(bundle.getId().longValue()).stop(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#diagnose(org.osgi.framework.Bundle) >+ */ >+ public MultiStatus diagnose(Bundle bundle) { >+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ State state = plaformAdmin.getState(false); >+ >+ BundleDescription desc = state.getBundle(bundle.getId().longValue()); >+ >+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(desc); >+ ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc); >+ >+ MultiStatus problems = new MultiStatus(PDERuntimePlugin.ID, IStatus.INFO, PDERuntimeMessages.RegistryView_found_problems, null); >+ for (int i = 0; i < resolverErrors.length; i++) { >+ if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST | ResolverError.MISSING_GENERIC_CAPABILITY | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0) >+ continue; >+ IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, resolverErrors[i].toString()); >+ problems.add(status); >+ } >+ >+ for (int i = 0; i < unsatisfied.length; i++) { >+ IStatus status = new Status(IStatus.WARNING, PDERuntimePlugin.ID, MessageHelper.getResolutionFailureMessage(unsatisfied[i])); >+ problems.add(status); >+ } >+ >+ return problems; >+ } >+ >+ public Map initializeBundles() { >+ org.osgi.framework.Bundle[] newBundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles(); >+ Map tmp = new HashMap(newBundles.length); >+ for (int i = 0; i < newBundles.length; i++) { >+ if (newBundles[i].getHeaders().get(Constants.FRAGMENT_HOST) == null) { >+ Bundle ba = createBundleAdapter(newBundles[i]); >+ tmp.put(ba.getId(), ba); >+ } >+ } >+ return tmp; >+ } >+ >+ public Map initializeExtensionPoints() { >+ IExtensionPoint[] extPoints = Platform.getExtensionRegistry().getExtensionPoints(); >+ Map tmp = new HashMap(extPoints.length); >+ for (int i = 0; i < extPoints.length; i++) { >+ ExtensionPoint epa = createExtensionPointAdapter(extPoints[i]); >+ tmp.put(epa.getUniqueIdentifier(), epa); >+ } >+ return tmp; >+ } >+ >+ public Map initializeServices() { >+ Map result = new HashMap(); >+ >+ ServiceReference[] references = null; >+ try { >+ references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null); >+ } catch (InvalidSyntaxException e) { // nothing >+ } >+ >+ if (references == null) { >+ return null; >+ } >+ >+ for (int i = 0; i < references.length; i++) { >+ ServiceRegistration service = createServiceReferenceAdapter(references[i]); >+ result.put(service.getId(), service); >+ } >+ >+ return result; >+ } >+ >+ private Bundle createBundleAdapter(org.osgi.framework.Bundle bundle) { >+ String symbolicName = bundle.getSymbolicName(); >+ String version = (String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); >+ int state = bundle.getState(); >+ Long id = new Long(bundle.getBundleId()); >+ String location = createLocation(bundle); >+ BundlePrerequisite[] imports = (BundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE); >+ BundleLibrary[] libraries = (BundleLibrary[]) getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH); >+ boolean isEnabled = getIsEnabled(bundle); >+ >+ return new Bundle(model, symbolicName, version, state, id, location, imports, libraries, isEnabled); >+ } >+ >+ private Extension createExtensionAdapter(IExtension extension) { >+ String namespaceIdentifier = extension.getNamespaceIdentifier(); >+ String label = extension.getLabel(); >+ String extensionPointUniqueIdentifier = extension.getExtensionPointUniqueIdentifier(); >+ Long contributor = getBundleId(extension.getContributor().getName()); >+ >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ ConfigurationElement[] configurationElements = new ConfigurationElement[elements.length]; >+ for (int i = 0; i < elements.length; i++) { >+ configurationElements[i] = createConfigurationElement(elements[i]); >+ } >+ return new Extension(model, namespaceIdentifier, label, extensionPointUniqueIdentifier, configurationElements, contributor); >+ } >+ >+ private ConfigurationElement createConfigurationElement(IConfigurationElement config) { >+ Attribute[] attributes = createConfigurationElementAttributes(config); >+ String name = createName(config); >+ return new ConfigurationElement(model, name, attributes); >+ } >+ >+ private static Long getBundleId(String name) { >+ BundleDescription descr = PDERuntimePlugin.getDefault().getPlatformAdmin().getState().getBundle(name, null); >+ return new Long(descr.getBundleId()); >+ } >+ >+ private ExtensionPoint createExtensionPointAdapter(IExtensionPoint extensionPoint) { >+ String label = extensionPoint.getLabel(); >+ String uniqueIdentifier = extensionPoint.getUniqueIdentifier(); >+ String namespaceIdentifier = extensionPoint.getNamespaceIdentifier(); >+ Long contributor = getBundleId(extensionPoint.getContributor().getName()); >+ Extension[] extensions = createExtensionAdapters(extensionPoint.getExtensions()); >+ ExtensionPoint adapter = new ExtensionPoint(model, label, uniqueIdentifier, namespaceIdentifier, contributor); >+ adapter.getExtensions().addAll(Arrays.asList(extensions)); >+ return adapter; >+ } >+ >+ private ServiceRegistration createServiceReferenceAdapter(ServiceReference ref) { >+ Long id = (Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID); >+ String bundle = ref.getBundle().getSymbolicName(); >+ org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles(); >+ Long[] usingBundlesIds = null; >+ if (usingBundles != null) { >+ usingBundlesIds = new Long[usingBundles.length]; >+ for (int i = 0; i < usingBundles.length; i++) { >+ usingBundlesIds[i] = new Long(usingBundles[i].getBundleId()); >+ } >+ } >+ String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS); >+ return new ServiceRegistration(model, id, bundle, usingBundlesIds, classes); >+ } >+ >+ private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) { >+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ State state = plaformAdmin.getState(false); >+ >+ BundleDescription description = state.getBundle(bundle.getBundleId()); >+ return (state.getDisabledInfos(description)).length == 0; >+ } >+ >+ private static String createLocation(org.osgi.framework.Bundle bundle) { >+ URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$ >+ try { >+ bundleEntry = FileLocator.resolve(bundleEntry); >+ } catch (IOException e) { // do nothing >+ } >+ IPath path = new Path(bundleEntry.getFile()); >+ String pathString = path.removeTrailingSeparator().toOSString(); >+ if (pathString.startsWith("file:")) //$NON-NLS-1$ >+ pathString = pathString.substring(5); >+ if (pathString.endsWith("!")) //$NON-NLS-1$ >+ pathString = pathString.substring(0, pathString.length() - 1); >+ return pathString; >+ } >+ >+ private Object[] getManifestHeaderArray(org.osgi.framework.Bundle bundle, String headerKey) { >+ String libraries = (String) bundle.getHeaders().get(headerKey); >+ try { >+ ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries); >+ if (elements == null) >+ return null; >+ if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) { >+ BundleLibrary[] array = new BundleLibrary[elements.length]; >+ for (int i = 0; i < elements.length; i++) >+ array[i] = new BundleLibrary(model, elements[i].getValue()); >+ return array; >+ } else if (headerKey.equals(Constants.REQUIRE_BUNDLE)) { >+ BundlePrerequisite[] array = new BundlePrerequisite[elements.length]; >+ for (int i = 0; i < elements.length; i++) { >+ ManifestElement element = elements[i]; >+ String name = element.getValue(); >+ String version = element.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); >+ >+ String visibility = element.getDirective(Constants.VISIBILITY_DIRECTIVE); >+ boolean isExported = Constants.VISIBILITY_REEXPORT.equals(visibility); >+ array[i] = new BundlePrerequisite(model, name, version, isExported); >+ } >+ return array; >+ } >+ } catch (BundleException e) { // do nothing >+ } >+ return null; >+ } >+ >+ private Attribute[] createConfigurationElementAttributes(IConfigurationElement config) { >+ String[] atts = config.getAttributeNames(); >+ >+ Attribute[] catts = new Attribute[atts.length]; >+ for (int i = 0; i < atts.length; i++) >+ catts[i] = new Attribute(model, atts[i], config.getAttribute(atts[i])); >+ >+ IConfigurationElement[] children = config.getChildren(); >+ Attribute[] result = new Attribute[children.length + catts.length]; >+ for (int i = 0; i < children.length; i++) { >+ IConfigurationElement child = children[i]; >+ result[i] = createConfigurationElement(child); >+ } >+ for (int i = 0; i < catts.length; i++) { >+ result[children.length + i] = catts[i]; >+ } >+ return result; >+ } >+ >+ private static String createName(IConfigurationElement config) { >+ String label = config.getAttribute("label"); //$NON-NLS-1$ >+ if (label == null) >+ label = config.getName(); >+ >+ if (label == null) >+ label = config.getAttribute("name"); //$NON-NLS-1$ >+ >+ if (label == null && config.getAttribute("id") != null) { //$NON-NLS-1$ >+ String[] labelSplit = config.getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$ >+ label = labelSplit.length == 0 ? null : labelSplit[labelSplit.length - 1]; >+ } >+ >+ return label; >+ } >+ >+ private Extension[] createExtensionAdapters(IExtension[] extensions) { >+ Extension[] extensionAdapters = new Extension[extensions.length]; >+ for (int i = 0; i < extensions.length; i++) { >+ extensionAdapters[i] = createExtensionAdapter(extensions[i]); >+ } >+ return extensionAdapters; >+ } >+ >+ public void bundleChanged(BundleEvent event) { >+ org.osgi.framework.Bundle bundle = event.getBundle(); >+ Bundle adapter = createBundleAdapter(bundle); >+ >+ switch (event.getType()) { >+ case BundleEvent.INSTALLED : >+ listener.addBundle(adapter); >+ break; >+ case BundleEvent.UNINSTALLED : >+ listener.removeBundle(adapter); >+ break; >+ case BundleEvent.UPDATED : >+ listener.updateBundle(adapter, ModelChangeDelta.UPDATED); >+ break; >+ case BundleEvent.RESOLVED : >+ listener.updateBundle(adapter, ModelChangeDelta.RESOLVED); >+ break; >+ case BundleEvent.UNRESOLVED : >+ listener.updateBundle(adapter, ModelChangeDelta.UNRESOLVED); >+ break; >+ case BundleEvent.STARTING : >+ listener.updateBundle(adapter, ModelChangeDelta.STARTING); >+ break; >+ case BundleEvent.STARTED : >+ listener.updateBundle(adapter, ModelChangeDelta.STARTED); >+ break; >+ case BundleEvent.STOPPING : >+ listener.updateBundle(adapter, ModelChangeDelta.STOPPING); >+ break; >+ case BundleEvent.STOPPED : >+ listener.updateBundle(adapter, ModelChangeDelta.STOPPED); >+ break; >+ default : >+ listener.updateBundle(adapter, ModelChangeDelta.UPDATED); >+ } >+ } >+ >+ public void serviceChanged(ServiceEvent event) { >+ ServiceReference ref = event.getServiceReference(); >+ ServiceRegistration adapter = createServiceReferenceAdapter(ref); >+ >+ switch (event.getType()) { >+ case ServiceEvent.REGISTERED : >+ listener.addService(adapter); >+ break; >+ case ServiceEvent.UNREGISTERING : >+ listener.removeService(adapter); >+ break; >+ case ServiceEvent.MODIFIED : >+ default : >+ listener.updateService(adapter); >+ break; >+ } >+ } >+ >+ private ExtensionPoint[] createExtensionPointAdapters(IExtensionPoint[] extensionPoints) { >+ ExtensionPoint[] result = new ExtensionPoint[extensionPoints.length]; >+ for (int i = 0; i < extensionPoints.length; i++) { >+ result[i] = createExtensionPointAdapter(extensionPoints[i]); >+ } >+ return result; >+ } >+ >+ public void added(IExtension[] extensions) { >+ listener.addExtensions(createExtensionAdapters(extensions)); >+ } >+ >+ public void removed(IExtension[] extensions) { >+ listener.removeExtensions(createExtensionAdapters(extensions)); >+ } >+ >+ public void added(IExtensionPoint[] extensionPoints) { >+ listener.addExtensionPoints(createExtensionPointAdapters(extensionPoints)); >+ } >+ >+ public void removed(IExtensionPoint[] extensionPoints) { >+ listener.removeExtensionPoints(createExtensionPointAdapters(extensionPoints)); >+ } >+ >+ public void setEnabled(Bundle bundle, boolean enabled) { >+ State state = PDERuntimePlugin.getDefault().getState(); >+ long bundleId = bundle.getId().longValue(); >+ BundleDescription desc = state.getBundle(bundleId); >+ >+ if (enabled) { >+ DisabledInfo[] infos = state.getDisabledInfos(desc); >+ for (int i = 0; i < infos.length; i++) { >+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ platformAdmin.removeDisabledInfo(infos[i]); >+ } >+ } else { >+ DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$ >+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ platformAdmin.addDisabledInfo(info); >+ } >+ >+ org.osgi.framework.Bundle b = PDERuntimePlugin.getDefault().getBundleContext().getBundle(bundleId); >+ PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); >+ packageAdmin.refreshPackages(new org.osgi.framework.Bundle[] {b}); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#setEnabled(org.osgi.framework.Bundle, boolean) >+ */ >+ public void setEnabled(org.osgi.framework.Bundle bundle, boolean enabled) { >+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ State state = plaformAdmin.getState(false); >+ >+ BundleDescription desc = state.getBundle(bundle.getBundleId()); >+ >+ if (enabled) { >+ DisabledInfo[] infos = state.getDisabledInfos(desc); >+ for (int i = 0; i < infos.length; i++) { >+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ platformAdmin.removeDisabledInfo(infos[i]); >+ } >+ } else { >+ DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$ >+ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ platformAdmin.addDisabledInfo(info); >+ } >+ >+ PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); >+ packageAdmin.refreshPackages(new org.osgi.framework.Bundle[] {bundle}); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/Extension.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/Extension.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/Extension.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/Extension.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class Extension extends ModelObject { >+ >+ private String namespaceIdentifier; >+ private String label; >+ private String extensionPointUniqueIdentifier; >+ private ConfigurationElement[] configurationElements; >+ private Long contributor; >+ >+ public Extension(RegistryModel model, String namespaceIdentifier, String label, String extensionPointUniqueIdentifier, ConfigurationElement[] cfg, Long contributor) { >+ super(model); >+ this.namespaceIdentifier = namespaceIdentifier; >+ this.label = label; >+ this.extensionPointUniqueIdentifier = extensionPointUniqueIdentifier; >+ this.configurationElements = cfg; >+ this.contributor = contributor; >+ } >+ >+ public ConfigurationElement[] getConfigurationElements() { >+ return configurationElements; >+ } >+ >+ public String getExtensionPointUniqueIdentifier() { >+ return extensionPointUniqueIdentifier; >+ } >+ >+ public String getLabel() { >+ return label; >+ } >+ >+ public String getNamespaceIdentifier() { >+ return namespaceIdentifier; >+ } >+ >+ public Long getContributorId() { >+ return contributor; >+ } >+ >+ public boolean equals(Object obj) { >+ if (obj instanceof Extension) { >+ Extension ext = (Extension) obj; >+ return namespaceIdentifier.endsWith(ext.namespaceIdentifier) && label.equals(ext.label) && extensionPointUniqueIdentifier.equals(ext.extensionPointUniqueIdentifier) && contributor.equals(ext.contributor); >+ } >+ >+ return false; >+ } >+ >+ public int hashCode() { >+ final int prime = 31; >+ int result = 1; >+ result = prime * result + ((contributor == null) ? 0 : contributor.hashCode()); >+ result = prime * result + ((extensionPointUniqueIdentifier == null) ? 0 : extensionPointUniqueIdentifier.hashCode()); >+ result = prime * result + ((label == null) ? 0 : label.hashCode()); >+ result = prime * result + ((namespaceIdentifier == null) ? 0 : namespaceIdentifier.hashCode()); >+ return result; >+ } >+ >+ public ExtensionPoint getExtensionPoint() { >+ return getModel().getExtensionPoint(extensionPointUniqueIdentifier); >+ } >+ >+ public Bundle getContributor() { >+ return getModel().getBundle(contributor); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,53 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+public class ExtensionPoint extends ModelObject { >+ >+ private String label; >+ private String uniqueIdentifier; >+ private String namespaceIdentifier; >+ private Long contributor; >+ private List extensions = new ArrayList(); >+ >+ public ExtensionPoint(RegistryModel model, String label, String uniqueIdentifier, String namespaceIdentifier, Long contributor) { >+ super(model); >+ this.label = label; >+ this.uniqueIdentifier = uniqueIdentifier; >+ this.namespaceIdentifier = namespaceIdentifier; >+ this.contributor = contributor; >+ } >+ >+ public List getExtensions() { >+ return extensions; >+ } >+ >+ public String getLabel() { >+ return label; >+ } >+ >+ public String getUniqueIdentifier() { >+ return uniqueIdentifier; >+ } >+ >+ public String getNamespaceIdentifier() { >+ return namespaceIdentifier; >+ } >+ >+ public Long getContributorId() { >+ return contributor; >+ } >+ >+ public Bundle getContributor() { >+ return getModel().getBundle(contributor); >+ } >+ >+ public boolean equals(Object obj) { >+ return (obj instanceof ExtensionPoint) && (uniqueIdentifier.equals(((ExtensionPoint) obj).uniqueIdentifier)); >+ } >+ >+ public int hashCode() { >+ return uniqueIdentifier.hashCode(); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+package org.eclipse.pde.internal.runtime.registry; >+ >+import org.eclipse.pde.internal.runtime.registry.model.*; >+ >+public class RegistryBrowserModelChangeListener implements ModelChangeListener { >+ >+ private RegistryBrowser fRegistryBrowser; >+ >+ public RegistryBrowserModelChangeListener(RegistryBrowser registryBrowser) { >+ fRegistryBrowser = registryBrowser; >+ } >+ >+ public void modelChanged(final ModelChangeDelta[] delta) { >+ fRegistryBrowser.getSite().getWorkbenchWindow().getWorkbench().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ update(delta); >+ } >+ }); >+ } >+ >+ private boolean topLevelElement(Object object) { >+ return fRegistryBrowser.showExtensionsOnly() ? object instanceof ExtensionPoint : object instanceof Bundle; >+ } >+ >+ private Object getTopLevelElement(Object object) { >+ if (!fRegistryBrowser.showExtensionsOnly()) { // show bundles >+ if (object instanceof Bundle) { >+ return object; >+ } else if (object instanceof ExtensionPoint) { >+ ExtensionPoint ext = (ExtensionPoint) object; >+ return ext.getContributor(); >+ } else if (object instanceof Extension) { >+ Extension ext = (Extension) object; >+ return ext.getContributor(); >+ } else if (object instanceof ServiceRegistration) { >+ ServiceRegistration reg = (ServiceRegistration) object; >+ //return reg.getBundle(); // TODO FIXME >+ } >+ } else { // show only extensions >+ if (object instanceof ExtensionPoint) { >+ return object; >+ } else if (object instanceof Extension) { >+ Extension ext = (Extension) object; >+ return ext.getExtensionPoint(); >+ } >+ } >+ >+ return null; >+ } >+ >+ protected void update(ModelChangeDelta[] deltas) { >+ for (int i = 0; i < deltas.length; i++) { >+ ModelObject object = deltas[i].getModelObject(); >+ >+ switch (deltas[i].getFlag()) { >+ case ModelChangeDelta.ADDED : >+ if (topLevelElement(object)) { >+ fRegistryBrowser.add(object); >+ } else { >+ Object topLevelElement = getTopLevelElement(object); >+ fRegistryBrowser.refresh(topLevelElement); >+ } >+ break; >+ case ModelChangeDelta.REMOVED : >+ if (topLevelElement(object)) { >+ fRegistryBrowser.remove(object); >+ } else { >+ Object topLevelElement = getTopLevelElement(object); >+ fRegistryBrowser.refresh(topLevelElement); >+ } >+ break; >+ case ModelChangeDelta.STARTED : >+ case ModelChangeDelta.STOPPED : >+ case ModelChangeDelta.RESOLVED : >+ case ModelChangeDelta.UNRESOLVED : >+ case ModelChangeDelta.UPDATED : >+ if (topLevelElement(object)) { >+ fRegistryBrowser.refresh(object); >+ } else { >+ Object topLevelElement = getTopLevelElement(object); >+ fRegistryBrowser.refresh(topLevelElement); >+ } >+ break; >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/Folder.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/Folder.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/Folder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/Folder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class Folder { >+ >+ public static final int F_EXTENSIONS = 1; >+ public static final int F_EXTENSION_POINTS = 2; >+ public static final int F_IMPORTS = 3; >+ public static final int F_LIBRARIES = 4; >+ public static final int F_REGISTERED_SERVICES = 5; >+ public static final int F_SERVICES_IN_USE = 6; >+ >+ private int id; >+ private Bundle parent; >+ >+ public Folder(int id, Bundle parent) { >+ this.id = id; >+ this.parent = parent; >+ } >+ >+ public int getId() { >+ return id; >+ } >+ >+ public ModelObject getParent() { >+ return parent; >+ } >+ >+ public ModelObject[] getChildren() { >+ switch (id) { >+ case F_EXTENSION_POINTS : >+ return parent.getExtensionPoints(); >+ case F_EXTENSIONS : >+ return parent.getExtensions(); >+ case F_IMPORTS : >+ return parent.getImports(); >+ case F_LIBRARIES : >+ return parent.getLibraries(); >+ case F_REGISTERED_SERVICES : >+ return parent.getRegisteredServices(); >+ case F_SERVICES_IN_USE : >+ return parent.getServicesInUse(); >+ } >+ >+ return null; >+ } >+ >+ public int hashCode() { >+ final int prime = 31; >+ int result = 1; >+ result = prime * result + id; >+ result = prime * result + ((parent == null) ? 0 : parent.hashCode()); >+ return result; >+ } >+ >+ public boolean equals(Object obj) { >+ return ((obj instanceof Folder) && (((Folder) obj).id == id) && (((Folder) obj).parent.equals(parent))); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class BundlePrerequisite extends ModelObject { >+ >+ private boolean isExported; >+ private String name; >+ private String version; >+ >+ public BundlePrerequisite(RegistryModel model, String name, String version, boolean isExported) { >+ super(model); >+ this.name = name; >+ this.version = version; >+ this.isExported = isExported; >+ } >+ >+ public boolean isExported() { >+ return isExported; >+ } >+ >+ public String getName() { >+ if (version != null) { >+ if (Character.isDigit(version.charAt(0))) >+ version = '(' + version + ')'; >+ return name + ' ' + version; >+ } >+ >+ return name; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+/** >+ * >+ * Delta model objects are of type IBundle, IService, IExtension, IExtensionPoint >+ */ >+public class ModelChangeDelta { >+ >+ public static final int ADDED = 0; >+ public static final int UPDATED = 1; >+ public static final int REMOVED = 2; >+ public static final int STARTING = 3; >+ public static final int STARTED = 4; >+ public static final int STOPPING = 5; >+ public static final int STOPPED = 6; >+ public static final int RESOLVED = 7; >+ public static final int UNRESOLVED = 8; >+ >+ private ModelObject fObject; >+ private int fFlag; >+ >+ public ModelChangeDelta(ModelObject object, int flag) { >+ fObject = object; >+ fFlag = flag; >+ } >+ >+ public ModelObject getModelObject() { >+ return fObject; >+ } >+ >+ public int getFlag() { >+ return fFlag; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public abstract class ModelObject { >+ >+ private RegistryModel model; >+ >+ public ModelObject(RegistryModel model) { >+ this.model = model; >+ } >+ >+ public RegistryModel getModel() { >+ return model; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+/** >+ * Notifies on any changes coming from backend. Usually RegistryModel is only interested in receiving >+ * news about that. >+ * >+ */ >+public interface BackendChangeListener { >+ >+ void addBundle(Bundle adapter); >+ >+ void removeBundle(Bundle adapter); >+ >+ void updateBundle(Bundle adapter, int updated); >+ >+ void addService(ServiceRegistration adapter); >+ >+ void removeService(ServiceRegistration adapter); >+ >+ void updateService(ServiceRegistration adapter); >+ >+ void addExtensions(Extension[] createExtensionAdapters); >+ >+ void removeExtensions(Extension[] createExtensionAdapters); >+ >+ void addExtensionPoints(ExtensionPoint[] createExtensionPointAdapters); >+ >+ void removeExtensionPoints(ExtensionPoint[] createExtensionPointAdapters); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.util.Map; >+import org.eclipse.core.runtime.MultiStatus; >+import org.osgi.framework.BundleException; >+ >+public interface RegistryBackend { >+ >+ public void connect(); >+ >+ public void disconnect(); >+ >+ public void setEnabled(Bundle bundle, boolean enabled); >+ >+ public void start(Bundle bundle) throws BundleException; >+ >+ public void stop(Bundle bundle) throws BundleException; >+ >+ public MultiStatus diagnose(Bundle bundle); >+ >+ public Map initializeBundles(); >+ >+ public Map initializeExtensionPoints(); >+ >+ public void setRegistryListener(BackendChangeListener listener); >+ >+ public void setRegistryModel(RegistryModel listener); >+ >+ public Map initializeServices(); >+ >+} >\ No newline at end of fileIndex: src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+/** >+ * Event provides a list of objects that have changed. >+ * Possible objects on the list are IBundle, IService, IExtension, IExtensionPoint. >+ * This is temporary solution and is subject to future changes. >+ * >+ */ >+public interface ModelChangeListener { >+ >+ void modelChanged(ModelChangeDelta[] deltas); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class Attribute extends ModelObject { >+ public static final String F_LOCATION = "Location"; >+ >+ private String name; >+ private String value; >+ >+ public Attribute(RegistryModel model, String name, String value) { >+ super(model); >+ this.name = name; >+ this.value = value; >+ } >+ >+ public String getValue() { >+ return value; >+ } >+ >+ public String getName() { >+ return name; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class ConfigurationElement extends Attribute { >+ >+ private Attribute[] elements; >+ >+ public ConfigurationElement(RegistryModel model, String name, Attribute[] attributes) { >+ super(model, name, null); >+ elements = attributes; >+ } >+ >+ public Attribute[] getElements() { >+ return elements; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class ServiceRegistration extends ModelObject { >+ >+ private Long id; >+ private String bundle; >+ private Long[] usingBundles; >+ private String[] classes; >+ >+ public ServiceRegistration(RegistryModel model, Long id, String bundle, Long[] usingBundles, String[] classes) { >+ super(model); >+ this.id = id; >+ this.bundle = bundle; >+ this.usingBundles = usingBundles; >+ this.classes = classes; >+ } >+ >+ public Long getId() { >+ return id; >+ } >+ >+ public String[] getClasses() { >+ return classes; >+ } >+ >+ public String getBundle() { >+ return bundle; >+ } >+ >+ public Long[] getUsingBundles() { >+ return usingBundles; >+ } >+ >+ public boolean equals(Object obj) { >+ return (obj instanceof ServiceRegistration) && (id.equals(((ServiceRegistration) obj).id)); >+ } >+ >+ public int hashCode() { >+ return id.intValue(); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.net.URI; >+ >+/** >+ * Produces RegistryModels for URLs. Valid URLs: >+ * local >+ * target >+ * remote://host:port >+ * >+ */ >+public class RegistryModelFactory { >+ >+ /** >+ * >+ * @param codename >+ * @return never returns null >+ */ >+ public static RegistryModel getRegistryModel(URI codename) { >+ return new RegistryModel(new LocalRegistryBackend()); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public class BundleLibrary extends ModelObject { >+ >+ private String library; >+ >+ public BundleLibrary(RegistryModel model, String library) { >+ super(model); >+ this.library = library; >+ } >+ >+ public String getLibrary() { >+ return library; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.util.*; >+ >+/** >+ * Model entry point for Eclipse runtime. Provides information about runtime bundles, services and extension points. >+ * >+ */ >+public class RegistryModel { >+ >+ private BackendChangeListener backendListener = new BackendChangeListener() { >+ public void addBundle(Bundle adapter) { >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED); >+ >+ bundles.put(adapter.getId(), adapter); >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void removeBundle(Bundle adapter) { >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.REMOVED); >+ >+ bundles.remove(adapter.getId()); >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void updateBundle(Bundle adapter, int updated) { >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, updated); >+ >+ bundles.put(adapter.getId(), adapter); // replace old with new one >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void addService(ServiceRegistration adapter) { >+ services.put(adapter.getId(), adapter); >+ >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED); >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void removeService(ServiceRegistration adapter) { >+ services.remove(adapter.getId()); >+ >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.REMOVED); >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void updateService(ServiceRegistration adapter) { >+ services.put(adapter.getId(), adapter); >+ >+ ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.UPDATED); >+ >+ fireModelChangeEvent(new ModelChangeDelta[] {delta}); >+ } >+ >+ public void addExtensions(Extension[] extensionAdapters) { >+ for (int i = 0; i < extensionAdapters.length; i++) { >+ String id = extensionAdapters[i].getExtensionPointUniqueIdentifier(); >+ ExtensionPoint extPoint = (ExtensionPoint) extensionPoints.get(id); >+ extPoint.getExtensions().add(extensionAdapters[i]); >+ } >+ >+ ModelChangeDelta[] delta = new ModelChangeDelta[extensionAdapters.length]; >+ for (int i = 0; i < delta.length; i++) { >+ delta[i] = new ModelChangeDelta(extensionAdapters[i], ModelChangeDelta.ADDED); >+ } >+ fireModelChangeEvent(delta); >+ } >+ >+ public void removeExtensions(Extension[] extensionAdapters) { >+ for (int i = 0; i < extensionAdapters.length; i++) { >+ String id = extensionAdapters[i].getExtensionPointUniqueIdentifier(); >+ ExtensionPoint extPoint = (ExtensionPoint) extensionPoints.get(id); >+ extPoint.getExtensions().remove(extensionAdapters[i]); >+ } >+ >+ ModelChangeDelta[] delta = new ModelChangeDelta[extensionAdapters.length]; >+ for (int i = 0; i < delta.length; i++) { >+ delta[i] = new ModelChangeDelta(extensionAdapters[i], ModelChangeDelta.REMOVED); >+ } >+ fireModelChangeEvent(delta); >+ } >+ >+ public void addExtensionPoints(ExtensionPoint[] extensionPointAdapters) { >+ for (int i = 0; i < extensionPointAdapters.length; i++) { >+ extensionPoints.put(extensionPointAdapters[i].getUniqueIdentifier(), extensionPointAdapters[i]); >+ } >+ >+ ModelChangeDelta[] delta = new ModelChangeDelta[extensionPointAdapters.length]; >+ for (int i = 0; i < delta.length; i++) { >+ delta[i] = new ModelChangeDelta(extensionPointAdapters[i], ModelChangeDelta.ADDED); >+ } >+ fireModelChangeEvent(delta); >+ } >+ >+ public void removeExtensionPoints(ExtensionPoint[] extensionPointAdapters) { >+ for (int i = 0; i < extensionPointAdapters.length; i++) { >+ extensionPoints.remove(extensionPointAdapters[i].getUniqueIdentifier()); >+ } >+ >+ ModelChangeDelta[] delta = new ModelChangeDelta[extensionPointAdapters.length]; >+ for (int i = 0; i < delta.length; i++) { >+ delta[i] = new ModelChangeDelta(extensionPointAdapters[i], ModelChangeDelta.REMOVED); >+ } >+ fireModelChangeEvent(delta); >+ } >+ }; >+ >+ private List listeners = new ArrayList(); >+ private Map bundles; >+ private Map services; >+ private Map extensionPoints; >+ protected RegistryBackend backend; >+ >+ public RegistryModel(RegistryBackend backend) { >+ this.backend = backend; >+ backend.setRegistryListener(backendListener); >+ backend.setRegistryModel(this); >+ } >+ >+ public void connect() { >+ backend.connect(); >+ } >+ >+ public void disconnect() { >+ backend.disconnect(); >+ } >+ >+ public Bundle[] getBundles() { >+ if (bundles == null) { >+ bundles = backend.initializeBundles(); >+ } >+ >+ return (Bundle[]) bundles.values().toArray(new Bundle[bundles.values().size()]); >+ } >+ >+ public ExtensionPoint[] getExtensionPoints() { >+ if (extensionPoints == null) { >+ extensionPoints = backend.initializeExtensionPoints(); >+ } >+ >+ return (ExtensionPoint[]) extensionPoints.values().toArray(new ExtensionPoint[extensionPoints.values().size()]); >+ } >+ >+ public ServiceRegistration[] getServices() { >+ if (services == null) { >+ services = backend.initializeServices(); >+ } >+ >+ return (ServiceRegistration[]) services.values().toArray(new ServiceRegistration[services.values().size()]); >+ } >+ >+ public void addModelChangeListener(ModelChangeListener listener) { >+ listeners.add(listener); >+ } >+ >+ public void removeModelChangeListener(ModelChangeListener listener) { >+ listeners.remove(listener); >+ } >+ >+ /** >+ * For received domain types: Bundle, IExtension, IExtensionPoint, ServiceReference, >+ * generates delta with model types: IBundle, IExtensionAdapter, IExtensionPointAdapter, IService >+ * >+ * @param objects >+ */ >+ protected void fireModelChangeEvent(ModelChangeDelta[] delta) { >+ for (Iterator i = listeners.iterator(); i.hasNext();) { >+ ModelChangeListener listener = (ModelChangeListener) i.next(); >+ listener.modelChanged(delta); >+ } >+ } >+ >+ public Bundle getBundle(Long id) { >+ return (Bundle) bundles.get(id); >+ } >+ >+ public ExtensionPoint getExtensionPoint(String extensionPointUniqueIdentifier) { >+ return (ExtensionPoint) extensionPoints.get(extensionPointUniqueIdentifier); >+ } >+ >+ /* void setEnabled(Bundle bundle, boolean enabled); >+ >+ void start(Bundle bundle) throws BundleException; // XXX Create custom Exception >+ >+ void stop(Bundle bundle) throws BundleException; >+ >+ MultiStatus diagnose(Bundle bundle);*/ >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,142 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.util.*; >+import org.eclipse.core.runtime.MultiStatus; >+import org.osgi.framework.BundleException; >+ >+public class Bundle extends ModelObject { >+ >+ public static final int ACTIVE = org.osgi.framework.Bundle.ACTIVE; >+ public static final int UNINSTALLED = org.osgi.framework.Bundle.UNINSTALLED; >+ public static final int INSTALLED = org.osgi.framework.Bundle.INSTALLED; >+ >+ private String symbolicName; >+ private String location; >+ private boolean isEnabled; >+ private BundlePrerequisite[] imports; >+ private String version; >+ private int state; >+ private Long id; >+ private BundleLibrary[] libraries; >+ >+ public Bundle(RegistryModel model, String symbolicName, String version, int state, Long id, String location, BundlePrerequisite[] prereq, BundleLibrary[] libs, boolean isEnabled) { >+ super(model); >+ this.symbolicName = symbolicName; >+ this.version = version; >+ this.state = state; >+ this.id = id; >+ this.location = location; >+ this.imports = prereq; >+ this.libraries = libs; >+ this.isEnabled = isEnabled; >+ } >+ >+ public String getSymbolicName() { >+ return symbolicName; >+ } >+ >+ public boolean isEnabled() { >+ return isEnabled; >+ } >+ >+ public BundlePrerequisite[] getImports() { >+ return imports; >+ } >+ >+ public BundleLibrary[] getLibraries() { >+ return libraries; >+ } >+ >+ public String getLocation() { >+ return location; >+ } >+ >+ public String getVersion() { >+ return version; >+ } >+ >+ public int getState() { >+ return state; >+ } >+ >+ public Long getId() { >+ return id; >+ } >+ >+ public void start() throws BundleException { >+ getModel().backend.start(this); >+ } >+ >+ public void stop() throws BundleException { >+ getModel().backend.stop(this); >+ } >+ >+ public void setEnabled(boolean enabled) { >+ getModel().backend.setEnabled(this, enabled); >+ } >+ >+ public MultiStatus diagnose() { >+ return getModel().backend.diagnose(this); >+ } >+ >+ public ExtensionPoint[] getExtensionPoints() { >+ ExtensionPoint[] extPoints = getModel().getExtensionPoints(); >+ List result = new ArrayList(); >+ >+ for (int i = 0; i < extPoints.length; i++) { >+ if (id.equals(extPoints[i].getContributorId())) >+ result.add(extPoints[i]); >+ } >+ return (ExtensionPoint[]) result.toArray(new ExtensionPoint[result.size()]); >+ } >+ >+ public Extension[] getExtensions() { >+ ExtensionPoint[] extPoints = getModel().getExtensionPoints(); >+ List result = new ArrayList(); >+ >+ for (int i = 0; i < extPoints.length; i++) { >+ for (Iterator it = extPoints[i].getExtensions().iterator(); it.hasNext();) { >+ Extension a = (Extension) it.next(); >+ if (id.equals(a.getContributorId())) >+ result.add(a); >+ } >+ >+ } >+ return (Extension[]) result.toArray(new Extension[result.size()]); >+ } >+ >+ public ServiceRegistration[] getRegisteredServices() { >+ ServiceRegistration[] services = getModel().getServices(); >+ List result = new ArrayList(); >+ >+ for (int i = 0; i < services.length; i++) { >+ if (symbolicName.equals(services[i].getBundle())) >+ result.add(services[i]); >+ } >+ return (ServiceRegistration[]) result.toArray(new ServiceRegistration[result.size()]); >+ } >+ >+ public ServiceRegistration[] getServicesInUse() { >+ ServiceRegistration[] services = getModel().getServices(); >+ List result = new ArrayList(); >+ >+ for (int i = 0; i < services.length; i++) { >+ Long[] usingBundles = services[i].getUsingBundles(); >+ if (usingBundles != null) { >+ for (int j = usingBundles.length; j < usingBundles.length; j++) >+ if (id.equals(usingBundles[j])) >+ result.add(services[i]); >+ } >+ } >+ return (ServiceRegistration[]) result.toArray(new ServiceRegistration[result.size()]); >+ } >+ >+ public boolean equals(Object obj) { >+ return (obj instanceof Bundle) && (id.equals(((Bundle) obj).id)); >+ } >+ >+ public int hashCode() { >+ return id.intValue(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 243441
:
109423
|
109425
|
109519
|
109664
|
109665
| 115415