blob: 746fe141cf97cc795b813a4c3b5018015c017f05 (
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
|
/**
* Copyright (c) 2007, 2009, 2013 Borland Software Corporation 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:
* Dmitry Stadnik (Borland) - initial API and implementation
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
* Ansgar Radermacher (CEA LIST) - added support for EMF validation
*/
package aspects.xpt.providers
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.gmf.codegen.gmfgen.GenDiagram
import xpt.Common
import xpt.editor.Editor
import xpt.editor.VisualIDRegistry
/**
* FIXME: [MG] monolithic template with most of the code "same-generated".
* Unfortunately, a lot of the logic is based around «IF editorGen.application == null» and we don't have a good ways to deal with taht in GMFT-runtimw
*/
@Singleton class ValidationDecoratorProvider extends xpt.providers.ValidationDecoratorProvider{
@Inject extension Common;
@Inject Editor xptEditor;
@Inject VisualIDRegistry xptVisualIDRegistry;
override ValidationDecoratorProvider(GenDiagram it) '''
«copyright(editorGen)»
package «packageName(it)»;
«generatedClassComment»
public class «className(it)»
extends org.eclipse.papyrus.uml.diagram.common.providers.ValidationDecoratorProvider
implements org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider {
«generatedMemberComment»
public void createDecorators(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget) {
org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) decoratorTarget.getAdapter(org.eclipse.gef.EditPart.class);
if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart ||
editPart instanceof org.eclipse.gef.editparts.AbstractConnectionEditPart) {
Object model = editPart.getModel();
if ((model instanceof org.eclipse.gmf.runtime.notation.View)) {
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) model;
if (!(view instanceof org.eclipse.gmf.runtime.notation.Edge) && !view.isSetElement()) {
return;
}
}
org.eclipse.gef.EditDomain ed = editPart.getViewer().getEditDomain();
if (!(ed instanceof org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain)) {
return;
}
if (((org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) ed).getEditorPart() instanceof
«xptEditor.qualifiedClassName(editorGen.editor)») {
decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget));
}
}
}
«generatedMemberComment»
public boolean provides(org.eclipse.gmf.runtime.common.core.service.IOperation operation) {
if (!(operation instanceof org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation)) {
return false;
}
org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget decoratorTarget =
((org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation) operation).getDecoratorTarget();
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) decoratorTarget.getAdapter(
org.eclipse.gmf.runtime.notation.View.class);
return view != null && «VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(view));
}
«additions(it)»
}
'''
}
|