1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 411649: Use CDT SharedImagesFactory for images of cdt.make.ui plugin

This commit is contained in:
Andrew Gvozdev 2013-06-26 21:15:27 -04:00
parent ce7c36ae04
commit 5b7641063a
15 changed files with 187 additions and 284 deletions

View file

@ -15,6 +15,6 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ MakeUISharedImagesTest.class })
@SuiteClasses({ MakeUIImagesTest.class })
public class AllMakeUITests {
}

View file

@ -19,8 +19,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URL;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUISharedImages;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@ -29,11 +29,11 @@ import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.swt.graphics.Image;
import org.junit.Test;
public class MakeUISharedImagesTest {
public class MakeUIImagesTest {
private static final ImageDescriptor MISSING_IMAGE_DESCRIPTOR = ImageDescriptor.getMissingImageDescriptor();
// sample image (IMG_ETOOL_MAKEFILE) from MakeUIPlugin bundle
private static final String KEY_ETOOL_MAKEFILE = MakeUISharedImages.IMG_ETOOL_MAKEFILE;
private static final String KEY_ETOOL_MAKEFILE = MakeUIImages.IMG_ETOOL_MAKEFILE;
private static final IPath PATH_ETOOL_MAKEFILE = new Path("icons/etool16/makefile.gif");
private static final URL URL_ETOOL_MAKEFILE= FileLocator.find(MakeUIPlugin.getDefault().getBundle(), PATH_ETOOL_MAKEFILE, null);
@ -42,11 +42,11 @@ public class MakeUISharedImagesTest {
*/
@Test
public void testNoImage() throws Exception {
ImageDescriptor descriptor = MakeUISharedImages.getImageDescriptor("missing key 1");
ImageDescriptor descriptor = MakeUIImages.getImageDescriptor("missing key 1");
assertSame(MISSING_IMAGE_DESCRIPTOR, descriptor);
Image image1 = MakeUISharedImages.getImage("missing key 1");
Image image2 = MakeUISharedImages.getImage("missing key 2");
Image image1 = MakeUIImages.getImage("missing key 1");
Image image2 = MakeUIImages.getImage("missing key 2");
assertSame(image1, image2);
}
@ -55,23 +55,23 @@ public class MakeUISharedImagesTest {
*/
@Test
public void testImage() throws Exception {
// create descriptor from MakeUISharedImages key
ImageDescriptor descriptorFromKey = MakeUISharedImages.getImageDescriptor(KEY_ETOOL_MAKEFILE);
// create descriptor from MakeUIImages key
ImageDescriptor descriptorFromKey = MakeUIImages.getImageDescriptor(KEY_ETOOL_MAKEFILE);
assertNotSame(MISSING_IMAGE_DESCRIPTOR, descriptorFromKey);
// create descriptor from registered bundle URL as a key
MakeUISharedImages.register(URL_ETOOL_MAKEFILE);
ImageDescriptor descriptorFromUrl = MakeUISharedImages.getImageDescriptor(URL_ETOOL_MAKEFILE.toString());
MakeUIImages.register(URL_ETOOL_MAKEFILE);
ImageDescriptor descriptorFromUrl = MakeUIImages.getImageDescriptor(URL_ETOOL_MAKEFILE.toString());
assertNotSame(MISSING_IMAGE_DESCRIPTOR, descriptorFromUrl);
assertSame(descriptorFromKey, descriptorFromUrl);
// verify that it is the same image
Image imageFromKey = MakeUISharedImages.getImage(KEY_ETOOL_MAKEFILE);
Image imageFromUrl = MakeUISharedImages.getImage(URL_ETOOL_MAKEFILE.toString());
Image imageFromKey = MakeUIImages.getImage(KEY_ETOOL_MAKEFILE);
Image imageFromUrl = MakeUIImages.getImage(URL_ETOOL_MAKEFILE.toString());
assertSame(imageFromKey, imageFromUrl);
// verify that no leaks on second access
Image imageFromKey2 = MakeUISharedImages.getImage(KEY_ETOOL_MAKEFILE);
Image imageFromKey2 = MakeUIImages.getImage(KEY_ETOOL_MAKEFILE);
assertSame(imageFromKey, imageFromKey2);
}
@ -81,37 +81,37 @@ public class MakeUISharedImagesTest {
@Test
public void testOverlays() throws Exception {
{
Image image1 = MakeUISharedImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, new String[5]);
Image image2 = MakeUISharedImages.getImage(KEY_ETOOL_MAKEFILE);
Image image1 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, new String[5]);
Image image2 = MakeUIImages.getImage(KEY_ETOOL_MAKEFILE);
assertSame(image1, image2);
}
{
String[] overlayKeys = new String[5];
overlayKeys[IDecoration.BOTTOM_LEFT] = MakeUISharedImages.IMG_OVR_AUTOMATIC;
Image imageOver1 = MakeUISharedImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, overlayKeys);
Image imageOver2 = MakeUISharedImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, MakeUISharedImages.IMG_OVR_AUTOMATIC, IDecoration.BOTTOM_LEFT);
overlayKeys[IDecoration.BOTTOM_LEFT] = MakeUIImages.IMG_OVR_AUTOMATIC;
Image imageOver1 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, overlayKeys);
Image imageOver2 = MakeUIImages.getImageOverlaid(KEY_ETOOL_MAKEFILE, MakeUIImages.IMG_OVR_AUTOMATIC, IDecoration.BOTTOM_LEFT);
assertSame(imageOver1, imageOver2);
}
}
/**
* Verify that MakeUISharedImages constants define existing images.
* Verify that MakeUIImages constants define existing images.
*/
@Test
public void testVerifyFields() throws Exception {
Class<MakeUISharedImages> clazz = MakeUISharedImages.class;
Class<MakeUIImages> clazz = MakeUIImages.class;
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
String name = field.getName();
if (name.startsWith("IMG_")) {
assertEquals("MakeUISharedImages."+name+" is not a String", String.class, field.getType());
assertTrue("MakeUISharedImages."+name+" is not a static field", (field.getModifiers() & Modifier.STATIC) != 0);
assertTrue("MakeUISharedImages."+name+" is not a public field", (field.getModifiers() & Modifier.PUBLIC) != 0);
assertEquals("MakeUIImages."+name+" is not a String", String.class, field.getType());
assertTrue("MakeUIImages."+name+" is not a static field", (field.getModifiers() & Modifier.STATIC) != 0);
assertTrue("MakeUIImages."+name+" is not a public field", (field.getModifiers() & Modifier.PUBLIC) != 0);
String imageKey = (String) field.get(null);
ImageDescriptor descriptor = MakeUISharedImages.getImageDescriptor(imageKey);
assertTrue("Missing image MakeUISharedImages."+name+"=\""+imageKey+"\"", descriptor!=MISSING_IMAGE_DESCRIPTOR);
ImageDescriptor descriptor = MakeUIImages.getImageDescriptor(imageKey);
assertTrue("Missing image MakeUIImages."+name+"=\""+imageKey+"\"", descriptor!=MISSING_IMAGE_DESCRIPTOR);
}
}
}

