1 package com.proalpha.pds.templates.jet.openEdge;
3 import com.openedge.pdt.core.template.ITemplateGenerator;
4 import com.openedge.pdt.core.template.TemplateGenerationException;
5 import com.openedge.pdt.text.template.OETemplateUtil;
6 import com.openedge.pdt.core.template.ITemplateArgs;
8 import org.eclipse.ui.PlatformUI;
9 import com.proalpha.pds.templates.helper.TemplatesUtils;
13 protected static String nl;
22 public final String NL = nl ==
null ? (System.getProperties().getProperty(
"line.separator")) : nl;
23 protected final String TEXT_1 =
"&IF DEFINED(EXCLUDE-";
24 protected final String TEXT_2 =
") = 0 &THEN" + NL +
"" + NL +
"&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE ";
25 protected final String TEXT_3 =
" Method-Library";
26 protected final String TEXT_4 = NL +
"procedure ";
27 protected final String TEXT_5 =
" ";
28 protected final String TEXT_6 =
":" + NL +
"/* Description ---------------------------------------------------------------*/" + NL +
"/* */" + NL +
"/* */" + NL +
"/* */" + NL +
"/* Notes ---------------------------------------------------------------------*/" + NL +
"/* */" + NL +
"/* */" + NL +
"/* */" + NL +
"/* Parameters ----------------------------------------------------------------*/" + NL +
"/* */" + NL +
"/* <none> */" + NL +
"/* */" + NL +
"/* Examples ------------------------------------------------------------------*/" + NL +
"/* */" + NL +
"/* */" + NL +
"/* */" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"" + NL +
"/* Variables -----------------------------------------------------------------*/" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"" + NL +
"/* Buffers -------------------------------------------------------------------*/" + NL +
"" + NL +
"/*----------------------------------------------------------------------------*/" + NL +
"/* Processing */" + NL +
"/*----------------------------------------------------------------------------*/";
29 protected final String TEXT_7 = NL;
30 protected final String TEXT_8 = NL +
"/* Execute standard behavior -------------------------------------------------*/" + NL +
"" + NL +
"run dispatch('";
31 protected final String TEXT_9 =
"':U).";
32 protected final String TEXT_10 = NL + NL +
"end procedure. /* ";
33 protected final String TEXT_11 =
" */" + NL + NL;
34 protected final String TEXT_12 = NL +
"/* _UIB-CODE-BLOCK-END */" + NL +
"&ANALYZE-RESUME" + NL +
"" + NL +
"&ENDIF";
39 public String generate(ITemplateArgs argument)
throws TemplateGenerationException
41 final StringBuffer stringBuffer =
new StringBuffer();
43 String fileName = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput().getName();
46 String procedureName = argument.get(
"procedurename");
47 boolean isPrivate = argument.get(
"private").equalsIgnoreCase(
"true");
48 boolean generateCatch = Boolean.valueOf(argument.get(
"generateCatch"));
49 boolean generateFinally = Boolean.valueOf(argument.get(
"generateFinally"));
52 if(!isUserExitInclude) {
53 stringBuffer.append(TEXT_1);
54 stringBuffer.append( procedureName );
55 stringBuffer.append(TEXT_2);
56 stringBuffer.append( procedureName );
57 stringBuffer.append(TEXT_3);
59 stringBuffer.append(TEXT_4);
60 stringBuffer.append( procedureName );
61 stringBuffer.append(TEXT_5);
62 stringBuffer.append( isPrivate ?
"private" :
"" );
63 stringBuffer.append(TEXT_6);
64 stringBuffer.append(generateCatch ? OETemplateUtil.generateCatchBlock(NL) :
"" );
65 stringBuffer.append(generateFinally ? OETemplateUtil.generateFinallyBlock(NL) :
"" );
66 stringBuffer.append(TEXT_7);
67 if (procedureName.startsWith(
"local-")){
68 String parentProcedure = procedureName.replaceFirst(
"local-",
"");
69 stringBuffer.append(TEXT_8);
70 stringBuffer.append(parentProcedure);
71 stringBuffer.append(TEXT_9);
73 stringBuffer.append(TEXT_10);
74 stringBuffer.append( procedureName );
75 stringBuffer.append(TEXT_11);
76 if(!isUserExitInclude) {
77 stringBuffer.append(TEXT_12);
79 stringBuffer.append(TEXT_7);
80 return stringBuffer.toString();
static Boolean isFileUserExitInclude(String fileName)