[266761] React to AcceptLicenses wizard moving to provisional
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java index de225d3..a361d8f 100644 --- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java +++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/ExtensionUtility.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.p2.core.Version; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; @@ -31,6 +30,8 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.wst.server.discovery.internal.model.Extension; import org.eclipse.wst.server.discovery.internal.model.ExtensionUpdateSite; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; public class ExtensionUtility { private static ExtensionUpdateSite[] getExtensionUpdateSites(URL url) throws CoreException { @@ -150,7 +151,7 @@ private static List<Extension> getExistingFeatures(IProgressMonitor monitor) throws CoreException { monitor.beginTask(Messages.discoverLocalConfiguration, 100); - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(Activator.getDefault().getBundle().getBundleContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = (IProfileRegistry) getService(Activator.getDefault().getBundle().getBundleContext(), IProfileRegistry.class.getName()); IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF); Query query = new InstallableUnitQuery(null); @@ -198,7 +199,7 @@ monitor.subTask(NLS.bind(Messages.discoverSearching, items[i].getUrl())); final int ii = i; final IProgressMonitor monitor2 = monitor; - threads[i] = new Thread("Extension Checker for" + items[i].getUrl()) { + threads[i] = new Thread("Extension Checker for " + items[i].getUrl()) { public void run() { try { List<Extension> list2 = items[ii].getExtensions(ProgressUtil.getSubMonitorFor(monitor2, x)); @@ -233,4 +234,24 @@ monitor.done(); return ef; } + + /** + * Returns the service described by the given arguments. Note that this is a helper class + * that <b>immediately</b> ungets the service reference. This results in a window where the + * system thinks the service is not in use but indeed the caller is about to use the returned + * service object. + * @param context + * @param name + * @return The requested service + */ + public static Object getService(BundleContext context, String name) { + if (context == null) + return null; + ServiceReference reference = context.getServiceReference(name); + if (reference == null) + return null; + Object result = context.getService(reference); + context.ungetService(reference); + return result; + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java index b21a865..0e944f0 100644 --- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java +++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java
@@ -12,7 +12,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.p2.core.Version; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; @@ -27,6 +26,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; import org.eclipse.wst.server.discovery.internal.Activator; +import org.eclipse.wst.server.discovery.internal.ExtensionUtility; import org.osgi.framework.BundleContext; public class Extension { @@ -80,10 +80,10 @@ if (!plan.getStatus().isOK()) return plan.getStatus(); - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(bundleContext, IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = (IProfileRegistry) ExtensionUtility.getService(bundleContext, IProfileRegistry.class.getName()); IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF); - IEngine engine = (IEngine) ServiceHelper.getService(bundleContext, IEngine.SERVICE_NAME); + IEngine engine = (IEngine) ExtensionUtility.getService(bundleContext, IEngine.SERVICE_NAME); return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), provContext, monitor); } @@ -96,9 +96,9 @@ return plan; BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext(); - IPlanner planner = (IPlanner) ServiceHelper.getService(bundleContext, IPlanner.class.getName()); + IPlanner planner = (IPlanner) ExtensionUtility.getService(bundleContext, IPlanner.class.getName()); - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(bundleContext, IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = (IProfileRegistry) ExtensionUtility.getService(bundleContext, IProfileRegistry.class.getName()); IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] { iu } );
diff --git a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/wizard/ExtensionComposite.java b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/wizard/ExtensionComposite.java index e315aaa..2dca1b1 100644 --- a/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/wizard/ExtensionComposite.java +++ b/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/wizard/ExtensionComposite.java
@@ -253,8 +253,11 @@ int yOffset = TEXT_MARGIN; gc.setFont(font); - gc.drawText(name, event.x + iw, event.y + yOffset, true); - Point size = event.gc.textExtent(name); + Point size = new Point(0, 0); + if (name != null) { + gc.drawText(name, event.x + iw, event.y + yOffset, true); + size = event.gc.textExtent(name); + } gc.setFont(null); yOffset += size.y + TEXT_MARGIN;