Commit d0f6efe2 authored by 王业明's avatar 王业明
Browse files

BAPIDE生成的python代码,需要能同时支持python2和python3的

parent f155fcbc
...@@ -33,6 +33,7 @@ import cn.com.bankit.ide.bap.compile.cgc.gen.CodeGen; ...@@ -33,6 +33,7 @@ import cn.com.bankit.ide.bap.compile.cgc.gen.CodeGen;
import cn.com.bankit.ide.bap.constants.IBapConstants; import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants; import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.constants.IWorkflowConstants; import cn.com.bankit.ide.bap.constants.IWorkflowConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.util.file.BapConsole; import cn.com.bankit.ide.bap.util.file.BapConsole;
import cn.com.bankit.ide.toolkit.file.CastorTools; import cn.com.bankit.ide.toolkit.file.CastorTools;
import cn.com.bankit.ide.toolkit.file.FileUtil; import cn.com.bankit.ide.toolkit.file.FileUtil;
...@@ -109,7 +110,9 @@ public class CGC extends BapCompile ...@@ -109,7 +110,9 @@ public class CGC extends BapCompile
File objdir = ((IFolder) wfFile.getParent()).getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation() File objdir = ((IFolder) wfFile.getParent()).getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation()
.toFile(); .toFile();
File pyFile = new File(objdir, "T" + name.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py")); File pyFile = new File(objdir, "T" + name.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
FileUtil.createFile(pyFile, content, IBapConstants.ENCODING_GBK); String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
FileUtil.createFile(pyFile, content, IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0.equals(cgcVer)
? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8);
isError = false; isError = false;
} }
......
...@@ -28,7 +28,7 @@ import java.util.Locale; ...@@ -28,7 +28,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import cn.com.bankit.ide.bap.constants.IBapConstants; import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import freemarker.template.TemplateException; import freemarker.template.TemplateException;
...@@ -42,7 +42,12 @@ public class TemplateUtil ...@@ -42,7 +42,12 @@ public class TemplateUtil
{ {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1"); // cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1");
cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v3"); String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
String pathPrefix = "/cgc_v3";
if(IBapConstants.BAP_PREF_CPL_CGC_VER_V3_PY3.equals(cgcVer)){
pathPrefix = "/cgc_v3_py3";
}
cfg.setClassForTemplateLoading(TemplateUtil.class, pathPrefix);
cfg.setEncoding(Locale.getDefault(), IBapConstants.ENCODING_UTF_8); cfg.setEncoding(Locale.getDefault(), IBapConstants.ENCODING_UTF_8);
Template temp = cfg.getTemplate(templateName); Template temp = cfg.getTemplate(templateName);
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
......
...@@ -227,6 +227,7 @@ bap.pref.cpl.type.cgc=CGC ...@@ -227,6 +227,7 @@ bap.pref.cpl.type.cgc=CGC
bap.pref.cpl.type.bapc=BAPC bap.pref.cpl.type.bapc=BAPC
bap.pref.cpl.cgc.version=CGC\u4f7f\u7528\u7248\u672c: bap.pref.cpl.cgc.version=CGC\u4f7f\u7528\u7248\u672c:
bap.pref.cpl.cgc.version.v1_0_0=V1.0.0 bap.pref.cpl.cgc.version.v1_0_0=V1.0.0
bap.pref.cpl.cgc.version.v3_py3=V3-PY3
bap.pref.cpl.bamc.version=\u4f7f\u7528BAPC\u4f5c\u4e3a\u7f16\u8bd1\u5668 bap.pref.cpl.bamc.version=\u4f7f\u7528BAPC\u4f5c\u4e3a\u7f16\u8bd1\u5668
bap.pref.cpl.bapc.use.alias=\u4f7f\u7528\u8282\u70b9\u522b\u540d\u505a\u4e3a\u7f16\u8bd1\u540epy\u51fd\u6570\u7684\u529f\u80fd\u8bf4\u660e bap.pref.cpl.bapc.use.alias=\u4f7f\u7528\u8282\u70b9\u522b\u540d\u505a\u4e3a\u7f16\u8bd1\u540epy\u51fd\u6570\u7684\u529f\u80fd\u8bf4\u660e
bap.pref.cpl.xml.file.remove=\u5220\u9664\u7f16\u8bd1XML\u6587\u4ef6 bap.pref.cpl.xml.file.remove=\u5220\u9664\u7f16\u8bd1XML\u6587\u4ef6
......
...@@ -410,6 +410,10 @@ public class BapResource ...@@ -410,6 +410,10 @@ public class BapResource
//v1.0.0版本 //v1.0.0版本
public static final String BAP_PREF_CPL_CGC_VER_V1_0_0 = "bap.pref.cpl.cgc.version.v1_0_0"; public static final String BAP_PREF_CPL_CGC_VER_V1_0_0 = "bap.pref.cpl.cgc.version.v1_0_0";
public static final String BAP_PREF_CPL_CGC_VER_V3_0_0 = "bap.pref.cpl.cgc.version.v3_0_0";
public static final String BAP_PREF_CPL_CGC_VER_V3_PY3 = "bap.pref.cpl.cgc.version.v3_py3";
public static final String BAP_PREF_CPL_NAME = "bap.pref.cpl.name"; public static final String BAP_PREF_CPL_NAME = "bap.pref.cpl.name";
public static final String BAP_PREF_CPL_FILTER_NAME = "bap.pref.cpl.filter.name"; public static final String BAP_PREF_CPL_FILTER_NAME = "bap.pref.cpl.filter.name";
......
...@@ -123,6 +123,10 @@ public interface IBapConstants ...@@ -123,6 +123,10 @@ public interface IBapConstants
//v1.0.0版本 //v1.0.0版本
public static final String BAP_PREF_CPL_CGC_VER_V1_0_0 = "bap.cpl.cgc.version.v1_0_0"; public static final String BAP_PREF_CPL_CGC_VER_V1_0_0 = "bap.cpl.cgc.version.v1_0_0";
public static final String BAP_PREF_CPL_CGC_VER_V3_0_0 = "bap.cpl.cgc.version.v3_0_0";
public static final String BAP_PREF_CPL_CGC_VER_V3_PY3 = "bap.cpl.cgc.version.v3_py3";
String BAP_PREF_EDITOR_MOUSE_HELPER = "bap.editor.mouse.helper"; String BAP_PREF_EDITOR_MOUSE_HELPER = "bap.editor.mouse.helper";
String BAP_PREF_EDITOR_COMP_RECOVERY = "bap.editor.comp.recovery"; String BAP_PREF_EDITOR_COMP_RECOVERY = "bap.editor.comp.recovery";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment