Browse Source

Allow colors for pseudo states
#110

muelder 10 years ago
parent
commit
b734e01586

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

@@ -39,7 +39,7 @@ public class FinalStateFigure extends Ellipse {
 		Ellipse whiteCircle = new Ellipse();
 		whiteCircle.setOutline(false);
 		whiteCircle.setLineWidth(1);
-		whiteCircle.setBackgroundColor(getBackgroundColor());
+		whiteCircle.setBackgroundColor(ColorConstants.white);
 		size = mapMode.DPtoLP(3);
 		whiteCircle.setBorder(new MarginBorder(size, size, size, size));
 		BorderLayout layout = new BorderLayout();
@@ -49,7 +49,7 @@ public class FinalStateFigure extends Ellipse {
 		Ellipse blackCircle = new Ellipse();
 		blackCircle.setOutline(false);
 		blackCircle.setLineWidth(mapMode.DPtoLP(1));
-		blackCircle.setBackgroundColor(getBackgroundColor());
+		blackCircle.setBackgroundColor(ColorConstants.black);
 		data = BorderLayout.CENTER;
 		whiteCircle.add(blackCircle, data);
 	}

+ 51 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/factories/EntryViewFactory.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2015 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 org.yakindu.sct.ui.editor.factories;
+
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.ShapeStyle;
+import org.eclipse.gmf.runtime.notation.Style;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class EntryViewFactory extends BorderItemLabelViewFactory {
+
+	public static final String ALLOW_COLORS = "allowColors";
+
+	@Override
+	protected void initializeFromPreferences(View view) {
+		super.initializeFromPreferences(view);
+		ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE);
+		style.setFillColor(FigureUtilities.RGBToInteger(ColorConstants.black.getRGB()));
+		style.setLineColor(FigureUtilities.RGBToInteger(ColorConstants.white.getRGB()));
+	}
+
+	@Override
+	protected List<Style> createStyles(View view) {
+		@SuppressWarnings("unchecked")
+		List<Style> styles = super.createStyles(view);
+		NamedStyle allowColorsStyle = NotationFactory.eINSTANCE.createNamedStyle();
+		allowColorsStyle.setName(ALLOW_COLORS);
+		styles.add(allowColorsStyle);
+		return styles;
+	}
+
+}