Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 441352 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.gef4.dot.tests/resources/nodeshapes_polygon_based.dot (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2016 itemis AG and others.
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution  and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *       Tamas Miklossy  (itemis AG) - Initial text (bug #441352)
11
 *******************************************************************************/
12
13
/* 
14
 * The PolygonBasedNodeShapes graph represents the different polygon based node shapes 
15
 * that an be used as valid values for the shape node attribute.
16
 */
17
graph PolygonBasedNodeShapes {
18
     rankdir=TB
19
     1[shape=box]
20
     
21
     /* If shape="polygon", the attributes sides, skew and distortion are also used.*/
22
     2[shape=polygon sides=5, skew=0, distortion=0]
23
     3[shape=ellipse]
24
     4[shape=oval]
25
     5[shape=circle]
26
     6[shape=point]
27
     7[shape=egg]
28
     8[shape=triangle]
29
     9[shape=plaintext]
30
    
31
    /*
32
     * The node shape=plain requires also the label attribute to be set, otherwise it will be rendered
33
     * as a box shape with the following warning: "Warning: using box for unknown shape plain."
34
     */
35
	10[shape=plain label=PLAIN_LABEL]
36
    11[shape=diamond]
37
    12[shape=trapezium]
38
    13[shape=parallelogram]
39
    14[shape=house]
40
    15[shape=pentagon]
41
    16[shape=hexagon]
42
    17[shape=septagon]
43
    18[shape=octagon]
44
    19[shape=doublecircle]
45
    20[shape=doubleoctagon]
46
    21[shape=tripleoctagon]
47
    22[shape=invtriangle]
48
    23[shape=invtrapezium]
49
    24[shape=invhouse]
50
    25[shape=Mdiamond]
51
    26[shape=Msquare]
52
    27[shape=Mcircle]
53
    28[shape=rect]
54
    29[shape=rectangle]
55
    30[shape=square]
56
    31[shape=star]
57
    32[shape=none]
58
    33[shape=underline]
59
    34[shape=cylinder]
60
    35[shape=note]
61
    36[shape=tab]
62
    37[shape=folder]
63
    38[shape=box3d]
64
    39[shape=component]
65
    40[shape=promoter]
66
    41[shape=cds]
67
    42[shape=terminator]
68
    43[shape=utr]
69
    44[shape=primersite]
70
    45[shape=restrictionsite]
71
    46[shape=fivepoverhang]
72
    47[shape=threepoverhang]
73
    48[shape=noverhang]
74
    49[shape=assembly]
75
    50[shape=signature]
76
    51[shape=insulator]
77
    52[shape=ribosite]
78
    53[shape=rnastab]
79
    54[shape=proteasesite]
80
    55[shape=proteinstab]
81
    56[shape=rpromoter]
82
    57[shape=rarrow]
83
    58[shape=larrow]
84
    59[shape=lpromoter]
85
}
(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotParserTests.java (-1 / +7 lines)
Lines 7-13 Link Here
7
 * http://www.eclipse.org/legal/epl-v10.html
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 *     Tamas Miklossy (itemis AG) - initial implementation (bug #477980)		
10
 *     Tamas Miklossy (itemis AG) - initial implementation (bug #477980)
11
 *                                - Add support for polygon-based node shapes (bug #441352)		
11
 *
12
 *
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.gef4.dot.tests;
14
package org.eclipse.gef4.dot.tests;
Lines 64-69 Link Here
64
		testFile("arrowshapes_invalid_modifiers.dot");
65
		testFile("arrowshapes_invalid_modifiers.dot");
65
	}
66
	}
66
67
68
	@Test
69
	public void testPolygonBasedNodeShapes() {
70
		testFile("nodeshapes_polygon_based.dot");
71
	}
72
67
	private void testFile(String fileName) {
73
	private void testFile(String fileName) {
68
		String fileContents = DotFileUtils
74
		String fileContents = DotFileUtils
69
				.read(new File(DotTestUtils.RESOURCES_TESTS + fileName));
75
				.read(new File(DotTestUtils.RESOURCES_TESTS + fileName));
(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotValidatorTests.java (+71 lines)
Lines 8-13 Link Here
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 *     Tamas Miklossy (itemis AG) - initial implementation (bug #477980)		
10
 *     Tamas Miklossy (itemis AG) - initial implementation (bug #477980)		
11
 *                                - Add support for polygon-based node shapes (bug #441352)
11
 *
12
 *
12
 *******************************************************************************/
13
 *******************************************************************************/
13
14
Lines 212-217 Link Here
212
		Assert.assertEquals(1, validationTestHelper.validate(dotAst).size());
213
		Assert.assertEquals(1, validationTestHelper.validate(dotAst).size());
213
	}
214
	}
214
215
216
	@Test
217
	public void testWrongNodeDistortion() throws Exception {
218
		String text = "graph { 1[distortion=foo] 2[distortion=\"-100.0001\"]}";
219
220
		DotAst dotAst = parserHelper.parse(text);
221
222
		validationTestHelper.assertError(dotAst,
223
				DotPackage.eINSTANCE.getAttribute(),
224
				DotAttributes.DISTORTION__N,
225
				"The value 'foo' is not a syntactically correct double: For input string: \"foo\".");
226
227
		validationTestHelper.assertError(dotAst,
228
				DotPackage.eINSTANCE.getAttribute(),
229
				DotAttributes.DISTORTION__N,
230
				"The double value '-100.0001' is not semantically correct: Value may not be smaller than -100.0");
231
232
		// verify that this is the only reported issue
233
		Assert.assertEquals(2, validationTestHelper.validate(dotAst).size());
234
	}
235
236
	@Test
237
	public void testWrongNodeShape() throws Exception {
238
		String text = "graph { 1[shape=foo] }";
239
240
		DotAst dotAst = parserHelper.parse(text);
241
242
		validationTestHelper.assertError(dotAst,
243
				DotPackage.eINSTANCE.getAttribute(), DotAttributes.SHAPE__N,
244
				"The value 'foo' is not a syntactically correct shape: Mismatched character 'o' expecting 'l'.");
245
246
		// verify that this is the only reported issue
247
		Assert.assertEquals(1, validationTestHelper.validate(dotAst).size());
248
	}
249
250
	@Test
251
	public void testWrongNodeSides() throws Exception {
252
		String text = "graph { 1[sides=foo] 2[sides=\"-1\"]}";
253
254
		DotAst dotAst = parserHelper.parse(text);
255
256
		validationTestHelper.assertError(dotAst,
257
				DotPackage.eINSTANCE.getAttribute(), DotAttributes.SIDES__N,
258
				"The value 'foo' is not a syntactically correct int: For input string: \"foo\".");
259
260
		validationTestHelper.assertError(dotAst,
261
				DotPackage.eINSTANCE.getAttribute(), DotAttributes.SIDES__N,
262
				"The int value '-1' is not semantically correct: Value may not be smaller than 0.");
263
264
		// verify that this is the only reported issue
265
		Assert.assertEquals(2, validationTestHelper.validate(dotAst).size());
266
	}
267
268
	@Test
269
	public void testWrongNodeSkew() throws Exception {
270
		String text = "graph { 1[skew=foo] 2[skew=\"-100.1\"]}";
271
272
		DotAst dotAst = parserHelper.parse(text);
273
274
		validationTestHelper.assertError(dotAst,
275
				DotPackage.eINSTANCE.getAttribute(), DotAttributes.SKEW__N,
276
				"The value 'foo' is not a syntactically correct double: For input string: \"foo\".");
277
278
		validationTestHelper.assertError(dotAst,
279
				DotPackage.eINSTANCE.getAttribute(), DotAttributes.SKEW__N,
280
				"The double value '-100.1' is not semantically correct: Value may not be smaller than -100.0");
281
282
		// verify that this is the only reported issue
283
		Assert.assertEquals(2, validationTestHelper.validate(dotAst).size());
284
	}
285
215
	private DotAst parse(String fileName) {
286
	private DotAst parse(String fileName) {
216
		DotAst dotAst = null;
287
		DotAst dotAst = null;
217
		String fileContents = DotFileUtils
288
		String fileContents = DotFileUtils
(-)a/org.eclipse.gef4.dot.ui/src/org/eclipse/gef4/dot/internal/parser/ui/DotShapeUiModule.java (+15 lines)
Added Link Here
1
/*
2
 * generated by Xtext
3
 */
4
package org.eclipse.gef4.dot.internal.parser.ui;
5
6
import org.eclipse.ui.plugin.AbstractUIPlugin;
7
8
/**
9
 * Use this class to register components to be used within the IDE.
10
 */
11
public class DotShapeUiModule extends org.eclipse.gef4.dot.internal.parser.ui.AbstractDotShapeUiModule {
12
	public DotShapeUiModule(AbstractUIPlugin plugin) {
13
		super(plugin);
14
	}
15
}
(-)a/org.eclipse.gef4.dot/META-INF/MANIFEST.MF (-1 / +4 lines)
Lines 24-30 Link Here
24
 org.eclipse.gef4.dot.internal.parser.arrowtype.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
24
 org.eclipse.gef4.dot.internal.parser.arrowtype.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
25
 org.eclipse.gef4.dot.internal.parser.conversion;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
25
 org.eclipse.gef4.dot.internal.parser.conversion;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
26
 org.eclipse.gef4.dot.internal.parser.dir;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
26
 org.eclipse.gef4.dot.internal.parser.dir;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
27
 org.eclipse.gef4.dot.internal.parser.rankdir;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
28
 org.eclipse.gef4.dot.internal.parser.dot;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
27
 org.eclipse.gef4.dot.internal.parser.dot;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
29
 org.eclipse.gef4.dot.internal.parser.dot.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
28
 org.eclipse.gef4.dot.internal.parser.dot.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
30
 org.eclipse.gef4.dot.internal.parser.dot.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
29
 org.eclipse.gef4.dot.internal.parser.dot.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
Lines 35-43 Link Here
35
 org.eclipse.gef4.dot.internal.parser.point;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
34
 org.eclipse.gef4.dot.internal.parser.point;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
36
 org.eclipse.gef4.dot.internal.parser.point.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
35
 org.eclipse.gef4.dot.internal.parser.point.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
37
 org.eclipse.gef4.dot.internal.parser.point.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
36
 org.eclipse.gef4.dot.internal.parser.point.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
37
 org.eclipse.gef4.dot.internal.parser.rankdir;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
38
 org.eclipse.gef4.dot.internal.parser.scoping;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
38
 org.eclipse.gef4.dot.internal.parser.scoping;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
39
 org.eclipse.gef4.dot.internal.parser.serializer;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
39
 org.eclipse.gef4.dot.internal.parser.serializer;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
40
 org.eclipse.gef4.dot.internal.parser.services;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
40
 org.eclipse.gef4.dot.internal.parser.services;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
41
 org.eclipse.gef4.dot.internal.parser.shape;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
42
 org.eclipse.gef4.dot.internal.parser.shape.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
43
 org.eclipse.gef4.dot.internal.parser.shape.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
41
 org.eclipse.gef4.dot.internal.parser.splinetype;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
44
 org.eclipse.gef4.dot.internal.parser.splinetype;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
42
 org.eclipse.gef4.dot.internal.parser.splinetype.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
45
 org.eclipse.gef4.dot.internal.parser.splinetype.impl;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
43
 org.eclipse.gef4.dot.internal.parser.splinetype.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
46
 org.eclipse.gef4.dot.internal.parser.splinetype.util;x-friends:="org.eclipse.gef4.dot.tests,org.eclipse.gef4.dot.ui",
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotAttributes.java (-2 / +259 lines)
Lines 10-15 Link Here
10
 *     Matthias Wienand (itemis AG) - initial API and implementation
10
 *     Matthias Wienand (itemis AG) - initial API and implementation
11
 *     Alexander Nyßen (itemis AG)  - initial API and implementation
11
 *     Alexander Nyßen (itemis AG)  - initial API and implementation
12
 *     Tamas Miklossy (itemis AG)   - Add support for arrowType edge decorations (bug #477980)
12
 *     Tamas Miklossy (itemis AG)   - Add support for arrowType edge decorations (bug #477980)
13
 *                                  - Add support for polygon-based node shapes (bug #441352)
13
 *
14
 *
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.gef4.dot.internal;
16
package org.eclipse.gef4.dot.internal;
Lines 28-33 Link Here
28
import org.eclipse.gef4.dot.internal.parser.dot.GraphType;
29
import org.eclipse.gef4.dot.internal.parser.dot.GraphType;
29
import org.eclipse.gef4.dot.internal.parser.point.Point;
30
import org.eclipse.gef4.dot.internal.parser.point.Point;
30
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
31
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
32
import org.eclipse.gef4.dot.internal.parser.shape.Shape;
31
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType;
33
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType;
32
import org.eclipse.gef4.dot.internal.parser.validation.DotJavaValidator;
34
import org.eclipse.gef4.dot.internal.parser.validation.DotJavaValidator;
33
import org.eclipse.gef4.dot.internal.parser.validation.DotJavaValidator.AttributeContext;
35
import org.eclipse.gef4.dot.internal.parser.validation.DotJavaValidator.AttributeContext;
Lines 102-107 Link Here
102
	 * Specifies the 'dir' attribute of an edge.
104
	 * Specifies the 'dir' attribute of an edge.
103
	 */
105
	 */
104
	public static final String DIR__E = "dir";
106
	public static final String DIR__E = "dir";
107
108
	/**
109
	 * Specifies the 'distortion' attribute of a node.
110
	 */
111
	public static final String DISTORTION__N = "distortion";
105
112
106
	/**
113
	/**
107
	 * Specifies the 'forceLabels' attribute of a graph.
114
	 * Specifies the 'forceLabels' attribute of a graph.
Lines 217-222 Link Here
217
	 * which is used for laying out the graph.
224
	 * which is used for laying out the graph.
218
	 */
225
	 */
219
	public static final String RANKDIR__G = "rankdir";
226
	public static final String RANKDIR__G = "rankdir";
227
228
	/**
229
	 * Specifies the 'shape' attribute of a node.
230
	 */
231
	public static final String SHAPE__N = "shape";
232
233
	/**
234
	 * Specifies the 'sides' attribute of a node.
235
	 */
236
	public static final String SIDES__N = "sides";
237
238
	/**
239
	 * Specifies the 'skew' attribute of a node.
240
	 */
241
	public static final String SKEW__N = "skew";
220
242
221
	/**
243
	/**
222
	 * Specifies the name of the 'splines' attribute. It is used to control how
244
	 * Specifies the name of the 'splines' attribute. It is used to control how
Lines 430-437 Link Here
430
	 * 
452
	 * 
431
	 * @param edge
453
	 * @param edge
432
	 *            The {@link Edge} for which to return the value of the
454
	 *            The {@link Edge} for which to return the value of the
433
	 *            {@link #ARROWSIZE__E} property, parsed as an {@link ArrowType}
455
	 *            {@link #ARROWSIZE__E} property, parsed as a {@link Double} .
434
	 *            .
435
	 * 
456
	 * 
436
	 * @return The value of the {@link #ARROWSIZE__E} property of the given
457
	 * @return The value of the {@link #ARROWSIZE__E} property of the given
437
	 *         {@link Edge}.
458
	 *         {@link Edge}.
Lines 499-504 Link Here
499
	public static DirType getDirParsed(Edge edge) {
520
	public static DirType getDirParsed(Edge edge) {
500
		return DotLanguageSupport.parseAttributeValue(
521
		return DotLanguageSupport.parseAttributeValue(
501
				DotLanguageSupport.DIRTYPE_PARSER, getDir(edge));
522
				DotLanguageSupport.DIRTYPE_PARSER, getDir(edge));
523
	}
524
525
	/**
526
	 * Returns the value of the {@link #DISTORTION__N} property of the given
527
	 * {@link Node}.
528
	 * 
529
	 * @param node
530
	 *            The {@link Node} for which to return the value of the
531
	 *            {@link #DISTORTION__N} property.
532
	 * @return The value of the {@link #DISTORTION__N} property of the given
533
	 *         {@link Node}.
534
	 */
535
	public static String getDistortion(Node node) {
536
		return (String) node.attributesProperty().get(DISTORTION__N);
537
	}
538
539
	/**
540
	 * Returns the (parsed) value of the {@link #DISTORTION__N} property of the
541
	 * given {@link Node}.
542
	 * 
543
	 * @param node
544
	 *            The {@link Node} for which to return the value of the
545
	 *            {@link #DISTORTION__N} property, parsed as a {@link Double} .
546
	 * 
547
	 * @return The value of the {@link #DISTORTION__N} property of the given
548
	 *         {@link Node}.
549
	 */
550
	public static Double getDistortionParsed(Node node) {
551
		return DotLanguageSupport.parseAttributeValue(
552
				DotLanguageSupport.DOUBLE_PARSER, getDistortion(node));
502
	}
553
	}
503
554
504
	/**
555
	/**
Lines 860-865 Link Here
860
	}
911
	}
861
912
862
	/**
913
	/**
914
	 * Returns the value of the {@link #SHAPE__N} property of the given
915
	 * {@link Node}.
916
	 * 
917
	 * @param node
918
	 *            The {@link Node} for which to return the value of the
919
	 *            {@link #SHAPE__N} property.
920
	 * @return The value of the {@link #SHAPE__N} property of the given
921
	 *         {@link Node}.
922
	 */
923
	public static String getShape(Node node) {
924
		return (String) node.attributesProperty().get(SHAPE__N);
925
	}
926
927
	/**
928
	 * Returns the (parsed) value of the {@link #SHAPE__N} property of the given
929
	 * {@link Node}.
930
	 * 
931
	 * @param node
932
	 *            The {@link Node} for which to return the value of the
933
	 *            {@link #SHAPE__N} property, parsed as an {@link Shape} .
934
	 * @return The value of the {@link #SHAPE__N} property of the given
935
	 *         {@link Node}.
936
	 */
937
	public static Shape getShapeParsed(Node node) {
938
		return DotLanguageSupport.parseAttributeValue(
939
				DotLanguageSupport.SHAPE_PARSER, getShape(node));
940
	}
941
942
	/**
943
	 * Returns the value of the {@link #SIDES__N} property of the given
944
	 * {@link Node}.
945
	 * 
946
	 * @param node
947
	 *            The {@link Node} for which to return the value of the
948
	 *            {@link #SIDES__N} property.
949
	 * @return The value of the {@link #SIDES__N} property of the given
950
	 *         {@link Node}.
951
	 */
952
	public static String getSides(Node node) {
953
		return (String) node.attributesProperty().get(SIDES__N);
954
	}
955
956
	/**
957
	 * Returns the (parsed) value of the {@link #SIDES__N} property of the given
958
	 * {@link Node}.
959
	 * 
960
	 * @param node
961
	 *            The {@link Node} for which to return the value of the
962
	 *            {@link #SIDES__N} property, parsed as a {@link Integer} .
963
	 * 
964
	 * @return The value of the {@link #SIDES__N} property of the given
965
	 *         {@link Node}.
966
	 */
967
	public static Integer getSidesParsed(Node node) {
968
		return DotLanguageSupport.parseAttributeValue(
969
				DotLanguageSupport.INT_PARSER, getSides(node));
970
	}
971
972
	/**
973
	 * Returns the value of the {@link #SKEW__N} property of the given
974
	 * {@link Node}.
975
	 * 
976
	 * @param node
977
	 *            The {@link Node} for which to return the value of the
978
	 *            {@link #SKEW__N} property.
979
	 * @return The value of the {@link #SKEW__N} property of the given
980
	 *         {@link Node}.
981
	 */
982
	public static String getSkew(Node node) {
983
		return (String) node.attributesProperty().get(SKEW__N);
984
	}
985
986
	/**
987
	 * Returns the (parsed) value of the {@link #SKEW__N} property of the given
988
	 * {@link Node}.
989
	 * 
990
	 * @param node
991
	 *            The {@link Node} for which to return the value of the
992
	 *            {@link #SKEW__N} property, parsed as a {@link Double} .
993
	 * 
994
	 * @return The value of the {@link #SKEW__N} property of the given
995
	 *         {@link Node}.
996
	 */
997
	public static Double getSkewParsed(Node node) {
998
		return DotLanguageSupport.parseAttributeValue(
999
				DotLanguageSupport.DOUBLE_PARSER, getSkew(node));
1000
	}
1001
1002
	/**
863
	 * Returns the value of the {@link #SPLINES__G} attribute of the given
1003
	 * Returns the value of the {@link #SPLINES__G} attribute of the given
864
	 * {@link Graph}.
1004
	 * {@link Graph}.
865
	 * 
1005
	 * 
Lines 1193-1198 Link Here
1193
	 */
1333
	 */
1194
	public static void setDirParsed(Edge edge, DirType dirParsed) {
1334
	public static void setDirParsed(Edge edge, DirType dirParsed) {
1195
		setDir(edge, dirParsed.toString());
1335
		setDir(edge, dirParsed.toString());
1336
	}
1337
1338
	/**
1339
	 * Sets the {@link #DISTORTION__N} property of the given {@link Node} to the
1340
	 * given <i>distortion</i> value.
1341
	 * 
1342
	 * @param node
1343
	 *            The {@link Node} for which to change the value of the
1344
	 *            {@link #DISTORTION__N} property.
1345
	 * @param distortion
1346
	 *            The new value for the {@link #DISTORTION__N} property.
1347
	 */
1348
	public static void setDistortion(Node node, String distortion) {
1349
		validate(AttributeContext.NODE, DISTORTION__N, distortion);
1350
		node.attributesProperty().put(DISTORTION__N, distortion);
1351
	}
1352
1353
	/**
1354
	 * Sets the {@link #DISTORTION__N} property of the given {@link Node} to the
1355
	 * given <i>distortion</i> value.
1356
	 * 
1357
	 * @param node
1358
	 *            The {@link Node} for which to change the value of the
1359
	 *            {@link #DISTORTION__N} property.
1360
	 * @param distortionParsed
1361
	 *            The new value for the {@link #DISTORTION__N} property.
1362
	 */
1363
	public static void setDistortionParsed(Node node, Double distortionParsed) {
1364
		setSkew(node, distortionParsed.toString());
1196
	}
1365
	}
1197
1366
1198
	/**
1367
	/**
Lines 1537-1542 Link Here
1537
	}
1706
	}
1538
1707
1539
	/**
1708
	/**
1709
	 * Sets the {@link #SIDES__N} property of the given {@link Node} to the
1710
	 * given <i>sides</i> value.
1711
	 * 
1712
	 * @param node
1713
	 *            The {@link Node} for which to change the value of the
1714
	 *            {@link #SIDES__N} property.
1715
	 * @param sides
1716
	 *            The new value for the {@link #SIDES__N} property.
1717
	 */
1718
	public static void setSides(Node node, String sides) {
1719
		validate(AttributeContext.NODE, SIDES__N, sides);
1720
		node.attributesProperty().put(SIDES__N, sides);
1721
	}
1722
1723
	/**
1724
	 * Sets the {@link #SIDES__N} property of the given {@link Node} to the
1725
	 * given <i>sides</i> value.
1726
	 * 
1727
	 * @param node
1728
	 *            The {@link Node} for which to change the value of the
1729
	 *            {@link #SIDES__N} property.
1730
	 * @param sidesParsed
1731
	 *            The new value for the {@link #SIDES__N} property.
1732
	 */
1733
	public static void setSidesParsed(Node node, Integer sidesParsed) {
1734
		setSides(node, sidesParsed.toString());
1735
	}
1736
1737
	/**
1738
	 * Sets the {@link #SHAPE__N} property of the given {@link Node} to the
1739
	 * given <i>shape</i> value.
1740
	 * 
1741
	 * @param node
1742
	 *            The {@link Node} for which to change the value of the
1743
	 *            {@link #SHAPE__N} property.
1744
	 * @param shape
1745
	 *            The new value for the {@link #SHAPE__N} property.
1746
	 */
1747
	public static void setShape(Node node, String shape) {
1748
		validate(AttributeContext.NODE, SHAPE__N, shape);
1749
		node.attributesProperty().put(SHAPE__N, shape);
1750
	}
1751
1752
	/**
1753
	 * Sets the {@link #SHAPE__N} property of the given {@link Node} to the
1754
	 * given <i>shape</i> value.
1755
	 * 
1756
	 * @param node
1757
	 *            The {@link Node} for which to change the value of the
1758
	 *            {@link #SHAPE__N} property.
1759
	 * @param shapeParsed
1760
	 *            The new value for the {@link #SHAPE__N} property.
1761
	 */
1762
	public static void setShapeParsed(Node node, Shape shapeParsed) {
1763
		setShape(node,
1764
				serialize(DotLanguageSupport.SHAPE_SERIALIZER, shapeParsed));
1765
	}
1766
1767
	/**
1768
	 * Sets the {@link #SKEW__N} property of the given {@link Node} to the given
1769
	 * <i>skew</i> value.
1770
	 * 
1771
	 * @param node
1772
	 *            The {@link Node} for which to change the value of the
1773
	 *            {@link #SKEW__N} property.
1774
	 * @param skew
1775
	 *            The new value for the {@link #SKEW__N} property.
1776
	 */
1777
	public static void setSkew(Node node, String skew) {
1778
		validate(AttributeContext.NODE, SKEW__N, skew);
1779
		node.attributesProperty().put(SKEW__N, skew);
1780
	}
1781
1782
	/**
1783
	 * Sets the {@link #SKEW__N} property of the given {@link Node} to the given
1784
	 * <i>skew</i> value.
1785
	 * 
1786
	 * @param node
1787
	 *            The {@link Node} for which to change the value of the
1788
	 *            {@link #SKEW__N} property.
1789
	 * @param skewParsed
1790
	 *            The new value for the {@link #SKEW__N} property.
1791
	 */
1792
	public static void setSkewParsed(Node node, Double skewParsed) {
1793
		setSkew(node, skewParsed.toString());
1794
	}
1795
1796
	/**
1540
	 * Sets the {@link #SPLINES__G} attribute of the given {@link Graph} to the
1797
	 * Sets the {@link #SPLINES__G} attribute of the given {@link Graph} to the
1541
	 * given value.
1798
	 * given value.
1542
	 * 
1799
	 * 
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java (+26 lines)
Lines 10-15 Link Here
10
 *     Fabian Steeg                - initial API and implementation (bug #277380)                     
10
 *     Fabian Steeg                - initial API and implementation (bug #277380)                     
11
 *     Alexander Nyßen (itemis AG) - several refactorings and additions (bugs #487081, #489793)
11
 *     Alexander Nyßen (itemis AG) - several refactorings and additions (bugs #487081, #489793)
12
 *     Tamas Miklossy  (itemis AG) - support for arrowType edge decorations (bug #477980)
12
 *     Tamas Miklossy  (itemis AG) - support for arrowType edge decorations (bug #477980)
13
 *                                 - support for polygon-based node shapes (bug #441352)
13
 *                                   
14
 *                                   
14
 *******************************************************************************/
15
 *******************************************************************************/
15
16
Lines 216-221 Link Here
216
		// name (from grammar definition, not attribute)
217
		// name (from grammar definition, not attribute)
217
		Node node = node(escaped(nodeStmt.getNode().getName()));
218
		Node node = node(escaped(nodeStmt.getNode().getName()));
218
219
220
		// distortion
221
		String distortion = getAttributeValue(nodeStmt,
222
				DotAttributes.DISTORTION__N);
223
		if (distortion != null) {
224
			DotAttributes.setDistortion(node, distortion);
225
		}
226
219
		// id
227
		// id
220
		String id = getAttributeValue(nodeStmt, DotAttributes.ID__GNE);
228
		String id = getAttributeValue(nodeStmt, DotAttributes.ID__GNE);
221
		if (id != null) {
229
		if (id != null) {
Lines 257-262 Link Here
257
		if (height != null) {
265
		if (height != null) {
258
			DotAttributes.setHeight(node, height);
266
			DotAttributes.setHeight(node, height);
259
		}
267
		}
268
269
		// shape
270
		String shape = getAttributeValue(nodeStmt, DotAttributes.SHAPE__N);
271
		if (shape != null) {
272
			DotAttributes.setShape(node, shape);
273
		}
274
275
		// sides
276
		String sides = getAttributeValue(nodeStmt, DotAttributes.SIDES__N);
277
		if (sides != null) {
278
			DotAttributes.setSides(node, sides);
279
		}
280
281
		// skew
282
		String skew = getAttributeValue(nodeStmt, DotAttributes.SKEW__N);
283
		if (skew != null) {
284
			DotAttributes.setSkew(node, skew);
285
		}
260
		return super.caseNodeStmt(nodeStmt);
286
		return super.caseNodeStmt(nodeStmt);
261
	}
287
	}
262
288
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotLanguageSupport.java (+49 lines)
Lines 8-13 Link Here
8
 *
8
 *
9
 * Contributors:
9
 * Contributors:
10
 *     Alexander Nyßen (itemis AG) - initial API and implementation
10
 *     Alexander Nyßen (itemis AG) - initial API and implementation
11
 *     Tamas Miklossy  (itemis AG) - Add support for polygon-based node shapes (bug #441352)
11
 *
12
 *
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.gef4.dot.internal;
14
package org.eclipse.gef4.dot.internal;
Lines 20-33 Link Here
20
import org.eclipse.emf.common.util.Diagnostic;
21
import org.eclipse.emf.common.util.Diagnostic;
21
import org.eclipse.gef4.dot.internal.parser.DotArrowTypeStandaloneSetup;
22
import org.eclipse.gef4.dot.internal.parser.DotArrowTypeStandaloneSetup;
22
import org.eclipse.gef4.dot.internal.parser.DotPointStandaloneSetup;
23
import org.eclipse.gef4.dot.internal.parser.DotPointStandaloneSetup;
24
import org.eclipse.gef4.dot.internal.parser.DotShapeStandaloneSetup;
23
import org.eclipse.gef4.dot.internal.parser.DotSplineTypeStandaloneSetup;
25
import org.eclipse.gef4.dot.internal.parser.DotSplineTypeStandaloneSetup;
24
import org.eclipse.gef4.dot.internal.parser.dir.DirType;
26
import org.eclipse.gef4.dot.internal.parser.dir.DirType;
25
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotArrowTypeParser;
27
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotArrowTypeParser;
26
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotPointParser;
28
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotPointParser;
29
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotShapeParser;
27
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotSplineTypeParser;
30
import org.eclipse.gef4.dot.internal.parser.parser.antlr.DotSplineTypeParser;
28
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
31
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
29
import org.eclipse.gef4.dot.internal.parser.validation.DotArrowTypeJavaValidator;
32
import org.eclipse.gef4.dot.internal.parser.validation.DotArrowTypeJavaValidator;
30
import org.eclipse.gef4.dot.internal.parser.validation.DotPointJavaValidator;
33
import org.eclipse.gef4.dot.internal.parser.validation.DotPointJavaValidator;
34
import org.eclipse.gef4.dot.internal.parser.validation.DotShapeJavaValidator;
31
import org.eclipse.gef4.dot.internal.parser.validation.DotSplineTypeJavaValidator;
35
import org.eclipse.gef4.dot.internal.parser.validation.DotSplineTypeJavaValidator;
32
import org.eclipse.xtext.parser.IParseResult;
36
import org.eclipse.xtext.parser.IParseResult;
33
import org.eclipse.xtext.parser.IParser;
37
import org.eclipse.xtext.parser.IParser;
Lines 255-260 Link Here
255
		}
259
		}
256
	};
260
	};
257
261
262
	/**
263
	 * A parser used to parse DOT int values.
264
	 */
265
	public static IPrimitiveValueParser<Integer> INT_PARSER = new IPrimitiveValueParser<Integer>() {
266
267
		@Override
268
		public IPrimitiveValueParseResult<Integer> parse(String rawValue) {
269
			if (rawValue == null) {
270
				return null;
271
			}
272
			try {
273
				int parsedValue = Integer.parseInt(rawValue);
274
				return new PrimitiveValueParseResultImpl<>(
275
						new Integer(parsedValue));
276
			} catch (NumberFormatException exception) {
277
				return new PrimitiveValueParseResultImpl<>(Collections
278
						.<Diagnostic> singletonList(new BasicDiagnostic(
279
								Diagnostic.ERROR, rawValue, -1,
280
								exception.getMessage(), new Object[] {})));
281
			}
282
		}
283
	};
284
258
	private static final Injector arrowTypeInjector = new DotArrowTypeStandaloneSetup()
285
	private static final Injector arrowTypeInjector = new DotArrowTypeStandaloneSetup()
259
			.createInjectorAndDoEMFRegistration();
286
			.createInjectorAndDoEMFRegistration();
260
287
Lines 298-303 Link Here
298
	public static final DotPointJavaValidator POINT_VALIDATOR = pointInjector
325
	public static final DotPointJavaValidator POINT_VALIDATOR = pointInjector
299
			.getInstance(DotPointJavaValidator.class);
326
			.getInstance(DotPointJavaValidator.class);
300
327
328
	private static final Injector shapeInjector = new DotShapeStandaloneSetup()
329
			.createInjectorAndDoEMFRegistration();
330
331
	/**
332
	 * The validator for shape attribute values.
333
	 */
334
	// TODO: move to dotjavaValidator
335
	public static final DotShapeJavaValidator SHAPE_VALIDATOR = shapeInjector
336
			.getInstance(DotShapeJavaValidator.class);
337
338
	/**
339
	 * The parser for shape attribute values.
340
	 */
341
	public static final DotShapeParser SHAPE_PARSER = shapeInjector
342
			.getInstance(DotShapeParser.class);
343
344
	/**
345
	 * The serializer for shape attribute values.
346
	 */
347
	public static final ISerializer SHAPE_SERIALIZER = shapeInjector
348
			.getInstance(ISerializer.class);
349
301
	private static final Injector splineTypeInjector = new DotSplineTypeStandaloneSetup()
350
	private static final Injector splineTypeInjector = new DotSplineTypeStandaloneSetup()
302
			.createInjectorAndDoEMFRegistration();
351
			.createInjectorAndDoEMFRegistration();
303
352
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/DotShape.xtext (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2016 itemis AG and others.
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Tamas Miklossy (itemis AG) - initial API and implementation (bug #441352)
11
 *     
12
 *******************************************************************************/
13
grammar org.eclipse.gef4.dot.internal.parser.DotShape
14
15
generate shape "http://www.eclipse.org/gef4/dot/internal/parser/DotShape"
16
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
17
18
Shape: 
19
	shape = (PolygonBasedShape | RecordBasedShape);
20
21
PolygonBasedShape:
22
	shape = PolygonBasedNodeShape;
23
24
RecordBasedShape:
25
	shape = RecordBasedNodeShape;
26
27
enum PolygonBasedNodeShape:
28
	box | polygon | ellipse | oval | circle | point | egg | triangle | plaintext | plain | diamond | trapezium | parallelogram | house |
29
	pentagon | hexagon | septagon | octagon | doublecircle | doubleoctagon | tripleoctagon | invtriangle | invtrapezium | invhouse | 
30
	Mdiamond | Msquare | Mcircle | rect | rectangle | square | star | none | underline | cylinder | note | tab | folder | box3d | 
31
	component | promoter | cds | terminator | utr | primersite | restrictionsite | fivepoverhang | threepoverhang | noverhang | 
32
	assembly |signature | insulator | ribosite | rnastab | proteasesite | proteinstab | rpromoter | rarrow | larrow | lpromoter;
33
34
enum RecordBasedNodeShape:
35
	record | Mrecord; 
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/DotShapeRuntimeModule.java (+11 lines)
Added Link Here
1
/*
2
 * generated by Xtext
3
 */
4
package org.eclipse.gef4.dot.internal.parser;
5
6
/**
7
 * Use this class to register components to be used at runtime / without the Equinox extension registry.
8
 */
9
public class DotShapeRuntimeModule extends org.eclipse.gef4.dot.internal.parser.AbstractDotShapeRuntimeModule {
10
11
}
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/DotShapeStandaloneSetup.java (+16 lines)
Added Link Here
1
/*
2
 * generated by Xtext
3
 */
4
package org.eclipse.gef4.dot.internal.parser;
5
6
/**
7
 * Initialization support for running Xtext languages 
8
 * without equinox extension registry
9
 */
10
public class DotShapeStandaloneSetup extends DotShapeStandaloneSetupGenerated{
11
12
	public static void doSetup() {
13
		new DotShapeStandaloneSetup().createInjectorAndDoEMFRegistration();
14
	}
15
}
16
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/GenerateDot.mwe2 (+32 lines)
Lines 11-16 Link Here
11
 *                        integration of attribute grammars
11
 *                        integration of attribute grammars
12
 *      Tamas Miklossy  - support for junit test plugin generation
12
 *      Tamas Miklossy  - support for junit test plugin generation
13
 *                      - support for formatter API generation
13
 *                      - support for formatter API generation
14
 *                      - integration of shape attribute grammar 
14
 *******************************************************************************/
15
 *******************************************************************************/
15
module org.eclipse.gef4.dot.internal.parser.Dot
16
module org.eclipse.gef4.dot.internal.parser.Dot
16
17
Lines 202-206 Link Here
202
			// generates junit test support classes into Generator#pathTestProject
203
			// generates junit test support classes into Generator#pathTestProject
203
			fragment = junit.Junit4Fragment auto-inject {}
204
			fragment = junit.Junit4Fragment auto-inject {}
204
		}
205
		}
206
		language = auto-inject {
207
			uri = "platform:/resource/${projectName}/src/org/eclipse/gef4/dot/internal/parser/DotShape.xtext"// Java API to access grammar elements (required by several other fragments)
208
			fileExtensions = "dot_shape"
209
			fragment = grammarAccess.GrammarAccessFragment auto-inject {}
210
211
			// a custom ResourceFactory for use with EMF
212
			fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
213
214
			// generates Java API for the generated EPackages
215
			fragment = ecore.EMFGeneratorFragment auto-inject {
216
			// has to be explicitly set for headless execution (Tycho)
217
				javaModelDirectory = "/${projectName}/src-gen"
218
			}
219
220
			// Java-based validator
221
			fragment = validation.JavaValidatorFragment auto-inject {}
222
						
223
			// formatter API
224
			fragment = formatting.FormatterFragment auto-inject {}
225
226
			// serializer 2.0
227
			fragment = serializer.SerializerFragment auto-inject {
228
				generateStub = false
229
			}
230
231
			// The antlr parser generator fragment
232
			fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {}
233
234
			// generates junit test support classes into Generator#pathTestProject
235
			fragment = junit.Junit4Fragment auto-inject {}
236
		}
205
	}
237
	}
206
}
238
}
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/formatting/DotShapeFormatter.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2016 itemis AG and others.
3
 *
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *     Tamas Miklossy (itemis AG) - initial implementation
11
 *
12
 *******************************************************************************/
13
14
/*
15
 * generated by Xtext
16
 */
17
package org.eclipse.gef4.dot.internal.parser.formatting;
18
19
import org.eclipse.gef4.dot.internal.parser.services.DotShapeGrammarAccess;
20
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
21
import org.eclipse.xtext.formatting.impl.FormattingConfig;
22
23
import com.google.inject.Inject;
24
25
/**
26
 * This class contains custom formatting declarations.
27
 * 
28
 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#
29
 * formatting on how and when to use it.
30
 * 
31
 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an
32
 * example
33
 */
34
public class DotShapeFormatter extends AbstractDeclarativeFormatter {
35
36
	@Inject
37
	private DotShapeGrammarAccess grammarAccess;
38
39
	@Override
40
	protected void configureFormatting(FormattingConfig c) {
41
		// It's usually a good idea to activate the following three statements.
42
		// They will add and preserve newlines around comments
43
		// c.setLinewrap(0, 1, 2).before(grammarAccess.getSL_COMMENTRule());
44
		// c.setLinewrap(0, 1, 2).before(grammarAccess.getML_COMMENTRule());
45
		// c.setLinewrap(0, 1, 1).after(grammarAccess.getML_COMMENTRule());
46
	}
47
}
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/validation/DotJavaValidator.java (+37 lines)
Lines 51-56 Link Here
51
import org.eclipse.gef4.dot.internal.parser.dot.NodeStmt;
51
import org.eclipse.gef4.dot.internal.parser.dot.NodeStmt;
52
import org.eclipse.gef4.dot.internal.parser.dot.Subgraph;
52
import org.eclipse.gef4.dot.internal.parser.dot.Subgraph;
53
import org.eclipse.gef4.dot.internal.parser.point.PointPackage;
53
import org.eclipse.gef4.dot.internal.parser.point.PointPackage;
54
import org.eclipse.gef4.dot.internal.parser.shape.ShapePackage;
54
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypePackage;
55
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypePackage;
55
import org.eclipse.xtext.nodemodel.INode;
56
import org.eclipse.xtext.nodemodel.INode;
56
import org.eclipse.xtext.parser.IParseResult;
57
import org.eclipse.xtext.parser.IParseResult;
Lines 207-212 Link Here
207
						unquotedValue, SplinetypePackage.Literals.SPLINE_TYPE,
208
						unquotedValue, SplinetypePackage.Literals.SPLINE_TYPE,
208
						"splineType");
209
						"splineType");
209
			}
210
			}
211
		} else if (DotAttributes.SHAPE__N.equals(name)) {
212
			// validate shape using delegate parser and validator
213
			return validateObjectAttributeValue(DotLanguageSupport.SHAPE_PARSER,
214
					DotLanguageSupport.SHAPE_VALIDATOR, name, unquotedValue,
215
					ShapePackage.Literals.SHAPE, "shape");
216
		} else if (DotAttributes.SIDES__N.equals(name)) {
217
			return validateIntAttributeValue(name, unquotedValue, 0);
218
		} else if (DotAttributes.SKEW__N.equals(name)) {
219
			return validateDoubleAttributeValue(name, unquotedValue, -100.0);
220
		} else if (DotAttributes.DISTORTION__N.equals(name)) {
221
			return validateDoubleAttributeValue(name, unquotedValue, -100.0);
210
		} else if (DotAttributes.ARROWSIZE__E.equals(name)) {
222
		} else if (DotAttributes.ARROWSIZE__E.equals(name)) {
211
			return validateDoubleAttributeValue(name, unquotedValue, 0.0);
223
			return validateDoubleAttributeValue(name, unquotedValue, 0.0);
212
		} else if (DotAttributes.WIDTH__N.equals(name)) {
224
		} else if (DotAttributes.WIDTH__N.equals(name)) {
Lines 444-449 Link Here
444
		}
