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 109519 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]
updated patch
patch.txt (text/plain), 120.48 KB, created by
Jacek Pospychala
on 2008-08-08 09:55:09 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Jacek Pospychala
Created:
2008-08-08 09:55:09 EDT
Size:
120.48 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 8 Aug 2008 13:46:53 -0000 >@@ -10,108 +10,16 @@ > *******************************************************************************/ > 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.*; >+import org.eclipse.pde.internal.runtime.registry.model.impl.generic.*; >+import org.eclipse.pde.internal.runtime.registry.model.impl.local.ExtensionPointAdapter; > > public class RegistryBrowserContentProvider implements ITreeContentProvider { >- private Hashtable fExtensionPointMap = new Hashtable(); > public boolean isInExtensionSet; > >- 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 void dispose() { // nothing to dispose > } > >@@ -123,25 +31,32 @@ > if (element == null) > return null; > >- if (element instanceof ExtensionAdapter) >- return ((ExtensionAdapter) element).getChildren(); >+ if (element instanceof IExtensionAdapter) >+ return ((IExtensionAdapter) element).getConfigurationElements(); > > isInExtensionSet = false; > if (element instanceof ExtensionPointAdapter) >- return ((ExtensionPointAdapter) element).getChildren(); >+ return ((ExtensionPointAdapter) element).getExtensions(); > >- if (element instanceof ConfigurationElementAdapter) >- return ((ConfigurationElementAdapter) element).getChildren(); >+ if (element instanceof IElement) >+ return ((IElement) element).getElements(); > >- if (element instanceof PluginAdapter) { >- PluginAdapter bundle = (PluginAdapter) element; >+ if (element instanceof IBundle) { >+ IBundle bundle = (IBundle) element; > >- Object[] folders = bundle.getChildren(); >+ Object[] folders = new Object[7]; >+ folders[0] = new ConfigurationAttribute(IAttribute.F_LOCATION, bundle.getLocation()); >+ folders[1] = new BundleFolder(bundle, IBundleFolder.F_IMPORTS); >+ folders[2] = new BundleFolder(bundle, IBundleFolder.F_LIBRARIES); >+ folders[3] = new BundleFolder(bundle, IBundleFolder.F_EXTENSION_POINTS); >+ folders[4] = new BundleFolder(bundle, IBundleFolder.F_EXTENSIONS); >+ folders[5] = new BundleFolder(bundle, IBundleFolder.F_REGISTERED_SERVICES); >+ folders[6] = new BundleFolder(bundle, IBundleFolder.F_SERVICES_IN_USE); > > // filter out empty folders > ArrayList folderList = new ArrayList(); >- for (int i = 0; i < folders.length; i++) { >- if (folders[i] != null && ((IBundleFolder) folders[i]).getChildren() != null || ((IBundleFolder) folders[i]).getFolderId() == IBundleFolder.F_LOCATION) >+ for (int i = 1; i < folders.length; i++) { >+ if (((IBundleFolder) folders[i]).getChildren() != null) > folderList.add(folders[i]); > } > folders = folderList.toArray(new Object[folderList.size()]); >@@ -157,93 +72,20 @@ > isInExtensionSet = folder.getFolderId() == IBundleFolder.F_EXTENSIONS; > return ((IBundleFolder) element).getChildren(); > } >- if (element instanceof IConfigurationElement) { >- return ((IConfigurationElement) element).getChildren(); >+ if (element instanceof IElement) { >+ return ((IElement) element).getElements(); > } > if (element instanceof Object[]) { > return (Object[]) element; > } >- if (element instanceof IExtensionPoint) { >- IExtensionPoint extensionPoint = (IExtensionPoint) element; >+ if (element instanceof IExtensionPointAdapter) { >+ IExtensionPointAdapter extensionPoint = (IExtensionPointAdapter) 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 extensionPoint.getExtensions(); > } > 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); >- } >- } >- return result; >- } >- >- protected static Object[] getServices(Bundle bundle, int type) { >- Set result = new HashSet(); >- >- try { >- ServiceReference[] references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null); >- >- 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)); >- } >- } >- >- } catch (InvalidSyntaxException e) { // nothing >- } >- >- if (result.size() == 0) >- return null; >- >- return result.toArray(new ServiceReferenceAdapter[result.size()]); >- } >- > public Object getParent(Object element) { > return null; > } >@@ -256,26 +98,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 8 Aug 2008 13:46:53 -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,11 @@ > 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.pde.internal.runtime.registry.model.impl.generic.PluginObjectAdapter; >+import org.eclipse.pde.internal.runtime.registry.model.impl.local.RegistryBrowserListener; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.dnd.*; >@@ -33,7 +37,8 @@ > 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.framework.Bundle; >+import org.osgi.framework.BundleException; > import org.osgi.service.packageadmin.PackageAdmin; > > public class RegistryBrowser extends ViewPart { >@@ -49,6 +54,8 @@ > private IMemento fMemento; > private int fTotalItems = 0; > >+ private IRegistryModel model; >+ > // menus and action items > private Action fRefreshAction; > private Action fShowPluginsAction; >@@ -70,30 +77,20 @@ > 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 Bundle) >- return ((Bundle) element).getState() == Bundle.ACTIVE; >+ if (element instanceof IExtensionPointAdapter) >+ element = Platform.getBundle(((IExtensionPointAdapter) element).getNamespaceIdentifier()); >+ else if (element instanceof IExtensionAdapter) >+ element = Platform.getBundle(((IExtensionAdapter) element).getNamespaceIdentifier()); >+ if (element instanceof IBundle) >+ return ((IBundle) element).getState() == Bundle.ACTIVE; > return true; > } > }; > > 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); >+ if (element instanceof IBundle) { >+ return !((IBundle) element).isEnabled(); > } > return false; > } >@@ -133,6 +130,14 @@ > } > } > >+ public RegistryBrowser() { >+ try { >+ model = RegistryModelFactory.getRegistryModel(new URI("local")); >+ } catch (URISyntaxException e) { >+ PDERuntimePlugin.log(e); >+ } >+ } >+ > public void init(IViewSite site, IMemento memento) throws PartInitException { > super.init(site, memento); > if (memento == null) >@@ -203,15 +208,11 @@ > 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 Bundle && e2 instanceof Bundle) { >- e1 = ((Bundle) e1).getSymbolicName(); >- e2 = ((Bundle) e2).getSymbolicName(); >+ if (e1 instanceof IBundle && e2 instanceof IBundle) { >+ e1 = ((IBundle) e1).getSymbolicName(); >+ e2 = ((IBundle) e2).getSymbolicName(); > } > return super.compare(viewer, e1, e2); > } >@@ -240,15 +241,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(); >@@ -398,7 +390,7 @@ > try { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >- Bundle bundle = (Bundle) it.next(); >+ IBundle bundle = (IBundle) it.next(); > bundle.start(); > } > } catch (BundleException e) { >@@ -412,7 +404,7 @@ > try { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >- Bundle bundle = (Bundle) it.next(); >+ IBundle bundle = (IBundle) it.next(); > bundle.stop(); > } > } catch (BundleException e) { >@@ -424,15 +416,9 @@ > 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]); >- } >+ IBundle bundle = (IBundle) it.next(); >+ bundle.setEnabled(true); > } > PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); > packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()])); >@@ -442,13 +428,9 @@ > 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); >+ IBundle bundle = (IBundle) it.next(); >+ bundle.setEnabled(false); > } > PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); > packageAdmin.refreshPackages((Bundle[]) bundles.toArray(new Bundle[bundles.size()])); >@@ -458,27 +440,12 @@ > 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); >- } >+ IBundle bundle = (IBundle) it.next(); >+ 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,13 +466,13 @@ > fCollapseAllAction.setToolTipText(PDERuntimeMessages.RegistryView_collapseAll_tooltip); > } > >- protected void updateItems(boolean resetInput) { >+ public/* was protected */void updateItems(boolean resetInput) { > Object[] input = null; > boolean extOnly = fShowExtensionsOnlyAction.isChecked(); > if (extOnly) >- input = Platform.getExtensionRegistry().getExtensionPoints(); >+ input = model.getExtensionPoints(); > else >- input = getBundles(); >+ input = model.getBundles(); > fListener.fExtOnly = extOnly; > fTotalItems = input.length; > if (resetInput) >@@ -517,7 +484,7 @@ > setContentDescription(getTitleSummary()); > } > >- protected Tree getUndisposedTree() { >+ public/* was protected */Tree getUndisposedTree() { > if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed()) > return null; > return fTreeViewer.getTree(); >@@ -556,11 +523,8 @@ > 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 IBundle) { >+ bundles.add(elements[i]); > } > } > } >@@ -570,7 +534,7 @@ > private boolean selectedBundlesStarted() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >- Bundle bundle = (Bundle) it.next(); >+ IBundle bundle = (IBundle) it.next(); > if (bundle.getState() != Bundle.ACTIVE) > return false; > } >@@ -580,7 +544,7 @@ > private boolean selectedBundlesStopped() { > List bundles = getSelectedBundles(); > for (Iterator it = bundles.iterator(); it.hasNext();) { >- Bundle bundle = (Bundle) it.next(); >+ IBundle bundle = (IBundle) it.next(); > if (bundle.getState() == Bundle.ACTIVE) > return false; > } >@@ -590,11 +554,8 @@ > 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) >+ IBundle bundle = (IBundle) it.next(); >+ if (!bundle.isEnabled()) > return false; > } > return true; >@@ -603,21 +564,18 @@ > 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) >- return false; >+ IBundle bundle = (IBundle) it.next(); >+ if (bundle.isEnabled()) >+ return true; > } > return true; > } > >- protected void add(Object object) { >+ public/* was protected */void add(Object object) { > add(fTreeViewer.getInput(), object); > } > >- protected void add(Object parent, Object object) { >+ public/* was protected */void add(Object parent, Object object) { > if (fDrillDownAdapter.canGoHome()) > return; > fTotalItems += 1; >@@ -625,7 +583,7 @@ > updateTitle(); > } > >- protected void remove(Object object) { >+ public/* was protected */void remove(Object object) { > if (fDrillDownAdapter.canGoHome()) > return; > fTotalItems -= 1; >@@ -633,15 +591,15 @@ > updateTitle(); > } > >- protected void update(Object object) { >+ public/* was protected */void update(Object object) { > fTreeViewer.update(object, null); > } > >- protected void refresh(Object object) { >+ public/* was protected */void refresh(Object object) { > fTreeViewer.refresh(object); > } > >- protected TreeItem[] getTreeItems() { >+ public/* was 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 30 May 2008 16:49:08 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,388 +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) { >- System.out.println("adding "); //$NON-NLS-1$ >- if (ext != null) >- System.out.println("ext: " + ext.getUniqueIdentifier() + "/" + ext.getLabel() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- if (extPoint != null) >- System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ >- addExtensionObjectToTree(ext, extOnly); >- addExtensionObjectToTree(extPoint, extOnly); >- // addToTree(ext); >- // addToTree(extPoint); >- } else if (delta.getKind() == IExtensionDelta.REMOVED) { >- System.out.println("removing "); //$NON-NLS-1$ >- if (ext != null) >- System.out.println("ext: " + ext.getUniqueIdentifier() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ >- if (extPoint != null) >- System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ >- 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/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/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 8 Aug 2008 13:46:53 -0000 >@@ -10,19 +10,17 @@ > *******************************************************************************/ > 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.core.runtime.IConfigurationElement; > 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.pde.internal.runtime.registry.model.impl.generic.PluginObjectAdapter; > import org.eclipse.swt.graphics.Image; > import org.osgi.framework.Bundle; >-import org.osgi.framework.ServiceReference; > > public class RegistryBrowserLabelProvider extends LabelProvider { > >@@ -105,15 +103,10 @@ > if (element instanceof PluginObjectAdapter) > element = ((PluginObjectAdapter) element).getObject(); > >- if (element instanceof Bundle) { >- Bundle bundle = (Bundle) element; >+ if (element instanceof IBundle) { >+ IBundle bundle = (IBundle) 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,14 +115,14 @@ > 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 IService) { > return fServiceImage; > } > >@@ -144,8 +137,6 @@ > return fRequiresImage; > case IBundleFolder.F_LIBRARIES : > return fRuntimeImage; >- case IBundleFolder.F_LOCATION : >- return fLocationImage; > case IBundleFolder.F_REGISTERED_SERVICES : > return fExporterImage; > case IBundleFolder.F_SERVICES_IN_USE : >@@ -153,10 +144,10 @@ > } > return null; > } >- if (element instanceof IExtension) >+ if (element instanceof IExtensionAdapter) > return fExtensionImage; > >- if (element instanceof IExtensionPoint) >+ if (element instanceof IExtensionPointAdapter) > return fExtensionPointImage; > > if (element instanceof IBundlePrerequisite) >@@ -168,26 +159,29 @@ > if (element instanceof IConfigurationElement) > return fGenericTagImage; > >- if (element instanceof IConfigurationAttribute) >+ if (element instanceof IAttribute) { >+ IAttribute attr = (IAttribute) element; >+ if (IAttribute.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); >+ if (element instanceof IBundle) { >+ String id = ((IBundle) element).getSymbolicName(); >+ String version = ((IBundle) 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 IService) { >+ IService ref = (IService) 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); > } >@@ -205,38 +199,24 @@ > return PDERuntimeMessages.RegistryBrowserLabelProvider_registeredServices; > case IBundleFolder.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 IExtensionAdapter) { > if (((RegistryBrowserContentProvider) fViewer.getContentProvider()).isInExtensionSet) { >- String name = ((IExtension) element).getLabel(); >- String id = ((IExtension) element).getExtensionPointUniqueIdentifier(); >+ String name = ((IExtensionAdapter) element).getLabel(); >+ String id = ((IExtensionAdapter) 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 = ((IExtensionAdapter) 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 IExtensionPointAdapter) { >+ String id = ((IExtensionPointAdapter) element).getUniqueIdentifier(); >+ String name = ((IExtensionPointAdapter) element).getLabel(); > if (name != null && name.length() > 0) > return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name); > return id; >@@ -247,22 +227,11 @@ > if (element instanceof IBundleLibrary) > return ((IBundleLibrary) 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 IElement) { >+ return ((IElement) element).getLabel(); > } >- if (element instanceof IConfigurationAttribute) >- return ((IConfigurationAttribute) element).getLabel(); >+ if (element instanceof IAttribute) >+ return ((IAttribute) element).getLabel(); > > return super.getText(element); > } >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.25 >diff -u -r1.25 MANIFEST.MF >--- META-INF/MANIFEST.MF 16 May 2008 17:17:24 -0000 1.25 >+++ META-INF/MANIFEST.MF 8 Aug 2008 13:46:53 -0000 >@@ -17,6 +17,9 @@ > 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.registry.model.impl.generic;x-internal:=true, >+ org.eclipse.pde.internal.runtime.registry.model.impl.local;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/registry/model/IRegistryModel.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IRegistryModel.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IRegistryModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IRegistryModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,20 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import org.eclipse.core.runtime.IExtensionPoint; >+ >+public interface IRegistryModel { >+ >+ void connect(); >+ >+ IBundle[] getBundles(); >+ >+ IService[] getServices(); >+ >+ IExtensionPoint[] getExtensionPoints(); >+ >+ void addModelChangeListener(IModelChangeListener listener); >+ >+ void removeModelChangeListener(IModelChangeListener listener); >+ >+ void disconnect(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IBundle.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IBundle.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IBundle.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IBundle.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import org.eclipse.core.runtime.MultiStatus; >+import org.osgi.framework.BundleException; >+ >+public interface IBundle extends IModelObject { >+ >+ String getSymbolicName(); >+ >+ String getVersion(); >+ >+ boolean isEnabled(); >+ >+ void setEnabled(boolean enabled); >+ >+ public IExtensionAdapter[] getExtensions(); >+ >+ public IExtensionPointAdapter[] getExtensionPoints(); >+ >+ public IBundlePrerequisite[] getImports(); >+ >+ public IBundleLibrary[] getLibraries(); >+ >+ public Object[] getRegisteredServices(); >+ >+ public Object[] getServicesInUse(); >+ >+ public String getLocation(); >+ >+ int getState(); >+ >+ void start() throws BundleException; // XXX Create custom Exception >+ >+ void stop() throws BundleException; >+ >+ MultiStatus diagnose(); >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IBundleFolder.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IBundleFolder.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IBundleFolder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IBundleFolder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * 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 interface IBundleFolder extends IModelObject { >+ 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(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IBundleLibrary.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IBundleLibrary.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IBundleLibrary.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IBundleLibrary.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,15 @@ >+/******************************************************************************* >+ * 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 interface IBundleLibrary extends IModelObject { >+ public String getLibrary(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ServiceReferenceAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ServiceReferenceAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ServiceReferenceAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ServiceReferenceAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * 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.model.impl.local; >+ >+import org.eclipse.pde.internal.runtime.registry.model.IModelObject; >+import org.eclipse.pde.internal.runtime.registry.model.IService; >+import org.osgi.framework.ServiceReference; >+ >+public class ServiceReferenceAdapter implements IService { >+ >+ private ServiceReference ref; >+ >+ public ServiceReferenceAdapter(ServiceReference object) { >+ this.ref = object; >+ } >+ >+ public boolean equals(Object obj) { >+ // imitate ServiceReference behavior, that multiple ServiceReference instances are equal >+ return (obj instanceof ServiceReferenceAdapter) ? ref.equals(((ServiceReferenceAdapter) obj).ref) : false; >+ } >+ >+ public int hashCode() { >+ // imitate ServiceReference behavior, that multiple ServiceReference instances return the same hashCode >+ return ref.hashCode(); >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String[] getClasses() { >+ return (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS); >+ } >+ >+ public Long getId() { >+ return (Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * 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.impl.local; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.pde.internal.runtime.registry.model.*; >+ >+public class ExtensionAdapter implements IExtensionAdapter { >+ >+ org.eclipse.core.runtime.IExtension extension; >+ >+ public ExtensionAdapter(org.eclipse.core.runtime.IExtension extension) { >+ this.extension = extension; >+ } >+ >+ public IElement[] getConfigurationElements() { >+ >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ IElement[] result = new IElement[elements.length]; >+ for (int i = 0; i < elements.length; i++) { >+ IConfigurationElement config = elements[i]; >+ result[i] = new ConfigurationElementAdapter(config); >+ } >+ return result; >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getExtensionPointUniqueIdentifier() { >+ return extension.getExtensionPointUniqueIdentifier(); >+ } >+ >+ public String getLabel() { >+ return extension.getLabel(); >+ } >+ >+ public String getNamespaceIdentifier() { >+ return extension.getNamespaceIdentifier(); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/RegistryBrowserListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/RegistryBrowserListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/RegistryBrowserListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/RegistryBrowserListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,393 @@ >+/****************************************************************************** >+ * 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.model.impl.local; >+ >+import org.eclipse.core.runtime.*; >+import org.eclipse.pde.internal.runtime.registry.RegistryBrowser; >+import org.eclipse.pde.internal.runtime.registry.model.IBundle; >+import org.eclipse.pde.internal.runtime.registry.model.IBundleFolder; >+import org.eclipse.pde.internal.runtime.registry.model.impl.generic.PluginObjectAdapter; >+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; >+ public/* was protected */boolean fExtOnly; >+ >+ public/* was 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) { >+ System.out.println("adding "); //$NON-NLS-1$ >+ if (ext != null) >+ System.out.println("ext: " + ext.getUniqueIdentifier() + "/" + ext.getLabel() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ if (extPoint != null) >+ System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ >+ addExtensionObjectToTree(ext, extOnly); >+ addExtensionObjectToTree(extPoint, extOnly); >+ // addToTree(ext); >+ // addToTree(extPoint); >+ } else if (delta.getKind() == IExtensionDelta.REMOVED) { >+ System.out.println("removing "); //$NON-NLS-1$ >+ if (ext != null) >+ System.out.println("ext: " + ext.getUniqueIdentifier() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (extPoint != null) >+ System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ >+ 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 BundleAdapter && ((IBundle) 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 BundleAdapter && ((IBundle) 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 BundleAdapter(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; >+ BundleAdapter bundleAdapter = ((BundleAdapter) bundleItem.getData()); >+ fBrowser.refresh(bundleAdapter); >+ >+ /*Object[] folders = bundleAdapter.getChildren(); // XXX uncomment this and split changes notification into model and impl specyfic >+ >+ 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/model/IBundlePrerequisite.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IBundlePrerequisite.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IBundlePrerequisite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IBundlePrerequisite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * 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; >+ >+import org.eclipse.osgi.util.ManifestElement; >+ >+public interface IBundlePrerequisite extends IModelObject { >+ public ManifestElement getPrerequisite(); >+ >+ public boolean isExported(); >+ >+ public String getLabel(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ConfigurationElementAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ConfigurationElementAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ConfigurationElementAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ConfigurationElementAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * 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.impl.local; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.pde.internal.runtime.registry.model.*; >+import org.eclipse.pde.internal.runtime.registry.model.impl.generic.ConfigurationAttribute; >+ >+public class ConfigurationElementAdapter implements IElement { >+ >+ private IConfigurationElement config; >+ private IAttribute[] elements; >+ >+ public ConfigurationElementAdapter(IConfigurationElement config) { >+ this.config = config; >+ } >+ >+ protected void createChildren() { >+ String[] atts = config.getAttributeNames(); >+ IAttribute[] catts = new IAttribute[atts.length]; >+ for (int i = 0; i < atts.length; i++) >+ catts[i] = new ConfigurationAttribute(atts[i], config.getAttribute(atts[i])); >+ IConfigurationElement[] children = config.getChildren(); >+ IAttribute[] result = new IAttribute[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++) { >+ result[children.length + i] = catts[i]; >+ } >+ elements = result; >+ } >+ >+ public IAttribute[] getElements() { >+ if (elements == null) { >+ createChildren(); >+ } >+ >+ return elements; >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getLabel() { >+ 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; >+ } >+ >+ public String getName() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IExtensionAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IExtensionAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IExtensionAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IExtensionAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,12 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IExtensionAdapter extends IModelObject { >+ >+ IElement[] getConfigurationElements(); >+ >+ String getLabel(); >+ >+ String getExtensionPointUniqueIdentifier(); >+ >+ String getNamespaceIdentifier(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/LocalModel.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/LocalModel.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/LocalModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/LocalModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+package org.eclipse.pde.internal.runtime.registry.model.impl.local; >+ >+import java.util.ArrayList; >+import java.util.List; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.pde.internal.runtime.PDERuntimePlugin; >+import org.eclipse.pde.internal.runtime.registry.model.*; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.Constants; >+ >+public class LocalModel implements IRegistryModel { >+ >+ private List listeners = new ArrayList(); >+ >+ public void connect() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void disconnect() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public IBundle[] 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 BundleAdapter(bundles[i])); >+ return (BundleAdapter[]) list.toArray(new BundleAdapter[list.size()]); >+ } >+ >+ public IExtensionPoint[] getExtensionPoints() { >+ return Platform.getExtensionRegistry().getExtensionPoints(); >+ } >+ >+ public IService[] getServices() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public void addModelChangeListener(IModelChangeListener listener) { >+ listeners.add(listener); >+ } >+ >+ public void removeModelChangeListener(IModelChangeListener listener) { >+ listeners.remove(listener); >+ } >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IExtensionPointAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IExtensionPointAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IExtensionPointAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IExtensionPointAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,13 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IExtensionPointAdapter extends IModelObject { >+ >+ String getUniqueIdentifier(); >+ >+ IExtensionAdapter[] getExtensions(); >+ >+ String getLabel(); >+ >+ String getNamespaceIdentifier(); >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/BundleFolder.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/BundleFolder.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/BundleFolder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/BundleFolder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,62 @@ >+/** >+ * >+ */ >+package org.eclipse.pde.internal.runtime.registry.model.impl.generic; >+ >+import org.eclipse.pde.internal.runtime.registry.model.*; >+ >+public class BundleFolder implements IBundleFolder { >+ private int id; >+ private IModelObject parent; >+ private Object[] children; >+ >+ public BundleFolder(IModelObject parent, int id) { >+ this.parent = parent; >+ this.id = id; >+ } >+ >+ protected void createChildren() { >+ switch (id) { >+ case F_EXTENSION_POINTS : >+ children = ((IBundle) parent).getExtensionPoints(); >+ return; >+ case F_EXTENSIONS : >+ children = ((IBundle) parent).getExtensions(); >+ return; >+ case F_IMPORTS : >+ children = ((IBundle) parent).getImports(); >+ return; >+ case F_LIBRARIES : >+ children = ((IBundle) parent).getLibraries(); >+ return; >+ case F_REGISTERED_SERVICES : >+ children = ((IBundle) parent).getRegisteredServices(); >+ return; >+ case F_SERVICES_IN_USE : >+ children = ((IBundle) parent).getServicesInUse(); >+ return; >+ } >+ } >+ >+ public Object[] getChildren() { >+ if (children == null) { >+ createChildren(); >+ } >+ return children; >+ } >+ >+ /** >+ * Resets folder's previously cached knowledge about it's children. >+ */ >+ public void refresh() { >+ children = null; >+ } >+ >+ public int getFolderId() { >+ return id; >+ } >+ >+ public IModelObject getParent() { >+ return parent; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IModelChangedEvent.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IModelChangedEvent.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IModelChangedEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IModelChangedEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IModelChangedEvent { >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeListener.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeListener.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IModelChangeListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IModelChangeListener { >+ >+ void modelChange(IModelChangedEvent event); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ConfigurationAttribute.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ConfigurationAttribute.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ConfigurationAttribute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/ConfigurationAttribute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/** >+ * >+ */ >+package org.eclipse.pde.internal.runtime.registry.model.impl.generic; >+ >+import org.eclipse.pde.internal.runtime.registry.model.IAttribute; >+import org.eclipse.pde.internal.runtime.registry.model.IModelObject; >+ >+public class ConfigurationAttribute implements IAttribute { >+ private String fLabel; >+ private String name; >+ >+ public ConfigurationAttribute(String name, String value) { >+ fLabel = name + " = " + value; //$NON-NLS-1$ >+ this.name = name; >+ } >+ >+ public String getLabel() { >+ return fLabel; >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getName() { >+ return name; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IModelObject.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IModelObject.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IModelObject.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IModelObject.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IModelObject { >+ >+ IModelObject getParent(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,223 @@ >+package org.eclipse.pde.internal.runtime.registry.model.impl.local; >+ >+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.eclipse.pde.internal.runtime.registry.model.*; >+import org.osgi.framework.*; >+ >+public class BundleAdapter implements IBundle { >+ >+ private Bundle bundle; >+ >+ private IExtensionAdapter[] fExtensions; >+ >+ private IExtensionPointAdapter[] fExtensionPoints; >+ >+ public BundleAdapter(Bundle bundle) { >+ this.bundle = bundle; >+ } >+ >+ public String getSymbolicName() { >+ return bundle.getSymbolicName(); >+ } >+ >+ public boolean isEnabled() { >+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ State state = plaformAdmin.getState(false); >+ >+ BundleDescription description = state.getBundle(bundle.getBundleId()); >+ return ((state.getDisabledInfos(description)).length == 0); >+ } >+ >+ public void setEnabled(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); >+ } >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public IExtensionAdapter[] getExtensions() { >+ if (fExtensions == null) { >+ IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(getSymbolicName()); >+ IExtensionAdapter[] tmp = new IExtensionAdapter[extensions.length]; >+ for (int i = 0; i < extensions.length; i++) { >+ tmp[i] = new ExtensionAdapter(extensions[i]); >+ } >+ fExtensions = tmp; >+ } >+ return fExtensions; >+ } >+ >+ public IExtensionPointAdapter[] getExtensionPoints() { >+ if (fExtensionPoints == null) { >+ IExtensionPoint[] extensions = Platform.getExtensionRegistry().getExtensionPoints(getSymbolicName()); >+ IExtensionPointAdapter[] tmp = new IExtensionPointAdapter[extensions.length]; >+ for (int i = 0; i < extensions.length; i++) { >+ tmp[i] = new ExtensionPointAdapter(extensions[i]); >+ } >+ fExtensionPoints = tmp; >+ } >+ return fExtensionPoints; >+ } >+ >+ public IBundlePrerequisite[] getImports() { >+ return (IBundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE); >+ } >+ >+ public IBundleLibrary[] getLibraries() { >+ return (IBundleLibrary[]) getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH); >+ } >+ >+ public Object[] getRegisteredServices() { >+ return getServices(bundle, IBundleFolder.F_REGISTERED_SERVICES); >+ } >+ >+ public Object[] getServicesInUse() { >+ return getServices(bundle, IBundleFolder.F_SERVICES_IN_USE); >+ } >+ >+ public static Object[] getServices(Bundle bundle, int type) { >+ Set result = new HashSet(); >+ >+ try { >+ ServiceReference[] references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null); >+ >+ 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)); >+ } >+ } >+ >+ } catch (InvalidSyntaxException e) { // nothing >+ } >+ >+ if (result.size() == 0) >+ return null; >+ >+ return result.toArray(new ServiceReferenceAdapter[result.size()]); >+ } >+ >+ /* public static Object[] getFolderChildren(int id) { >+ Object[] array = null; >+ >+ 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); >+ } >+ } >+ return result; >+ }*/ >+ >+ public static 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; >+ } >+ >+ public String getLocation() { >+ 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; >+ } >+ >+ public String getVersion() { >+ return (String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); >+ } >+ >+ public int getState() { >+ return bundle.getState(); >+ } >+ >+ public void start() throws BundleException { >+ bundle.start(); >+ } >+ >+ public void stop() throws BundleException { >+ bundle.stop(); >+ } >+ >+ public MultiStatus diagnose() { >+ PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); >+ State state = plaformAdmin.getState(false); >+ >+ 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); >+ } >+ >+ 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; >+ } >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionPointAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionPointAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionPointAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/ExtensionPointAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * 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.impl.local; >+ >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.pde.internal.runtime.registry.model.*; >+ >+public class ExtensionPointAdapter implements IExtensionPointAdapter { >+ >+ private IExtensionPoint extensionPoint; >+ >+ private IExtensionAdapter[] extensions; >+ >+ public ExtensionPointAdapter(IExtensionPoint extensionPoint) { >+ this.extensionPoint = extensionPoint; >+ } >+ >+ protected void createChildren() { >+ IExtension[] exts = extensionPoint.getExtensions(); >+ IExtensionAdapter[] result = new IExtensionAdapter[exts.length]; >+ for (int i = 0; i < exts.length; i++) { >+ result[i] = new ExtensionAdapter(exts[i]); >+ } >+ extensions = result; >+ } >+ >+ public IExtensionAdapter[] getExtensions() { >+ if (extensions == null) { >+ createChildren(); >+ } >+ >+ return extensions; >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ public String getLabel() { >+ return extensionPoint.getLabel(); >+ } >+ >+ public String getUniqueIdentifier() { >+ return extensionPoint.getUniqueIdentifier(); >+ } >+ >+ public String getNamespaceIdentifier() { >+ return extensionPoint.getNamespaceIdentifier(); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IAttribute.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IAttribute.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IAttribute.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IAttribute.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+/******************************************************************************* >+ * 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 interface IAttribute extends IModelObject { >+ String F_LOCATION = "Location"; >+ >+ public String getLabel(); >+ >+ String getName(); >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundlePrerequisite.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundlePrerequisite.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundlePrerequisite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundlePrerequisite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+/** >+ * >+ */ >+package org.eclipse.pde.internal.runtime.registry.model.impl.local; >+ >+import org.eclipse.osgi.util.ManifestElement; >+import org.eclipse.pde.internal.runtime.registry.model.IBundlePrerequisite; >+import org.eclipse.pde.internal.runtime.registry.model.IModelObject; >+import org.osgi.framework.Constants; >+ >+public 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; >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/IElement.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IElement.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IElement extends IAttribute { >+ >+ IAttribute[] getElements(); >+ >+} >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,23 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+import java.net.URI; >+import org.eclipse.pde.internal.runtime.registry.model.impl.local.LocalModel; >+ >+/** >+ * Produces RegistryModels for URLs. Valid URLs: >+ * local >+ * target >+ * remote://host:port >+ * >+ */ >+public class RegistryModelFactory { >+ >+ /** >+ * >+ * @param codename >+ * @return never returns null >+ */ >+ public static IRegistryModel getRegistryModel(URI codename) { >+ return new LocalModel(); >+ } >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/PluginObjectAdapter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/PluginObjectAdapter.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/PluginObjectAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/generic/PluginObjectAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * 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.impl.generic; >+ >+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/model/IService.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/IService.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/IService.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/IService.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+package org.eclipse.pde.internal.runtime.registry.model; >+ >+public interface IService extends IModelObject { >+ >+ String[] getClasses(); >+ >+ Long getId(); >+ >+} >Index: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleLibrary.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleLibrary.java >diff -N src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleLibrary.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/runtime/registry/model/impl/local/BundleLibrary.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/** >+ * >+ */ >+package org.eclipse.pde.internal.runtime.registry.model.impl.local; >+ >+import org.eclipse.osgi.util.ManifestElement; >+import org.eclipse.pde.internal.runtime.registry.model.IBundleLibrary; >+import org.eclipse.pde.internal.runtime.registry.model.IModelObject; >+ >+public class BundleLibrary implements IBundleLibrary { >+ private ManifestElement underlyingElement; >+ >+ public BundleLibrary(ManifestElement element) { >+ underlyingElement = element; >+ } >+ >+ public String getLibrary() { >+ return underlyingElement.getValue(); >+ } >+ >+ public IModelObject getParent() { >+ // TODO Auto-generated method stub >+ return null; >+ } >+}
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