Merge "Use styled text in tooltips"
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/.api_filters b/examples/org.eclipse.graphiti.examples.tutorial/.api_filters
new file mode 100644
index 0000000..589cef8
--- /dev/null
+++ b/examples/org.eclipse.graphiti.examples.tutorial/.api_filters
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

+<component id="org.eclipse.graphiti.examples.tutorial" version="2">

+    <resource path="src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java" type="org.eclipse.graphiti.examples.tutorial.diagram.TutorialToolBehaviorProvider">

+        <filter comment="Tutorial is not API" id="338792546">

+            <message_arguments>

+                <message_argument value="org.eclipse.graphiti.examples.tutorial.diagram.TutorialToolBehaviorProvider"/>

+                <message_argument value="getToolTip(GraphicsAlgorithm)"/>

+            </message_arguments>

+        </filter>

+    </resource>

+</component>

diff --git a/examples/org.eclipse.graphiti.examples.tutorial/.settings/.api_filters b/examples/org.eclipse.graphiti.examples.tutorial/.settings/.api_filters
new file mode 100644
index 0000000..4740a0e
--- /dev/null
+++ b/examples/org.eclipse.graphiti.examples.tutorial/.settings/.api_filters
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

+<component id="org.eclipse.graphiti.examples.tutorial" version="2">

+    <resource path="src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java" type="org.eclipse.graphiti.examples.tutorial.diagram.TutorialToolBehaviorProvider">

+        <filter comment="Tutorial is not api" id="338792546">

+            <message_arguments>

+                <message_argument value="org.eclipse.graphiti.examples.tutorial.diagram.TutorialToolBehaviorProvider"/>

+                <message_argument value="getToolTip(GraphicsAlgorithm)"/>

+            </message_arguments>

+        </filter>

+    </resource>

+</component>

diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java
index 0f0d0f0..73fc3d4 100644
--- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java
+++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/diagram/TutorialToolBehaviorProvider.java
@@ -233,7 +233,7 @@
 	}
 
 	@Override
