Merge "Use styled text in tooltips"
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
index 1108023..d5dbfac 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/util/draw2d/GFSurroundingHandle.java
@@ -9,6 +9,7 @@
  *
  * Contributors:
  *    SAP AG - initial API, implementation and documentation
+ *    mgorning - Bug 365172 - Shape Selection Info Solid Line 
  *
  * </copyright>
  *
@@ -26,8 +27,14 @@
 import org.eclipse.gef.editpolicies.ResizableEditPolicy;
 import org.eclipse.gef.handles.AbstractHandle;
 import org.eclipse.gef.tools.DragEditPartsTracker;
+import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.tb.ISelectionInfo;
+import org.eclipse.graphiti.tb.IToolBehaviorProvider;
 import org.eclipse.graphiti.ui.internal.config.IConfigurationProviderInternal;
 import org.eclipse.graphiti.ui.internal.figures.GFFigureUtil;
+import org.eclipse.graphiti.ui.internal.parts.ShapeEditPart;
+import org.eclipse.graphiti.ui.internal.util.DataTypeTransformation;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 
@@ -53,16 +60,6 @@
 	private static Insets HANDLE_INSETS = new Insets(LINE_WIDTH, LINE_WIDTH, LINE_WIDTH, LINE_WIDTH);
 
 	/**
-	 * The line-style to use for resizable directions.
-	 */
-	private static int[] LINE_STYLE_RESIZABLE = new int[] { 2, 2 };
-
-	/**
-	 * The line-style to use for not-resizable directions.
-	 */
-	private static int[] LINE_STYLE_NOT_RESIZABLE = new int[] { 2, 2 };
-
-	/**
 	 * The foreground color to use for resizable directions.
 	 */
 	private static Color FG_COLOR_RESIZABLE;
@@ -108,6 +105,8 @@
 	 */
 	private boolean movable;
 
+	private ISelectionInfo selectionInfoForShape = null;
+
 	/**
 	 * Creates a new GFSurroundingHandle.
 	 * 
@@ -123,12 +122,18 @@
 	 *            Indicates, if moving the owner edit-part via this handle is
 	 *            supported.
 	 */
