Browse Source

Added some highlighting for mouse over to indicate a clickable area

Andreas Mülder 12 years ago
parent
commit
198c2419e6

+ 6 - 7
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/figures/RegionFigure.java

@@ -25,6 +25,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
 import org.eclipse.swt.graphics.Color;
 import org.yakindu.sct.ui.editor.editor.figures.utils.GridDataFactory;
 
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
+
 /**
  * 
  * @author muelder
@@ -50,9 +52,8 @@ public class RegionFigure extends RectangleFigure {
 	}
 
 	private void createContents() {
-		nameLabel = new WrappingLabel();
-		GridData data = GridDataFactory.fillDefaults().grab(true, false)
-				.getData();
+		nameLabel = new HighlightingWrappingLabel();
+		GridData data = GridDataFactory.fillDefaults().grab(true, false).getData();
 		nameLabel.setTextPlacement(PositionConstants.WEST);
 		this.add(nameLabel, data);
 
@@ -61,8 +62,7 @@ public class RegionFigure extends RectangleFigure {
 		compartmentPane.setOutline(false);
 		compartmentPane.setLayoutManager(new StackLayout());
 		compartmentPane.setFill(false);
-		this.add(compartmentPane,
-				GridDataFactory.fillDefaults().grab(true, true).getData());
+		this.add(compartmentPane, GridDataFactory.fillDefaults().grab(true, true).getData());
 	}
 
 	public WrappingLabel getNameLabel() {
@@ -82,8 +82,7 @@ public class RegionFigure extends RectangleFigure {
 	@Override
 	protected void fillShape(Graphics graphics) {
 		Color c = mixColor(getBackgroundColor(), ColorConstants.white, 220);
-		fillVerticalGradientRectangle(graphics, getBounds(),
-				getBackgroundColor(), c);
+		fillVerticalGradientRectangle(graphics, getBounds(), getBackgroundColor(), c);
 		c.dispose();
 	}
 

+ 3 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/figures/StateFigure.java

@@ -28,6 +28,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
 import org.eclipse.swt.graphics.Color;
 import org.yakindu.sct.ui.editor.editor.figures.utils.GridDataFactory;
 
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
+
 /**
  * 
  * @author andreas muelder
@@ -55,7 +57,7 @@ public class StateFigure extends RoundedRectangle {
 
 	protected void createContents() {
 		// Name Label
-		nameFigure = new WrappingLabel();
+		nameFigure = new HighlightingWrappingLabel();
 		nameFigure.setAlignment(PositionConstants.CENTER);
 		this.add(nameFigure, GridDataFactory.fillDefaults().grab(true, false)
 				.getData());

+ 3 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editor/figures/StatechartTextFigure.java

@@ -19,6 +19,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
 import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
 import org.yakindu.sct.ui.editor.editor.figures.utils.GridDataFactory;
 
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
+
 /**
  * Figure for text compartment statechart declarations
  * 
@@ -45,8 +47,7 @@ public class StatechartTextFigure extends RectangleFigure {
 	}
 
 	private void createContents() {
-		// Name Label
-		name = new WrappingLabel();
+		name = new HighlightingWrappingLabel();
 		name.setLayoutManager(new StackLayout());
 		GridData data = GridDataFactory.fillDefaults()
 				.align(GridData.CENTER, GridData.CENTER).grab(true, false)

+ 8 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StateFigureCompartmentEditPart.java

@@ -23,6 +23,7 @@ import org.eclipse.gmf.runtime.notation.BooleanValueStyle;
 import org.eclipse.gmf.runtime.notation.NotationPackage;
 import org.eclipse.gmf.runtime.notation.View;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.ui.editor.DiagramActivator;
 import org.yakindu.sct.ui.editor.factories.StateViewFactory;
 import org.yakindu.sct.ui.editor.policies.StateCompartmentCanonicalEditPolicy;
@@ -73,6 +74,11 @@ public class StateFigureCompartmentEditPart extends ResizableCompartmentEditPart
 		((ResizableCompartmentFigure) getFigure()).getScrollPane().setScrollBarVisibility(
 				org.eclipse.draw2d.ScrollPane.NEVER);
 	}
+	
+	@Override
+	public State resolveSemanticElement() {
+		return (State) super.resolveSemanticElement();
+	}
 
 	@Override
 	public boolean isSelectable() {
@@ -86,6 +92,8 @@ public class StateFigureCompartmentEditPart extends ResizableCompartmentEditPart
 		figure.setBorder(null);
 		// Should be initialized with null to display nothing.
 		figure.setToolTip((String) null);
+		figure.getScrollPane().setScrollBarVisibility(
+				org.eclipse.draw2d.ScrollPane.NEVER);
 		return figure;
 	}
 

+ 19 - 6
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StateTextCompartmentEditPart.java

@@ -10,11 +10,14 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.GridData;
+import org.eclipse.draw2d.GridLayout;
 import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.StackLayout;
+import org.eclipse.gef.EditPart;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart;
 import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
 import org.eclipse.gmf.runtime.notation.View;
+import org.yakindu.sct.ui.editor.editor.figures.utils.GridDataFactory;
 
 /**
  * 
@@ -27,14 +30,24 @@ public class StateTextCompartmentEditPart extends ResizableCompartmentEditPart {
 		super(view);
 	}
 
+	@Override
+	protected void addChildVisual(EditPart childEditPart, int index) {
+		if (childEditPart instanceof StateTextCompartmentExpressionEditPart) {
+			GridData data = GridDataFactory.fillDefaults().grab(true, true).getData();
+			getContentPane().add(((StateTextCompartmentExpressionEditPart) childEditPart).getFigure(), data);
+		} else
+			super.addChildVisual(childEditPart, index);
+	}
+
 	@Override
 	protected IFigure createFigure() {
-		ResizableCompartmentFigure figure = (ResizableCompartmentFigure) super
-				.createFigure();
-		figure.getContentPane().setLayoutManager(new StackLayout());
+		ResizableCompartmentFigure figure = (ResizableCompartmentFigure) super.createFigure();
+		GridLayout gridLayout = new GridLayout(1, true);
+		gridLayout.marginHeight = 0;
+		gridLayout.marginWidth = 0;
+		figure.getContentPane().setLayoutManager(gridLayout);
 		figure.setBorder(null);
-		figure.setToolTip((String)null);
+		figure.setToolTip((String) null);
 		return figure;
 	}
-
 }

+ 7 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StatechartTextExpressionEditPart.java

@@ -16,6 +16,7 @@ import static org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE;
 import static org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE;
 
 import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.SWT;
 import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
@@ -32,6 +33,12 @@ public class StatechartTextExpressionEditPart extends SpecificationElementEditPa
 	public StatechartTextExpressionEditPart(View view) {
 		super(view, SemanticTarget.StatechartSpecification);
 	}
+	
+	@Override
+	public WrappingLabel getFigure() {
+		// TODO Auto-generated method stub
+		return super.getFigure();
+	}
 
 	@Override
 	protected void createDefaultEditPolicies() {