Commit 00106ba0 authored by 王业明's avatar 王业明
Browse files

1、BAPIDE适配到1.8

2、BAPIDE支持sftp
3、BAPIDE集成git插件
parent 24329b75
*.class
*.ftl
*.pkc
bin/
\ No newline at end of file
*.class
*.ftl
*.pkc
bin/
.metadata/
// created by 陈雨露 at 2012-3-9 上午9:13:53
/**
* Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company.
*
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明!
*
* Copyright(C) 2012 Bankit Tech, All rights reserved.
*/
package cn.com.bankit.ide.bap.compile.cgc;
import java.io.File;
import java.io.FileInputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import cn.com.bankit.common.castor.model.workflow.Workflow;
import cn.com.bankit.ide.bap.compile.BapCompile;
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.INavigatorConstants;
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.toolkit.file.CastorTools;
import cn.com.bankit.ide.toolkit.file.FileUtil;
/**
* CGC编译器
*
* @author 陈雨露
* @author 浙江宇信班克信息技术有限公司
* @version 1.0.0 2012-3-9 上午9:14:03
*/
public class CGC extends BapCompile
{
public static final int CGC_VERSION_1 = 0x1;
public static final int CGC_VERSION_2 = 0x2;
public static final int CGC_VERSION_3 = 0x3;
@Override
public void compile(IFolder folder, String type)
{
if (null == folder || !folder.exists())
return;
try
{
if (INavigatorConstants.NV_NODE_APPTRD.equals(type)) //编译交易
{
IResource resource[] = folder.members();
for (IResource res : resource)
{
if (res.getType() == IResource.FILE && res.getName().endsWith(IWorkflowConstants.WF_FILE_SUFFIX))
{
trdCompile((IFile) res);
}
}
}
else if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))//编译业务组件
{
bizCompile(folder);
}
//输出到控制台编译成功
//刷新目录
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 编译流程交易
* @param wfFile
*/
private void trdCompile(IFile wfFile)
{
if (null == wfFile || !wfFile.exists())
return;
boolean isError = true;
try
{
File workflowFile = wfFile.getLocation().toFile();
Workflow workflow = null;
workflow = (Workflow) CastorTools.unmarshaller(new FileInputStream(workflowFile), Workflow.class);
CodeGen<Workflow> codeGen = CodeGen.getTrdInstance(0x103);
String content = codeGen.genCode(workflow);
String name = wfFile.getName().replace(IWorkflowConstants.WF_FILE_SUFFIX, "py");
File objdir = ((IFolder) wfFile.getParent()).getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation()
.toFile();
File pyFile = new File(objdir, "T" + name.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
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;
}
catch (Exception e)
{
e.printStackTrace();
}
printConsole(wfFile, isError, INavigatorConstants.NV_NODE_APPTRD, null);
}
/**
* 编译业务组件
* @param folder
*/
private void bizCompile(IFolder folder) throws Exception
{
boolean isError = true;
try
{
CodeGen<IFolder> codeGen = CodeGen.getBizInstance(0x103);
String content = codeGen.genCode(folder);
File objdir = folder.getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation().toFile();
File pyFile = new File(objdir, folder.getName() + ".py");
FileUtil.createFile(pyFile, content, IBapConstants.ENCODING_GBK);
isError = false;
}
catch (Exception e)
{
e.printStackTrace();
}
printConsole(folder, isError, INavigatorConstants.NV_NODE_PKGCMP, null);
}
private void printConsole(IResource res, boolean error, String type, String detail)
{
StringBuffer buf = new StringBuffer();
buf.append("==========CGC==========").append("\n");
if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))
{
buf.append("编译交易:").append(res.getFullPath().toString()).append("\n");
}
else
{
buf.append("编译业务组件:").append(res.getFullPath().toString()).append("\n");
}
//相信的编译过程.
if (null != detail)
{
buf.append(detail).append("\n");
}
if (error)
{
buf.append("结果:编译失败").append("\n");
}
else
{
buf.append("结果:编译成功").append("\n");
}
BapConsole.getInstance().printMsg(buf.toString(), error);
}
}
// created by 陈雨露 at 2012-3-9 上午9:13:53
/**
* Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company.
*
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明!
*
* Copyright(C) 2012 Bankit Tech, All rights reserved.
*/
package cn.com.bankit.ide.bap.compile.cgc;
import java.io.File;
import java.io.FileInputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import cn.com.bankit.common.castor.model.workflow.Workflow;
import cn.com.bankit.ide.bap.compile.BapCompile;
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.INavigatorConstants;
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.toolkit.file.CastorTools;
import cn.com.bankit.ide.toolkit.file.FileUtil;
/**
* CGC编译器
*
* @author 陈雨露
* @author 浙江宇信班克信息技术有限公司
* @version 1.0.0 2012-3-9 上午9:14:03
*/
public class CGC extends BapCompile
{
public static final int CGC_VERSION_1 = 0x1;
public static final int CGC_VERSION_2 = 0x2;
public static final int CGC_VERSION_3 = 0x3;
@Override
public void compile(IFolder folder, String type)
{
if (null == folder || !folder.exists())
return;
try
{
if (INavigatorConstants.NV_NODE_APPTRD.equals(type)) //编译交易
{
IResource resource[] = folder.members();
for (IResource res : resource)
{
if (res.getType() == IResource.FILE && res.getName().endsWith(IWorkflowConstants.WF_FILE_SUFFIX))
{
trdCompile((IFile) res);
}
}
}
else if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))//编译业务组件
{
bizCompile(folder);
}
//输出到控制台编译成功
//刷新目录
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 编译流程交易
* @param wfFile
*/
private void trdCompile(IFile wfFile)
{
if (null == wfFile || !wfFile.exists())
return;
boolean isError = true;
try
{
File workflowFile = wfFile.getLocation().toFile();
Workflow workflow = null;
workflow = (Workflow) CastorTools.unmarshaller(new FileInputStream(workflowFile), Workflow.class);
CodeGen<Workflow> codeGen = CodeGen.getTrdInstance(0x103);
String content = codeGen.genCode(workflow);
String name = wfFile.getName().replace(IWorkflowConstants.WF_FILE_SUFFIX, "py");
File objdir = ((IFolder) wfFile.getParent()).getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation()
.toFile();
File pyFile = new File(objdir, "T" + name.replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"));
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;
}
catch (Exception e)
{
e.printStackTrace();
}
printConsole(wfFile, isError, INavigatorConstants.NV_NODE_APPTRD, null);
}
/**
* 编译业务组件
* @param folder
*/
private void bizCompile(IFolder folder) throws Exception
{
boolean isError = true;
try
{
CodeGen<IFolder> codeGen = CodeGen.getBizInstance(0x103);
String content = codeGen.genCode(folder);
File objdir = folder.getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation().toFile();
File pyFile = new File(objdir, folder.getName() + ".py");
FileUtil.createFile(pyFile, content, IBapConstants.ENCODING_GBK);
isError = false;
}
catch (Exception e)
{
e.printStackTrace();
}
printConsole(folder, isError, INavigatorConstants.NV_NODE_PKGCMP, null);
}
private void printConsole(IResource res, boolean error, String type, String detail)
{
StringBuffer buf = new StringBuffer();
buf.append("==========CGC==========").append("\n");
if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))
{
buf.append("编译交易:").append(res.getFullPath().toString()).append("\n");
}
else
{
buf.append("编译业务组件:").append(res.getFullPath().toString()).append("\n");
}
//相信的编译过程.
if (null != detail)
{
buf.append(detail).append("\n");
}
if (error)
{
buf.append("结果:编译失败").append("\n");
}
else
{
buf.append("结果:编译成功").append("\n");
}
BapConsole.getInstance().printMsg(buf.toString(), error);
}
}
// created by 陈雨露 at 2012-3-20 下午2:38:38
/**
* Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company.
*
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明!
*
* Copyright(C) 2012 Bankit Tech, All rights reserved.
*/
package cn.com.bankit.ide.bap.compile.cgc.template;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Locale;
import java.util.Map;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class TemplateUtil
{
public static String merge(String templateName, Map<?, ?> root)
{
try
{
Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1");
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);
Template temp = cfg.getTemplate(templateName);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Writer out = new OutputStreamWriter(bos);
temp.process(root, out);
out.flush();
out.close();
return new String(bos.toByteArray());
}
catch (IOException e)
{
e.printStackTrace();
}
catch (TemplateException e)
{
e.printStackTrace();
}
return null;
}
}
// created by 陈雨露 at 2012-3-20 下午2:38:38
/**
* Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company.
*
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明!
*
* Copyright(C) 2012 Bankit Tech, All rights reserved.
*/
package cn.com.bankit.ide.bap.compile.cgc.template;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Locale;
import java.util.Map;
import cn.com.bankit.ide.bap.constants.IBapConstants;
import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class TemplateUtil
{
public static String merge(String templateName, Map<?, ?> root)
{
try
{
Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1");
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);
Template temp = cfg.getTemplate(templateName);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Writer out = new OutputStreamWriter(bos);
temp.process(root, out);
out.flush();
out.close();
return new String(bos.toByteArray());
}
catch (IOException e)
{
e.printStackTrace();
}
catch (TemplateException e)
{
e.printStackTrace();
}
return null;
}
}
......@@ -45,107 +45,99 @@ import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.preferences.controls.BapBooleanEditField;
/**
* <DL>
* <DT><B> 标题. </B></DT>
* <p>
* <DD>详细介绍</DD>
* </DL>
* <p>
*
* <DL>
* <DT><B>使用范例</B></DT>
* <p>
* <DD>使用范例说明</DD>
* </DL>
* <p>
*
* @author 朱克平 $Author$
* @author 浙江宇信班克信息技术有限公司
* @version $Id$
*/
public class CGCCompilePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
{
* <DL>
* <DT><B> 标题. </B></DT>
* <p>
* <DD>详细介绍</DD>
* </DL>
* <p>
*
* <DL>
* <DT><B>使用范例</B></DT>
* <p>
* <DD>使用范例说明</DD>
* </DL>
* <p>
*
* @author 朱克平 $Author$
* @author 浙江宇信班克信息技术有限公司
* @version $Id$
*/
public class CGCCompilePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
BapBooleanEditField filter;
Group filterGroup;
StringFieldEditor value;
public CGCCompilePreferencePage()
{
super(GRID);
setPreferenceStore(BapPreActivator.getDefault().getPreferenceStore());
// setDescription(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
}
protected void createFieldEditors()
{
ComboFieldEditor combo = new ComboFieldEditor(IBapConstants.BAP_PREF_CPL_CGC_VER, BapResource
.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER), new String[][] {
{ BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V1_0_0),
IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0 }}, getFieldEditorParent());
addField(combo);
addFilter();
// addDescriptor();
}
private void addFilter()
{
filterGroup = new Group(getFieldEditorParent(), SWT.NONE);
filterGroup.setText(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
filterGroup.setLayout(new FillLayout());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
filterGroup.setLayoutData(gd);
filter = new BapBooleanEditField(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE, BapResource.getPluginResource()
.getString(BapResource.BAP_PREF_CPL_FILTER_ENABLE), filterGroup);
value = new StringFieldEditor(IBapConstants.BAP_PREF_CPL_FILTER_VALUE, BapResource.getPluginResource()
.getString(BapResource.BAP_PREF_CPL_FILTER_VALUE), filterGroup);
addField(filter);
addField(value);
final Button button = (Button) filter.getChangeControl(filterGroup);
button.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
boolean bval = button.getSelection();
value.setEnabled(bval, filterGroup);
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
}
});
}
@Override
public void init(IWorkbench workbench)
{
// TODO Auto-generated method stub
}
@Override
protected void checkState()
{
// TODO Auto-generated method stub
super.checkState();
IPreferenceStore store = BapPreActivator.getDefault().getPreferenceStore();
if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE))
{
value.setEnabled(true, filterGroup);
}
else
{
value.setEnabled(false, filterGroup);
}
}
StringFieldEditor value;
public CGCCompilePreferencePage() {
super(GRID);
setPreferenceStore(BapPreActivator.getDefault().getPreferenceStore());
// setDescription(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
}
protected void createFieldEditors() {
ComboFieldEditor combo = new ComboFieldEditor(IBapConstants.BAP_PREF_CPL_CGC_VER,
BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER),
new String[][] {
{ BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V1_0_0),
IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0 },
{ BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V3_PY3),
IBapConstants.BAP_PREF_CPL_CGC_VER_V3_PY3 } },
getFieldEditorParent());
addField(combo);
addFilter();
// addDescriptor();
}
private void addFilter() {
filterGroup = new Group(getFieldEditorParent(), SWT.NONE);
filterGroup.setText(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
filterGroup.setLayout(new FillLayout());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
filterGroup.setLayoutData(gd);
filter = new BapBooleanEditField(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE,
BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_ENABLE), filterGroup);
value = new StringFieldEditor(IBapConstants.BAP_PREF_CPL_FILTER_VALUE,
BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_VALUE), filterGroup);
addField(filter);
addField(value);
final Button button = (Button) filter.getChangeControl(filterGroup);
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean bval = button.getSelection();
value.setEnabled(bval, filterGroup);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
@Override
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
@Override
protected void checkState() {
// TODO Auto-generated method stub
super.checkState();
IPreferenceStore store = BapPreActivator.getDefault().getPreferenceStore();
if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE)) {
value.setEnabled(true, filterGroup);
} else {
value.setEnabled(false, filterGroup);
}
}
}
......@@ -78,7 +78,7 @@
</property>
<property
name="aboutText"
value="业务处理平台基础开发环境(BAP IDE)&#x0A;&#x0A;授权版本: V1.5.0 SMART&#x0A;发布日期: 20140513&#x0A;&#x0A;宇信班克版权所有 ©2011-2014">
value="业务处理平台基础开发环境(BAP IDE)&#x0A;&#x0A;授权版本: V1.5.0&#x0A;发布日期: 20140510&#x0A;&#x0A;宇信班克版权所有 ©2011-2014">
</property>
<property
name="startupForegroundColor"
......@@ -96,14 +96,14 @@
name="appName"
value="Bap IDE">
</property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
<property
name="aboutImage"
value="icons/splash.png">
</property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
</product>
</extension>
<extension
......
......@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources;bundle-version="3.7.100",
cn.com.bankit.ide.common.lib;bundle-version="1.0.0",
cn.com.bankit.ide.common.resources;bundle-version="1.0.0",
org.eclipse.core.filesystem;bundle-version="1.3.100"
org.eclipse.core.filesystem;bundle-version="1.3.100",
com.jcraft.jsch;bundle-version="0.1.53"
Bundle-ClassPath: .
Export-Package: cn.com.bankit.ide.common.ftp,
cn.com.bankit.ide.common.ftp.actions,
......
package cn.com.bankit.ide.common.ftp;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.Properties;
import java.util.Vector;
public class SSHRemoteCall {
String home = "";
public static final int DEFAULT_PORT = 22;
private Session session;
public String getHome() {
return this.home;
}
public void sshRemoteCallLogin(String ipAddress, String userName, String password, int port) throws Exception {
JSch jSch = new JSch();
try {
this.session = jSch.getSession(userName, ipAddress, port);
this.session.setPassword(password);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
this.session.setConfig(config);
this.session.connect();
} catch (JSchException e) {
throw new Exception(
"主机登录失败, IP = " + ipAddress + ", USERNAME = " + userName + ", Exception:" + e.getMessage());
}
}
public void closeSession() {
if (this.session == null)
return;
this.session.disconnect();
}
public boolean uploadFile(String directory, File uploadFile, boolean flag) throws Exception {
boolean upload = false;
try {
ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
channelSftp.connect();
this.home = channelSftp.pwd();
String[] path = directory.split("/");
for (String p : path) {
if ("".equals(p))
continue;
try {
channelSftp.cd(p);
} catch (SftpException localSftpException) {
channelSftp.mkdir(p);
channelSftp.cd(p);
}
}
if (flag) {
channelSftp.put(new FileInputStream(uploadFile), uploadFile.getName(), 0);
upload = true;
} else {
Vector v = channelSftp.ls(uploadFile.getName());
if (v.isEmpty()) {
channelSftp.put(new FileInputStream(uploadFile), uploadFile.getName(), 0);
upload = true;
}
}
channelSftp.exit();
} catch (Exception e) {
throw e;
}
return upload;
}
public void fileDownload(String src, String dst) throws JSchException, SftpException {
ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
channelSftp.connect();
channelSftp.get(src, dst);
channelSftp.quit();
System.out.println("3、" + src + " ,下载文件成功.....");
}
public void deleteFile(String directoryFile) throws SftpException, JSchException {
ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
channelSftp.connect();
channelSftp.rm(directoryFile);
channelSftp.exit();
System.out.println("4、" + directoryFile + " 删除的文件.....");
}
public Vector listFiles(String directory) throws JSchException, SftpException {
ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
channelSftp.connect();
Vector ls = channelSftp.ls(directory);
System.out.println("5、" + ls);
channelSftp.exit();
return ls;
}
}
\ No newline at end of file
package cn.com.bankit.ide.common.ftp.jobs;
import cn.com.bankit.ide.common.ftp.FtpActivator;
import cn.com.bankit.ide.common.ftp.FtpConstants;
import cn.com.bankit.ide.common.ftp.SSHRemoteCall;
import cn.com.bankit.ide.common.ftp.console.ConsoleFactory;
import cn.com.bankit.ide.common.ftp.model.ConnNode;
import cn.com.bankit.ide.common.ftp.model.UploadModel;
import cn.com.bankit.ide.common.resources.ResourceProvider;
import java.io.File;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
public class SFtpUploadJob extends FtpUploadJob {
private SSHRemoteCall ssh;
public SFtpUploadJob(ConnNode connNode, List<UploadModel> list, int times) {
super(connNode, list, times);
this.ssh = new SSHRemoteCall();
ConsoleFactory.regist(connNode);
}
protected void doRun(IProgressMonitor monitor) throws Exception {
uploadFile(monitor);
}
protected void uploadFile(IProgressMonitor monitor) throws Exception {
if (monitor.isCanceled()) {
return;
}
this.ssh.sshRemoteCallLogin(this.connNode.getHost(), this.connNode.getUsername(), this.connNode.getPassword(),
this.connNode.getPort());
this.total = this.list.size();
label244: for (UploadModel up : this.list)
try {
monitor.beginTask(
FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_OTHER_X_NOW,
new Object[] {
FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_ACTION_UPLOAD),
up.getLocalFile().getFullPath().toString() }),
1);
boolean upload = this.ssh.uploadFile(up.getRemotePath(), up.getLocalJavaFile(), up.isOverWrite());
monitor.worked(1);
if (upload) {
this.connNode.setConsoleMessage("文件 " + up.getLocalJavaFile().getAbsolutePath() + "上传到 "
+ this.ssh.getHome() + up.getRemotePath() + "成功");
}
if (!(monitor.isCanceled()))
break label244;
return;
} catch (Exception e) {
this.connNode.setConsoleError(e.getMessage());
throw e;
}
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@
<classpathentry exported="true" kind="lib" path="lib/wsdl4j-1.6.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.9.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/XmlSchema-1.3.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jsch-0.1.54.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
#Mon Sep 01 17:19:01 CST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
......
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