Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9fd68e5ecb2b60159bbe6c92c6510ceadcf3edf0 (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
/*
 * Copyright (c) 2007, 2008 Borland Software Corporation
 * 
 * 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:
 *    Artem Tikhomirov (Borland) - initial API and implementation
 */
«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
«EXTENSION xpt::GenAuditRoot»
«EXTENSION xpt::GenEditorGenerator»
«EXTENSION xpt::NativeGenAuditRoot»

«DEFINE extensions FOR gmfgen::GenEditorGenerator-»
«IF hasAudits(self)»«EXPAND extensions FOR audits»«ENDIF-»
«ENDDEFINE»

«DEFINE extensions FOR gmfgen::GenAuditRoot-»
«EXPAND extensions_emfv_constraintProviders»
«EXPAND extensions_emfv_constraintBindings»
«EXPAND extensions_emfv_uiContexts»
«ENDDEFINE»

//
// Extension point: org.eclipse.emf.validation.constraintProviders
//
«DEFINE extensions_emfv_constraintProviders FOR gmfgen::GenAuditRoot-»
   <extension point="org.eclipse.emf.validation.constraintProviders">
      «EXPAND xpt::Common::xmlGeneratedTag»
      «EXPAND declareCategory FOREACH categories-»
      <constraintProvider cache="true">
«FOREACH getAllTargetedModelPackages(self) AS p-»
         <package namespaceUri="«p.ecorePackage.nsURI»"/>
«ENDFOREACH-»
      «EXPAND defineCategory FOREACH categories-»
      </constraintProvider>
   </extension>
«ENDDEFINE»

//
// Extension point: org.eclipse.emf.validation.constraintBindings
//
«DEFINE extensions_emfv_constraintBindings FOR gmfgen::GenAuditRoot-»
   <extension point="org.eclipse.emf.validation.constraintBindings">
      «EXPAND xpt::Common::xmlGeneratedTag»
«FOREACH clientContexts->asSequence() AS ctx-»
      <clientContext default="false" id="«getQualifiedIdentity(ctx)»">
         <selector class="«ctx.getQualifiedClassName()»"/>
      </clientContext>
      <binding context="«getQualifiedIdentity(ctx)»">
         «FOREACH rules->select(r | r.target <> null and r.target.contextSelector = ctx)->asSequence() /*alternative: ctx.ruleTargets.contains(r.target)*/ AS rule-»
         <constraint ref="«editorGen.plugin.iD».«escapeXML(rule.id)»"/>
         «ENDFOREACH-»
      </binding>

«ENDFOREACH-»
   </extension>
«ENDDEFINE»

//
// Extension point: org.eclipse.emf.validation.ui.UIRegisteredClientContext
//
«DEFINE extensions_emfv_uiContexts FOR gmfgen::GenAuditRoot-»
«IF editorGen.diagram.liveValidationUIFeedback»
   <extension point="org.eclipse.emf.validation.ui.UIRegisteredClientContext">
      «EXPAND xpt::Common::xmlGeneratedTag»
«FOREACH clientContexts->asSequence() AS ctx-»
      <clientContext id="«getQualifiedIdentity(ctx)»"/>
«ENDFOREACH-»
   </extension>
«ENDIF-»
«ENDDEFINE»

«DEFINE declareCategory FOR gmfgen::GenAuditContainer-»
      <category id="«EXPAND _pathMap»" mandatory="false" name="«IF name <> null»«escapeXML(name)»«ELSE»«EXPAND _pathMap»«ENDIF»">
         <![CDATA[«(if description <> null then description else '' endif)»]]>
      </category>
«ENDDEFINE»

«DEFINE defineCategory FOR gmfgen::GenAuditContainer-»
         <constraints categories="«EXPAND _pathMap»">
         «FOREACH audits->select(a | a.target <> null and a.target.getTargetClass() <> null)->asSequence() AS audit-»
         <constraint id="«escapeXML(audit.id)»"
            «IF audit.requiresConstraintAdapter»lang="Java" class="«audit.getConstraintAdapterQualifiedClassName()»"«ELSE»lang="OCL"«ENDIF»
            name="«escapeXML((if audit.name <> null then audit.name else audit.id endif))»"
            mode="«IF audit.useInLiveMode»Live«ELSE»Batch«ENDIF»"
            severity="«audit.severity.repr()»" statusCode="200">
            «IF not audit.requiresConstraintAdapter»<![CDATA[«(if audit.rule <> null then audit.rule.body else '' endif)»]]>«ENDIF»
            <description><![CDATA[«(if audit.description <> null then audit.description else '' endif)»]]></description>
            <message><![CDATA[«IF audit.message <> null»«audit.message»«ELSE»«(if audit.name <> null then audit.name else audit.id endif)» audit violated«ENDIF»]]></message>
            <target class="«audit.target.getTargetClassModelQualifiedName()»"/>
         </constraint>
         «ENDFOREACH-»
         </constraints>
«ENDDEFINE»

«DEFINE _pathMap FOR gmfgen::GenAuditContainer»«FOREACH path->asSequence() AS p SEPARATOR '/' »«escapeXML(p.id)»«ENDFOREACH»«ENDDEFINE»

Back to the top