Skip to content

Commit

Permalink
Bug 568466 - Remove reference to Bundle
Browse files Browse the repository at this point in the history
The bundle is only stored to access the symbolic name for the purposes
of image lookup, and that's not necessary because there's an alternate
function which passes in a class from that bundle which is more
efficient. Replace calls to the bundle's symbolic name with the class
and remove caching the bundle.

Change-Id: I6f98a680f7cac65ff5d4d6f48470011fd6e26879
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
  • Loading branch information
alblue authored and l3-g5 committed Nov 5, 2020
1 parent 9325e3c commit 41cd18a
Showing 1 changed file with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 The Eclipse Foundation and others.
* Copyright (c) 2018, 2020 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -25,7 +25,6 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
Expand All @@ -40,13 +39,11 @@ public class MarketplaceClientUiResources {

private ResourceProvider resourceProvider;

private Bundle bundle;

private AbstractUIPlugin delegate;

@Activate
protected void activate(ComponentContext context) throws Exception {
bundle = context.getBundleContext().getBundle();
context.getBundleContext().getBundle();
delegate = new AbstractUIPlugin() {
@Override
protected void initializeImageRegistry(ImageRegistry reg) {
Expand Down Expand Up @@ -78,11 +75,6 @@ protected void deactivate(ComponentContext context) throws Exception {
delegate.stop(context.getBundleContext());
}
delegate = null;
bundle = null;
}

protected Bundle getBundle() {
return bundle;
}

public IPreferenceStore getPreferenceStore() {
Expand All @@ -104,22 +96,22 @@ public IDialogSettings getDialogSettings() {
protected void initializeImageRegistry(ImageRegistry imageRegistry) {

imageRegistry.put(MarketplaceClientUiPlugin.NO_ICON_PROVIDED,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/noiconprovided.png") //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/noiconprovided.png") //$NON-NLS-1$
.get());
imageRegistry.put(MarketplaceClientUiPlugin.NO_ICON_PROVIDED_CATALOG,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/noiconprovided32.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/noiconprovided32.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.DEFAULT_MARKETPLACE_ICON,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/marketplace_banner.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/marketplace_banner.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.IU_ICON,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/iu_obj.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/iu_obj.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.IU_ICON_UPDATE,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/iu_update_obj.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/iu_update_obj.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.IU_ICON_INSTALL,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/iu_install_obj.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/iu_install_obj.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.IU_ICON_UNINSTALL,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/iu_uninstall_obj.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/iu_uninstall_obj.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.IU_ICON_DISABLED,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/iu_disabled_obj.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/iu_disabled_obj.png").get()); //$NON-NLS-1$
{
ImageDescriptor errorOverlay = PlatformUI.getWorkbench()
.getSharedImages()
Expand All @@ -131,23 +123,23 @@ protected void initializeImageRegistry(ImageRegistry imageRegistry) {
}

imageRegistry.put(MarketplaceClientUiPlugin.NEWS_ICON_UPDATE,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/news_update.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/news_update.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ITEM_ICON_STAR,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/star.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/star.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ITEM_ICON_STAR_SELECTED,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/star-selected.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/star-selected.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ITEM_ICON_SHARE,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/share.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/share.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ACTION_ICON_FAVORITES,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/action-item-favorites.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/action-item-favorites.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ACTION_ICON_LOGIN,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/action-item-login.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/action-item-login.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ACTION_ICON_WARNING,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/action-item-warning.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/action-item-warning.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.ACTION_ICON_UPDATE,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/action-item-update.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/action-item-update.png").get()); //$NON-NLS-1$
imageRegistry.put(MarketplaceClientUiPlugin.FAVORITES_LIST_ICON,
imageDescriptorFromBundle(getBundle().getSymbolicName(), "icons/favorites-list.png").get()); //$NON-NLS-1$
imageDescriptorFromBundle(MarketplaceClientUiResources.class, "icons/favorites-list.png").get()); //$NON-NLS-1$
}

public static synchronized MarketplaceClientUiResources getInstance() {
Expand Down

0 comments on commit 41cd18a

Please sign in to comment.