View file

@ -643,7 +643,7 @@ public class MakeEnvironmentBlock extends AbstractCOptionPage {
@Override
public Image getImage(Object element) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENVIRONMNET);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENVIRONMENT);
}
@Override
public String getText(Object element) {

View file

@ -1,129 +1,157 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2013, 2013 Andrew Gvozdev 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:
* QNX Software Systems - Initial API and implementation
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.jface.action.IAction;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.SharedImagesFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.swt.graphics.Image;
/**
* A repository for common images used by org.eclipse.cdt.make.ui plugin.
* <p>
* This class provides {@link Image} and {@link ImageDescriptor}
* for each named image in the interface. All {@code Image} objects provided
* by this class are managed by this class and must never be disposed
* by other clients.
* </p>
* <p>
* For common CDT images see {@link CDTSharedImages}.
* <p>
* For common platform images see {@link org.eclipse.ui.ISharedImages}
* ({@code org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages()})
* <br>
* and {@link org.eclipse.ui.ide.IDE.SharedImages}.
* </p>
* <p>
* Note that org.eclipse.cdt.ui.tests.misc.MakeUISharedImagesTest will verify
* existence of the images defined here.
* </p>
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class MakeUIImages {
// images
public static final String IMG_OBJS_TARGET = "icons/obj16/target_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_TARGET_RULE = "icons/obj16/trule_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_MACRO = "icons/obj16/macro_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INFERENCE_RULE = "icons/obj16/irule_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_RELATION = "icons/obj16/relation_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_COMMAND = "icons/obj16/command_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INCLUDE = "icons/obj16/include_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ENVIRONMENT = "icons/obj16/environment_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ENV_VAR = "icons/obj16/envvar_obj.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_MAKEFILE = "icons/etool16/makefile.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_TARGET_BUILD = "icons/etool16/target_build.png"; //$NON-NLS-1$
public static final String IMG_DTOOL_TARGET_BUILD = "icons/dtool16/target_build.png"; //$NON-NLS-1$
public static final String IMG_ETOOL_TARGET_ADD = "icons/etool16/target_add.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_TARGET_ADD = "icons/dtool16/target_add.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_TARGET_EDIT = "icons/etool16/target_edit.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_TARGET_EDIT = "icons/dtool16/target_edit.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_TARGET_DELETE = "icons/etool16/target_delete.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_TARGET_DELETE = "icons/dtool16/target_delete.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_TARGET_FILTER = "icons/etool16/target_filter.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_TARGET_FILTER = "icons/dtool16/target_filter.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_ALPHA_SORTING = "icons/etool16/alphab_sort_co.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_ALPHA_SORTING = "icons/dtool16/alphab_sort_co.gif"; //$NON-NLS-1$
public static final String IMG_ETOOL_SEGMENT_EDIT = "icons/etool16/segment_edit.gif"; //$NON-NLS-1$
public static final String IMG_DTOOL_SEGMENT_EDIT = "icons/dtool16/segment_edit.gif"; //$NON-NLS-1$
// overlays
public static final String IMG_OVR_AUTOMATIC = "icons/ovr16/auto_co.gif"; //$NON-NLS-1$
public static final String IMG_OVR_SPECIAL = "icons/ovr16/special_co.gif"; //$NON-NLS-1$
private static SharedImagesFactory imagesFactory = new SharedImagesFactory(MakeUIPlugin.getDefault());
/**
* Bundle of all images used by the Make plugin.
* Internal method. It lets register image URL from a bundle directly to the map.
* It is user responsibility to ensure that a valid URL is passed.
*
* @param url - URL of the image pointing to its location in a bundle (bundle entry).
*
* @noreference This is internal method which is not intended to be referenced by clients.
*/
// The plugin registry
private static ImageRegistry imageRegistry = new ImageRegistry();
// Subdirectory (under the package containing this class) where 16 color images are
private static URL fgIconBaseURL;
static {
try {
fgIconBaseURL = new URL(MakeUIPlugin.getDefault().getBundle().getEntry("/"), "icons/"); //$NON-NLS-1$ //$NON-NLS-2$
} catch (MalformedURLException e) {
MakeUIPlugin.log(e);
}
}
private static final String NAME_PREFIX = MakeUIPlugin.getUniqueIdentifier() + '.';
private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
public static final String OBJ = "obj16/"; //$NON-NLS-1$
public static final String T_TOOL= "tool16/"; //$NON-NLS-1$
// For the build image
public static final String IMG_OBJS_BUILD_TARGET = NAME_PREFIX + "target_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_BUILD_TARGET = createManaged(OBJ, IMG_OBJS_BUILD_TARGET);
public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJ_ERROR = createManaged(OBJ, IMG_OBJS_ERROR);
public static final String IMG_TOOLS_MAKE_TARGET_BUILD = NAME_PREFIX + "target_build.png"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKE_TARGET_ADD = NAME_PREFIX + "target_add.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKE_TARGET_DELETE = NAME_PREFIX + "target_delete.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKE_TARGET_EDIT = NAME_PREFIX + "target_edit.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKE_TARGET_FILTER = NAME_PREFIX + "target_filter.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_MAKEFILE_MACRO = NAME_PREFIX + "macro_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_MACRO = createManaged(OBJ, IMG_OBJS_MAKEFILE_MACRO);
public static final String IMG_OBJS_MAKEFILE_TARGET_RULE = NAME_PREFIX + "trule_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_TARGET_RULE = createManaged(OBJ, IMG_OBJS_MAKEFILE_TARGET_RULE);
public static final String IMG_OBJS_MAKEFILE_INFERENCE_RULE = NAME_PREFIX + "irule_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_INFERENCE_RULE = createManaged(OBJ, IMG_OBJS_MAKEFILE_INFERENCE_RULE);
public static final String IMG_OBJS_MAKEFILE_RELATION = NAME_PREFIX + "relation_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_RELATION = createManaged(OBJ, IMG_OBJS_MAKEFILE_RELATION);
public static final String IMG_OBJS_MAKEFILE_COMMAND = NAME_PREFIX + "command_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_COMMAND = createManaged(OBJ, IMG_OBJS_MAKEFILE_COMMAND);
public static final String IMG_OBJS_MAKEFILE_INCLUDE = NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_MAKEFILE_INCLUDE = createManaged(OBJ, IMG_OBJS_MAKEFILE_INCLUDE);
public static final String IMG_OBJS_ENVIRONMNET = NAME_PREFIX + "environment_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_ENVIRONMENT = createManaged(OBJ, IMG_OBJS_ENVIRONMNET);
public static final String IMG_OBJS_ENV_VAR = NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_ENV_VAR = createManaged(OBJ, IMG_OBJS_ENV_VAR);
public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
private static ImageDescriptor createManaged(String prefix, String name) {
return createManaged(imageRegistry, prefix, name);
}
private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
registry.put(name, result);
return result;
public static void register(URL url) {
imagesFactory.register(url);
}
/**
* The method retrieves an image from the internal repository according to the given key.
* The image is managed by image registry and the caller must not dispose it.
*
* @param key - one of {@code MakeUISharedImages.IMG_} constants.
* <p>
* Reserved for internal usage: the key could be a string representation of URL pointing to location
* of the image in the bundle. Such URL key must be registered first with {@code register(URL url)}.
* </p>
* @return the image from the repository or the default image for missing image descriptor.
*/
public static Image getImage(String key) {
return imageRegistry.get(key);
}
private static ImageDescriptor create(String prefix, String name) {
return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
}
private static URL makeIconFileURL(String prefix, String name) {
StringBuffer buffer = new StringBuffer(prefix);
buffer.append(name);
try {
return new URL(fgIconBaseURL, buffer.toString());
} catch (MalformedURLException e) {
MakeUIPlugin.log(e);
return null;
}
return imagesFactory.getImage(key);
}
/**
* Sets all available image descriptors for the given action.
* The method retrieves an image descriptor from the internal repository according to the given key.
* See also {@link #getImage(String)}.
*
* @param key - one of {@code MakeUISharedImages.IMG_} constants.
* @return the image from the repository or {@link ImageDescriptor#getMissingImageDescriptor()}.
*/
public static void setImageDescriptors(IAction action, String type, String relPath) {
relPath = relPath.substring(NAME_PREFIX_LENGTH);
action.setDisabledImageDescriptor(create("d" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
// action.setHoverImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
action.setImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$
public static ImageDescriptor getImageDescriptor(String key) {
return imagesFactory.getImageDescriptor(key);
}
/**
* Helper method to access the image registry from the JavaPlugin class.
* Retrieves an overlaid image from the internal repository of images.
* If there is no image one will be created.
*
* The decoration overlay for the base image will use the array of
* provided overlays. The indices of the array correspond to the values
* of the 5 overlay constants defined on {@link IDecoration}, i.e.
* {@link IDecoration#TOP_LEFT},
* {@link IDecoration#TOP_RIGHT},
* {@link IDecoration#BOTTOM_LEFT},
* {@link IDecoration#BOTTOM_RIGHT} or
* {@link IDecoration#UNDERLAY}.
*
* @param baseKey the base image key.
* @param overlayKeys the keys for the overlay images. Must be
* String[5], i.e. string array of 5 elements. Put {@code null} as
* an element to the array if no overlay should be added in given quadrant.
*/
static ImageRegistry getImageRegistry() {
return imageRegistry;
public static Image getImageOverlaid(String baseKey, String[] overlayKeys) {
return imagesFactory.getImageOverlaid(baseKey, overlayKeys);
}
/**
* Retrieves an overlaid image descriptor from the repository of images.
* If there is no image one will be created.
*
* @param baseKey - key of the base image. Expected to be in repository.
* @param overlayKey - key of overlay image. Expected to be in repository as well.
* @param quadrant - location of overlay, one of those:
* {@link IDecoration#TOP_LEFT},
* {@link IDecoration#TOP_RIGHT},
* {@link IDecoration#BOTTOM_LEFT},
* {@link IDecoration#BOTTOM_RIGHT}
*
* @return image overlaid with smaller image in the specified quadrant.
*/
public static Image getImageOverlaid(String baseKey, String overlayKey, int quadrant) {
return imagesFactory.getImageOverlaid(baseKey, overlayKey, quadrant);
}
}

View file

@ -1,135 +0,0 @@
/*******************************************************************************
* Copyright (c) 2013, 2013 Andrew Gvozdev 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:
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui;
import java.net.URL;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.SharedImagesFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.swt.graphics.Image;
/**
* A repository for common images used by org.eclipse.cdt.make.ui plugin.
* <p>
* This class provides {@link Image} and {@link ImageDescriptor}
* for each named image in the interface. All {@code Image} objects provided
* by this class are managed by this class and must never be disposed
* by other clients.
* </p>
* <p>
* For common CDT images see {@link CDTSharedImages}.
* <p>
* For common platform images see {@link org.eclipse.ui.ISharedImages}
* ({@code org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages()})
* <br>
* and {@link org.eclipse.ui.ide.IDE.SharedImages}.
* </p>
* <p>
* Note that org.eclipse.cdt.ui.tests.misc.MakeUISharedImagesTest will verify
* existence of the images defined here.
* </p>
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
* @since 5.3
*/
public class MakeUISharedImages {
public static final String IMG_ETOOL_MAKEFILE = "icons/etool16/makefile.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_TARGET = "icons/obj16/target_obj.gif"; //$NON-NLS-1$
// overlays
public static final String IMG_OVR_AUTOMATIC = "icons/ovr16/auto_co.gif"; //$NON-NLS-1$
public static final String IMG_OVR_SPECIAL = "icons/ovr16/special_co.gif"; //$NON-NLS-1$
private static SharedImagesFactory imagesFactory = new SharedImagesFactory(MakeUIPlugin.getDefault());
/**
* Internal method. It lets register image URL from a bundle directly to the map.
* It is user responsibility to ensure that a valid URL is passed.
*
* @param url - URL of the image pointing to its location in a bundle (bundle entry).
*
* @noreference This is internal method which is not intended to be referenced by clients.
*/
public static void register(URL url) {
imagesFactory.register(url);
}
/**
* The method retrieves an image from the internal repository according to the given key.
* The image is managed by image registry and the caller must not dispose it.
*
* @param key - one of {@code MakeUISharedImages.IMG_} constants.
* <p>
* Reserved for internal usage: the key could be a string representation of URL pointing to location
* of the image in the bundle. Such URL key must be registered first with {@code register(URL url)}.
* </p>
* @return the image from the repository or the default image for missing image descriptor.
*/
public static Image getImage(String key) {
return imagesFactory.getImage(key);
}
/**
* The method retrieves an image descriptor from the internal repository according to the given key.
* See also {@link #getImage(String)}.
*
* @param key - one of {@code MakeUISharedImages.IMG_} constants.
* @return the image from the repository or {@link ImageDescriptor#getMissingImageDescriptor()}.
*/
public static ImageDescriptor getImageDescriptor(String key) {
return imagesFactory.getImageDescriptor(key);
}
/**
* Retrieves an overlaid image from the internal repository of images.
* If there is no image one will be created.
*
* The decoration overlay for the base image will use the array of
* provided overlays. The indices of the array correspond to the values
* of the 5 overlay constants defined on {@link IDecoration}, i.e.
* {@link IDecoration#TOP_LEFT},
* {@link IDecoration#TOP_RIGHT},
* {@link IDecoration#BOTTOM_LEFT},
* {@link IDecoration#BOTTOM_RIGHT} or
* {@link IDecoration#UNDERLAY}.
*
* @param baseKey the base image key.
* @param overlayKeys the keys for the overlay images. Must be
* String[5], i.e. string array of 5 elements. Put {@code null} as
* an element to the array if no overlay should be added in given quadrant.
*/
public static Image getImageOverlaid(String baseKey, String[] overlayKeys) {
return imagesFactory.getImageOverlaid(baseKey, overlayKeys);
}
/**
* Retrieves an overlaid image descriptor from the repository of images.
* If there is no image one will be created.
*
* @param baseKey - key of the base image. Expected to be in repository.
* @param overlayKey - key of overlay image. Expected to be in repository as well.
* @param quadrant - location of overlay, one of those:
* {@link IDecoration#TOP_LEFT},
* {@link IDecoration#TOP_RIGHT},
* {@link IDecoration#BOTTOM_LEFT},
* {@link IDecoration#BOTTOM_RIGHT}
*
* @return image overlaid with smaller image in the specified quadrant.
*/
public static Image getImageOverlaid(String baseKey, String overlayKey, int quadrant) {
return imagesFactory.getImageOverlaid(baseKey, overlayKey, quadrant);
}
}

View file

@ -16,6 +16,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
/**
* A message line. It distinguishs between "normal" messages and errors.
@ -54,7 +56,7 @@ public class MessageLine extends CLabel {
if (message != null && message.length() > 0) {
hasErrorMessage = true;
setText(message);
setImage(MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR));
setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK));
setBackground(JFaceColors.getErrorBackground(getDisplay()));
return;
}

View file

@ -15,8 +15,8 @@ import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.IInferenceRule;
import org.eclipse.cdt.make.core.makefile.IMacroDefinition;
import org.eclipse.cdt.make.core.makefile.ISpecialRule;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerSorter;
@ -34,7 +34,8 @@ public class LexicalSortingAction extends Action {
setDescription(MakeUIPlugin.getResourceString(ACTION_NAME + ".description")); //$NON-NLS-1$
setToolTipText(MakeUIPlugin.getResourceString(ACTION_NAME + ".tooltip")); //$NON-NLS-1$
MakeUIImages.setImageDescriptors(this, MakeUIImages.T_TOOL, MakeUIImages.IMG_TOOLS_ALPHA_SORTING);
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_ALPHA_SORTING));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_ALPHA_SORTING));
fTreeViewer = treeViewer;
fSorter = new LexicalMakefileSorter();

View file

@ -27,8 +27,8 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule;
import org.eclipse.cdt.make.core.makefile.gnu.IInclude;
import org.eclipse.cdt.make.core.makefile.gnu.ITerminal;
import org.eclipse.cdt.make.internal.core.makefile.NullMakefile;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@ -47,7 +47,9 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
@ -183,19 +185,19 @@ public class MakefileContentOutlinePage extends ContentOutlinePage {
@Override
public Image getImage(Object element) {
if (element instanceof ITargetRule) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_TARGET_RULE);
} else if (element instanceof IInferenceRule) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_INFERENCE_RULE);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_INFERENCE_RULE);
} else if (element instanceof IMacroDefinition) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MACRO);
} else if (element instanceof ICommand) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_COMMAND);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_COMMAND);
} else if (element instanceof IInclude) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_INCLUDE);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_INCLUDE);
} else if (element instanceof IBadDirective) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR);
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
} else if (element instanceof IParent) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_RELATION);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_RELATION);
}
return super.getImage(element);
}

View file

@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
@ -24,7 +24,8 @@ public class MakefileEditorTogglePresentationAction extends TextEditorAction {
*/
public MakefileEditorTogglePresentationAction() {
super(MakeUIPlugin.getDefault().getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
MakeUIImages.setImageDescriptors(this, MakeUIImages.T_TOOL, MakeUIImages.IMG_TOOLS_MAKEFILE_SEGMENT_EDIT);
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_SEGMENT_EDIT));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_SEGMENT_EDIT));
update();
}

View file

@ -18,8 +18,8 @@ import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.IMacroDefinition;
import org.eclipse.cdt.make.core.makefile.IMakefile;
import org.eclipse.cdt.make.core.makefile.IRule;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.text.CompletionProposalComparator;
import org.eclipse.cdt.make.internal.ui.text.WordPartDetector;
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
@ -87,8 +87,8 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
}
protected IContextInformationValidator fValidator = new Validator();
protected Image imageMacro = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO);
protected Image imageTarget = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE);
protected Image imageMacro = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MACRO);
protected Image imageTarget = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_TARGET_RULE);
protected CompletionProposalComparator comparator = new CompletionProposalComparator();
protected IEditorPart fEditor;

