diff options
author | ustieber | 2011-05-12 12:25:12 +0000 |
---|---|---|
committer | ustieber | 2011-05-12 12:25:12 +0000 |
commit | a181e1b9e9b9db4cafa7ce79aeaf82a57ec1bb02 (patch) | |
tree | ad0b4af88cdee4f4d2aa659b5399a1f11c1b4917 | |
parent | 1872071ffb080b222581a39ca6ddf5d714e86889 (diff) | |
download | org.eclipse.tcf-a181e1b9e9b9db4cafa7ce79aeaf82a57ec1bb02.tar.gz org.eclipse.tcf-a181e1b9e9b9db4cafa7ce79aeaf82a57ec1bb02.tar.xz org.eclipse.tcf-a181e1b9e9b9db4cafa7ce79aeaf82a57ec1bb02.zip |
Target Explorer: Remove custom image registry implementation
14 files changed, 177 insertions, 444 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/activator/UIPlugin.java index d62ab5ff2..9bf95bf10 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/activator/UIPlugin.java @@ -3,18 +3,18 @@ * 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: * Uwe Stieber (Wind River) - initial API and implementation *******************************************************************************/ package org.eclipse.tm.te.tcf.filesystem.activator; +import java.net.URL; + import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.tm.te.tcf.filesystem.internal.registries.InternalImageRegistry; -import org.eclipse.tm.te.ui.images.AbstractImageDescriptor; -import org.eclipse.tm.te.ui.images.AbstractImageRegistry; +import org.eclipse.tm.te.tcf.filesystem.internal.ImageConsts; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -74,17 +74,13 @@ public class UIPlugin extends AbstractUIPlugin { */ @Override protected void initializeImageRegistry(ImageRegistry registry) { - if (registry instanceof InternalImageRegistry) { - ((InternalImageRegistry)registry).initialize(); - } - } + URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "folder.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_FOLDER, ImageDescriptor.createFromURL(url)); - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry() - */ - @Override - protected ImageRegistry createImageRegistry() { - return new InternalImageRegistry(this); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "rootdrive.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_ROOT_DRIVE, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "rootdriveopen.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_ROOT_DRIVE_OPEN, ImageDescriptor.createFromURL(url)); } /** @@ -108,17 +104,4 @@ public class UIPlugin extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String key) { return getDefault().getImageRegistry().getDescriptor(key); } - - /** - * Loads the image given by the specified image descriptor from the image - * registry. If the image has been loaded ones before already, the cached - * <code>Image</code> object instance is returned. Otherwise, the <code> - * Image</code> object instance will be created and cached before returned. - * - * @param descriptor The image descriptor. - * @return The corresponding <code>Image</code> object instance or <code>null</code>. - */ - public static Image getSharedImage(AbstractImageDescriptor descriptor) { - return ((AbstractImageRegistry)getDefault().getImageRegistry()).getSharedImage(descriptor); - } } diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/controls/FSTreeLabelProvider.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/controls/FSTreeLabelProvider.java index d40a4e326..c08653536 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/controls/FSTreeLabelProvider.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/controls/FSTreeLabelProvider.java @@ -3,7 +3,7 @@ * 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: * Uwe Stieber (Wind River) - initial API and implementation *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.graphics.Image; import org.eclipse.tm.te.tcf.filesystem.activator.UIPlugin; -import org.eclipse.tm.te.tcf.filesystem.internal.registries.InternalImageRegistry; +import org.eclipse.tm.te.tcf.filesystem.internal.ImageConsts; import org.eclipse.tm.te.tcf.filesystem.model.FSTreeNode; import org.eclipse.tm.te.ui.views.interfaces.IUIConstants; import org.eclipse.ui.IEditorRegistry; @@ -101,9 +101,9 @@ public class FSTreeLabelProvider extends LabelProvider implements ITableLabelPro if (element instanceof FSTreeNode) { FSTreeNode node = (FSTreeNode)element; if ("FSRootDirNode".equals(node.type)) {//$NON-NLS-1$ - return isExpanded ? UIPlugin.getImage(InternalImageRegistry.OBJ_RootDriveOpen) : UIPlugin.getImage(InternalImageRegistry.OBJ_RootDrive); + return isExpanded ? UIPlugin.getImage(ImageConsts.IMAGE_ROOT_DRIVE_OPEN) : UIPlugin.getImage(ImageConsts.IMAGE_ROOT_DRIVE); } else if ("FSDirNode".equals(node.type)) { //$NON-NLS-1$ - return isExpanded ? PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER) : UIPlugin.getImage(InternalImageRegistry.OBJ_Folder); + return isExpanded ? PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER) : UIPlugin.getImage(ImageConsts.IMAGE_FOLDER); } else if ("FSFileNode".equals(node.type)) { //$NON-NLS-1$ String key = node.name; Image image = UIPlugin.getImage(key); diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/ImageConsts.java new file mode 100644 index 000000000..ef4390f93 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/ImageConsts.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Uwe Stieber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.tcf.filesystem.internal; + +/** + * Target Explorer: File system plug-in Image registry constants. + */ +public interface ImageConsts { + + // ***** The directory structure constants ***** + + /** + * The root directory where to load the images from, relative to + * the bundle directory. + */ + public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ + + /** + * The directory where to load model object images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$ + + // ***** The image constants ***** + + /** + * The key to access the base folder object image. + */ + public static final String IMAGE_FOLDER = "Folder"; //$NON-NLS-1$ + + /** + * The key to access the base folder object image. + */ + public static final String IMAGE_ROOT_DRIVE = "RootDrive"; //$NON-NLS-1$ + + /** + * The key to access the base folder object image. + */ + public static final String IMAGE_ROOT_DRIVE_OPEN = "RootDriveOpen"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/registries/InternalImageRegistry.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/registries/InternalImageRegistry.java deleted file mode 100644 index 0ea23ad5b..000000000 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/internal/registries/InternalImageRegistry.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. 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: - * Uwe Stieber (Wind River) - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.te.tcf.filesystem.internal.registries; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.tm.te.ui.images.AbstractImageRegistry; - - -/** - * Target Explorer: File System UI Plug-in image registry. - */ -public class InternalImageRegistry extends AbstractImageRegistry { - private static List<Object[]> fStore = new ArrayList<Object[]>(); - - // declare all keys down here - public static final String OBJ_RootDrive = declareLocalImage("obj16", "rootdrive.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String OBJ_RootDriveOpen = declareLocalImage("obj16", "rootdriveopen.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String OBJ_Folder = declareLocalImage("obj16", "folder.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - - // external eclipse icons not reachable using ISharedImages - - /** - * Constructor. - * - * @param plugin The plugin descriptor the image registry is created for. - */ - public InternalImageRegistry(Plugin plugin) { - super(plugin); - } - - /** - * Initialize image registry with all keys known yet. - */ - public void initialize() { - for (Iterator<Object[]> iter = fStore.iterator(); iter.hasNext();) { - Object[] element = iter.next(); - if (element.length == 3) { - localImage((String)element[0], (String)element[1], (String)element[2]); - } - else if (element.length > 3){ - externalImage((String)element[0], (String)element[1], (String[])element[2], (String)element[3]); - } - } - } - - /** - * Declare a locally stored image to the image registry. - */ - static String declareLocalImage(String dir, String name) { - List<Object> registryObject = new ArrayList<Object>(); - registryObject.add(dir); - registryObject.add(name); - String key = name + "_" + registryObject.hashCode(); //$NON-NLS-1$ - registryObject.add(0, key); - fStore.add(registryObject.toArray()); - return key; - } - - /** - * Declare a externally stored image to the image registry. - */ - static String declareExternalImage(String plugin, String[] dirs, String name) { - List<Object> registryObject = new ArrayList<Object>(); - registryObject.add(plugin); - registryObject.add(dirs); - registryObject.add(name); - String key = name + "_" + registryObject.hashCode(); //$NON-NLS-1$ - registryObject.add(0, key); - fStore.add(registryObject.toArray()); - return key; - } -} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dlcl16/newRemoteTarget_wiz.gif Binary files differindex fd7af8403..fd7af8403 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dlcl16/newRemoteTarget_wiz.gif diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/elcl16/newRemoteTarget_wiz.gif Binary files differindex 5b0b25fbe..5b0b25fbe 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/elcl16/newRemoteTarget_wiz.gif diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml index 849edcefb..75d1ffe32 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml @@ -45,7 +45,7 @@ <wizard category="org.eclipse.tm.te.ui.newWizards.category" class="org.eclipse.tm.te.tcf.ui.internal.wizards.NewRemoteTargetWizard" - icon="icons/etool16/newRemoteTarget_wiz.gif" + icon="icons/elcl16/newRemoteTarget_wiz.gif" id="org.eclipse.tm.te.tcf.ui.wizards.NewPeerWizard" name="%NewPeerWizard.name"> </wizard> diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java index 751715329..430400522 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java @@ -9,12 +9,13 @@ *******************************************************************************/ package org.eclipse.tm.te.tcf.ui.activator; +import java.net.URL; + import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.tm.te.tcf.ui.internal.registries.InternalImageRegistry; +import org.eclipse.tm.te.tcf.ui.internal.ImageConsts; import org.eclipse.tm.te.ui.images.AbstractImageDescriptor; -import org.eclipse.tm.te.ui.images.AbstractImageRegistry; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -74,17 +75,19 @@ public class UIPlugin extends AbstractUIPlugin { */ @Override protected void initializeImageRegistry(ImageRegistry registry) { - if (registry instanceof InternalImageRegistry) { - ((InternalImageRegistry)registry).initialize(); - } - } + URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "target.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_TARGET, ImageDescriptor.createFromURL(url)); - /* (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry() - */ - @Override - protected ImageRegistry createImageRegistry() { - return new InternalImageRegistry(this); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "gold_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_GOLD_OVR, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "green_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_GREEN_OVR, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "grey_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_GREY_OVR, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "red_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_RED_OVR, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "redX_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.IMAGE_RED_X_OVR, ImageDescriptor.createFromURL(url)); } /** @@ -119,6 +122,15 @@ public class UIPlugin extends AbstractUIPlugin { * @return The corresponding <code>Image</code> object instance or <code>null</code>. */ public static Image getSharedImage(AbstractImageDescriptor descriptor) { - return ((AbstractImageRegistry)getDefault().getImageRegistry()).getSharedImage(descriptor); + ImageRegistry registry = getDefault().getImageRegistry(); + + String imageKey = descriptor.getKey(); + Image image = registry.get(imageKey); + if (image == null) { + registry.put(imageKey, descriptor); + image = registry.get(imageKey); + } + + return image; } } diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/ImageConsts.java new file mode 100644 index 000000000..cfd35dc7f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/ImageConsts.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Uwe Stieber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.tcf.ui.internal; + +/** + * Target Explorer: TCF UI Plug-in Image registry constants. + */ +public interface ImageConsts { + + // ***** The directory structure constants ***** + + /** + * The root directory where to load the images from, relative to + * the bundle directory. + */ + public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ + + /** + * The directory where to load disabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_DLCL = "dlcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load enabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_ELCL = "elcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load model object images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$ + + /** + * The directory where to load object overlay images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_OVR = "ovr16/"; //$NON-NLS-1$ + + // ***** The image constants ***** + + /** + * The key to access the base target object image. + */ + public static final String IMAGE_TARGET = "TargetObject"; //$NON-NLS-1$ + + /** + * The key to access the target object gold overlay image. + */ + public static final String IMAGE_GOLD_OVR = "GoldOverlay"; //$NON-NLS-1$ + + /** + * The key to access the target object green overlay image. + */ + public static final String IMAGE_GREEN_OVR = "GreenOverlay"; //$NON-NLS-1$ + + /** + * The key to access the target object grey overlay image. + */ + public static final String IMAGE_GREY_OVR = "GreyOverlay"; //$NON-NLS-1$ + + /** + * The key to access the target object red overlay image. + */ + public static final String IMAGE_RED_OVR = "RedOverlay"; //$NON-NLS-1$ + + /** + * The key to access the target object red X overlay image. + */ + public static final String IMAGE_RED_X_OVR = "RedXOverlay"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/LabelProviderDelegate.java index 73f712871..03cfaee25 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/LabelProviderDelegate.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/LabelProviderDelegate.java @@ -16,8 +16,8 @@ import org.eclipse.tm.tcf.protocol.IPeer; import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tm.te.tcf.ui.activator.UIPlugin; +import org.eclipse.tm.te.tcf.ui.internal.ImageConsts; import org.eclipse.tm.te.tcf.ui.internal.navigator.images.PeerImageDescriptor; -import org.eclipse.tm.te.tcf.ui.internal.registries.InternalImageRegistry; import org.eclipse.tm.te.ui.images.AbstractImageDescriptor; @@ -62,7 +62,7 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora @Override public Image getImage(Object element) { if (element instanceof IPeerModel) { - return UIPlugin.getImage(InternalImageRegistry.OBJ_Target); + return UIPlugin.getImage(ImageConsts.IMAGE_TARGET); } return super.getImage(element); diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java index 7cfa92136..220372242 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java @@ -15,7 +15,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModelProperties; -import org.eclipse.tm.te.tcf.ui.internal.registries.InternalImageRegistry; +import org.eclipse.tm.te.tcf.ui.internal.ImageConsts; import org.eclipse.tm.te.ui.images.AbstractImageDescriptor; @@ -82,19 +82,19 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { drawCentered(fBaseImage, width, height); if (fState == IPeerModelProperties.STATE_UNKNOWN) { /* unknown */ - drawBottomRight(InternalImageRegistry.OVERLAY_Grey); + drawBottomRight(ImageConsts.IMAGE_GREY_OVR); } else if (fState == IPeerModelProperties.STATE_REACHABLE) { /* not connected, but reachable */ - drawBottomRight(InternalImageRegistry.OVERLAY_Gold); + drawBottomRight(ImageConsts.IMAGE_GOLD_OVR); } else if (fState == IPeerModelProperties.STATE_CONNECTED) { /* connected */ - drawBottomRight(InternalImageRegistry.OVERLAY_Green); + drawBottomRight(ImageConsts.IMAGE_GREEN_OVR); } else if (fState == IPeerModelProperties.STATE_NOT_REACHABLE) { /* not connected, not reachable */ - drawBottomRight(InternalImageRegistry.OVERLAY_Red); + drawBottomRight(ImageConsts.IMAGE_RED_OVR); } else if (fState == IPeerModelProperties.STATE_ERROR) { /* not connected, error */ - drawBottomRight(InternalImageRegistry.OVERLAY_RedX); + drawBottomRight(ImageConsts.IMAGE_RED_X_OVR); } } diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/registries/InternalImageRegistry.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/registries/InternalImageRegistry.java deleted file mode 100644 index c5bae59a2..000000000 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/registries/InternalImageRegistry.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. 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: - * Uwe Stieber (Wind River) - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.te.tcf.ui.internal.registries; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.tm.te.ui.images.AbstractImageRegistry; - - -/** - * Target Explorer: TCF UI plugin image registry. - */ -public class InternalImageRegistry extends AbstractImageRegistry { - private static List<Object[]> fStore = new ArrayList<Object[]>(); - - // declare all keys down here - public static final String OBJ_Target = declareLocalImage("obj16", "target.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - - // Overlays - public final static String OVERLAY_Gold = declareLocalImage("ovr16", "gold_ovr.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public final static String OVERLAY_Green = declareLocalImage("ovr16", "green_ovr.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public final static String OVERLAY_Grey = declareLocalImage("ovr16", "grey_ovr.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public final static String OVERLAY_Red = declareLocalImage("ovr16", "red_ovr.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public final static String OVERLAY_RedX = declareLocalImage("ovr16", "redX_ovr.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - - // external eclipse icons not reachable using ISharedImages - - /** - * Constructor. - * - * @param plugin The plugin descriptor the image registry is created for. - */ - public InternalImageRegistry(Plugin plugin) { - super(plugin); - } - - /** - * Initialize image registry with all keys known yet. - */ - public void initialize() { - for (Iterator<Object[]> iter = fStore.iterator(); iter.hasNext();) { - Object[] element = iter.next(); - if (element.length == 3) { - localImage((String)element[0], (String)element[1], (String)element[2]); - } - else if (element.length > 3){ - externalImage((String)element[0], (String)element[1], (String[])element[2], (String)element[3]); - } - } - } - - /** - * Declare a locally stored image to the image registry. - */ - static String declareLocalImage(String dir, String name) { - List<Object> registryObject = new ArrayList<Object>(); - registryObject.add(dir); - registryObject.add(name); - String key = name + "_" + registryObject.hashCode(); //$NON-NLS-1$ - registryObject.add(0, key); - fStore.add(registryObject.toArray()); - return key; - } - - /** - * Declare a externally stored image to the image registry. - */ - static String declareExternalImage(String plugin, String[] dirs, String name) { - List<Object> registryObject = new ArrayList<Object>(); - registryObject.add(plugin); - registryObject.add(dirs); - registryObject.add(name); - String key = name + "_" + registryObject.hashCode(); //$NON-NLS-1$ - registryObject.add(0, key); - fStore.add(registryObject.toArray()); - return key; - } -} diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/activator/UIPlugin.java index dd9063d2b..8412540e5 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/activator/UIPlugin.java @@ -3,7 +3,7 @@ * 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: * Uwe Stieber (Wind River) - initial API and implementation *******************************************************************************/ @@ -75,7 +75,7 @@ public class UIPlugin extends AbstractUIPlugin { */ @Override protected void initializeImageRegistry(ImageRegistry registry) { - URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_EDITOR + "prop_ps.gif"); //$NON-NLS-1$ + URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_EVIEW + "prop_ps.gif"); //$NON-NLS-1$ registry.put(ImageConsts.IMAGE_EDITOR, ImageDescriptor.createFromURL(url)); } diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageRegistry.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageRegistry.java deleted file mode 100644 index 9274e93a1..000000000 --- a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageRegistry.java +++ /dev/null @@ -1,218 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Wind River Systems, Inc. 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: - * Uwe Stieber (Wind River) - initial API and implementation - *******************************************************************************/ -package org.eclipse.tm.te.ui.images; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.SWTException; -import org.eclipse.swt.graphics.Image; -import org.eclipse.tm.te.ui.activator.UIPlugin; -import org.eclipse.tm.te.ui.nls.Messages; -import org.osgi.framework.Bundle; - - - -/** - * Target Explorer: Abstract image registry that allows for defining fallback paths for images. - */ -public abstract class AbstractImageRegistry extends ImageRegistry { - private List<ImageRegistry> fDelegates = new ArrayList<ImageRegistry>(); - private Map<String,String> fPlugins = new HashMap<String,String>(); - private Map<String,String[]> fLocations = new HashMap<String,String[]>(); - private URL fBaseUrl; - - protected AbstractImageRegistry(Plugin plugin) { - fBaseUrl = plugin.getBundle().getEntry("/"); //$NON-NLS-1$ - } - - /** - * Adds the given image registry as delegate. Delegates are queried if - * an image or image descriptor cannot be found locally. If the image - * registry delegate had been added before, the method will do nothing. - * - * @param registry The image registry. Must not be <code>null</code>. - */ - protected final void addImageRegistryDelegate(ImageRegistry registry) { - assert registry != null; - if (!fDelegates.contains(registry)) fDelegates.add(registry); - } - - /** - * Removes the given image registry from the list of delegates. - * - * @param registry The image registry. Must not be <code>null</code>. - */ - protected final void removeImageRegistryDelegate(ImageRegistry registry) { - assert registry != null; - fDelegates.remove(registry); - } - - /** - * Defines the key for a local image, that must be found below the icons directory - * in the plugin. - * @param key Key by which the image can be referred by. - * @param dir Directory relative to icons/ - * @param name The name of the file defining the icon. The name will be used as - * key. - */ - protected void localImage(String key, String dir, String name) { - if (dir== null || dir.equals(""))//$NON-NLS-1$ - fLocations.put(key, new String[] {"icons/" + name}); //$NON-NLS-1$ - else - fLocations.put(key, new String[] {"icons/" + dir + "/" + name}); //$NON-NLS-1$ //$NON-NLS-2$ - } - - /** - * Defines the key for a non-local image, that must be found below the icons directory - * of some plugin. - * @param key Key by which the image can be referred by. - * @param plugin The plugin id, where the icon is searched. - * @param dirs A couple of directories below icons/ in the plugin. If loading fails, - * the next dir will be taken as fallback. - * @param name The name of the file defining the icon. The name will be used as - * key. - */ - protected void externalImage(String key, String plugin, String[] dirs, String name) { - if (plugin != null) { - fPlugins.put(key, plugin); - } - String[] locations = new String[dirs.length]; - for (int i = 0; i < dirs.length; i++) { - String dir = dirs[i]; - if (dir== null || dir.equals(""))//$NON-NLS-1$ - locations[i] = "icons/" + name; //$NON-NLS-1$ - else - locations[i] = "icons/" + dir + "/" + name; //$NON-NLS-1$ //$NON-NLS-2$ - } - fLocations.put(key, locations); - } - - final private Image internalDoGet(String key) { - // First query the parent (local) image registry if - // an image for the given key is registered. - Image i = super.get(key); - if (i != null) return i; - - // If no image had been returned, try the delegates - for (ImageRegistry delegate : fDelegates) { - i = delegate.get(key); - if (i != null) break; - } - - return i; - } - - final private ImageDescriptor internalDoGetDescriptor(String key) { - // First query the parent (local) image registry if - // an image for the given key is registered. - ImageDescriptor d = super.getDescriptor(key); - if (d != null) return d; - - // If no image had been returned, try the delegates - for (ImageRegistry delegate : fDelegates) { - d = delegate.getDescriptor(key); - if (d != null) break; - } - - return d; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.resource.ImageRegistry#get(java.lang.String) - */ - @Override - final public Image get(String key) { - Image i = internalDoGet(key); - if (i != null) { - return i; - } - - ImageDescriptor d = createFileImageDescriptor(key); - if (d != null) { - put(key, d); - return internalDoGet(key); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.resource.ImageRegistry#getDescriptor(java.lang.String) - */ - @Override - final public ImageDescriptor getDescriptor(String key) { - ImageDescriptor d = internalDoGetDescriptor(key); - if (d != null) { - return d; - } - - d = createFileImageDescriptor(key); - if (d != null) { - put(key, d); - return d; - } - return null; - } - - private ImageDescriptor createFileImageDescriptor(String key) { - URL url = fBaseUrl; - String pluginId = fPlugins.get(key); - if (pluginId != null) { - Bundle bundle= Platform.getBundle(pluginId); - if (bundle != null) { - url = bundle.getEntry("/"); //$NON-NLS-1$ - } - } - String[] locations= fLocations.get(key); - if (locations != null) { - for (int i = 0; i < locations.length; i++) { - String loc = locations[i]; - URL full; - try { - full = new URL(url, loc); - ImageDescriptor candidate = ImageDescriptor.createFromURL(full); - if (candidate != null && candidate.getImageData() != null) { - return candidate; - } - } catch (MalformedURLException e) { - IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), - Messages.AbstractImageRegistry_error_malformedImage, e); - UIPlugin.getDefault().getLog().log(status); - } catch (SWTException e) { - // try the next one. - } - } - } - return null; - } - - /** - * Get a shared Image for a given descriptor - */ - public Image getSharedImage(AbstractImageDescriptor d) { - String key = d.getKey(); - Image shared = super.get(key); - if (shared != null) { - return shared; - } - put(key, d); - return super.get(key); - } -} |