blob: d6e4ef71e3e30a246bf02a06fb751c4e6a780567 (
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
|
/*****************************************************************************
* Copyright (c) 2015 Christian W. Damus 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:
* Christian W. Damus - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.dev.assistants.codegen.generator
import javax.inject.Inject
import javax.inject.Singleton
import org.eclipse.papyrus.infra.gmfdiag.assistant.AssistantFactory
import org.eclipse.papyrus.infra.gmfdiag.assistant.ModelingAssistantProvider
import org.eclipse.papyrus.uml.profile.elementtypesconfigurations.generator.UMLElementTypes
import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration
import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator
/**
* Transformation rule for generating a {@link ModelingAssistantProvider} from a UML {@link Profile}.
*/
@Singleton
class ModelingAssistantProviderRule extends org.eclipse.papyrus.uml.profile.assistants.generator.ModelingAssistantProviderRule {
static extension AssistantFactory assistantFactory = AssistantFactory.eINSTANCE
@Inject extension ElementTypeToAssistantRule
@Inject extension GMFGenToAssistantRule
@Inject extension UMLElementTypes
def create createModelingAssistantProvider toModelingAssistantProvider(ElementTypeSetConfiguration elementTypeSet) {
name = elementTypeSet.name
elementTypeSet.elementTypeConfigurations.forEach[ type |
elementTypeIDs.add(type.identifier)
if (!type.relationship) {
// Popup assistants to create non-relationships
popupAssistants.add(type.toPopupAssistant)
} else {
relationshipTypeIDs.add(type.identifier)
connectionAssistants.add(type.toConnectionAssistant)
}
]
}
def create createModelingAssistantProvider toModelingAssistantProvider(GenEditorGenerator editor) {
name = editor.modelID
elementTypeIDs.addAll(editor.diagram.validNodes.map[elementType?.uniqueIdentifier].filterNull)
relationshipTypeIDs.addAll(editor.diagram.validLinks.map[elementType?.uniqueIdentifier].filterNull)
elementTypeIDs.addAll(relationshipTypeIDs)
popupAssistants.addAll(editor.diagram.validNodes.map[toPopupAssistant])
connectionAssistants.addAll(editor.diagram.validLinks.map[toConnectionAssistant])
}
}
|