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;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
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.editor.BapEditor;
import cn.com.bankit.ide.bap.constants.BapResource;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.navigator.model.desc.Directory;
import cn.com.bankit.ide.bap.util.BapUtil;
import cn.com.bankit.ide.bap.util.file.BapFileUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil;
public class OpenSrcAction extends WorkflowNodeAction
{
public static final String ID = "open node src";
private File trdFile = null;
public OpenSrcAction(IWorkbenchPart part)
{
super(part);
this.setId(ID);
this.setText(BapResource.getPluginResource().getString(
BapResource.BAP_WLF_ACTION_OPEN_SRC));
trdFile = ((IFile) ((BapEditor) part).getEditorInput().getAdapter(
IFile.class)).getLocation().toFile();
}
public void run()
{
Node node = this.getNode();
String func = null;
String index = node.getDescription();
if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_BASIC)))
{
//基础组件
func = getPyFileContent(BapUtil.getBasicFolder2File(),
node.getDefinition());
} else if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_PUB)))
{
//公共组件
func = getPyFileContent(BapUtil.getPubFolder2File(),
node.getDefinition());
} else if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_APP)))
{
File folder = trdFile.getParentFile();
while (folder != null)
{
Directory directory = BapFileUtil
.getDirectoryFromDescFile(new File(folder,
INavigatorConstants.NV_DESC_XML));
if (null != directory)
if (INavigatorConstants.NV_NODE_BNKAPP.equals(directory
.getType()))
break;
folder = folder.getParentFile();
}
if (null != folder)
//应用组件
func = getPyFileContent(new File(folder,
INavigatorConstants.NV_NODE_APPCMP),
node.getDefinition());
}
if (null != func)
{
ShowContentDialog dialog = new ShowContentDialog(this
.getWorkbenchPart().getSite().getShell());
dialog.setMessage(func);
dialog.open();
} else
{
MessageBoxUtil.showErrorMessageBox(new Shell(),
"此组件为内置组件或者源代码文件不存在!");
}
}
private String getPyFileContent(File folder, String name)
{
if (null == name || null == folder)
return null;
if (folder.exists())
{
String m[] = name.split("\\.");
if (m.length < 2)
return null;
File pyFile = new File(folder, m[0] + ".py");
if (pyFile.exists())
{
BufferedReader br = null;
try
{
br = new BufferedReader(new InputStreamReader(
new FileInputStream(pyFile),
IBapConstants.ENCODING_GBK));
String line = "";
StringBuffer sb = null;
while ((line = br.readLine()) != null)
{
if (sb != null && line.startsWith("def"))
break;
if (line.matches("^def.*" + m[1] + "\\(.*"))
{
sb = new StringBuffer();
sb.append(line).append("\n");
} else if (null != sb)
{
sb.append(line).append("\n");
}
}
return sb == null ? null : sb.toString();
} catch (Exception e)
{
e.printStackTrace();
} finally
{
if (br != null)
{
try
{
br.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
return null;
}
}
package cn.com.bankit.ide.bap.business.workflow.action;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
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.editor.BapEditor;
import cn.com.bankit.ide.bap.constants.BapResource;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.navigator.model.desc.Directory;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.util.BapUtil;
import cn.com.bankit.ide.bap.util.file.BapFileUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil;
public class OpenSrcAction extends WorkflowNodeAction
{
public static final String ID = "open node src";
private File trdFile = null;
public OpenSrcAction(IWorkbenchPart part)
{
super(part);
this.setId(ID);
this.setText(BapResource.getPluginResource().getString(
BapResource.BAP_WLF_ACTION_OPEN_SRC));
trdFile = ((IFile) ((BapEditor) part).getEditorInput().getAdapter(
IFile.class)).getLocation().toFile();
}
public void run()
{
Node node = this.getNode();
String func = null;
String index = node.getDescription();
if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_BASIC)))
{
//基础组件
func = getPyFileContent(BapUtil.getBasicFolder2File(),
node.getDefinition());
} else if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_PUB)))
{
//公共组件
func = getPyFileContent(BapUtil.getPubFolder2File(),
node.getDefinition());
} else if (index.startsWith(BapResource.getPluginResource().getString(
BapResource.BAP_CMP_LEVEL_APP)))
{
File folder = trdFile.getParentFile();
while (folder != null)
{
Directory directory = BapFileUtil
.getDirectoryFromDescFile(new File(folder,
INavigatorConstants.NV_DESC_XML));
if (null != directory)
if (INavigatorConstants.NV_NODE_BNKAPP.equals(directory
.getType()))
break;
folder = folder.getParentFile();
}
if (null != folder)
//应用组件
func = getPyFileContent(new File(folder,
INavigatorConstants.NV_NODE_APPCMP),
node.getDefinition());
}
if (null != func)
{
ShowContentDialog dialog = new ShowContentDialog(this
.getWorkbenchPart().getSite().getShell());
dialog.setMessage(func);
dialog.open();
} else
{
MessageBoxUtil.showErrorMessageBox(new Shell(),
"此组件为内置组件或者源代码文件不存在!");
}
}
private String getPyFileContent(File folder, String name)
{
if (null == name || null == folder)
return null;
if (folder.exists())
{
String m[] = name.split("\\.");
if (m.length < 2)
return null;
File pyFile = new File(folder, m[0] + ".py");
if (pyFile.exists())
{
BufferedReader br = null;
try
{
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;
br = new BufferedReader(new InputStreamReader(
new FileInputStream(pyFile),
charsetName));
String line = "";
StringBuffer sb = null;
while ((line = br.readLine()) != null)
{
if (sb != null && line.startsWith("def"))
break;
if (line.matches("^def.*" + m[1] + "\\(.*"))
{
sb = new StringBuffer();
sb.append(line).append("\n");
} else if (null != sb)
{
sb.append(line).append("\n");
}
}
return sb == null ? null : sb.toString();
} catch (Exception e)
{
e.printStackTrace();
} finally
{
if (br != null)
{
try
{
br.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
return null;
}
}
......@@ -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.common.resources;bundle-version="2.0.1",
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-RequiredExecutionEnvironment: JavaSE-1.6
......@@ -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.INavigatorConstants;
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.util.file.BapFileUtil;
import cn.com.bankit.ide.toolkit.common.MessageBoxUtil;
......@@ -288,7 +289,10 @@ public class RegisterFactory
try
{
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);
if(PyParser.PY_REG_OK == regRes)
regSucCnt++;
......
/*
* cn.com.bankit.ide.bsp.navigator.handler.impl.CreateFixFolderHandler.java
* Created by zhoudian @ 2012-1-14 下午3:24:40
*/
package cn.com.bankit.ide.bap.navigator.handler.impl;
import java.io.File;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.constants.IWorkflowConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.toolkit.file.FileUtil;
/**
*
* <DL>
* <DT><B> 固定目录名称的handler. </B></DT>
* <DT><B> 例如:bizcmp、fileobject、form、inputflow、outputflow.... </B></DT>
* <p>
* <DD>详细介绍</DD>
* </DL>
* <p>
*
* <DL>
* <DT><B>使用范例</B></DT>
* <p>
* <DD>使用范例说明</DD>
* </DL>
* <p>
*
* @author zhoudian $Author$
* @author 浙江宇信班克信息技术有限公司
* @version $Id$
*/
public class CreateObjectFolderHandler extends AbstractFolderHandler
{
@Override
public void beforCopy()
{
this.targetFolder = foldertemplate.substring(foldertemplate.lastIndexOf("/") + 1);
}
@Override
public void afterCopy()
{
createRescplFiles();
}
private void createRescplFiles()
{
String fileName = this.properties.getProperty("filename");
boolean isTrade = Boolean.valueOf(String.valueOf(this.properties.get("isTrade")));
String filePath = icontainer.getLocationURI().getPath().toString() + File.separator
+ INavigatorConstants.NV_NODE_RESCPL + File.separator;
if (isTrade)
filePath = filePath + "T" + fileName;
else
filePath = filePath + fileName;
//仅仅是bam编译器的时候才需要生成中间xml文件
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"));
if (!oxfile.exists())
FileUtil.createFile(oxfile, "", IBapConstants.ENCODING_UTF_8);
File pyfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
if (!pyfile.exists())
FileUtil.createFile(pyfile, "", IBapConstants.ENCODING_GBK);
}
}
}
/*
* cn.com.bankit.ide.bsp.navigator.handler.impl.CreateFixFolderHandler.java
* Created by zhoudian @ 2012-1-14 下午3:24:40
*/
package cn.com.bankit.ide.bap.navigator.handler.impl;
import java.io.File;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.constants.INavigatorConstants;
import cn.com.bankit.ide.bap.constants.IWorkflowConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.toolkit.file.FileUtil;
/**
*
* <DL>
* <DT><B> 固定目录名称的handler. </B></DT>
* <DT><B> 例如:bizcmp、fileobject、form、inputflow、outputflow.... </B></DT>
* <p>
* <DD>详细介绍</DD>
* </DL>
* <p>
*
* <DL>
* <DT><B>使用范例</B></DT>
* <p>
* <DD>使用范例说明</DD>
* </DL>
* <p>
*
* @author zhoudian $Author$
* @author 浙江宇信班克信息技术有限公司
* @version $Id$
*/
public class CreateObjectFolderHandler extends AbstractFolderHandler
{
@Override
public void beforCopy()
{
this.targetFolder = foldertemplate.substring(foldertemplate.lastIndexOf("/") + 1);
}
@Override
public void afterCopy()
{
createRescplFiles();
}
private void createRescplFiles()
{
String fileName = this.properties.getProperty("filename");
boolean isTrade = Boolean.valueOf(String.valueOf(this.properties.get("isTrade")));
String filePath = icontainer.getLocationURI().getPath().toString() + File.separator
+ INavigatorConstants.NV_NODE_RESCPL + File.separator;
if (isTrade)
filePath = filePath + "T" + fileName;
else
filePath = filePath + fileName;
//仅仅是bam编译器的时候才需要生成中间xml文件
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"));
if (!oxfile.exists())
FileUtil.createFile(oxfile, "", IBapConstants.ENCODING_UTF_8);
File pyfile = new File(filePath.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
if (!pyfile.exists()) {
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,
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.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-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: BankIt
......@@ -78,7 +78,7 @@
</property>
<property
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
name="startupForegroundColor"
......
......@@ -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.util;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-ActivationPolicy: lazy
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