456
		}
445
	}
457
	}
446
458
459
	private List<Diagnostic> validateIntAttributeValue(
460
			final String attributeName, String attributeValue, int minValue) {
461
		// parse value
462
		IPrimitiveValueParseResult<Integer> parseResult = DotLanguageSupport.INT_PARSER
463
				.parse(attributeValue);
464
		if (parseResult.hasSyntaxErrors()) {
465
			return Collections.<Diagnostic> singletonList(
466
					createSyntacticAttributeValueProblem(attributeValue, "int",
467
							getFormattedSyntaxErrorMessages(parseResult),
468
							attributeName));
469
		} else {
470
			// validate value
471
			if (parseResult.getParsedValue().intValue() < minValue) {
472
				return Collections
473
						.<Diagnostic> singletonList(
474
								createSemanticAttributeValueProblem(
475
										Diagnostic.ERROR, attributeValue, "int",
476
										"Value may not be smaller than "
477
												+ minValue + ".",
478
										attributeName));
479
			}
480
			return Collections.emptyList();
481
		}
482
	}
483
447
	private String getFormattedValues(Set<String> values) {
484
	private String getFormattedValues(Set<String> values) {
448
		StringBuilder sb = new StringBuilder();
485
		StringBuilder sb = new StringBuilder();
449
		for (String value : new TreeSet<>(values)) {
486
		for (String value : new TreeSet<>(values)) {
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/validation/DotShapeJavaValidator.java (+19 lines)
Added Link Here
1
/*
2
 * generated by Xtext
3
 */
4
package org.eclipse.gef4.dot.internal.parser.validation;
5
6
/**
7
 * This class contains custom validation rules. 
8
 *
9
 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
10
 */
11
public class DotShapeJavaValidator extends org.eclipse.gef4.dot.internal.parser.validation.AbstractDotShapeJavaValidator {
12
13
//	@Check
14
//	public void checkGreetingStartsWithCapital(Greeting greeting) {
15
//		if (!Character.isUpperCase(greeting.getName().charAt(0))) {
16
//			warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME);
17
//		}
18
//	}
19
}

Return to bug 441352