-	public GFSurroundingHandle(GraphicalEditPart owner, IConfigurationProviderInternal configurationProvider, int supportedResizeDirections,
-			boolean movable) {
+	public GFSurroundingHandle(GraphicalEditPart owner, IConfigurationProviderInternal configurationProvider,
+			int supportedResizeDirections, boolean movable) {
 		this.configurationProvider = configurationProvider;
 		this.supportedResizeDirections = supportedResizeDirections;
 		this.movable = movable;
 
+		if (owner instanceof ShapeEditPart && owner.getModel() instanceof Shape) {
+			Shape shape = (Shape) owner.getModel();
+			IToolBehaviorProvider tbp = configurationProvider.getDiagramTypeProvider().getCurrentToolBehaviorProvider();
+			selectionInfoForShape = tbp.getSelectionInfoForShape(shape);
+		}
+
 		setOwner(owner);
 		setLocator(new ZoomingInsetsHandleLocator(owner.getFigure(), configurationProvider, HANDLE_INSETS));
 
@@ -217,30 +222,35 @@
 	private void prepareForDrawing(Graphics g, int direction) {
 		boolean resizable = (supportedResizeDirections & direction) != 0;
 
-		int dash[];
 		Color fg;
 		if (resizable) {
-			dash = LINE_STYLE_RESIZABLE;
 			fg = getFG_COLOR_RESIZABLE();
 		} else {
-			dash = LINE_STYLE_NOT_RESIZABLE;
 			fg = getFG_COLOR_NOT_RESIZABLE();
 		}
 
-		int dashZoomed[];
-		double zoom = GFHandleHelper.getZoomLevel(configurationProvider);
-		if (zoom == 1.0) {
-			dashZoomed = dash;
+		if (selectionInfoForShape != null) {
+			LineStyle lineStyle = selectionInfoForShape.getLineStyle();
+			int draw2dLineStyle = DataTypeTransformation.toDraw2dLineStyle(lineStyle);
+			g.setLineStyle(draw2dLineStyle);
 		} else {
-			dashZoomed = new int[dash.length];
-			for (int i = 0; i < dashZoomed.length; i++) {
-				dashZoomed[i] = Math.max(1, (int) (zoom * dash[i]));
+			// default line style for selection
+			int[] dash = new int[] { 2, 2 };
+			int dashZoomed[];
+			double zoom = GFHandleHelper.getZoomLevel(configurationProvider);
+			if (zoom == 1.0) {
+				dashZoomed = dash;
+			} else {
+				dashZoomed = new int[dash.length];
+				for (int i = 0; i < dashZoomed.length; i++) {
+					dashZoomed[i] = Math.max(1, (int) (zoom * dash[i]));
+				}
 			}
+			g.setLineStyle(Graphics.LINE_CUSTOM);
+			g.setLineDash(dashZoomed);
 		}
-
-		g.setLineStyle(Graphics.LINE_CUSTOM);
-		g.setLineDash(dashZoomed);
-		// It is necessary to set the color. This ensures the support for the high contrast mode.
+		// It is necessary to set the color. This ensures the support for the
+		// high contrast mode.
 		setForegroundColor(fg);
 		g.setForegroundColor(getForegroundColor());
 	}
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/features/impl/AbstractFeature.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/features/impl/AbstractFeature.java
index 68ee67a..d3c9f6f 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/features/impl/AbstractFeature.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/features/impl/AbstractFeature.java
@@ -1,7 +1,7 @@
 /*******************************************************************************
  * <copyright>
  *
- * Copyright (c) 2005, 2011 SAP AG.
+ * Copyright (c) 2005, 2012 SAP AG.
  * 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
@@ -10,6 +10,7 @@
  * Contributors:
  *    SAP AG - initial API, implementation and documentation
  *    mwenz - Bug 363464: Return IReason to pass on information if layout has been performed
+ *    mwenz - Added convenience methods for font handling
  *
  * </copyright>
  *
@@ -27,6 +28,7 @@
 import org.eclipse.graphiti.features.context.impl.LayoutContext;
 import org.eclipse.graphiti.features.context.impl.UpdateContext;
 import org.eclipse.graphiti.mm.algorithms.styles.Color;
+import org.eclipse.graphiti.mm.algorithms.styles.Font;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
 import org.eclipse.graphiti.mm.pictograms.PictogramElement;
 import org.eclipse.graphiti.platform.IDiagramEditor;
@@ -269,6 +271,80 @@
 	}
 
 	/**
+	 * Provides the font instance for the default font (Arial in size 8) by
+	 * either creating a new one and aggregating it to the diagram or finding it
+	 * in the diagrams list of fonts.
+	 * 
+	 * @param diagram
+	 *            the diagram that aggregates the fonts
+	 * @return the font instance
+	 * 
+	 * @since 0.10
+	 */
+	protected Font manageDefaultFont(Diagram diagram) {
+		return Graphiti.getGaService().manageDefaultFont(diagram);
+	}
+
+	/**
+	 * Provides the font instance for the default font (Arial in size 8) by
+	 * either creating a new one and aggregating it to the diagram or finding it
+	 * in the diagrams list of fonts.
+	 * 
+	 * @param diagram
+	 *            the diagram that aggregates the fonts
+	 * @param isItalic
+	 *            the is italic
+	 * @param isBold
+	 *            the is bold
+	 * @return the font instance
+	 * 
+	 * @since 0.10
+	 */
+	Font manageDefaultFont(Diagram diagram, boolean isItalic, boolean isBold) {
+		return Graphiti.getGaService().manageDefaultFont(diagram, isItalic, isBold);
+	}
+
+	/**
+	 * Provides a font instance by either creating a new one and aggregating it
+	 * to the diagram or finding it in the diagrams list of fonts.
+	 * 
+	 * @param diagram
+	 *            the diagram that aggregates the fonts
+	 * @param name
+	 *            the name of the font
+	 * @param size
+	 *            the size of the font
+	 * @return the font instance
+	 * 
+	 * @since 0.10
+	 */
+	public Font manageFont(Diagram diagram, String name, int size) {
+		return Graphiti.getGaService().manageFont(diagram, name, size);
+	}
+
+	/**
+	 * Provides a font instance by either creating a new one and aggregating it
+	 * to the diagram or finding it in the diagrams list of fonts.
+	 * 
+	 * @param diagram
+	 *            the diagram that aggregates the fonts
+	 * @param name
+	 *            the name of the font
+	 * @param size
+	 *            the size of the font
+	 * @param isItalic
+	 *            the is italic
+	 * @param isBold
+	 *            the is bold
+	 * @return the font instance
+	 * 
+	 * @since 0.10
+	 */
+	public Font manageFont(Diagram diagram, String name, int size, boolean isItalic, boolean isBold) {
+		return Graphiti.getGaService().manageFont(diagram, name, size, isItalic, isBold);
+	}
+
+	/**
 	 * Updates the given pictogram element. This implementation asks the feature
 	 * provider for available update features and processes the first one.
 	 *