Eclipseplugins
pAMethodLibrary.java
1 package com.proalpha.pds.templates.jet.trunk;
2 
3 import com.openedge.pdt.core.template.TemplateGenerationException;
4 import com.proalpha.pds.templates.jet.IpaTemplateGenerator;
5 import com.proalpha.pds.templates.data.GeneratorSettingsConstans;
6 
7 import java.util.Map;
8 import java.util.Date;
9 import java.text.SimpleDateFormat;
10 import com.proalpha.pds.templates.helper.CodeFormatter;
11 
12 public class pAMethodLibrary implements IpaTemplateGenerator
13 {
14  protected static String nl;
15  public static synchronized pAMethodLibrary create(String lineSeparator)
16  {
17  nl = lineSeparator;
18  pAMethodLibrary result = new pAMethodLibrary();
19  nl = null;
20  return result;
21  }
22 
23  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
24  protected final String TEXT_1 = "&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r2 GUI" + NL + "&ANALYZE-RESUME" + NL;
25  protected final String TEXT_2 = NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DECLARATIONS V-table-Win " + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */ " + NL + "&ANALYZE-RESUME" + NL + NL;
26  protected final String TEXT_3 = NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR \"Update Information\" Procedure _INLINE" + NL + "/* Actions: ? ? ? ? adm/support/proc/ds_pa_01.w */" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure" + NL + "/******************************************************************************/" + NL + "/* @COPYRIGHT@ */" + NL + "/* Project: proALPHA */" + NL + "/* */";
27  protected final String TEXT_4 = NL;
28  protected final String TEXT_5 = NL + "/* */";
29  protected final String TEXT_6 = NL + "/* Current: @PAVERSION@ as of @PADATE@/@PALASTAUTHOR@ */" + NL + "/* */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* DESCRIPTION */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* */";
30  protected final String TEXT_7 = NL + "/* */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* PARAMETERS */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* Name Description */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* HISTORY */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* @FILEHISTORY@ */" + NL + "/******************************************************************************/" + NL + "" + NL + "/*---------------------------------------------------------------------------*/" + NL + "/* Exclude any code if same library is included more than one time */" + NL + "/*---------------------------------------------------------------------------*/" + NL + "" + NL + "&IF DEFINED(PA-";
31  protected final String TEXT_8 = ") = 0 &THEN" + NL + " &GLOBAL-DEFINE PA-";
32  protected final String TEXT_9 = " YES" + NL + "" + NL + "/* Procedure Information -----------------------------------------------------*/" + NL + "" + NL + "&SCOPED-DEFINE pa-XLibBasisName ";
33  protected final String TEXT_10 = NL + NL + "/* User-Exits ----------------------------------------------------------------*/" + NL + "" + NL + "{&{&PA-XLIBBASISNAME}_CX}" + NL + "{&{&PA-XLIBBASISNAME}_UX}" + NL + "{&{&PA-XLIBBASISNAME}_QX}" + NL + "{&{&PA-XLIBBASISNAME}_XX}" + NL + "{&{&PA-XLIBBASISNAME}_YX}" + NL + "" + NL + "/* SCOPEDs -------------------------------------------------------------------*/" + NL + "" + NL + "/* Variables -----------------------------------------------------------------*/" + NL + "/*----------------------------------------------------------------------------*/" + NL + "" + NL + "/* Buffers -------------------------------------------------------------------*/" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK" + NL + "" + NL + "/* ******************** Preprocessor Definitions ******************** */" + NL + "" + NL + "" + NL + "" + NL + "/* _UIB-PREPROCESSOR-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "" + NL + "/* *********************** Procedure Settings ************************ */" + NL + "" + NL + "&ANALYZE-SUSPEND _PROCEDURE-SETTINGS" + NL + "/* Settings for THIS-PROCEDURE" + NL + " Type: Method-Library Template" + NL + " Allow:" + NL + " Frames: 0" + NL + " Add Fields to: Neither" + NL + " Other Settings: INCLUDE-ONLY" + NL + " */" + NL + "&ANALYZE-RESUME _END-PROCEDURE-SETTINGS" + NL + "" + NL + "/* ************************* Create Window ************************** */" + NL + "" + NL + "&ANALYZE-SUSPEND _CREATE-WINDOW" + NL + "/* DESIGN Window definition (used by the UIB)" + NL + " CREATE WINDOW Method-Library ASSIGN" + NL + " HEIGHT = 6.33" + NL + " WIDTH = 54.2." + NL + "/* END WINDOW DEFINITION */" + NL + " */" + NL + "&ANALYZE-RESUME" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR \"Header\" Method-Library _INLINE" + NL + "/* Actions: adm/support/proc/ds_pa_00.w ? ? ? ? */" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR \"MethodLibraryCues\" Method-Library _INLINE" + NL + "/* Actions: adecomm/_so-cue.w ? adecomm/_so-cued.p ? adecomm/_so-cuew.p */" + NL + "/* Method Library" + NL + "Creating and Using a Method Library" + NL + "" + NL + "A Method Library is a structured PROGRESS include file that contains a collection of methods (internal Procedures) used by SmartObjects." + NL + "" + NL + "1) Click on the Code button image to open the Method Library Code Window." + NL + "*/" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Method-Library" + NL + "/* ************************* Included-Libraries *********************** */" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "" + NL + "" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library" + NL + "" + NL + "" + NL + "/* *************************** Main Block *************************** */" + NL + "" + NL + "/*---------------------------------------------------------------------------*/" + NL + "/* Prototypes */" + NL + "/*---------------------------------------------------------------------------*/" + NL + "" + NL + "Required if 4GL-Functions are called within a Super-Proc" + NL + "" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* Register Super-Procs */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "" + NL + "Required if pieces of the code are implemented within a dynamic library" + NL + "" + NL + "dynamic-function('hPABrkAddSuper':U in pa-broker-hdl," + NL + " 'Path/Name of program.p':U," + NL + " this-procedure)." + NL + "" + NL + "/*---------------------------------------------------------------------------*/" + NL + "/* User-Exits LIBRARY */" + NL + "/*---------------------------------------------------------------------------*/" + NL + "" + NL + "&IF DEFINED(PA-XLibBasisName) = 3 &THEN" + NL + "" + NL + " {&{&PA-XLIBBASISNAME}_C_MAIN}" + NL + " {&{&PA-XLIBBASISNAME}_U_MAIN}" + NL + " {&{&PA-XLIBBASISNAME}_Q_MAIN}" + NL + " {&{&PA-XLIBBASISNAME}_MAIN}" + NL + " {&{&PA-XLIBBASISNAME}_Y_MAIN}" + NL + "" + NL + "&ENDIF" + NL + "" + NL + "/*---------------------------------------------------------------------------*/" + NL + "/* ENDIF to close outer exclude */" + NL + "/* MUST ALWAYS BE AT THE END OF LAST PROCEDURE/FUNCTION WITHIN LIBRARY */" + NL + "/* (JUST BEFORE LAST &ANALYZE-RESUME */" + NL + "/*---------------------------------------------------------------------------*/" + NL + "" + NL + "&ENDIF" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME";
34 
35 /* (non-javadoc)
36  * @see ITemplateGenerator#generate(Object)
37  */
38 public String generate(Map<String, Object> wizardSettings) throws TemplateGenerationException
39  {
40  final StringBuffer stringBuffer = new StringBuffer();
41  String author = (String)wizardSettings.get(GeneratorSettingsConstans.AUTHOR);
42  String description = (String)wizardSettings.get(GeneratorSettingsConstans.DESCRIPTION);
43  String fileName = (String)wizardSettings.get(GeneratorSettingsConstans.FILE_NAME);
44  String product = (String)wizardSettings.get(GeneratorSettingsConstans.PRODUCT);
45  String productDesc = (String)wizardSettings.get(GeneratorSettingsConstans.PRODUCT_DESCRIPTION);
46  String module = (String)wizardSettings.get("Module");
47  String moduleDesc = (String)wizardSettings.get(GeneratorSettingsConstans.MODULE_DESCRIPTION);
48  String version = (String)wizardSettings.get(GeneratorSettingsConstans.VERSION);
49  String xbasename = fileName.replace(".","_");
50  Date date = new Date();
51  SimpleDateFormat year = new SimpleDateFormat("yyyy");
52  SimpleDateFormat today = new SimpleDateFormat("dd.MM.yyyy");
53  stringBuffer.append(TEXT_1);
54  if ((fileName.endsWith(".p")) || (fileName.endsWith(".w") || (fileName.endsWith(".cls"))))
55 {
56  stringBuffer.append(TEXT_2);
57  }
58  stringBuffer.append(TEXT_3);
59  stringBuffer.append(TEXT_4);
60  stringBuffer.append(CodeFormatter.SingleLineComment("Name : " + fileName));
61  stringBuffer.append(TEXT_4);
62  stringBuffer.append(CodeFormatter.SingleLineComment("Product: " + product + " - " + productDesc ));
63  stringBuffer.append(TEXT_4);
64  stringBuffer.append(CodeFormatter.SingleLineComment("Module : " + module + " - " + moduleDesc ));
65  stringBuffer.append(TEXT_5);
66  stringBuffer.append(TEXT_4);
67  stringBuffer.append(CodeFormatter.SingleLineComment("Created: " + version + " as of " + today.format(date) + "/" + author));
68  stringBuffer.append(TEXT_6);
69  stringBuffer.append(TEXT_4);
70  stringBuffer.append(CodeFormatter.MultiLineComment(description));
71  stringBuffer.append(TEXT_7);
72  stringBuffer.append(xbasename);
73  stringBuffer.append(TEXT_8);
74  stringBuffer.append(xbasename);
75  stringBuffer.append(TEXT_9);
76  stringBuffer.append(xbasename);
77  stringBuffer.append(TEXT_10);
78  stringBuffer.append(TEXT_4);
79  return stringBuffer.toString();
80  }
81 }