Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eee24c2d86d062e61578b2bde32f69d6d66bc973 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import xpt.GlobalVarOperations;
import xpt.StringOperations;

modeltype graphicalDefinition uses "http://www.eclipse.org/gmf/2006/GraphicalDefinition";

library Util;

property bordersInUse : Sequence(graphicalDefinition::CustomBorder) = Sequence {  };

helper addBorder(border : graphicalDefinition::CustomBorder) : OclVoid {
	bordersInUse := bordersInUse->including(border);
	return null
}

helper clearBorders() : OclVoid {
	bordersInUse := Sequence {  };
	return null
}

helper getBordersInUse() : Sequence(graphicalDefinition::CustomBorder) {
	return bordersInUse;
}

helper compilationUnitName(figure : graphicalDefinition::FigureDescriptor) : String {
	return figure.name.firstToUpper()
}

helper hasSourceDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean {
	return null <> figure.sourceDecoration
}

helper requiredBundles(referencedBundles : Sequence(String)) : Sequence(String) {
	return (if isFullRuntime() then Sequence { 'org.eclipse.core.runtime', 'org.eclipse.draw2d', 'org.eclipse.gmf.runtime.draw2d.ui' }->union(referencedBundles)->asOrderedSet()->asSequence()->asOrderedSet()->asSequence() else Sequence { 'org.eclipse.core.runtime', 'org.eclipse.draw2d' }->union(referencedBundles)->asOrderedSet()->asSequence()->asOrderedSet()->asSequence() endif)
}

helper additionalStaticFields() : String {
return xpandGetStringGlobalVar('outputStaticFields')
}

helper hasTargetDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean {
	return null <> figure.targetDecoration
}

helper isFullRuntime() : Boolean {
	return (if internalCheckRuntimeToken() <> null then internalCheckRuntimeToken().toLower() = 'full' else true endif)
}

helper internalCheckRuntimeToken() : String {
return xpandGetStringGlobalVar('runtimeToken')
}

helper needsField(figure : graphicalDefinition::RealFigure) : Boolean {
	return figure.descriptor <> null and figure.descriptor.accessors.figure->includes(figure)
}

helper figureVariableName(figure : graphicalDefinition::RealFigure, count : Integer) : String {
	return (if needsField(figure) then figure.figureFieldName() else (if figure.name <> null and figure.name.trim().xpandLength() > 0 then figure.name.xpandToFirstLower() + count.repr() else figure.variableNameStem() + count.repr() endif) endif)
}

helper graphicalDefinition::FigureRef::nameStem() : String {
	return self.figure.variableNameStem()
}

helper graphicalDefinition::Figure::nameStem() : String {
	return self.variableNameStem()
}

helper graphicalDefinition::Figure::variableNameStem() : String {
	return 'fig'
}

helper graphicalDefinition::RealFigure::variableNameStem() : String {
	return 'fig'
}

helper graphicalDefinition::Shape::variableNameStem() : String {
	return 'shape'
}

helper graphicalDefinition::Rectangle::variableNameStem() : String {
	return 'rect'
}

helper graphicalDefinition::RoundedRectangle::variableNameStem() : String {
	return 'rrect'
}

helper graphicalDefinition::Ellipse::variableNameStem() : String {
	return 'elli'
}

helper graphicalDefinition::Polyline::variableNameStem() : String {
	return 'polyline'
}

helper graphicalDefinition::Label::variableNameStem() : String {
	return 'l'
}

helper graphicalDefinition::DecorationFigure::variableNameStem() : String {
	return 'dec'
}

helper graphicalDefinition::ConnectionFigure::variableNameStem() : String {
	return 'conn'
}

helper graphicalDefinition::RealFigure::figureFieldName() : String {
	return figureFieldName(self.descriptor.accessors->select(a | self = a.figure)->asSequence())
}

helper figureFieldName(aaa : Sequence(graphicalDefinition::ChildAccess)) : String {
	return aaa->collect(x | x.figureFieldName())->first()
}

helper graphicalDefinition::ChildAccess::figureFieldName() : String {
	return 'f' + (if self.accessor.xpandStartsWith('get') and self.accessor.xpandLength() > 3 then self.accessor.xpandSubstring(3) else self.accessor endif)
}

helper borderLayoutConstant(layoutData : graphicalDefinition::BorderLayoutData) : String {
	return switch { case (layoutData.alignment = graphicalDefinition::Alignment::BEGINNING) (if layoutData.vertical then 'TOP' else 'LEFT' endif); case (layoutData.alignment = graphicalDefinition::Alignment::END) (if layoutData.vertical then 'BOTTOM' else 'RIGHT' endif); else 'CENTER'; }
}

helper allCustomAccessors(fd : graphicalDefinition::FigureDescriptor) : Sequence(graphicalDefinition::FigureAccessor) {
	return filterCustom(Sequence { fd.actualFigure }).customChildren
}

helper filterCustom(figures : Sequence(graphicalDefinition::Figure)) : Sequence(graphicalDefinition::CustomFigure) {
	return (if figures->isEmpty() then Sequence {  } else (figures)[graphicalDefinition::CustomFigure]->union(filterCustom((figures)[graphicalDefinition::RealFigure].children))->asOrderedSet()->asSequence() endif)->collect(it | it)->asSequence()
}


helper svgPropertyType(p : graphicalDefinition::SVGProperty) : String {
	return switch { case (p.type = graphicalDefinition::SVGPropertyType::COLOR) 'org.eclipse.swt.graphics.Color'; case (p.type = graphicalDefinition::SVGPropertyType::FLOAT) 'float'; else 'String'; }
}

Back to the top