Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b7f133e410b4634051bce46c71420c5be8266641 (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
import xpt.StringOperations;

modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";

library Utils;

helper genModel::Palette::activatorFQN() : String {
	return self.diagram.editorGen.plugin.getActivatorQualifiedClassName()
}

helper genModel::AbstractToolEntry::activatorFQN() : String {
	return self.group.palette.activatorFQN()
}

helper genModel::ToolGroup::activatorFQN() : String {
	return self.palette.activatorFQN()
}

helper i18nKey(group : genModel::EntryBase) : String {
	return let rv = group.createMethodName in (if rv.xpandStartsWith('get') then rv.xpandSubstring(3) else (if rv.xpandStartsWith('create') then rv.xpandSubstring(6) else rv endif) endif)
}

helper i18nTitleKey(group : genModel::EntryBase) : String {
	return i18nKey(group) + '_title'
}

helper i18nDescKey(group : genModel::EntryBase) : String {
	return i18nKey(group) + '_desc'
}

helper collectGroups(palette : genModel::Palette) : Sequence(genModel::ToolGroup) {
	return palette.groups->asSequence()->union(palette.groups->collect(it | collectSubGroups(it)))->asOrderedSet()->asSequence()
}

helper collectSubGroups(group : genModel::ToolGroup) : Sequence(genModel::ToolGroup) {
	return let rv = (group.entries)[genModel::ToolGroup] in rv->union(rv->collect(g | collectSubGroups(g))->flatten()->asSet())->asSequence()
}

helper collectTools(palette : genModel::Palette) : Sequence(genModel::AbstractToolEntry) {
	return collectGroups(palette)->collect(g | (g.entries)[genModel::AbstractToolEntry])->flatten()
}

helper needsNodeToolEntryClass(palette : genModel::Palette) : Boolean {
	return (collectTools(palette))[genModel::ToolEntry]->exists(e | not e.genNodes->isEmpty())
}

helper needsLinkToolEntryClass(palette : genModel::Palette) : Boolean {
	return (collectTools(palette))[genModel::ToolEntry]->exists(e | not e.genLinks->isEmpty())
}

Back to the top