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

1、BAPIDE适配到1.8

2、BAPIDE支持sftp
3、BAPIDE集成git插件
parent 24329b75
*.class *.class
*.ftl *.ftl
*.pkc *.pkc
bin/ bin/
\ No newline at end of file .metadata/
// created by 陈雨露 at 2012-3-9 上午9:13:53 // created by 陈雨露 at 2012-3-9 上午9:13:53
/** /**
* Special Declaration: These technical material reserved as the technical * Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law" * secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant * "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written * administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to * permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and * the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any * disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company. * infringer shall afford the legal liability to the company.
* *
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》 * 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公 * 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人 * 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使 * 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。 * 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明! * 特此声明!
* *
* Copyright(C) 2012 Bankit Tech, All rights reserved. * Copyright(C) 2012 Bankit Tech, All rights reserved.
*/ */
package cn.com.bankit.ide.bap.compile.cgc; package cn.com.bankit.ide.bap.compile.cgc;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import cn.com.bankit.common.castor.model.workflow.Workflow; import cn.com.bankit.common.castor.model.workflow.Workflow;
import cn.com.bankit.ide.bap.compile.BapCompile; import cn.com.bankit.ide.bap.compile.BapCompile;
import cn.com.bankit.ide.bap.compile.cgc.gen.CodeGen; 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.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;
/** /**
* CGC编译器 * CGC编译器
* *
* @author 陈雨露 * @author 陈雨露
* @author 浙江宇信班克信息技术有限公司 * @author 浙江宇信班克信息技术有限公司
* @version 1.0.0 2012-3-9 上午9:14:03 * @version 1.0.0 2012-3-9 上午9:14:03
*/ */
public class CGC extends BapCompile public class CGC extends BapCompile
{ {
public static final int CGC_VERSION_1 = 0x1; public static final int CGC_VERSION_1 = 0x1;
public static final int CGC_VERSION_2 = 0x2; public static final int CGC_VERSION_2 = 0x2;
public static final int CGC_VERSION_3 = 0x3; public static final int CGC_VERSION_3 = 0x3;
@Override @Override
public void compile(IFolder folder, String type) public void compile(IFolder folder, String type)
{ {
if (null == folder || !folder.exists()) if (null == folder || !folder.exists())
return; return;
try try
{ {
if (INavigatorConstants.NV_NODE_APPTRD.equals(type)) //编译交易 if (INavigatorConstants.NV_NODE_APPTRD.equals(type)) //编译交易
{ {
IResource resource[] = folder.members(); IResource resource[] = folder.members();
for (IResource res : resource) for (IResource res : resource)
{ {
if (res.getType() == IResource.FILE && res.getName().endsWith(IWorkflowConstants.WF_FILE_SUFFIX)) if (res.getType() == IResource.FILE && res.getName().endsWith(IWorkflowConstants.WF_FILE_SUFFIX))
{ {
trdCompile((IFile) res); trdCompile((IFile) res);
} }
} }
} }
else if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))//编译业务组件 else if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))//编译业务组件
{ {
bizCompile(folder); bizCompile(folder);
} }
//输出到控制台编译成功 //输出到控制台编译成功
//刷新目录 //刷新目录
folder.refreshLocal(IResource.DEPTH_INFINITE, null); folder.refreshLocal(IResource.DEPTH_INFINITE, null);
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* 编译流程交易 * 编译流程交易
* @param wfFile * @param wfFile
*/ */
private void trdCompile(IFile wfFile) private void trdCompile(IFile wfFile)
{ {
if (null == wfFile || !wfFile.exists()) if (null == wfFile || !wfFile.exists())
return; return;
boolean isError = true; boolean isError = true;
try try
{ {
File workflowFile = wfFile.getLocation().toFile(); File workflowFile = wfFile.getLocation().toFile();
Workflow workflow = null; Workflow workflow = null;
workflow = (Workflow) CastorTools.unmarshaller(new FileInputStream(workflowFile), Workflow.class); workflow = (Workflow) CastorTools.unmarshaller(new FileInputStream(workflowFile), Workflow.class);
CodeGen<Workflow> codeGen = CodeGen.getTrdInstance(0x103); CodeGen<Workflow> codeGen = CodeGen.getTrdInstance(0x103);
String content = codeGen.genCode(workflow); String content = codeGen.genCode(workflow);
String name = wfFile.getName().replace(IWorkflowConstants.WF_FILE_SUFFIX, "py"); String name = wfFile.getName().replace(IWorkflowConstants.WF_FILE_SUFFIX, "py");
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"));
String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER); 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) FileUtil.createFile(pyFile, content, IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0.equals(cgcVer)
? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8); ? IBapConstants.ENCODING_GBK : IBapConstants.ENCODING_UTF_8);
isError = false; isError = false;
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
printConsole(wfFile, isError, INavigatorConstants.NV_NODE_APPTRD, null); printConsole(wfFile, isError, INavigatorConstants.NV_NODE_APPTRD, null);
} }
/** /**
* 编译业务组件 * 编译业务组件
* @param folder * @param folder
*/ */
private void bizCompile(IFolder folder) throws Exception private void bizCompile(IFolder folder) throws Exception
{ {
boolean isError = true; boolean isError = true;
try try
{ {
CodeGen<IFolder> codeGen = CodeGen.getBizInstance(0x103); CodeGen<IFolder> codeGen = CodeGen.getBizInstance(0x103);
String content = codeGen.genCode(folder); String content = codeGen.genCode(folder);
File objdir = folder.getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation().toFile(); File objdir = folder.getFolder(INavigatorConstants.NV_NODE_RESCPL).getLocation().toFile();
File pyFile = new File(objdir, folder.getName() + ".py"); File pyFile = new File(objdir, folder.getName() + ".py");
FileUtil.createFile(pyFile, content, IBapConstants.ENCODING_GBK); FileUtil.createFile(pyFile, content, IBapConstants.ENCODING_GBK);
isError = false; isError = false;
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
printConsole(folder, isError, INavigatorConstants.NV_NODE_PKGCMP, null); printConsole(folder, isError, INavigatorConstants.NV_NODE_PKGCMP, null);
} }
private void printConsole(IResource res, boolean error, String type, String detail) private void printConsole(IResource res, boolean error, String type, String detail)
{ {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append("==========CGC==========").append("\n"); buf.append("==========CGC==========").append("\n");
if (INavigatorConstants.NV_NODE_PKGCMP.equals(type)) if (INavigatorConstants.NV_NODE_PKGCMP.equals(type))
{ {
buf.append("编译交易:").append(res.getFullPath().toString()).append("\n"); buf.append("编译交易:").append(res.getFullPath().toString()).append("\n");
} }
else else
{ {
buf.append("编译业务组件:").append(res.getFullPath().toString()).append("\n"); buf.append("编译业务组件:").append(res.getFullPath().toString()).append("\n");
} }
//相信的编译过程. //相信的编译过程.
if (null != detail) if (null != detail)
{ {
buf.append(detail).append("\n"); buf.append(detail).append("\n");
} }
if (error) if (error)
{ {
buf.append("结果:编译失败").append("\n"); buf.append("结果:编译失败").append("\n");
} }
else else
{ {
buf.append("结果:编译成功").append("\n"); buf.append("结果:编译成功").append("\n");
} }
BapConsole.getInstance().printMsg(buf.toString(), error); BapConsole.getInstance().printMsg(buf.toString(), error);
} }
} }
// created by 陈雨露 at 2012-3-20 下午2:38:38 // created by 陈雨露 at 2012-3-20 下午2:38:38
/** /**
* Special Declaration: These technical material reserved as the technical * Special Declaration: These technical material reserved as the technical
* secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law" * secrets by Bankit TECHNOLOGY have been protected by the "Copyright Law"
* "ordinances on Protection of Computer Software" and other relevant * "ordinances on Protection of Computer Software" and other relevant
* administrative regulations and international treaties. Without the written * administrative regulations and international treaties. Without the written
* permission of the Company, no person may use (including but not limited to * permission of the Company, no person may use (including but not limited to
* the illegal copy, distribute, display, image, upload, and download) and * the illegal copy, distribute, display, image, upload, and download) and
* disclose the above technical documents to any third party. Otherwise, any * disclose the above technical documents to any third party. Otherwise, any
* infringer shall afford the legal liability to the company. * infringer shall afford the legal liability to the company.
* *
* 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》 * 特别声明:本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》
* 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公 * 等法律、法规、行政规章以及有关国际条约的保护,浙江宇信班克信息技术有限公
* 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人 * 司享有知识产权、保留一切权利并视其为技术秘密。未经本公司书面许可,任何人
* 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使 * 不得擅自(包括但不限于:以非法的方式复制、传播、展示、镜像、上载、下载)使
* 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。 * 用,不得向第三方泄露、透露、披露。否则,本公司将依法追究侵权者的法律责任。
* 特此声明! * 特此声明!
* *
* Copyright(C) 2012 Bankit Tech, All rights reserved. * Copyright(C) 2012 Bankit Tech, All rights reserved.
*/ */
package cn.com.bankit.ide.bap.compile.cgc.template; package cn.com.bankit.ide.bap.compile.cgc.template;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Locale; 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 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;
public class TemplateUtil public class TemplateUtil
{ {
public static String merge(String templateName, Map<?, ?> root) public static String merge(String templateName, Map<?, ?> root)
{ {
try try
{ {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1"); // cfg.setClassForTemplateLoading(TemplateUtil.class, "/cgc_v1");
String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER); String cgcVer = BapPreActivator.getDefault().getPreferenceStore().getString(IBapConstants.BAP_PREF_CPL_CGC_VER);
String pathPrefix = "/cgc_v3"; String pathPrefix = "/cgc_v3";
if(IBapConstants.BAP_PREF_CPL_CGC_VER_V3_PY3.equals(cgcVer)){ if(IBapConstants.BAP_PREF_CPL_CGC_VER_V3_PY3.equals(cgcVer)){
pathPrefix = "/cgc_v3_py3"; pathPrefix = "/cgc_v3_py3";
} }
cfg.setClassForTemplateLoading(TemplateUtil.class, pathPrefix); 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();
Writer out = new OutputStreamWriter(bos); Writer out = new OutputStreamWriter(bos);
temp.process(root, out); temp.process(root, out);
out.flush(); out.flush();
out.close(); out.close();
return new String(bos.toByteArray()); return new String(bos.toByteArray());
} }
catch (IOException e) catch (IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
catch (TemplateException e) catch (TemplateException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
} }
...@@ -45,107 +45,99 @@ import cn.com.bankit.ide.bap.preferences.BapPreActivator; ...@@ -45,107 +45,99 @@ import cn.com.bankit.ide.bap.preferences.BapPreActivator;
import cn.com.bankit.ide.bap.preferences.controls.BapBooleanEditField; import cn.com.bankit.ide.bap.preferences.controls.BapBooleanEditField;
/** /**
* <DL> * <DL>
* <DT><B> 标题. </B></DT> * <DT><B> 标题. </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 朱克平 $Author$ * @author 朱克平 $Author$
* @author 浙江宇信班克信息技术有限公司 * @author 浙江宇信班克信息技术有限公司
* @version $Id$ * @version $Id$
*/ */
public class CGCCompilePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage public class CGCCompilePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
{
BapBooleanEditField filter; BapBooleanEditField filter;
Group filterGroup; Group filterGroup;
StringFieldEditor value; StringFieldEditor value;
public CGCCompilePreferencePage() public CGCCompilePreferencePage() {
{ super(GRID);
super(GRID); setPreferenceStore(BapPreActivator.getDefault().getPreferenceStore());
setPreferenceStore(BapPreActivator.getDefault().getPreferenceStore()); // setDescription(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
// setDescription(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME)); }
}
protected void createFieldEditors() {
protected void createFieldEditors() ComboFieldEditor combo = new ComboFieldEditor(IBapConstants.BAP_PREF_CPL_CGC_VER,
{ BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER),
ComboFieldEditor combo = new ComboFieldEditor(IBapConstants.BAP_PREF_CPL_CGC_VER, BapResource new String[][] {
.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER), new String[][] { { BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V1_0_0),
{ BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V1_0_0), IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0 },
IBapConstants.BAP_PREF_CPL_CGC_VER_V1_0_0 }}, getFieldEditorParent()); { BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER_V3_PY3),
addField(combo); IBapConstants.BAP_PREF_CPL_CGC_VER_V3_PY3 } },
getFieldEditorParent());
addFilter(); addField(combo);
// addDescriptor();
} addFilter();
// addDescriptor();
private void addFilter() }
{
filterGroup = new Group(getFieldEditorParent(), SWT.NONE); private void addFilter() {
filterGroup.setText(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME)); filterGroup = new Group(getFieldEditorParent(), SWT.NONE);
filterGroup.setLayout(new FillLayout()); 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; GridData gd = new GridData(GridData.FILL_HORIZONTAL);
filterGroup.setLayoutData(gd); 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); 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); value = new StringFieldEditor(IBapConstants.BAP_PREF_CPL_FILTER_VALUE,
BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_VALUE), filterGroup);
addField(filter);
addField(value); addField(filter);
addField(value);
final Button button = (Button) filter.getChangeControl(filterGroup);
button.addSelectionListener(new SelectionListener() final Button button = (Button) filter.getChangeControl(filterGroup);
{ button.addSelectionListener(new SelectionListener() {
@Override @Override
public void widgetSelected(SelectionEvent e) public void widgetSelected(SelectionEvent e) {
{ boolean bval = button.getSelection();
boolean bval = button.getSelection(); value.setEnabled(bval, filterGroup);
value.setEnabled(bval, filterGroup); }
}
@Override
@Override public void widgetDefaultSelected(SelectionEvent e) {
public void widgetDefaultSelected(SelectionEvent e)
{ }
});
} }
});
} @Override
public void init(IWorkbench workbench) {
@Override // TODO Auto-generated method stub
public void init(IWorkbench workbench)
{ }
// TODO Auto-generated method stub
@Override
} protected void checkState() {
// TODO Auto-generated method stub
@Override super.checkState();
protected void checkState() IPreferenceStore store = BapPreActivator.getDefault().getPreferenceStore();
{ if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE)) {
// TODO Auto-generated method stub value.setEnabled(true, filterGroup);
super.checkState(); } else {
IPreferenceStore store = BapPreActivator.getDefault().getPreferenceStore(); value.setEnabled(false, filterGroup);
if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE)) }
{ }
value.setEnabled(true, filterGroup);
}
else
{
value.setEnabled(false, filterGroup);
}
}
} }
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
</property> </property>
<property <property
name="aboutText" 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>
<property <property
name="startupForegroundColor" name="startupForegroundColor"
...@@ -96,14 +96,14 @@ ...@@ -96,14 +96,14 @@
name="appName" name="appName"
value="Bap IDE"> value="Bap IDE">
</property> </property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
<property <property
name="aboutImage" name="aboutImage"
value="icons/splash.png"> value="icons/splash.png">
</property> </property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
</product> </product>
</extension> </extension>
<extension <extension
......
...@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui, ...@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources;bundle-version="3.7.100", 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.lib;bundle-version="1.0.0",
cn.com.bankit.ide.common.resources;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: . Bundle-ClassPath: .
Export-Package: cn.com.bankit.ide.common.ftp, Export-Package: cn.com.bankit.ide.common.ftp,
cn.com.bankit.ide.common.ftp.actions, 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 @@ ...@@ -15,6 +15,7 @@
<classpathentry exported="true" kind="lib" path="lib/wsdl4j-1.6.2.jar"/> <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/xercesImpl-2.9.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/XmlSchema-1.3.2.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.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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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.4"/>
<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.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
#Mon Sep 01 17:19:01 CST 2008
eclipse.preferences.version=1 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.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning 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