mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-06 15:55:47 +02:00
Bug 368222 - Preferences page uses wrong icons
This commit is contained in:
parent
521f90af28
commit
352eae2865
3 changed files with 51 additions and 10 deletions
|
@ -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.
|
||||
|
|
|
@ -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$
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue