-
Notifications
You must be signed in to change notification settings - Fork 15
/
CommonPageBottomPattern.java
165 lines (131 loc) · 6.31 KB
/
CommonPageBottomPattern.java
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//Generated with EGF 1.6.4.202309201142
package org.polarsys.kitalpha.vp.requirements.docgen.common;
import org.eclipse.egf.common.helper.*;
import java.util.*;
import org.eclipse.emf.ecore.*;
import org.eclipse.egf.model.pattern.*;
import org.eclipse.egf.pattern.execution.*;
import org.eclipse.egf.pattern.query.*;
import org.polarsys.kitalpha.vp.requirements.docgen.utils.RequirementFileNameService;
import org.polarsys.kitalpha.vp.requirements.docgen.utils.RequirementDiagramHelper;
import org.eclipse.sirius.diagram.DSemanticDiagram;
import org.polarsys.kitalpha.doc.gen.business.core.util.LabelProviderHelper;
import org.polarsys.kitalpha.vp.requirements.docgen.utils.RequirementsServices;
import org.polarsys.kitalpha.vp.requirements.Requirements.*;
public class CommonPageBottomPattern {
protected static String nl;
public static synchronized CommonPageBottomPattern create(String lineSeparator) {
nl = lineSeparator;
CommonPageBottomPattern result = new CommonPageBottomPattern();
nl = null;
return result;
}
public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
protected final String TEXT_1 = "<h2>Diagrams displaying \"";
protected final String TEXT_2 = "\"</h2>" + NL + "<ul>";
protected final String TEXT_3 = NL + "<li>";
protected final String TEXT_4 = NL;
protected final String TEXT_5 = " " + NL + "</li>";
protected final String TEXT_6 = NL + "</ul>";
public CommonPageBottomPattern() {
//Here is the constructor
StringBuffer stringBuffer = new StringBuffer();
// add initialisation of the pattern variables (declaration has been already done).
}
public String generate(Object argument) throws Exception {
final StringBuffer stringBuffer = new StringBuffer();
InternalPatternContext ctx = (InternalPatternContext) argument;
Map<String, String> queryCtx = null;
IQuery.ParameterDescription paramDesc = null;
Node.Container currentNode = ctx.getNode();
List<Object> elementList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)
List<Object> domainFileNameServiceList = null;
//this pattern can only be called by another (i.e. it's not an entry point in execution)
for (Object elementParameter : elementList) {
for (Object domainFileNameServiceParameter : domainFileNameServiceList) {
this.element = (org.polarsys.kitalpha.vp.requirements.Requirements.ReqIFElement) elementParameter;
this.domainFileNameService = (org.polarsys.kitalpha.doc.gen.business.core.util.IFileNameService) domainFileNameServiceParameter;
if (preCondition(ctx)) {
ctx.setNode(new Node.Container(currentNode, getClass()));
orchestration(ctx);
}
}
}
ctx.setNode(currentNode);
if (ctx.useReporter()) {
ctx.getReporter().executionFinished(OutputManager.computeExecutionOutput(ctx), ctx);
}
stringBuffer.append(TEXT_4);
stringBuffer.append(TEXT_4);
return stringBuffer.toString();
}
public String orchestration(PatternContext ctx) throws Exception {
InternalPatternContext ictx = (InternalPatternContext) ctx;
method_setContext(new StringBuffer(), ictx);
method_body(new StringBuffer(), ictx);
if (ictx.useReporter()) {
Map<String, Object> parameterValues = new HashMap<String, Object>();
parameterValues.put("element", this.element);
parameterValues.put("domainFileNameService", this.domainFileNameService);
String outputWithCallBack = OutputManager.computeLoopOutput(ictx);
String loop = OutputManager.computeLoopOutputWithoutCallback(ictx);
ictx.getReporter().loopFinished(loop, outputWithCallBack, ictx, parameterValues);
}
return null;
}
protected org.polarsys.kitalpha.doc.gen.business.core.util.IFileNameService fileNameService = null;
public void set_fileNameService(org.polarsys.kitalpha.doc.gen.business.core.util.IFileNameService object) {
this.fileNameService = object;
}
protected org.polarsys.kitalpha.doc.gen.business.core.util.IDiagramHelper helper = null;
public void set_helper(org.polarsys.kitalpha.doc.gen.business.core.util.IDiagramHelper object) {
this.helper = object;
}
protected org.polarsys.kitalpha.vp.requirements.Requirements.ReqIFElement element = null;
public void set_element(org.polarsys.kitalpha.vp.requirements.Requirements.ReqIFElement object) {
this.element = object;
}
protected org.polarsys.kitalpha.doc.gen.business.core.util.IFileNameService domainFileNameService = null;
public void set_domainFileNameService(org.polarsys.kitalpha.doc.gen.business.core.util.IFileNameService object) {
this.domainFileNameService = object;
}
public Map<String, Object> getParameters() {
final Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("element", this.element);
parameters.put("domainFileNameService", this.domainFileNameService);
return parameters;
}
protected void method_body(final StringBuffer stringBuffer, final PatternContext ctx) throws Exception {
Set<DSemanticDiagram> diagramSet = RequirementsServices.getDiagramContainingObject(element);
if (diagramSet.size() >= 1) {
stringBuffer.append(TEXT_1);
stringBuffer.append(LabelProviderHelper.getText(element));
stringBuffer.append(TEXT_2);
for (DSemanticDiagram diagram : diagramSet) {
EObject eObject = diagram.getTarget();
if (eObject == null) {
//The diagram could not be exported
continue;
}
stringBuffer.append(TEXT_3);
stringBuffer.append(TEXT_4);
stringBuffer.append(RequirementsServices.getHyperlinkFromElement(diagram, domainFileNameService));
stringBuffer.append(TEXT_5);
}
stringBuffer.append(TEXT_6);
}
stringBuffer.append(TEXT_4);
InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "body", stringBuffer.toString());
}
protected void method_setContext(final StringBuffer stringBuffer, final PatternContext ctx) throws Exception {
fileNameService = RequirementFileNameService.SERVICE;
helper = new RequirementDiagramHelper();
InternalPatternContext ictx = (InternalPatternContext) ctx;
new Node.DataLeaf(ictx.getNode(), getClass(), "setContext", stringBuffer.toString());
}
public boolean preCondition(PatternContext ctx) throws Exception {
return true;
}
}