Commit 21f92e39 authored by 王业明's avatar 王业明
Browse files

#==BapIDE工程代码转换

1、修改ide_py2-tranto-py3.py中SRCPATH变量定义为对应的BapIDE-workspace路径

2、执行如下命令,转换后的文件夹名称会加后缀-py3,对以前手工在代码中处理的编码转换会进行提示,也需手工去进行修改
python3 ide_py2-tranto-py3.py

3、升级BapIDE版本到BapIDE_1.5.1_20250521及以上

4、修改BapIDE中配置:
(1) TAB键设置为4个空格、编辑器编码设置为UTF-8
        窗口 --> 首选项 --> 常规 --> 编辑器 --> 文本编辑器:
        *: 查看和修改“显示的Tab键宽度(T):”为4,选择“插入空格代替制表符”
        *: --> 拼写 --> 将“编码(C):”修改为“缺省值(UTF-8)”
(2) 内容类型里将Python文件的编码设置为UTF-8
        窗口 --> 首选项 --> 常规 --> 内容类型 --> 在右边“内容类型(C):”里找到“Python
File”,将下方的缺省编码改为“UTF-8”,并点击“更新”
(3) CGC编译器
        窗口 --> 首选项 --> BAP设置 --> 编译器(将编译器类型改为:CGC) -->
CGC编译器(将CGC使用版本改为:V3-PY3)

5、若本机已经安装Python3,可以在BapIDE中配置Python3版本:
	窗口 --> 首选项 --> PyDev --> Interpreter - Python --> 新建(W)... -->
