1 package com.proalpha.pds.templates.jet.version61;
3 import com.openedge.pdt.core.template.TemplateGenerationException;
4 import com.proalpha.pds.templates.jet.IpaTemplateGenerator;
5 import com.proalpha.pds.templates.data.GeneratorSettingsConstans;
9 import com.proalpha.pds.templates.helper.CodeFormatter;
13 protected static String nl;
14 public static synchronized pABalpxxcdf create(String lineSeparator)
22 public final String NL = nl ==
null ? (System.getProperties().getProperty(
"line.separator")) : nl;
23 protected final String TEXT_1 =
"";
24 protected final String TEXT_2 = NL;
25 protected final String TEXT_3 = NL + NL +
"/* *************************** Main Block *************************** */" + NL +
"" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"/* User-Exits */" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"" + NL +
"{&{&PA-XINCLBASISNAME}_CX}" + NL +
"{&{&PA-XINCLBASISNAME}_UX}" + NL +
"{&{&PA-XINCLBASISNAME}_QX}" + NL +
"{&{&PA-XINCLBASISNAME}_XX}" + NL +
"{&{&PA-XINCLBASISNAME}_YX}" + NL +
"" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"/* Include Code */" + NL +
"/*----------------------------------------------------------------------------*/" + NL + NL;
26 protected final String TEXT_4 = NL + NL +
"/* _UIB-CODE-BLOCK-END */" + NL +
"&ANALYZE-RESUME";
31 public String generate(Map<String, Object> wizardSettings)
throws TemplateGenerationException
33 final StringBuffer stringBuffer =
new StringBuffer();
40 String xbasename = parentObject.replace(
".",
"_");
42 List<String> userExitList = (List<String>)wizardSettings.get(
"userExitList");
43 List<String> balpTemplateList = (List<String>)wizardSettings.get(
"baltTemplateList");
45 int iSpace = 80 - 35 - xbasename.length() +
"_".length() + customLevel.length() + 1;
48 String newUserExit =
"";
50 if (fileName.endsWith(
".cls")){
52 xbasename = mainClassName.concat(
"_CLS");
54 relativePath = relativePath.replace(
"/",
".");
56 iSpace = 80 - 35 - xbasename.length() - 3;
64 if (customLevel.equals(
"X")){
65 newUserExit =
"&GLOB " + xbasename +
"_INHERITS" + sBlanks + relativePath +
"." + fileName.replace(
".cls",
"");
67 newUserExit =
"&GLOB " + xbasename +
"_" + customLevel +
"_INHERITS" + sBlanks + relativePath +
"." + fileName.replace(
".cls",
"");
70 }
else if (parentObject.contains(
".fld")){
72 if (customLevel.equals(
"X")){
75 fldSuffix =
"_" + customLevel;
78 newUserExit =
"&GLOB " + xbasename + fldSuffix + sBlanks + relativePath +
"/" + fileName;
80 newUserExit =
"&GLOB " + xbasename +
"_" + customLevel +
"X" + sBlanks +
"~{" + relativePath +
"/" + fileName +
" &" + customLevel +
"X}";
84 Boolean isInList = Boolean.FALSE;
85 for (String userExit : userExitList) {
86 String userExitWithoutComment = userExit.replaceAll(
"/\\*([^*]|[\\r\\n])*\\*/",
"");
87 if (userExitWithoutComment.equals(newUserExit)) {
88 isInList = Boolean.TRUE;
93 userExitList.add(newUserExit.trim());
96 HashSet<String> hashSet =
new HashSet<String>(userExitList);
98 userExitList.addAll(hashSet);
99 Collections.sort(userExitList, String.CASE_INSENSITIVE_ORDER);
101 ListIterator<String> contentIterator = balpTemplateList.listIterator();
103 while (contentIterator.hasNext()){
105 stringBuffer.append(TEXT_1);
106 stringBuffer.append(contentIterator.next());
107 stringBuffer.append(TEXT_2);
109 stringBuffer.append(TEXT_3);
111 for(String userExit : userExitList){
113 stringBuffer.append(userExit);
114 stringBuffer.append(TEXT_2);
118 stringBuffer.append(TEXT_4);
119 stringBuffer.append(TEXT_2);
120 return stringBuffer.toString();