aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2013-11-02 11:39:28 (EDT)
committerGerrit Code Review @ Eclipse.org2014-01-07 08:10:38 (EST)
commit39b4efc9f8668a284151ed2fc4b08987b743f73c (patch)
tree728f8c6d944495ad0afb95cd5d29ec93f2a5a897
parent1ce692a636680a912eb9ca10b980dddd4f7e5595 (diff)
downloadeclipse.platform.ui-39b4efc9f8668a284151ed2fc4b08987b743f73c.zip
eclipse.platform.ui-39b4efc9f8668a284151ed2fc4b08987b743f73c.tar.gz
eclipse.platform.ui-39b4efc9f8668a284151ed2fc4b08987b743f73c.tar.bz2
Bug 236006 - [Viewers] Add tooltip support for DelegatingStyledCellLabelProviderrefs/changes/04/18004/6
Delegate to the styled label provider in case it implements the new interface IToolTipProvider (which was extracted from CellLabelProvider). If it does not implement IToolTipProvider, the super implementation is used as before. Change-Id: Ibe8e965959c92414fcd4d2c7c7eee87facf3bc18 Signed-off-by: Robin Stocker <robin@nibor.org>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java4
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java15
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IToolTipProvider.java32
3 files changed, 49 insertions, 2 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
index 1333f95..7bb7090 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2013 IBM Corporation 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
@@ -29,7 +29,7 @@ import org.eclipse.swt.graphics.Point;
* @since 3.3
* @see ColumnLabelProvider as a concrete implementation
*/
-public abstract class CellLabelProvider extends BaseLabelProvider {
+public abstract class CellLabelProvider extends BaseLabelProvider implements IToolTipProvider {
/**
* Create a new instance of the receiver.
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
index 1ce122b..c667a90 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Robin Stocker - Bug 236006 - [Viewers] Add tooltip support for DelegatingStyledCellLabelProvider
*******************************************************************************/
package org.eclipse.jface.viewers;
@@ -34,6 +35,12 @@ import org.eclipse.swt.graphics.Image;
* optionally implement {@link IColorProvider} and {@link IFontProvider} to
* provide foreground and background color and a default font.
* </p>
+ *
+ * <p>
+ * Since 3.10, {@link DelegatingStyledCellLabelProvider.IStyledLabelProvider}
+ * can optionally implement {@link IToolTipProvider} to provide tooltip
+ * support.
+ * </p>
*
* @since 3.4
*/
@@ -171,6 +178,14 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
return null;
}
+ @Override
+ public String getToolTipText(Object element) {
+ if (styledLabelProvider instanceof IToolTipProvider) {
+ return ((IToolTipProvider) this.styledLabelProvider).getToolTipText(element);
+ }
+ return super.getToolTipText(element);
+ }
+
/**
* Returns the image for the label of the given element. The image is owned
* by the label provider and must not be disposed directly. Instead, dispose
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IToolTipProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IToolTipProvider.java
new file mode 100644
index 0000000..ac243ec
--- /dev/null
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IToolTipProvider.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Robin Stocker 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:
+ * Robin Stocker - extracted API out of CellLabelProvider
+ *******************************************************************************/
+package org.eclipse.jface.viewers;
+
+/**
+ * Interface to provide tool tip information for a given element.
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider
+ *
+ * @since 3.10
+ */
+public interface IToolTipProvider {
+
+ /**
+ * Get the text displayed in the tool tip for object.
+ *
+ * @param element
+ * the element for which the tool tip is shown
+ * @return the {@link String} or <code>null</code> if there is not text to
+ * display
+ */
+ public String getToolTipText(Object element);
+
+}