找到Python3执行文件进行导入。
parent d6727218
package cn.com.bankit.ide.bap.business.workflow.action; package cn.com.bankit.ide.bap.business.workflow.action;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import cn.com.bankit.common.castor.model.workflow.Node; import cn.com.bankit.common.castor.model.workflow.Node;
import cn.com.bankit.ide.bap.business.workflow.dialog.ShowContentDialog; import cn.com.bankit.ide.bap.business.workflow.dialog.ShowContentDialog;
import cn.com.bankit.ide.bap.business.workflow.editor.BapEditor; import cn.com.bankit.ide.bap.business.workflow.editor.BapEditor;
import cn.com.bankit.ide.bap.constants.BapResource; import cn.com.bankit.ide.bap.constants.BapResource;
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.navigator.model.desc.Directory; import cn.com.bankit.ide.bap.navigator.model.desc.Directory;
import cn.com.bankit.ide.bap.util.BapUtil; import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.util.file.BapFileUtil; import cn.com.bankit.ide.bap.util.BapUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil; import cn.com.bankit.ide.bap.util.file.BapFileUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil;
public class OpenSrcAction extends WorkflowNodeAction
{ public class OpenSrcAction extends WorkflowNodeAction
public static final String ID = "open node src"; {
public static final String ID = "open node src";
private File trdFile = null;
private File trdFile = null;
public OpenSrcAction(IWorkbenchPart part)
{ public OpenSrcAction(IWorkbenchPart part)
super(part); {
this.setId(ID); super(part);
this.setText(BapResource.getPluginResource().getString( this.setId(ID);
BapResource.BAP_WLF_ACTION_OPEN_SRC)); this.setText(BapResource.getPluginResource().getString(
trdFile = ((IFile) ((BapEditor) part).getEditorInput().getAdapter( BapResource.BAP_WLF_ACTION_OPEN_SRC));
IFile.class)).getLocation().toFile(); trdFile = ((IFile) ((BapEditor) part).getEditorInput().getAdapter(
} IFile.class)).getLocation().toFile();
}
public void run()
{ public void run()
{
Node node = this.getNode();
String func = null; Node node = this.getNode();
String index = node.getDescription(); String func = null;
if (index.startsWith(BapResource.getPluginResource().getString( String index = node.getDescription();
BapResource.BAP_CMP_LEVEL_BASIC))) if (index.startsWith(BapResource.getPluginResource().getString(
{ BapResource.BAP_CMP_LEVEL_BASIC)))
//基础组件 {
func = getPyFileContent(BapUtil.getBasicFolder2File(), //基础组件
node.getDefinition()); func = getPyFileContent(BapUtil.getBasicFolder2File(),
} else if (index.startsWith(BapResource.getPluginResource().getString( node.getDefinition());
BapResource.BAP_CMP_LEVEL_PUB))) } else if (index.startsWith(BapResource.getPluginResource().getString(
{ BapResource.BAP_CMP_LEVEL_PUB)))
//公共组件 {
func = getPyFileContent(BapUtil.getPubFolder2File(), //公共组件
node.getDefinition()); func = getPyFileContent(BapUtil.getPubFolder2File(),
} else if (index.startsWith(BapResource.getPluginResource().getString( node.getDefinition());
BapResource.BAP_CMP_LEVEL_APP))) } else if (index.startsWith(BapResource.getPluginResource().getString(
{ BapResource.BAP_CMP_LEVEL_APP)))
File folder = trdFile.getParentFile(); {
while (folder != null) File folder = trdFile.getParentFile();
{ while (folder != null)
Directory directory = BapFileUtil {
.getDirectoryFromDescFile(new File(folder, Directory directory = BapFileUtil
INavigatorConstants.NV_DESC_XML)); .getDirectoryFromDescFile(new File(folder,
if (null != directory) INavigatorConstants.NV_DESC_XML));
if (INavigatorConstants.NV_NODE_BNKAPP.equals(directory if (null != directory)
.getType())) if (INavigatorConstants.NV_NODE_BNKAPP.equals(directory
break; .getType()))
folder = folder.getParentFile(); break;
} folder = folder.getParentFile();
}
if (null != folder)
//应用组件 if (null != folder)
func = getPyFileContent(new File(folder, //应用组件
INavigatorConstants.NV_NODE_APPCMP), func = getPyFileContent(new File(folder,
node.getDefinition()); INavigatorConstants.NV_NODE_APPCMP),
} node.getDefinition());
}
if (null != func)
{ if (null != func)
ShowContentDialog dialog = new ShowContentDialog(this {
.getWorkbenchPart().getSite().getShell()); ShowContentDialog dialog = new ShowContentDialog(this
dialog.setMessage(func); .getWorkbenchPart().getSite().getShell());
dialog.open(); dialog.setMessage(func);
} else dialog.open();
{ } else
MessageBoxUtil.showErrorMessageBox(new Shell(), {
"此组件为内置组件或者源代码文件不存在!"); MessageBoxUtil.showErrorMessageBox(new Shell(),
} "此组件为内置组件或者源代码文件不存在!");
} }
}
private String getPyFileContent(File folder, String name)
{ private String getPyFileContent(File folder, String name)
if (null == name || null == folder) {
return null; if (null == name || null == folder)
return null;
if (folder.exists())
{ if (folder.exists())
String m[] = name.split("\\."); {
if (m.length < 2) String m[] = name.split("\\.");
return null; if (m.length < 2)
return null;
File pyFile = new File(folder, m[0] + ".py");
File pyFile = new File(folder, m[0] + ".py");
if (pyFile.exists())
{ if (pyFile.exists())
BufferedReader br = null; {
try BufferedReader br = null;
{ try
br = new BufferedReader(new InputStreamReader( {
new FileInputStream(pyFile), String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
IBapConstants.ENCODING_GBK)); String charsetName = IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0.equals(cgcVer)
? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8;
String line = ""; br = new BufferedReader(new InputStreamReader(
StringBuffer sb = null; new FileInputStream(pyFile),
while ((line = br.readLine()) != null) charsetName));
{
if (sb != null && line.startsWith("def")) String line = "";
break; StringBuffer sb = null;
while ((line = br.readLine()) != null)
if (line.matches("^def.*" + m[1] + "\\(.*")) {
{ if (sb != null && line.startsWith("def"))
sb = new StringBuffer(); break;
sb.append(line).append("\n");
} else if (null != sb) if (line.matches("^def.*" + m[1] + "\\(.*"))
{ {
sb.append(line).append("\n"); sb = new StringBuffer();
} sb.append(line).append("\n");
} } else if (null != sb)
{
return sb == null ? null : sb.toString(); sb.append(line).append("\n");
}
} catch (Exception e) }
{
e.printStackTrace(); return sb == null ? null : sb.toString();
} finally
{ } catch (Exception e)
if (br != null) {
{ e.printStackTrace();
try } finally
{ {
br.close(); if (br != null)
} catch (IOException e) {
{ try
e.printStackTrace(); {
} br.close();
} } catch (IOException e)
} {
e.printStackTrace();
} }
} }
}
return null;
} }
} }
return null;
}
}
...@@ -23,6 +23,7 @@ Require-Bundle: org.eclipse.ui, ...@@ -23,6 +23,7 @@ Require-Bundle: org.eclipse.ui,
cn.com.bankit.ide.bap.business.workflow;bundle-version="1.0.0", cn.com.bankit.ide.bap.business.workflow;bundle-version="1.0.0",
cn.com.bankit.ide.common.resources;bundle-version="2.0.1", cn.com.bankit.ide.common.resources;bundle-version="2.0.1",
org.eclipse.ui.workbench.texteditor;bundle-version="3.7.0", org.eclipse.ui.workbench.texteditor;bundle-version="3.7.0",
org.eclipse.jface.text;bundle-version="3.7.2" org.eclipse.jface.text;bundle-version="3.7.2",
cn.com.bankit.ide.bap.preferences
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
...@@ -48,6 +48,7 @@ import cn.com.bankit.ide.bap.constants.IBapConstants; ...@@ -48,6 +48,7 @@ import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.IComponentConstants; import cn.com.bankit.ide.bap.constants.IComponentConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants; import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.navigator.model.desc.Directory; import cn.com.bankit.ide.bap.navigator.model.desc.Directory;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.python.parser.PyParser; import cn.com.bankit.ide.bap.python.parser.PyParser;
import cn.com.bankit.ide.bap.util.file.BapFileUtil; import cn.com.bankit.ide.bap.util.file.BapFileUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil; import cn.com.bankit.ide.toolkit.common.MessageBoxUtil;
...@@ -288,7 +289,10 @@ public class RegisterFactory ...@@ -288,7 +289,10 @@ public class RegisterFactory
try try
{ {
File xmlCmpFile = new File(xmlPath + "/" + fileName); File xmlCmpFile = new File(xmlPath + "/" + fileName);
int regRes = PyParser.register(pythonFile, IBapConstants.ENCODING_GBK, String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
String charsetName = IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0.equals(cgcVer)
? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8;
int regRes = PyParser.register(pythonFile, charsetName,
xmlCmpFile, pyLevel); xmlCmpFile, pyLevel);
if(PyParser.PY_REG_OK == regRes) if(PyParser.PY_REG_OK == regRes)
regSucCnt++; regSucCnt++;
......
/* /*
* cn.com.bankit.ide.bsp.navigator.handler.impl.CreateFixFolderHandler.java * cn.com.bankit.ide.bsp.navigator.handler.impl.CreateFixFolderHandler.java
* Created by zhoudian @ 2012-1-14 下午3:24:40 * Created by zhoudian @ 2012-1-14 下午3:24:40
*/ */
package cn.com.bankit.ide.bap.navigator.handler.impl; package cn.com.bankit.ide.bap.navigator.handler.impl;
import java.io.File; import java.io.File;
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.preferences.BapPreActivator;
import cn.com.bankit.ide.toolkit.file.FileUtil; import cn.com.bankit.ide.toolkit.file.FileUtil;
/** /**
* *
* <DL> * <DL>
* <DT><B> 固定目录名称的handler. </B></DT> * <DT><B> 固定目录名称的handler. </B></DT>
* <DT><B> 例如:bizcmp、fileobject、form、inputflow、outputflow.... </B></DT> * <DT><B> 例如:bizcmp、fileobject、form、inputflow、outputflow.... </B></DT>
* <p> * <p>
* <DD>详细介绍</DD> * <DD>详细介绍</DD>
* </DL> * </DL>
* <p> * <p>
* *
* <DL> * <DL>
* <DT><B>使用范例</B></DT> * <DT><B>使用范例</B></DT>
* <p> * <p>
* <DD>使用范例说明</DD> * <DD>使用范例说明</DD>
* </DL> * </DL>
* <p> * <p>
* *
* @author zhoudian $Author$ * @author zhoudian $Author$
* @author 浙江宇信班克信息技术有限公司 * @author 浙江宇信班克信息技术有限公司
* @version $Id$ * @version $Id$
*/ */
public class CreateObjectFolderHandler extends AbstractFolderHandler public class CreateObjectFolderHandler extends AbstractFolderHandler
{ {
@Override @Override
public void beforCopy() public void beforCopy()
{ {
this.targetFolder = foldertemplate.substring(foldertemplate.lastIndexOf("/") + 1); this.targetFolder = foldertemplate.substring(foldertemplate.lastIndexOf("/") + 1);
} }
@Override @Override
public void afterCopy() public void afterCopy()
{ {
createRescplFiles(); createRescplFiles();
} }
private void createRescplFiles() private void createRescplFiles()
{ {
String fileName = this.properties.getProperty("filename"); String fileName = this.properties.getProperty("filename");
boolean isTrade = Boolean.valueOf(String.valueOf(this.properties.get("isTrade"))); boolean isTrade = Boolean.valueOf(String.valueOf(this.properties.get("isTrade")));
String filePath = icontainer.getLocationURI().getPath().toString() + File.separator String filePath = icontainer.getLocationURI().getPath().toString() + File.separator
+ INavigatorConstants.NV_NODE_RESCPL + File.separator; + INavigatorConstants.NV_NODE_RESCPL + File.separator;
if (isTrade) if (isTrade)
filePath = filePath + "T" + fileName; filePath = filePath + "T" + fileName;
else else
filePath = filePath + fileName; filePath = filePath + fileName;
//仅仅是bam编译器的时候才需要生成中间xml文件 //仅仅是bam编译器的时候才需要生成中间xml文件
if (IBapConstants.BAP_PREF_CPL_TYPE_BAPC.equals(BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_TYPE))) if (IBapConstants.BAP_PREF_CPL_TYPE_BAPC.equals(BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_TYPE)))
{ {
File oxfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "xml")); File oxfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "xml"));
if (!oxfile.exists()) if (!oxfile.exists())
FileUtil.createFile(oxfile, "", IBapConstants.ENCODING_UTF_8); FileUtil.createFile(oxfile, "", IBapConstants.ENCODING_UTF_8);
File pyfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py")); File pyfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
if (!pyfile.exists()) if (!pyfile.exists()) {
FileUtil.createFile(pyfile, "", IBapConstants.ENCODING_GBK); String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
} String charsetName = IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0.equals(cgcVer)
} ? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8;
} FileUtil.createFile(pyfile, "", charsetName);
}
}
}
}
...@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui, ...@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui,
cn.com.bankit.ide.bap.util;bundle-version="1.0.0", cn.com.bankit.ide.bap.util;bundle-version="1.0.0",
cn.com.bankit.ide.bap.navigator.model;bundle-version="1.0.0", cn.com.bankit.ide.bap.navigator.model;bundle-version="1.0.0",
cn.com.bankit.common.castor.model;bundle-version="1.0.0", cn.com.bankit.common.castor.model;bundle-version="1.0.0",
cn.com.bankit.ide.toolkit;bundle-version="1.0.0" cn.com.bankit.ide.toolkit;bundle-version="1.0.0",
cn.com.bankit.ide.bap.preferences
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: BankIt Bundle-Vendor: BankIt
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
</property> </property>
<property <property
name="aboutText" name="aboutText"
value="业务处理平台基础开发环境(BAP IDE)&#x0A;&#x0A;授权版本: V1.5.0&#x0A;发布日期: 20140510&#x0A;&#x0A;宇信班克版权所有 ©2011-2014"> value="业务处理平台基础开发环境(BAP IDE)&#x0A;&#x0A;授权版本: V1.5.1&#x0A;发布日期: 20250521&#x0A;&#x0A;北京宇信科技集团股份有限公司">
</property> </property>
<property <property
name="startupForegroundColor" name="startupForegroundColor"
......
...@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0", ...@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
cn.com.bankit.ide.bap.python.parser;bundle-version="1.0.0", cn.com.bankit.ide.bap.python.parser;bundle-version="1.0.0",
cn.com.bankit.ide.bap.util;bundle-version="1.0.0", cn.com.bankit.ide.bap.util;bundle-version="1.0.0",
cn.com.bankit.ide.bap.configure;bundle-version="1.0.0", cn.com.bankit.ide.bap.configure;bundle-version="1.0.0",
cn.com.bankit.ide.toolkit;bundle-version="1.0.0" cn.com.bankit.ide.toolkit;bundle-version="1.0.0",
cn.com.bankit.ide.bap.preferences
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: cn.com.bankit.ide.bap.trans, Export-Package: cn.com.bankit.ide.bap.trans,
......
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