فهرست منبع

Added some highlighting for mouse over to indicate a clickable area

Andreas Mülder 12 سال پیش
والد
کامیت
d8de764db4

+ 2 - 1
de.itemis.gmf.utils/plugins/de.itemis.gmf.runtime.commons/src/de/itemis/gmf/runtime/commons/editparts/TextAwareExternalLabelEditPart.java

@@ -35,6 +35,7 @@ import org.eclipse.jface.viewers.ICellEditorValidator;
 import org.eclipse.swt.graphics.Color;
 
 import de.itemis.gmf.runtime.commons.parsers.StringAttributeParser;
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
 
 /**
  * This is a common abstract base class for all {@link LabelEditPart} which are
@@ -124,7 +125,7 @@ public abstract class TextAwareExternalLabelEditPart extends LabelEditPart
 
 	@Override
 	protected IFigure createFigure() {
-		return new WrappingLabel();
+		return new HighlightingWrappingLabel();
 	}
 
 	public ICellEditorValidator getEditTextValidator() {

+ 2 - 1
de.itemis.gmf.utils/plugins/de.itemis.gmf.runtime.commons/src/de/itemis/gmf/runtime/commons/editparts/TextAwareLabelEditPart.java

@@ -39,6 +39,7 @@ import org.eclipse.swt.graphics.Color;
 import de.itemis.gmf.runtime.commons.parsers.StringAttributeParser;
 import de.itemis.xtext.utils.gmf.directedit.DoubleClickDirectEditDragTracker;
 import de.itemis.xtext.utils.gmf.directedit.DoubleClickDirectEditDragTracker.IDoubleClickCallback;
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
 
 /**
  * This is a common abstract base class for all Label which are
@@ -127,7 +128,7 @@ public abstract class TextAwareLabelEditPart extends CompartmentEditPart
 
 	@Override
 	protected IFigure createFigure() {
-		return new WrappingLabel();
+		return new HighlightingWrappingLabel();
 	}
 
 	public ICellEditorValidator getEditTextValidator() {

+ 1 - 0
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.gmf/META-INF/MANIFEST.MF

@@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Export-Package: de.itemis.xtext.utils.gmf.directedit,
  de.itemis.xtext.utils.gmf.experimental,
+ de.itemis.xtext.utils.gmf.figures,
  de.itemis.xtext.utils.gmf.resource,
  de.itemis.xtext.utils.gmf.viewers
 Bundle-ActivationPolicy: lazy

+ 0 - 1
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.gmf/build.properties

@@ -2,4 +2,3 @@ source.. = src/
 output.. = bin/
 bin.includes = META-INF/,\
                .
-src.includes = .project

+ 3 - 1
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.gmf/src/de/itemis/xtext/utils/gmf/directedit/ExternalXtextLabelEditPart.java

@@ -28,6 +28,8 @@ import org.eclipse.gmf.runtime.notation.ShapeStyle;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.graphics.Color;
 
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
+
 /**
  * Abstract base implementation for all external {@link LabelEditPart} that use
  * Xtext for direct editing.
@@ -46,7 +48,7 @@ public abstract class ExternalXtextLabelEditPart extends LabelEditPart implement
 
 	@Override
 	protected IFigure createFigure() {
-		final WrappingLabel label = new WrappingLabel();
+		final WrappingLabel label = new HighlightingWrappingLabel();
 		label.setTextWrap(true);
 		label.setAlignment(PositionConstants.LEFT | PositionConstants.TOP);
 		return label;

+ 2 - 1
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.gmf/src/de/itemis/xtext/utils/gmf/directedit/XtextLabelEditPart.java

@@ -29,6 +29,7 @@ import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.graphics.Color;
 
 import de.itemis.xtext.utils.gmf.directedit.DoubleClickDirectEditDragTracker.IDoubleClickCallback;
+import de.itemis.xtext.utils.gmf.figures.HighlightingWrappingLabel;
 
 /**
  * Abstract base implementation for all Labels that that use Xtext for direct
@@ -48,7 +49,7 @@ public abstract class XtextLabelEditPart extends CompartmentEditPart implements
 
 	@Override
 	protected IFigure createFigure() {
-		final WrappingLabel label = new WrappingLabel();
+		final WrappingLabel label = new HighlightingWrappingLabel();
 		label.setTextWrap(true);
 		label.setAlignment(PositionConstants.LEFT | PositionConstants.TOP);
 		return label;

+ 56 - 0
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.gmf/src/de/itemis/xtext/utils/gmf/figures/HighlightingWrappingLabel.java

@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package de.itemis.xtext.utils.gmf.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.MouseEvent;
+import org.eclipse.draw2d.MouseMotionListener;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class HighlightingWrappingLabel extends WrappingLabel implements MouseMotionListener {
+
+	private static final MarginBorder NO_FOCUS_BORDER = new MarginBorder(new Insets(1, 1, 1, 1));
+	private static final LineBorder FOCUS_BORDER = new LineBorder(ColorConstants.lightGray);
+
+	public HighlightingWrappingLabel() {
+		setBorder(NO_FOCUS_BORDER);
+		addMouseMotionListener(this);
+	}
+
+	public void mouseEntered(MouseEvent me) {
+		setBorder(FOCUS_BORDER);
+	}
+
+	public void mouseExited(MouseEvent me) {
+		setBorder(NO_FOCUS_BORDER);
+	}
+
+	public void mouseDragged(MouseEvent me) {
+		// Nothing to do
+	}
+
+	public void mouseHover(MouseEvent me) {
+		// Nothing to do
+	}
+
+	public void mouseMoved(MouseEvent me) {
+		// Nothing to do
+	}
+
+}