diff options
author | Marc-Andre Laperle | 2012-11-09 04:43:21 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2012-11-09 04:43:21 +0000 |
commit | 352eae2865c54199e49db6ffecae589c41613569 (patch) | |
tree | 64db46368d2543c07403c764075478facdd1f458 /codan | |
parent | 521f90af28071f85fa4680465a583e8d78f5f0d2 (diff) | |
download | org.eclipse.cdt-352eae2865c54199e49db6ffecae589c41613569.tar.gz org.eclipse.cdt-352eae2865c54199e49db6ffecae589c41613569.tar.xz org.eclipse.cdt-352eae2865c54199e49db6ffecae589c41613569.zip |
Bug 368222 - Preferences page uses wrong icons
Diffstat (limited to 'codan')
3 files changed, 51 insertions, 10 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java index 20800ee4011..e0ae2add77f 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Alena Laskavaia + * Copyright (c) 2010, 2012 Alena Laskavaia 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 @@ -19,6 +19,10 @@ import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.osgi.framework.BundleContext; @@ -71,6 +75,26 @@ public class CodanUIActivator extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String path) { return imageDescriptorFromPlugin(PLUGIN_ID, path); } + + /** + * + * @param key - key is usually plug-in relative path to image like icons/xxx.gif + * @return Image loaded from key location or from registry cache, it will be stored in plug-in registry and disposed when plug-in unloads + */ + public Image getImage(String key) { + ImageRegistry registry = getImageRegistry(); + Image image = registry.get(key); + if (image == null) { + ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, key); + if (descriptor==null) { + ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); + return sharedImages.getImage(key); + } + registry.put(key, descriptor); + image = registry.get(key); + } + return image; + } /** * Logs the specified status with this plug-in's log. diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/ImageConstants.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/ImageConstants.java new file mode 100644 index 00000000000..f65ad853333 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/ImageConstants.java @@ -0,0 +1,17 @@ +/*******************************************************************************
+ * Copyright (c) 2012 Marc-Andre Laperle
+ * 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:
+ * Marc-Andre Laperle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui;
+
+public interface ImageConstants {
+ String ICON_WARNING = "icons/yellow_bug.gif"; //$NON-NLS-1$
+ String ICON_ERROR = "icons/red_bug.gif"; //$NON-NLS-1$
+ String ICON_INFO = "icons/blue_bug.gif"; //$NON-NLS-1$
+}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java index 664d2b3d750..58749efb69e 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Alena Laskavaia and others. + * Copyright (c) 2009, 2012 Alena Laskavaia 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 @@ -8,9 +8,12 @@ * Contributors: * Alena Laskavaia - initial API and implementation * IBM Corporation + * Marc-Andre Laperle *******************************************************************************/ package org.eclipse.cdt.codan.internal.ui.preferences; +import java.text.MessageFormat; + import org.eclipse.cdt.codan.core.CodanRuntime; import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.core.model.CodanSeverity; @@ -23,7 +26,9 @@ import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference; import org.eclipse.cdt.codan.core.param.RootProblemPreference; import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader; +import org.eclipse.cdt.codan.internal.ui.CodanUIActivator; import org.eclipse.cdt.codan.internal.ui.CodanUIMessages; +import org.eclipse.cdt.codan.internal.ui.ImageConstants; import org.eclipse.core.resources.IMarker; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CheckStateChangedEvent; @@ -40,10 +45,6 @@ import org.eclipse.jface.window.ToolTip; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -import java.text.MessageFormat; public class ProblemsTreeEditor extends CheckedTreeEditor { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ @@ -261,16 +262,15 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { column2.setLabelProvider(new ColumnLabelProvider() { @Override public Image getImage(Object element) { - final ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); if (element instanceof IProblem) { IProblem p = (IProblem) element; switch (p.getSeverity().intValue()) { case IMarker.SEVERITY_INFO: - return images.getImage(ISharedImages.IMG_OBJS_INFO_TSK); + return CodanUIActivator.getDefault().getImage(ImageConstants.ICON_INFO); case IMarker.SEVERITY_WARNING: - return images.getImage(ISharedImages.IMG_OBJS_WARN_TSK); + return CodanUIActivator.getDefault().getImage(ImageConstants.ICON_WARNING); case IMarker.SEVERITY_ERROR: - return images.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); + return CodanUIActivator.getDefault().getImage(ImageConstants.ICON_ERROR); } } return null; |