-	public String getToolTip(GraphicsAlgorithm ga) {
+	public Object getToolTip(GraphicsAlgorithm ga) {
 		PictogramElement pe = ga.getPictogramElement();
 		Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
 		if (bo instanceof EClass) {
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
index 3c416d6..88d1e6c 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
@@ -610,7 +610,7 @@
 		}
 
 		// Create a tooltip label
-		Label tooltipLabel = null;
+		IFigure tooltipFigure = null;
 
 		// First check the need for an update needed tooltip
 		Label indicateUpdateNeedeTooltipLabel = null;
@@ -624,20 +624,36 @@
 		if (indicateUpdateNeedeTooltipLabel != null) {
 			// Use update needed tooltip in any case (tool provided tooltip
 			// would be probably invalid)
-			tooltipLabel = indicateUpdateNeedeTooltipLabel;
+			tooltipFigure = indicateUpdateNeedeTooltipLabel;
 		} else {
 			// ... if not get the tool provided tooltip (for performance reasons
 			// only called in case no update needed tooltip exists)
-			String toolTip = toolBehaviorProvider.getToolTip(graphicsAlgorithm);
-			if (toolTip != null && !(toolTip.length() == 0)) {
-				// null or empty string means no tooltip wanted
-				tooltipLabel = new Label(toolTip);
+			Object toolTip = toolBehaviorProvider.getToolTip(graphicsAlgorithm);
+			// null or empty string means no tooltip wanted
+			if (toolTip != null)
+			{
+				if (toolTip instanceof String)
+				{
+					tooltipFigure = new Label((String) toolTip);
+				} else if (toolTip instanceof Text)
+				{
+					Text text = (Text) toolTip;
+					if (text.getValue() != null && !(text.getValue().length() == 0)) {
+						tooltipFigure = new GFText(this, text);
+						((GFText) tooltipFigure).setText(text.getValue());
+					}
+				} else if (toolTip instanceof MultiText) {
+					MultiText multiText = (MultiText) toolTip;
+					if (multiText.getValue() != null && !(multiText.getValue().length() == 0)) {
+						tooltipFigure = new GFMultilineText(this, multiText);
+					}
+				}
 			}
 		}
 
 		// Set the tooltip in any case, especially also when it's null to clean
 		// up a previously set tooltip (see Bugzilla 348662)
-		figure.setToolTip(tooltipLabel);
+		figure.setToolTip(tooltipFigure);
 	}
 
 	private void refreshFont(AbstractText text, Figure label) {
diff --git a/plugins/org.eclipse.graphiti/.settings/.api_filters b/plugins/org.eclipse.graphiti/.settings/.api_filters
index 4faf23f..ecdaa80 100644
--- a/plugins/org.eclipse.graphiti/.settings/.api_filters
+++ b/plugins/org.eclipse.graphiti/.settings/.api_filters
@@ -62,6 +62,22 @@
             </message_arguments>

         </filter>

     </resource>

+    <resource path="src/org/eclipse/graphiti/tb/DefaultToolBehaviorProvider.java" type="org.eclipse.graphiti.tb.DefaultToolBehaviorProvider">

+        <filter comment="getToolTip changes its return type to Object" id="338792546">

+            <message_arguments>

+                <message_argument value="org.eclipse.graphiti.tb.DefaultToolBehaviorProvider"/>

+                <message_argument value="getToolTip(GraphicsAlgorithm)"/>

+            </message_arguments>

+        </filter>

+    </resource>

+    <resource path="src/org/eclipse/graphiti/tb/IToolBehaviorProvider.java" type="org.eclipse.graphiti.tb.IToolBehaviorProvider">

+        <filter comment="getToolTip changes its return type to Object" id="405901410">

+            <message_arguments>

+                <message_argument value="org.eclipse.graphiti.tb.IToolBehaviorProvider"/>

+                <message_argument value="getToolTip(GraphicsAlgorithm)"/>

+            </message_arguments>

+        </filter>

+    </resource>

     <resource path="src/org/eclipse/graphiti/util/PredefinedColoredAreas.java" type="org.eclipse.graphiti.util.PredefinedColoredAreas">

         <filter id="1143996420">

             <message_arguments>

diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/CreateServiceImpl.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/CreateServiceImpl.java
index 67d0397..492b0ad 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/CreateServiceImpl.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/CreateServiceImpl.java
@@ -25,6 +25,7 @@
 
 import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
 import org.eclipse.graphiti.mm.StyleContainer;
+import org.eclipse.graphiti.mm.algorithms.AbstractText;
 import org.eclipse.graphiti.mm.algorithms.Ellipse;
 import org.eclipse.graphiti.mm.algorithms.Image;
 import org.eclipse.graphiti.mm.algorithms.MultiText;
@@ -37,6 +38,9 @@
 import org.eclipse.graphiti.mm.algorithms.styles.Color;
 import org.eclipse.graphiti.mm.algorithms.styles.Point;
 import org.eclipse.graphiti.mm.algorithms.styles.Style;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion;
+import org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle;
 import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
 import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;
 import org.eclipse.graphiti.mm.pictograms.ChopboxAnchor;
@@ -657,4 +661,50 @@
 	public Shape createShape(ContainerShape parentContainerShape, boolean active) {
 		return getPeService().createShape(parentContainerShape, active);
 	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyleRegion(
+	 * org.eclipse.graphiti.mm.algorithms.AbstractText)
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText) {
+		return getGaService().createTextStyleRegion(abstractText);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyleRegion(
+	 * org.eclipse.graphiti.mm.algorithms.AbstractText, int, int)
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText, int start, int end) {
+		return getGaService().createTextStyleRegion(abstractText, start, end);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyle(org.eclipse
+	 * .graphiti.mm.algorithms.styles.TextStyleRegion)
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region) {
+		return getGaService().createTextStyle(region);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyle(org.eclipse
+	 * .graphiti.mm.algorithms.styles.TextStyleRegion, boolean, boolean,
+	 * org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle)
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region, boolean underline, boolean strikeout,
+			UnderlineStyle underlineStyle) {
+		return getGaService().createTextStyle(region, underline, strikeout, underlineStyle);
+	}
 }
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaCreateService.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaCreateService.java
index acc7699..567a351 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaCreateService.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaCreateService.java
@@ -22,6 +22,7 @@
 
 import org.eclipse.graphiti.mm.GraphicsAlgorithmContainer;
 import org.eclipse.graphiti.mm.StyleContainer;
+import org.eclipse.graphiti.mm.algorithms.AbstractText;
 import org.eclipse.graphiti.mm.algorithms.Ellipse;
 import org.eclipse.graphiti.mm.algorithms.Image;
 import org.eclipse.graphiti.mm.algorithms.MultiText;
@@ -35,6 +36,9 @@
 import org.eclipse.graphiti.mm.algorithms.styles.Color;
 import org.eclipse.graphiti.mm.algorithms.styles.Point;
 import org.eclipse.graphiti.mm.algorithms.styles.Style;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion;
+import org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
 import org.eclipse.graphiti.mm.pictograms.PictogramElement;
 import org.eclipse.graphiti.util.IColorConstant;
@@ -1155,4 +1159,68 @@
 	 */
 	public Style createPlainStyle(StyleContainer styleContainer, String id);
 
+	/**
+	 * Creates a {@link TextStyleRegion}. The style is aggregated under the
+	 * given abstract text.
+	 * 
+	 * @param abstractText
+	 *            container text
+	 * @return the newly created text style region
+	 * @see TextStyleRegion
+	 * @see #createTextStyleRegion(AbstractText, int, int)
+	 * @since 0.10
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText);
+
+	/**
+	 * Creates a {@link TextStyleRegion} with the given bounds. The style is
+	 * aggregated under the given abstract text.
+	 * 
+	 * @param abstractText
+	 *            container text
+	 * @param start
+	 *            region start
+	 * @param end
+	 *            retion end
+	 * @return the newly created text style region
+	 * 
+	 * @see TextStyleRegion
+	 * @since 0.10
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText, int start, int end);
+
+	/**
+	 * Creates a {@link TextStyle}. The style is aggregated under the given text
+	 * style region.
+	 * 
+	 * @param region
+	 *            container region
+	 * @return the newly created text style
+	 * 
+	 * @see TextStyle
+	 * @see #createTextStyle(TextStyleRegion, boolean, boolean, UnderlineStyle)
+	 * @since 0.10
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region);
+
+	/**
+	 * Creates a {@link TextStyle} with the given values. The style is
+	 * aggregated under the given text style region.
+	 * 
+	 * @param region
+	 *            container region
+	 * @param underline
+	 *            the is underlined
+	 * @param strikeout
+	 *            the is stroke out
+	 * @param underlineStyle
+	 *            the underline style
+	 * @return the newly created text style
+	 * 
+	 * @see TextStyle
+	 * @see #createStyle(StyleContainer, String)
+	 * @since 0.10
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region, boolean underline, boolean strikeout,
+			UnderlineStyle underlineStyle);
 }
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java
index de2711c..e619e7c 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java
@@ -54,6 +54,9 @@
 import org.eclipse.graphiti.mm.algorithms.styles.Style;
 import org.eclipse.graphiti.mm.algorithms.styles.StylesFactory;
 import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion;
+import org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
 import org.eclipse.graphiti.mm.pictograms.PictogramElement;
 import org.eclipse.graphiti.services.Graphiti;
@@ -1010,6 +1013,75 @@
 	 * (non-Javadoc)
 	 * 
 	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyleRegion(
+	 * org.eclipse.graphiti.mm.algorithms.AbstractText)
+	 */
+	/**
+	 * @since 0.10
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText) {
+		TextStyleRegion textStyleRegion = StylesFactory.eINSTANCE.createTextStyleRegion();
+		abstractText.getStyleRegions().add(textStyleRegion);
+		return textStyleRegion;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyleRegion(
+	 * org.eclipse.graphiti.mm.algorithms.AbstractText, int, int)
+	 */
+	/**
+	 * @since 0.10
+	 */
+	public TextStyleRegion createTextStyleRegion(AbstractText abstractText, int start, int end) {
+		TextStyleRegion textStyleRegion = createTextStyleRegion(abstractText);
+		textStyleRegion.setStart(start);
+		textStyleRegion.setEnd(end);
+		return textStyleRegion;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyle(org.eclipse
+	 * .graphiti.mm.algorithms.styles.TextStyleRegion)
+	 */
+	/**
+	 * @since 0.10
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region) {
+		TextStyle textStyle = StylesFactory.eINSTANCE.createTextStyle();
+		region.setStyle(textStyle);
+		return textStyle;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.graphiti.services.IGaCreateService#createTextStyle(org.eclipse
+	 * .graphiti.mm.algorithms.styles.TextStyleRegion, boolean, boolean,
+	 * org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle)
+	 */
+	/**
+	 * @since 0.10
+	 */
+	public TextStyle createTextStyle(TextStyleRegion region, boolean underline, boolean strikeout,
+			UnderlineStyle underlineStyle) {
+		TextStyle textStyle = createTextStyle(region);
+		textStyle.setStrikeout(strikeout);
+		textStyle.setUnderline(underline);
+		textStyle.setUnderlineStyle(underlineStyle);
+		return textStyle;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
 	 * org.eclipse.graphiti.services.IGaService#deleteFont(org.eclipse.graphiti
 	 * .mm.pictograms.AbstractText)
 	 */
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/DefaultToolBehaviorProvider.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/DefaultToolBehaviorProvider.java
index cc26b8a..e8aee37 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/DefaultToolBehaviorProvider.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/DefaultToolBehaviorProvider.java
@@ -421,7 +421,16 @@
 	public void postExecute(IExecutionInfo executionInfo) {
 	}
 
-	public String getToolTip(GraphicsAlgorithm ga) {
+	/**
+	 * Returns the tooltip to be attached to the graphical representation of the
+	 * given graphics algorithm.
+	 * 
+	 * @param graphicsAlgorithm
+	 *            the graphics algorithm
+	 * @return the tooltip
+	 * @since 0.10
+	 */
+	public Object getToolTip(GraphicsAlgorithm ga) {
 		return null;
 	}
 
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/IToolBehaviorProvider.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/IToolBehaviorProvider.java
index 76cf023..a3ff016 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/IToolBehaviorProvider.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/tb/IToolBehaviorProvider.java
@@ -28,8 +28,12 @@
 import org.eclipse.graphiti.features.context.ISingleClickContext;
 import org.eclipse.graphiti.features.custom.ICustomFeature;
 import org.eclipse.graphiti.features.impl.IIndependenceSolver;
+import org.eclipse.graphiti.mm.algorithms.AbstractText;
 import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
 import org.eclipse.graphiti.mm.algorithms.Polyline;
+import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.algorithms.styles.Font;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyle;
 import org.eclipse.graphiti.mm.pictograms.Anchor;
 import org.eclipse.graphiti.mm.pictograms.Connection;
 import org.eclipse.graphiti.mm.pictograms.ContainerShape;
@@ -236,13 +240,53 @@
 
 	/**
 	 * Returns the tooltip to be attached to the graphical representation of the
-	 * given graphics algorithm.
+	 * given graphics algorithm. <br>
+	 * <p>
+	 * It can either be a String, creating a simple tooltip, or an AbstractText.
+	 * In the latter case, a rich text label would be created, respecting the
+	 * contained {@link TextStyle}s.
+	 * 
+	 * <p>
+	 * Since the pictogram element doesn't belong to the diagram, you have to be
+	 * careful with the {@link Color}s and {@link Font}s used in the
+	 * {@link TextStyle}s within the {@link AbstractText}. <strong>They should
+	 * be created and added to the diagram beforehand</strong>, preferably in
+	 * the add feature that created the given graphicsAlgorithm, i.e.:
+	 * <p>
+	 * Somewhere in the <em>add</em> method of the <em>addFeature</em>
+	 * :<blockquote>
+	 * 
+	 * <pre>
+	 * manageFont(diagram, &quot;Verdana&quot;, 9, true, false);
+	 * </pre>
+	 * 
+	 * </blockquote>
+	 * <p>
+	 * Inside the <em>getRichToolTip</em>:<blockquote>
+	 * 
+	 * <pre>
+	 * Font font = manageFont(getDiagramTypeProvider().getDiagram(), &quot;Verdana&quot;, 9, true, false);
+	 * textStyle.setFont(font);
+	 * </pre>
+	 * 
+	 * </blockquote>
+	 * <p>
+	 * This will ensure resource management for both fonts and colors, and
+	 * prevent transaction read-only errors if trying to add a font o a color to
+	 * the diagram without a write transaction.
+	 * <p>
+	 * <strong>Note</strong>: Be extremely careful when adding rich text
+	 * tooltips to an previously existing diagram. Since the pictograms may have
+	 * already been added to the diagram, the tooltip may cause an
+	 * {@link IllegalStateException} if trying to use a resource that was not
+	 * previously added to the diagram.
 	 * 
 	 * @param graphicsAlgorithm
 	 *            the graphics algorithm
 	 * @return the tooltip
+	 * @since 0.10
 	 */
-	String getToolTip(GraphicsAlgorithm graphicsAlgorithm);
+	Object getToolTip(GraphicsAlgorithm graphicsAlgorithm);
 
 	/**
 	 * The returned graphics algorithm defines the selection border and the
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java
index 9afab19..572871c 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFOtherTests.java
@@ -33,8 +33,6 @@
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.notNullValue;
 
-import java.awt.Robot;
-import java.awt.event.KeyEvent;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -138,6 +136,7 @@
 import org.eclipse.graphiti.ui.internal.util.ui.PopupMenu.CascadingMenu;
 import org.eclipse.graphiti.util.IColorConstant;
 import org.eclipse.graphiti.util.PredefinedColoredAreas;
+import org.eclipse.jface.action.ActionContributionItem;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.GC;
@@ -147,9 +146,11 @@
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.results.VoidResult;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton;
 import org.eclipse.ui.IMemento;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
 import org.junit.After;
 import org.junit.Test;
 
@@ -1152,26 +1153,29 @@
 
 		Thread.sleep(500);
 
-		try {
-			final Robot robot = new Robot();
-			robot.setAutoDelay(500);
-			try {
-				robot.keyPress(KeyEvent.VK_ALT);
-				robot.setAutoDelay(0);
-				robot.keyPress(KeyEvent.VK_LEFT);
-			} catch (RuntimeException e) {
-				fail(e.getMessage());
-			} finally {
-				robot.keyRelease(KeyEvent.VK_LEFT);
-				robot.keyRelease(KeyEvent.VK_ALT);
+		final Object[] data = new Object[1];
+		for (int i = 0; i > -1; i++) {
+			final SWTBotToolbarDropDownButton toolbarDropDownButton = bot.toolbarDropDownButton(i);
+			Display.getDefault().syncExec(new Runnable() {
+
+				public void run() {
+					data[0] = toolbarDropDownButton.widget.getData();
+				}
+			});
+
+			if (data[0] instanceof ActionContributionItem) {
+				ActionContributionItem item = (ActionContributionItem) data[0];
+				if (item.getId().equals(ActionFactory.BACKWARD_HISTORY.getId())) { // Found!
+					toolbarDropDownButton.click();
+					break;
+				}
 			}
-		} catch (Exception e) {
-			fail(e.getMessage());
 		}
 
-		SWTBotEditor swtBotEditor = bot.editorById(DiagramEditor.DIAGRAM_EDITOR_ID);
-		assertNotNull(swtBotEditor);
-		SWTBotStyledText styledText = swtBotEditor.bot().styledText();
+		SWTBotEditor editor = bot.editorById(DiagramEditor.DIAGRAM_EDITOR_ID);
+		assertNotNull(editor);
+		editor.show();
+		SWTBotStyledText styledText = editor.bot().styledText();
 		assertNotNull(styledText);
 		assertTrue(styledText.getText().startsWith("No Diagram found for URI"));
 
diff --git a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/SketchToolBehavior.java b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/SketchToolBehavior.java
index f3d6344..d3ab20b 100644
--- a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/SketchToolBehavior.java
+++ b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/SketchToolBehavior.java
@@ -38,7 +38,12 @@
 import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
 import org.eclipse.graphiti.mm.algorithms.Rectangle;
 import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
+import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.algorithms.styles.Font;
 import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion;
+import org.eclipse.graphiti.mm.algorithms.styles.UnderlineStyle;
 import org.eclipse.graphiti.mm.pictograms.Connection;
 import org.eclipse.graphiti.mm.pictograms.ContainerShape;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -510,21 +515,40 @@
 	}
 
 	@Override
-	public String getToolTip(GraphicsAlgorithm ga) {
+	public AbstractText getToolTip(GraphicsAlgorithm ga) {
 		if (SketchUtil.isConnectionPoint(ga.getPictogramElement())) {
 			return null;
 		}
 		
 		if (ga instanceof AbstractText && ga.getParentGraphicsAlgorithm() != null) {
 			return getToolTip(ga.getParentGraphicsAlgorithm());
-		} else {
-			final int x = ga.getX();
-			final int y = ga.getY();
-			final int width = ga.getWidth();
-			final int height = ga.getHeight();
-			String ret = ga.getClass().getSimpleName() + " (x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + ")";
-			return ret;
 		}
+		final int x = ga.getX();
+		final int y = ga.getY();
+		final int width = ga.getWidth();
+		final int height = ga.getHeight();
+		String first = ga.getClass().getPackage().getName();
+		String second = ga.getClass().getSimpleName();
+		String third = "(x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + ")";
+		String toolTip = first + "." + second + "\n" + third;
+
+		IGaService gaService = Graphiti.getGaService();
+		Text text = gaService.createPlainText(null, toolTip);
+
+		TextStyleRegion textStyleRegion = gaService.createTextStyleRegion(text, first.length() + 1, first.length()
+				+ second.length());
+		gaService.createTextStyle(textStyleRegion, true, false, UnderlineStyle.UNDERLINE_SINGLE);
+
+		TextStyleRegion textStyleRegion2 = gaService.createTextStyleRegion(text);
+		textStyleRegion2.setStart(first.length() + second.length() + 2);
+		textStyleRegion2.setEnd(toolTip.length());
+
+		TextStyle textStyle = gaService.createTextStyle(textStyleRegion2);
+		Font font = gaService.manageFont(getDiagramTypeProvider().getDiagram(), IGaService.DEFAULT_FONT,
+				IGaService.DEFAULT_FONT_SIZE, true, false);
+		textStyle.setFont(font);
+
+		return text;
 	}
 
 	@Override
diff --git a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java
index 6327eb5..abbe1bd 100644
--- a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java
+++ b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java
@@ -55,6 +55,9 @@
 		gaService.setLocationAndSize(textGa, 0, 0, 400, 100);
 		textGa.setAngle(-1);
 
+		// Create an italic font to use it later in the rich tooltip
+		gaService.manageFont(getDiagram(), IGaService.DEFAULT_FONT, IGaService.DEFAULT_FONT_SIZE, true, false);
+
 		return shape;
 	}
 
diff --git a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/create/SketchCreateGaFeature.java b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/create/SketchCreateGaFeature.java
index c9c5f12..2bee428 100644
--- a/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/create/SketchCreateGaFeature.java
+++ b/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/create/SketchCreateGaFeature.java
@@ -144,6 +144,8 @@
 			r.setTransparency(1.0);
 			fpa.setLocation(gaService.createPoint(10, 10));
 		}
+		// Create an italic font to use it later in the rich tooltip
+		gaService.manageFont(getDiagram(), IGaService.DEFAULT_FONT, IGaService.DEFAULT_FONT_SIZE, true, false);
 
 		return new Object[] { newAc };
 	}