View file

@ -55,7 +55,7 @@ public class MakeLabelProvider extends LabelProvider implements ITableLabelProvi
return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
return fLableProvider.getImage(obj);
} else if (obj instanceof IMakeTarget) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_BUILD_TARGET);
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_TARGET);
}
return image;
}

View file

@ -12,8 +12,8 @@ package org.eclipse.cdt.make.ui.views;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil;
import org.eclipse.cdt.make.ui.TargetSourceContainer;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
@ -36,7 +36,8 @@ public class AddTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText(MakeUIPlugin.getResourceString("AddTargetAction.tooltip")); //$NON-NLS-1$
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_ADD); //$NON-NLS-1$
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_TARGET_ADD));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_TARGET_ADD));
setEnabled(false);
}

View file

@ -14,8 +14,8 @@ package org.eclipse.cdt.make.ui.views;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.ui.TargetBuild;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
@ -37,7 +37,8 @@ public class BuildTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText(MakeUIPlugin.getResourceString("BuildTargetAction.tooltip")); //$NON-NLS-1$
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_TARGET_BUILD));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_TARGET_BUILD));
setEnabled(false);
}

View file

@ -14,8 +14,8 @@ package org.eclipse.cdt.make.ui.views;
import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
@ -34,7 +34,8 @@ public class EditTargetAction extends SelectionListenerAction {
this.shell = shell;
setToolTipText(MakeUIPlugin.getResourceString("EditTargetAction.tooltip")); //$NON-NLS-1$
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_EDIT); //$NON-NLS-1$
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_TARGET_EDIT));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_TARGET_EDIT));
}
@Override

View file

@ -14,8 +14,8 @@ package org.eclipse.cdt.make.ui.views;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.ui.MakeContentProvider;
import org.eclipse.cdt.make.ui.TargetSourceContainer;
import org.eclipse.core.resources.IContainer;
@ -55,7 +55,8 @@ public class FilterEmtpyFoldersAction extends Action {
setToolTipText(MakeUIPlugin.getResourceString("FilterEmptyFolderAction.tooltip")); //$NON-NLS-1$
setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS));
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$
setDisabledImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_DTOOL_TARGET_FILTER));
setImageDescriptor(MakeUIImages.getImageDescriptor(MakeUIImages.IMG_ETOOL_TARGET_FILTER));
fViewer.addFilter(new ViewerFilter() {
/**