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

1、BAPIDE适配到1.8

2、BAPIDE支持sftp
3、BAPIDE集成git插件
parent 24329b75
......@@ -2,3 +2,4 @@
*.ftl
*.pkc
bin/
.metadata/
......@@ -45,51 +45,51 @@ 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()
{
public CGCCompilePreferencePage() {
super(GRID);
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()
{
ComboFieldEditor combo = new ComboFieldEditor(IBapConstants.BAP_PREF_CPL_CGC_VER, BapResource
.getPluginResource().getString(BapResource.BAP_PREF_CPL_CGC_VER), new String[][] {
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());
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();
// addDescriptor();
}
private void addFilter()
{
private void addFilter() {
filterGroup = new Group(getFieldEditorParent(), SWT.NONE);
filterGroup.setText(BapResource.getPluginResource().getString(BapResource.BAP_PREF_CPL_FILTER_NAME));
filterGroup.setLayout(new FillLayout());
......@@ -98,53 +98,45 @@ public class CGCCompilePreferencePage extends FieldEditorPreferencePage implemen
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);
final Button button = (Button) filter.getChangeControl(filterGroup);
button.addSelectionListener(new SelectionListener()
{
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e)
{
public void widgetSelected(SelectionEvent e) {
boolean bval = button.getSelection();
value.setEnabled(bval, filterGroup);
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
@Override
public void init(IWorkbench workbench)
{
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
@Override
protected void checkState()
{
protected void checkState() {
// TODO Auto-generated method stub
super.checkState();
IPreferenceStore store = BapPreActivator.getDefault().getPreferenceStore();
if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE))
{
if (store.getBoolean(IBapConstants.BAP_PREF_CPL_FILTER_ENABLE)) {
value.setEnabled(true, filterGroup);
}
else
{
} 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
......@@ -51,44 +51,59 @@ import cn.com.bankit.ide.common.ftp.model.UploadModel;
* @author 浙江宇信班克信息技术有限公司
* @version 1.0.0 2012-2-13 上午11:40:59
*/
public class FtpUploadJob extends Job implements IJobChangeListener
{
private List<UploadModel> list;
public class FtpUploadJob extends Job implements IJobChangeListener {
protected List<UploadModel> list;
private ConnNode connNode;
protected ConnNode connNode;
private FTPClient ftpClient;
// private volatile boolean isOverload = false;
//
// private volatile boolean isRemeber = false;
// private volatile boolean isOverload = false;
//
// private volatile boolean isRemeber = false;
public static final int FTP_DEFAULT_TIMES = 1;
public static final int UP_OW = 0;//上传成功,覆盖
public static final int UP_UN_OW = 1;//文件存在,不覆盖。
public static final int UP_LOAD = 2;//上传成功,覆盖
public static final int UP_OW = 0;// 上传成功,覆盖
public static final int UP_UN_OW = 1;// 文件存在,不覆盖。
public static final int UP_LOAD = 2;// 上传成功,覆盖
protected int total;
private int total, upcnt,owcnt, unowcnt;
private int upcnt;
private int times = FTP_DEFAULT_TIMES;//默认为1次
private int owcnt;
public FtpUploadJob(String name)
{
private int unowcnt;
private int times = FTP_DEFAULT_TIMES;// 默认为1次
public FtpUploadJob(String name) {
super(name);
}
public FtpUploadJob(ConnNode connNode, List<UploadModel> list, int times)
{
public FtpUploadJob(ConnNode connNode, List<UploadModel> list, int times) {
super(FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_ACTION_UPLOAD));
this.connNode = connNode;
this.list = list;
this.times = times;
}
protected void doRun(IProgressMonitor monitor) throws Exception {
if ((this.connNode.getStatus() == 0) || (this.connNode.isModify())) {
this.connNode.aysconnect(false);
Thread.currentThread();
Thread.sleep(100L);
}
this.ftpClient = this.connNode.getFtpClient();
if (this.ftpClient != null)
uploadFile(monitor);
}
@Override
protected IStatus run(IProgressMonitor monitor)
{
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_OTHER_X_WAIT_MSG),
IProgressMonitor.UNKNOWN);
......@@ -96,10 +111,8 @@ public class FtpUploadJob extends Job implements IJobChangeListener
IStatus status = Status.OK_STATUS;
total = owcnt = unowcnt = 0;
while (times > 0)
{
try
{
while (times > 0) {
try {
if (null == list || list.size() <= 0)
return status;
......@@ -115,62 +128,54 @@ public class FtpUploadJob extends Job implements IJobChangeListener
// }
// ftpClient.changeWorkingDirectory(remoteDir);
//ftpClient
try
{
ftpClient = connNode.getFtpClient();
if (ftpClient.isAvailable())
{
connNode.setStatus(ConnNode.DISCONNECT);
}
}catch(Exception e)
{
e.printStackTrace();
connNode.setStatus(ConnNode.DISCONNECT);
}
if (connNode.getStatus() == ConnNode.DISCONNECT || connNode.isModify())
// ftpClient = connNode.getFtpClient();
// if (null == ftpClient || ftpClient.isConnected())
{
connNode.aysconnect(false);
Thread.currentThread();
Thread.sleep(100);
}
ftpClient = connNode.getFtpClient();
if (ftpClient != null)
uploadFile(monitor);
// ftpClient
// try {
// ftpClient = connNode.getFtpClient();
// if (ftpClient.isAvailable()) {
// connNode.setStatus(ConnNode.DISCONNECT);
// }
// } catch (Exception e) {
// e.printStackTrace();
// connNode.setStatus(ConnNode.DISCONNECT);
// }
// if (connNode.getStatus() == ConnNode.DISCONNECT || connNode.isModify())
//
// // ftpClient = connNode.getFtpClient();
// // if (null == ftpClient || ftpClient.isConnected())
// {
// connNode.aysconnect(false);
//
// Thread.currentThread();
// Thread.sleep(100);
// }
// ftpClient = connNode.getFtpClient();
//
// if (ftpClient != null)
// uploadFile(monitor);
doRun(monitor);
connNode.setModify(false);
return status;
} catch (Exception e)
{
} catch (Exception e) {
if (status == Status.OK_STATUS)
status = new Status(Status.ERROR, FtpActivator.PLUGIN_ID,
FtpActivator.getPluginResource().getString(
FtpConstants.FTP_I18N_J_D_E_UP_F)
+ "\n" + e.getMessage());
FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_J_D_E_UP_F) + "\n"
+ e.getMessage());
else
e.printStackTrace();
// 服务器断开了传输通道连接,
connNode.disConnect();
times--;
} finally
{
} finally {
monitor.done();
if (this.total >= 0 && connNode.getStatus() != ConnNode.DISCONNECT)
{
Display.getDefault().asyncExec(new Runnable()
{
if (this.total >= 0 && connNode.getStatus() != ConnNode.DISCONNECT) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run()
{
public void run() {
StringBuffer sb = new StringBuffer();
sb.append(connNode.getLabel());
sb.append("[").append(connNode.getUsername());
......@@ -180,13 +185,13 @@ public class FtpUploadJob extends Job implements IJobChangeListener
sb.append(connNode.getPort());
sb.append("]-部署结果");
MessageDialog.openInformation(new Shell(), sb.toString(), FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_OTHER_X_TOTAL, new Object[]
{
FtpUploadJob.this.total,
FtpUploadJob.this.upcnt,
FtpUploadJob.this.owcnt,
FtpUploadJob.this.unowcnt}));
MessageDialog
.openInformation(new Shell(), sb.toString(),
FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_OTHER_X_TOTAL,
new Object[] { FtpUploadJob.this.total,
FtpUploadJob.this.upcnt, FtpUploadJob.this.owcnt,
FtpUploadJob.this.unowcnt }));
// MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
// "ftp", FtpActivator
......@@ -215,21 +220,21 @@ public class FtpUploadJob extends Job implements IJobChangeListener
}
// if (connNode.getStatus() == ConnNode.DISCONNECT)
// Display.getDefault().asyncExec(new Runnable()
// {
// @Override
// public void run()
// {
// MessageDialog.openError(Display.getDefault().getActiveShell(), "ftp", "服务器断开了连接,请重试");
// }
// });
// if (connNode.getStatus() == ConnNode.DISCONNECT)
// Display.getDefault().asyncExec(new Runnable()
// {
// @Override
// public void run()
// {
// MessageDialog.openError(Display.getDefault().getActiveShell(), "ftp",
// "服务器断开了连接,请重试");
// }
// });
return status;
}
private void uploadFile(IProgressMonitor monitor) throws Exception
{
private void uploadFile(IProgressMonitor monitor) throws Exception {
if (monitor.isCanceled())
return;
......@@ -242,90 +247,80 @@ public class FtpUploadJob extends Job implements IJobChangeListener
int upType = UP_LOAD;
try
{
for (UploadModel up : list)
{
try {
for (UploadModel up : list) {
upType = UP_LOAD;
try
{
try {
String remoteDir = null;
boolean isExist = false;
if (up.isAbsPath())
remoteDir = up.getRemotePath();
else
{
else {
remoteDir = basePath + up.getRemotePath();
}
// 判断上传目录是否为当前ftp目录,否则要cd到那个目录
if (!remoteDir.equals(ftpClient.printWorkingDirectory()))
{
if (!remoteDir.equals(ftpClient.printWorkingDirectory())) {
ftpClient.enterLocalPassiveMode();
// String chgPath = remoteDir.substring(0, remoteDir.lastIndexOf("/"));
// boolean ischg = ftpClient.changeWorkingDirectory(chgPath);
// String chgPath = remoteDir.substring(0,
// remoteDir.lastIndexOf("/"));
// boolean ischg =
// ftpClient.changeWorkingDirectory(chgPath);
// if (!ischg)
// {
// throw new RuntimeException(FtpActivator.getPluginResource().getString(
// FtpConstants.FTP_I18N_OTHER_IO_E_DIR_N)
// + "\n" + chgPath);
// }
// if (!ischg)
// {
// throw new
// RuntimeException(FtpActivator.getPluginResource().getString(
// FtpConstants.FTP_I18N_OTHER_IO_E_DIR_N)
// + "\n" + chgPath);
// }
// // 判断是否存在目录,如果不存在则创建
// isExist = false;
//
// for (FTPFile rf : ftpClient.listFiles())
// {
// // System.err.println(rf);
// if (remoteDir.endsWith(rf.getName()))
// {
// isExist = true;
// }
// }
// if (!isExist)
// {
// ftpClient.makeDirectory(remoteDir);
// }
// // 判断是否存在目录,如果不存在则创建
// isExist = false;
//
// for (FTPFile rf : ftpClient.listFiles())
// {
// // System.err.println(rf);
// if (remoteDir.endsWith(rf.getName()))
// {
// isExist = true;
// }
// }
// if (!isExist)
// {
// ftpClient.makeDirectory(remoteDir);
// }
String dirPath = "";
if (up.isAbsPath())
{
if (up.isAbsPath()) {
dirPath = up.getRemotePath();
ftpClient.changeWorkingDirectory("/");
}
else
{
} else {
dirPath = up.getRemotePath();
ftpClient.changeWorkingDirectory(basePath);
}
for(String p : dirPath.split("/"))
{
for (String p : dirPath.split("/")) {
if (p.length() == 0)
continue;
// System.out.println("path : " + p);
// System.out.println("path : " + p);
isExist = ftpClient.changeWorkingDirectory(p);
if (!isExist)
{
if (!ftpClient.makeDirectory(p))
{
if (!isExist) {
if (!ftpClient.makeDirectory(p)) {
throw new RuntimeException(FtpActivator.getPluginResource().getString(
FtpConstants.FTP_I18N_OTHER_IO_MK_DIR_N)
+ "\n" + ftpClient.printWorkingDirectory() + "/" + p);
throw new RuntimeException(FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_OTHER_IO_MK_DIR_N) + "\n"
+ ftpClient.printWorkingDirectory() + "/" + p);
}
if (!ftpClient.changeWorkingDirectory(p))
{
throw new RuntimeException(FtpActivator.getPluginResource().getString(
FtpConstants.FTP_I18N_OTHER_IO_E_DIR_N)
+ "\n" + ftpClient.printWorkingDirectory() + "/" + p);
if (!ftpClient.changeWorkingDirectory(p)) {
throw new RuntimeException(FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_OTHER_IO_E_DIR_N) + "\n"
+ ftpClient.printWorkingDirectory() + "/" + p);
}
}
}
......@@ -336,99 +331,91 @@ public class FtpUploadJob extends Job implements IJobChangeListener
// ftpClient.setFileType(FTP.ASCII_FILE_TYPE);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
for (final FTPFile rf : ftpClient.listFiles())
{
for (final FTPFile rf : ftpClient.listFiles()) {
final File localFile = up.getLocalJavaFile();
//如存在并且不覆盖,不上传。
if (rf.getName().equals(localFile.getName()) && !up.isOverWrite())
{
// 如存在并且不覆盖,不上传。
if (rf.getName().equals(localFile.getName()) && !up.isOverWrite()) {
upType = UP_UN_OW;
continue;
}
else if (rf.getName().equals(localFile.getName()) && up.isOverWrite())
{
} else if (rf.getName().equals(localFile.getName()) && up.isOverWrite()) {
upType = UP_OW;
break;
}
}
// 判断是需要覆盖
// if (!isRemeber)
// {
// isOverload = false;
// isExist = false;
// for (final FTPFile rf : ftpClient.listFiles())
// {
// final File localFile = up.getLocalJavaFile();
// if (rf.getName().equals(localFile.getName()))
// {
// isExist = true;
// Display.getDefault().syncExec(new Runnable()
// {
//
// @Override
// public void run()
// {
// OverwriteDialog dialog = new OverwriteDialog(
// Display.getDefault().getShells()[0], FtpActivator.getPluginResource()
// .getString(FtpConstants.FTP_I18N_ACTION_UPLOAD), localFile, rf);
//
// int status = dialog.open();
// isRemeber = dialog.getRemeber();
//
// if (status == IDialogConstants.OK_ID)
// isOverload = true;
// else
// {
// isOverload = false;
// }
// }
// });
// break;
// }
// }
// if (!isRemeber)
// {
// isOverload = false;
// isExist = false;
// for (final FTPFile rf : ftpClient.listFiles())
// {
// final File localFile = up.getLocalJavaFile();
// if (rf.getName().equals(localFile.getName()))
// {
// isExist = true;
// Display.getDefault().syncExec(new Runnable()
// {
//
// @Override
// public void run()
// {
// OverwriteDialog dialog = new OverwriteDialog(
// Display.getDefault().getShells()[0],
// FtpActivator.getPluginResource()
// .getString(FtpConstants.FTP_I18N_ACTION_UPLOAD),
// localFile, rf);
//
// int status = dialog.open();
// isRemeber = dialog.getRemeber();
//
// if (status == IDialogConstants.OK_ID)
// isOverload = true;
// else
// {
// isOverload = false;
// }
// }
// });
// break;
// }
// }
// 如果记住操作,并且取消上传
// if (isRemeber && !isOverload)
// return;
//
// if (isExist && !isOverload)
// continue;
// }
// if (isRemeber && !isOverload)
// return;
//
// if (isExist && !isOverload)
// continue;
// }
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() }), (int) (up.getLocalJavaFile()
.length() / 1024));
FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_OTHER_X_NOW,
new Object[] {
FtpActivator.getPluginResource()
.getString(FtpConstants.FTP_I18N_ACTION_UPLOAD),
up.getLocalFile().getFullPath().toString() }),
(int) (up.getLocalJavaFile().length() / 1024));
out = ftpClient.storeFileStream(up.getLocalJavaFile().getName());
if (out == null)
{
throw new Exception(FtpActivator.getPluginResource().getString(
FtpConstants.FTP_I18N_OTHER_IO_E_W));
if (out == null) {
throw new Exception(
FtpActivator.getPluginResource().getString(FtpConstants.FTP_I18N_OTHER_IO_E_W));
}
in = new FileInputStream(up.getLocalJavaFile());
} catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
throw e;
}
try
{
if (null != out && null != in)
{
try {
if (null != out && null != in) {
byte[] buf = new byte[FtpConstants.FTP_TRANS_PER_SIZE];
int count = 0;
int tail = 0;
while ((count = in.read(buf)) > 0)
{
while ((count = in.read(buf)) > 0) {
out.write(buf, 0, count);
out.flush();
tail += count % 1024;
......@@ -438,39 +425,31 @@ public class FtpUploadJob extends Job implements IJobChangeListener
return;
}
}
} catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally
{
try
{
} finally {
try {
if (null != in)
in.close();
} catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
try
{
if (null != out)
{
try {
if (null != out) {
out.close();
out = null;
if (ftpClient.completePendingCommand())
{
if(upType == UP_OW)
if (ftpClient.completePendingCommand()) {
if (upType == UP_OW)
this.owcnt++;
else if(upType == UP_LOAD)
this.upcnt ++;
else if (upType == UP_LOAD)
this.upcnt++;
else
this.unowcnt ++;
this.unowcnt++;
}
}
} catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
// try
......@@ -488,42 +467,35 @@ public class FtpUploadJob extends Job implements IJobChangeListener
// }
}
}
} finally
{
} finally {
// 变换为原来的目录
ftpClient.changeWorkingDirectory(basePath);
}
}
@Override
public void aboutToRun(IJobChangeEvent event)
{
public void aboutToRun(IJobChangeEvent event) {
// TODO Auto-generated method stub
}
@Override
public void awake(IJobChangeEvent event)
{
public void awake(IJobChangeEvent event) {
}
@Override
public void done(IJobChangeEvent event)
{
public void done(IJobChangeEvent event) {
}
@Override
public void running(IJobChangeEvent event)
{
public void running(IJobChangeEvent event) {
}
@Override
public void scheduled(IJobChangeEvent event)
{
public void scheduled(IJobChangeEvent event) {
}
@Override
public void sleeping(IJobChangeEvent event)
{
public void sleeping(IJobChangeEvent event) {
}
}
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