diff options
author | Darin Wright | 2010-05-10 19:21:18 +0000 |
---|---|---|
committer | Darin Wright | 2010-05-10 19:21:18 +0000 |
commit | 6281ae8cce16a322e6e640cf8e28068a99989491 (patch) | |
tree | 8449ada4c321a222b5daed6819a14fd9dc2dca43 | |
parent | 0b0ecb059cd2cb0037468125fd5973f06a4a1e84 (diff) | |
download | eclipse.platform.debug-6281ae8cce16a322e6e640cf8e28068a99989491.tar.gz eclipse.platform.debug-6281ae8cce16a322e6e640cf8e28068a99989491.tar.xz eclipse.platform.debug-6281ae8cce16a322e6e640cf8e28068a99989491.zip |
Bug 306768 - ElementLabelProvider doesn't handle mixed label provider properly
2 files changed, 92 insertions, 39 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointLabelProvider.java index 6659e00c7..5e21aada1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointLabelProvider.java @@ -1,37 +1,60 @@ -/*****************************************************************
- * Copyright (c) 2009 Texas Instruments 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:
- * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
- *****************************************************************/
-package org.eclipse.debug.internal.ui.model.elements;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.jface.viewers.TreePath;
-
-/**
- * Breakpoint label provider.
- *
- * @since 3.6
- */
-public class BreakpointLabelProvider extends DebugElementLabelProvider {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getChecked(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
- */
- public boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException {
- Object lastSegment = path.getLastSegment();
- if (lastSegment instanceof IBreakpoint) {
- return ((IBreakpoint) lastSegment).isEnabled();
- }
-
- return false;
- }
-}
+/***************************************************************** + * Copyright (c) 2009, 2010 Texas Instruments 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: + * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956) + * Patrick Chuong (Texas Instruments) - bug fix 306768 + *****************************************************************/ +package org.eclipse.debug.internal.ui.model.elements; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.TreePath; + +/** + * Breakpoint label provider. + * + * @since 3.6 + */ +public class BreakpointLabelProvider extends DebugElementLabelProvider { + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, int) + */ + protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId, int columnIndex) throws CoreException { + if (columnIndex == 0) + return super.getLabel(elementPath, presentationContext, columnId, columnIndex); + else + return IInternalDebugCoreConstants.EMPTY_STRING; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getImageDescriptor(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, int) + */ + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId, int columnIndex) throws CoreException { + if (columnIndex == 0) + return super.getImageDescriptor(elementPath, presentationContext, columnId, columnIndex); + else + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider#getChecked(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext) + */ + public boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException { + Object lastSegment = path.getLastSegment(); + if (lastSegment instanceof IBreakpoint) { + return ((IBreakpoint) lastSegment).isEnabled(); + } + + return false; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java index 1a0d5e68e..d35e9219b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310) + * Patrick Chuong (Texas Instruments) - bug fix 306768 *******************************************************************************/ package org.eclipse.debug.internal.ui.model.elements; @@ -211,8 +212,8 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { if (columnIds != null) { columnId = columnIds[i]; } - update.setLabel(getLabel(elementPath, presentationContext, columnId), i); - update.setImageDescriptor(getImageDescriptor(elementPath, presentationContext, columnId), i); + update.setLabel(getLabel(elementPath, presentationContext, columnId, i), i); + update.setImageDescriptor(getImageDescriptor(elementPath, presentationContext, columnId, i), i); update.setBackground(getBackground(elementPath, presentationContext, columnId), i); update.setForeground(getForeground(elementPath, presentationContext, columnId), i); update.setFontData(getFontData(elementPath, presentationContext, columnId), i); @@ -272,6 +273,21 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { return null; } + + /** + * Returns the <code>ImageDescriptor</code> for the path in the given column with the current presentation + * @param elementPath + * @param presentationContext + * @param columnId + * @param columnIndex + * @return image descriptor or <code>null</code> + * @throws CoreException + * + * @since 3.6 + */ + protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId, int columnIndex) throws CoreException { + return getImageDescriptor(elementPath, presentationContext, columnId); + } /** * Returns the label for the path in the given column with the current presentation @@ -283,6 +299,20 @@ public abstract class ElementLabelProvider implements IElementLabelProvider { protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException; /** + * Returns the label for the path in the given column with the current presentation. + * @param elementPath + * @param presentationContext + * @param columnId + * @param columnIndex + * @return label + * + * @since 3.6 + */ + protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId, int columnIndex) throws CoreException { + return getLabel(elementPath, presentationContext, columnId); + } + + /** * Returns the checked state for the given path. * * @param path Path of the element to retrieve the grayed state for. |