### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.runtime 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.53 diff -u -r1.53 RegistryBrowser.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java 29 Oct 2007 19:20:28 -0000 1.53 +++ src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java 29 Oct 2007 23:53:10 -0000 @@ -19,13 +19,19 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IRegistryChangeEvent; import org.eclipse.core.runtime.IRegistryChangeListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.internal.adaptor.MessageHelper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; @@ -34,7 +40,9 @@ import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.DisabledInfo; import org.eclipse.osgi.service.resolver.PlatformAdmin; +import org.eclipse.osgi.service.resolver.ResolverError; import org.eclipse.osgi.service.resolver.State; +import org.eclipse.osgi.service.resolver.VersionConstraint; import org.eclipse.pde.internal.runtime.IHelpContextIds; import org.eclipse.pde.internal.runtime.PDERuntimeMessages; import org.eclipse.pde.internal.runtime.PDERuntimePlugin; @@ -84,6 +92,7 @@ private Action fStopAction; private Action fEnableAction; private Action fDisableAction; + private Action fDiagnoseAction; private DrillDownAdapter drillDownAdapter; private ViewerFilter fActiveFilter = new ViewerFilter() { @@ -279,6 +288,8 @@ if(selectedBundlesStarted()) manager.add(fStopAction); + manager.add(fDiagnoseAction); + // security related actions if(selectedBundlesDisabled()) manager.add(fEnableAction); @@ -587,6 +598,60 @@ } }; + 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); + } + + for (int i = 0; i < unsatisfied.length; i++) { + // XXX what should we do with the MessageHelper? Copy over? + IStatus status = new Status( + IStatus.WARNING, + PDERuntimePlugin.ID, + MessageHelper + .getResolutionFailureMessage(unsatisfied[i])); + problems.add(status); + } + Dialog dialog; + if (unsatisfied.length != 0 || resolverErrors.length != 0) { + dialog = new DiagnosticsDialog( + getSite().getShell(), + PDERuntimeMessages.RegistryView_diag_dialog_title, + null, problems, IStatus.WARNING); + dialog.open(); + } else { + MessageDialog + .openInformation( + getSite().getShell(), + PDERuntimeMessages.RegistryView_diag_dialog_title, + PDERuntimeMessages.RegistryView_no_unresolved_constraints); + } + + } + } + }; + fCollapseAllAction = new Action("collapseAll"){ //$NON-NLS-1$ public void run(){ fTreeViewer.collapseAll(); Index: src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java,v retrieving revision 1.10 diff -u -r1.10 PDERuntimeMessages.java --- src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java 29 Oct 2007 18:28:36 -0000 1.10 +++ src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java 29 Oct 2007 23:52:57 -0000 @@ -23,13 +23,21 @@ public static String RegistryView_folders_libraries; public static String RegistryView_folders_extensionPoints; public static String RegistryView_folders_extensions; + + public static String RegistryView_found_problems; public static String RegistryView_showRunning_label; public static String RegistryView_showAdvanced_label; public static String RegistryView_titleSummary; public static String RegistryView_startAction_label; public static String RegistryView_stopAction_label; public static String RegistryView_enableAction_label; + public static String RegistryView_diag_dialog_title; + + public static String RegistryView_diagnoseAction_label; + public static String RegistryView_disableAction_label; + + public static String RegistryView_no_unresolved_constraints; public static String RegistryBrowserLabelProvider_nameIdBind; Index: src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties,v retrieving revision 1.58 diff -u -r1.58 pderuntimeresources.properties --- src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties 29 Oct 2007 18:23:09 -0000 1.58 +++ src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties 29 Oct 2007 23:53:00 -0000 @@ -20,6 +20,7 @@ RegistryView_folders_libraries = Run-time Libraries RegistryView_folders_extensionPoints = Extension Points RegistryView_folders_extensions = Extensions +RegistryView_found_problems=The following problems were found by diagnosing the bundle: RegistryView_showRunning_label = &Show Active Plug-ins Only RegistryView_showAdvanced_label = Show Advanced &Operations RegistryBrowserLabelProvider_nameIdBind={0} [{1}] @@ -27,7 +28,10 @@ RegistryView_startAction_label = Start RegistryView_stopAction_label = Stop RegistryView_enableAction_label = Enable +RegistryView_diag_dialog_title=Bundle Diagnose +RegistryView_diagnoseAction_label=Diagnose RegistryView_disableAction_label = Disable +RegistryView_no_unresolved_constraints=No unresolved constraints. # Plug-in Spy SpyDialog_title = Plug-in Spy Index: src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java diff -N src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +package org.eclipse.pde.internal.runtime.registry; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +public class DiagnosticsDialog extends ErrorDialog { + + public DiagnosticsDialog(Shell parentShell, String dialogTitle, + String message, IStatus status, int displayMask) { + super(parentShell, dialogTitle, message, status, displayMask); + } + + protected Control createDialogArea(Composite parent) { + Control area = super.createDialogArea(parent); + createDropDownList((Composite) area); + return area; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, + true); + } + +}