Kaynağa Gözat

The fonts of transition labels and text compartments are now changeable with the appearance property view.

markus.muehlbrandt@itemis.de 14 yıl önce
ebeveyn
işleme
4af9cb55c8

+ 5 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableExternalXtextLabelEditPart.java

@@ -72,9 +72,12 @@ public abstract class PlugableExternalXtextLabelEditPart extends
 
 	@Override
 	protected void handleNotificationEvent(Notification notification) {
-		super.handleNotificationEvent(notification);
-		if (notification.getFeature() == SGraphPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION)
+		if (notification.getFeature() == SGraphPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION) {
 			refreshVisuals();
+		}
+		else {
+			super.handleNotificationEvent(notification);
+		}
 	}
 
 	public String getEditText() {

+ 5 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableXtextLabelEditPart.java

@@ -71,9 +71,12 @@ public abstract class PlugableXtextLabelEditPart extends XtextLabelEditPart {
 
 	@Override
 	protected void handleNotificationEvent(Notification notification) {
-		super.handleNotificationEvent(notification);
-		if (notification.getFeature() == SGraphPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION)
+		if (notification.getFeature() == SGraphPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION) {
 			refreshVisuals();
+		}
+		else {
+			super.handleNotificationEvent(notification);
+		}
 	}
 
 	public String getEditText() {

+ 25 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StateTextCompartmentExpressionEditPart.java

@@ -19,6 +19,24 @@ public class StateTextCompartmentExpressionEditPart extends
 		super(view);
 	}
 
+	@Override
+	protected void addNotationalListeners() {
+		super.addNotationalListeners();
+		View parentStateView = getParentStateView();
+		if (parentStateView != null) {
+			addListenerFilter("parentStateView", this,parentStateView);
+		}
+	}
+	
+	@Override
+	protected void removeNotationalListeners() {
+		View parentStateView = getParentStateView();
+		if (parentStateView != null) {
+			removeListenerFilter("parentStateView");
+		}
+		super.removeNotationalListeners();
+	}
+
 	@Override
 	protected void createDefaultEditPolicies() {
 		super.createDefaultEditPolicies();
@@ -28,4 +46,11 @@ public class StateTextCompartmentExpressionEditPart extends
 				new ContextSensitiveHelpPolicy(
 						IYakinduSctHelpContextIds.SC_PROPERTIES_STATE_EXPRESSION));
 	}
+
+	private View getParentStateView() {
+		if (getParent().getParent() instanceof StateEditPart) {
+			return ((StateEditPart) getParent().getParent()).getNotationView();
+		}
+		return null;
+	}
 }

+ 6 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StatechartTextEditPart.java

@@ -84,4 +84,10 @@ public class StatechartTextEditPart extends ShapeNodeEditPart implements
 	private StatechartTextFigure getPrimaryShape() {
 		return (StatechartTextFigure) getFigure().getChildren().get(0);
 	}
+	
+	@Override
+	protected void refreshFont() {
+		// TODO Auto-generated method stub
+		super.refreshFont();
+	}
 }

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

@@ -18,6 +18,31 @@ public class StatechartTextExpressionEditPart extends
 	public StatechartTextExpressionEditPart(View view) {
 		super(view);
 	}
+	
+	@Override
+	protected void addNotationalListeners() {
+		super.addNotationalListeners();
+		View parentStateView = getParentStateView();
+		if (parentStateView != null) {
+			addListenerFilter("parentStateView", this,parentStateView);
+		}
+	}
+	
+	@Override
+	protected void removeNotationalListeners() {
+		View parentStateView = getParentStateView();
+		if (parentStateView != null) {
+			removeListenerFilter("parentStateView");
+		}
+		super.removeNotationalListeners();
+	}
+	
+	private View getParentStateView() {
+		if (getParent() instanceof StatechartTextEditPart) {
+			return ((StatechartTextEditPart) getParent()).getNotationView();
+		}
+		return null;
+	}
 
 	@Override
 	protected void createDefaultEditPolicies() {

+ 12 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/TransitionEditPart.java

@@ -11,8 +11,10 @@
 package org.yakindu.sct.ui.editor.editparts;
 
 import org.eclipse.draw2d.Connection;
+import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.gef.EditPart;
 import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
 import org.eclipse.gmf.runtime.notation.View;
 import org.yakindu.sct.ui.editor.editor.figures.TransitionFigure;
 
@@ -52,5 +54,14 @@ public class TransitionEditPart extends ConnectionNodeEditPart {
 					((TransitionExpressionEditPart) childEditPart).getFigure());
 		}
 	}
-
+	
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (NotationPackage.eINSTANCE.getFontStyle().getEAllAttributes()
+				.contains(notification.getFeature())) {
+			refreshFont();
+		} else {
+			super.handleNotificationEvent(notification);
+		}
+	}
 }

+ 1 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/preferences/PreferenceInitializer.java

@@ -41,7 +41,7 @@ public class PreferenceInitializer extends DiagramPreferenceInitializer
 				IPreferenceConstants.PREF_SNAP_TO_GEOMETRY, true);
 
 		// set default font
-		FontData defaultFont = new FontData("Arial", 10	, SWT.NONE);
+		FontData defaultFont = new FontData("Verdana", 9	, SWT.NONE);
 		PreferenceConverter.setDefault(getPreferenceStore(),
 				IPreferenceConstants.PREF_DEFAULT_FONT, defaultFont);