use of org.apache.hop.workflow.actions.sftp.SftpClient in project hop by apache.
the class ActionSftpPut method execute.
@Override
public Result execute(Result previousResult, int nr) throws HopException {
Result result = previousResult;
List<RowMetaAndData> rows = result.getRows();
result.setResult(false);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.StartAction"));
}
ArrayList<FileObject> myFileList = new ArrayList<>();
if (copyingPrevious) {
if (rows.size() == 0) {
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.ArgsFromPreviousNothing"));
}
result.setResult(true);
return result;
}
try {
RowMetaAndData resultRow = null;
// Copy the input row to the (command line) arguments
for (int iteration = 0; iteration < rows.size(); iteration++) {
resultRow = rows.get(iteration);
// Get file names
String filePrevious = resultRow.getString(0, null);
if (!Utils.isEmpty(filePrevious)) {
FileObject file = HopVfs.getFileObject(filePrevious);
if (!file.exists()) {
logError(BaseMessages.getString(PKG, "ActionSftpPut.Log.FilefromPreviousNotFound", filePrevious));
} else {
myFileList.add(file);
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ActionSftpPut.Log.FilenameFromResult", filePrevious));
}
}
}
}
} catch (Exception e) {
logError(BaseMessages.getString(PKG, "ActionSftpPut.Error.ArgFromPrevious"));
result.setNrErrors(1);
// free resource
myFileList = null;
return result;
}
}
if (copyingPreviousFiles) {
List<ResultFile> resultFiles = result.getResultFilesList();
if (resultFiles == null || resultFiles.size() == 0) {
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.ArgsFromPreviousNothingFiles"));
}
result.setResult(true);
return result;
}
try {
for (Iterator<ResultFile> it = resultFiles.iterator(); it.hasNext() && !parentWorkflow.isStopped(); ) {
ResultFile resultFile = it.next();
FileObject file = resultFile.getFile();
if (file != null) {
if (!file.exists()) {
logError(BaseMessages.getString(PKG, "ActionSftpPut.Log.FilefromPreviousNotFound", file.toString()));
} else {
myFileList.add(file);
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ActionSftpPut.Log.FilenameFromResult", file.toString()));
}
}
}
}
} catch (Exception e) {
logError(BaseMessages.getString(PKG, "ActionSftpPut.Error.ArgFromPrevious"));
result.setNrErrors(1);
// free resource
myFileList = null;
return result;
}
}
SftpClient sftpclient = null;
// String substitution..
String realServerName = resolve(serverName);
String realServerPort = resolve(serverPort);
String realUsername = resolve(userName);
String realPassword = Encr.decryptPasswordOptionallyEncrypted(resolve(password));
String realSftpDirString = resolve(remoteDirectory);
String realWildcard = resolve(wildcard);
String realLocalDirectory = resolve(localDirectory);
String realKeyFilename = null;
String realPassPhrase = null;
// Destination folder (Move to)
String realDestinationFolder = resolve(getDestinationFolder());
try {
if (getAfterFtps() == AFTER_FTPSPUT_MOVE) {
if (Utils.isEmpty(realDestinationFolder)) {
logError(BaseMessages.getString(PKG, "ActionSSH2PUT.Log.DestinatFolderMissing"));
result.setNrErrors(1);
return result;
} else {
FileObject folder = null;
try {
folder = HopVfs.getFileObject(realDestinationFolder);
// Let's check if folder exists...
if (!folder.exists()) {
// Do we need to create it?
if (createDestinationFolder) {
folder.createFolder();
} else {
logError(BaseMessages.getString(PKG, "ActionSSH2PUT.Log.DestinatFolderNotExist", realDestinationFolder));
result.setNrErrors(1);
return result;
}
}
realDestinationFolder = HopVfs.getFilename(folder);
} catch (Exception e) {
throw new HopException(e);
} finally {
if (folder != null) {
try {
folder.close();
} catch (Exception e) {
/* Ignore */
}
}
}
}
}
if (isUseKeyFile()) {
// We must have here a private keyfilename
realKeyFilename = resolve(getKeyFilename());
if (Utils.isEmpty(realKeyFilename)) {
// Error..Missing keyfile
logError(BaseMessages.getString(PKG, "ActionSftp.Error.KeyFileMissing"));
result.setNrErrors(1);
return result;
}
if (!HopVfs.fileExists(realKeyFilename)) {
// Error.. can not reach keyfile
logError(BaseMessages.getString(PKG, "ActionSftp.Error.KeyFileNotFound"));
result.setNrErrors(1);
return result;
}
realPassPhrase = resolve(getKeyPassPhrase());
}
// Create sftp client to host ...
sftpclient = new SftpClient(InetAddress.getByName(realServerName), Const.toInt(realServerPort, 22), realUsername, realKeyFilename, realPassPhrase);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.OpenedConnection", realServerName, "" + realServerPort, realUsername));
}
// Set compression
sftpclient.setCompression(getCompression());
// Set proxy?
String realProxyHost = resolve(getProxyHost());
if (!Utils.isEmpty(realProxyHost)) {
// Set proxy
sftpclient.setProxy(realProxyHost, resolve(getProxyPort()), resolve(getProxyUsername()), resolve(getProxyPassword()), getProxyType());
}
// login to ftp host ...
sftpclient.login(realPassword);
// move to spool dir ...
if (!Utils.isEmpty(realSftpDirString)) {
boolean existfolder = sftpclient.folderExists(realSftpDirString);
if (!existfolder) {
if (!isCreateRemoteFolder()) {
throw new HopException(BaseMessages.getString(PKG, "ActionSftpPut.Error.CanNotFindRemoteFolder", realSftpDirString));
}
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Error.CanNotFindRemoteFolder", realSftpDirString));
}
// Let's create folder
sftpclient.createFolder(realSftpDirString);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.RemoteFolderCreated", realSftpDirString));
}
}
sftpclient.chdir(realSftpDirString);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.ChangedDirectory", realSftpDirString));
}
}
if (!copyingPrevious && !copyingPreviousFiles) {
// Get all the files in the local directory...
myFileList = new ArrayList<>();
FileObject localFiles = HopVfs.getFileObject(realLocalDirectory);
FileObject[] children = localFiles.getChildren();
if (children != null) {
for (int i = 0; i < children.length; i++) {
// Get filename of file or directory
if (children[i].getType().equals(FileType.FILE)) {
myFileList.add(children[i]);
}
}
// end for
}
}
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.RowsFromPreviousResult", myFileList.size()));
}
Pattern pattern = null;
if (!copyingPrevious && !copyingPreviousFiles) {
if (!Utils.isEmpty(realWildcard)) {
pattern = Pattern.compile(realWildcard);
}
}
int nrFilesSent = 0;
int nrFilesMatched = 0;
// Get the files in the list and execute sftp.put() for each file
Iterator<FileObject> it = myFileList.iterator();
while (it.hasNext() && !parentWorkflow.isStopped()) {
FileObject myFile = it.next();
try {
String localFilename = myFile.toString();
String destinationFilename = myFile.getName().getBaseName();
boolean getIt = true;
// First see if the file matches the regular expression!
if (pattern != null) {
Matcher matcher = pattern.matcher(destinationFilename);
getIt = matcher.matches();
}
if (getIt) {
nrFilesMatched++;
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ActionSftpPut.Log.PuttingFile", localFilename, realSftpDirString));
}
sftpclient.put(myFile, destinationFilename);
nrFilesSent++;
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.TransferredFile", localFilename));
}
// what's next ...
switch(getAfterFtps()) {
case AFTER_FTPSPUT_DELETE:
myFile.delete();
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.DeletedFile", localFilename));
}
break;
case AFTER_FTPSPUT_MOVE:
FileObject destination = null;
try {
destination = HopVfs.getFileObject(realDestinationFolder + Const.FILE_SEPARATOR + myFile.getName().getBaseName());
myFile.moveTo(destination);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.FileMoved", myFile, destination));
}
} finally {
if (destination != null) {
destination.close();
}
}
break;
default:
if (addFilenameResut) {
// Add to the result files...
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, myFile, parentWorkflow.getWorkflowName(), toString());
result.getResultFiles().put(resultFile.getFile().toString(), resultFile);
if (log.isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "ActionSftpPut.Log.FilenameAddedToResultFilenames", localFilename));
}
}
break;
}
}
} finally {
if (myFile != null) {
myFile.close();
}
}
}
// end for
result.setResult(true);
// Abuse the nr of files retrieved vector in the results
//
result.setNrFilesRetrieved(nrFilesSent);
//
if (nrFilesMatched == 0) {
if (isSuccessWhenNoFile()) {
// Just warn user
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionSftpPut.Error.NoFileToSend"));
}
} else {
// Fail
logError(BaseMessages.getString(PKG, "ActionSftpPut.Error.NoFileToSend"));
result.setNrErrors(1);
result.setResult(false);
return result;
}
}
} catch (Exception e) {
result.setNrErrors(1);
logError(BaseMessages.getString(PKG, "ActionSftpPut.Exception", e.getMessage()));
logError(Const.getStackTracker(e));
} finally {
// close connection, if possible
try {
if (sftpclient != null) {
sftpclient.disconnect();
}
} catch (Exception e) {
// just ignore this, makes no big difference
}
// end catch
myFileList = null;
}
return result;
}
use of org.apache.hop.workflow.actions.sftp.SftpClient in project hop by apache.
the class ActionSftpPutDialog method open.
@Override
public IAction open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, action);
ModifyListener lsMod = e -> {
sftpclient = null;
action.setChanged();
};
changed = action.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "ActionSftpPut.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Filename line
Label wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "ActionSftpPut.Name.Label"));
props.setLook(wlName);
FormData fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
fdlName.top = new FormAttachment(0, margin);
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
// The buttons at the bottom
//
Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
// The tab folder between the name and the buttons
//
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "ActionSftpPut.Tab.General.Label"));
Composite wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// ////////////////////////
// START OF SERVER SETTINGS GROUP///
// /
Group wServerSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wServerSettings);
wServerSettings.setText(BaseMessages.getString(PKG, "ActionSftpPut.ServerSettings.Group.Label"));
FormLayout serverSettingsgroupLayout = new FormLayout();
serverSettingsgroupLayout.marginWidth = 10;
serverSettingsgroupLayout.marginHeight = 10;
wServerSettings.setLayout(serverSettingsgroupLayout);
// ServerName line
Label wlServerName = new Label(wServerSettings, SWT.RIGHT);
wlServerName.setText(BaseMessages.getString(PKG, "ActionSftpPut.Server.Label"));
props.setLook(wlServerName);
FormData fdlServerName = new FormData();
fdlServerName.left = new FormAttachment(0, 0);
fdlServerName.top = new FormAttachment(wName, margin);
fdlServerName.right = new FormAttachment(middle, -margin);
wlServerName.setLayoutData(fdlServerName);
wServerName = new TextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wServerName);
wServerName.addModifyListener(lsMod);
FormData fdServerName = new FormData();
fdServerName.left = new FormAttachment(middle, 0);
fdServerName.top = new FormAttachment(wName, margin);
fdServerName.right = new FormAttachment(100, 0);
wServerName.setLayoutData(fdServerName);
// ServerPort line
Label wlServerPort = new Label(wServerSettings, SWT.RIGHT);
wlServerPort.setText(BaseMessages.getString(PKG, "ActionSftpPut.Port.Label"));
props.setLook(wlServerPort);
FormData fdlServerPort = new FormData();
fdlServerPort.left = new FormAttachment(0, 0);
fdlServerPort.top = new FormAttachment(wServerName, margin);
fdlServerPort.right = new FormAttachment(middle, -margin);
wlServerPort.setLayoutData(fdlServerPort);
wServerPort = new TextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wServerPort);
wServerPort.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.Port.Tooltip"));
wServerPort.addModifyListener(lsMod);
FormData fdServerPort = new FormData();
fdServerPort.left = new FormAttachment(middle, 0);
fdServerPort.top = new FormAttachment(wServerName, margin);
fdServerPort.right = new FormAttachment(100, 0);
wServerPort.setLayoutData(fdServerPort);
// UserName line
Label wlUserName = new Label(wServerSettings, SWT.RIGHT);
wlUserName.setText(BaseMessages.getString(PKG, "ActionSftpPut.Username.Label"));
props.setLook(wlUserName);
FormData fdlUserName = new FormData();
fdlUserName.left = new FormAttachment(0, 0);
fdlUserName.top = new FormAttachment(wServerPort, margin);
fdlUserName.right = new FormAttachment(middle, -margin);
wlUserName.setLayoutData(fdlUserName);
wUserName = new TextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wUserName);
wUserName.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.Username.Tooltip"));
wUserName.addModifyListener(lsMod);
FormData fdUserName = new FormData();
fdUserName.left = new FormAttachment(middle, 0);
fdUserName.top = new FormAttachment(wServerPort, margin);
fdUserName.right = new FormAttachment(100, 0);
wUserName.setLayoutData(fdUserName);
// Password line
Label wlPassword = new Label(wServerSettings, SWT.RIGHT);
wlPassword.setText(BaseMessages.getString(PKG, "ActionSftpPut.Password.Label"));
props.setLook(wlPassword);
FormData fdlPassword = new FormData();
fdlPassword.left = new FormAttachment(0, 0);
fdlPassword.top = new FormAttachment(wUserName, margin);
fdlPassword.right = new FormAttachment(middle, -margin);
wlPassword.setLayoutData(fdlPassword);
wPassword = new PasswordTextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPassword);
wPassword.addModifyListener(lsMod);
FormData fdPassword = new FormData();
fdPassword.left = new FormAttachment(middle, 0);
fdPassword.top = new FormAttachment(wUserName, margin);
fdPassword.right = new FormAttachment(100, 0);
wPassword.setLayoutData(fdPassword);
// usePublicKey
Label wlUsePublicKey = new Label(wServerSettings, SWT.RIGHT);
wlUsePublicKey.setText(BaseMessages.getString(PKG, "ActionSftpPut.useKeyFile.Label"));
props.setLook(wlUsePublicKey);
FormData fdlUsePublicKey = new FormData();
fdlUsePublicKey.left = new FormAttachment(0, 0);
fdlUsePublicKey.top = new FormAttachment(wPassword, margin);
fdlUsePublicKey.right = new FormAttachment(middle, -margin);
wlUsePublicKey.setLayoutData(fdlUsePublicKey);
wUsePublicKey = new Button(wServerSettings, SWT.CHECK);
wUsePublicKey.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.useKeyFile.Tooltip"));
props.setLook(wUsePublicKey);
FormData fdUsePublicKey = new FormData();
fdUsePublicKey.left = new FormAttachment(middle, 0);
fdUsePublicKey.top = new FormAttachment(wlUsePublicKey, 0, SWT.CENTER);
fdUsePublicKey.right = new FormAttachment(100, 0);
wUsePublicKey.setLayoutData(fdUsePublicKey);
wUsePublicKey.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeUseKey();
action.setChanged();
}
});
// Key File
wlKeyFilename = new Label(wServerSettings, SWT.RIGHT);
wlKeyFilename.setText(BaseMessages.getString(PKG, "ActionSftpPut.KeyFilename.Label"));
props.setLook(wlKeyFilename);
FormData fdlKeyFilename = new FormData();
fdlKeyFilename.left = new FormAttachment(0, 0);
fdlKeyFilename.top = new FormAttachment(wlUsePublicKey, 2 * margin);
fdlKeyFilename.right = new FormAttachment(middle, -margin);
wlKeyFilename.setLayoutData(fdlKeyFilename);
wbKeyFilename = new Button(wServerSettings, SWT.PUSH | SWT.CENTER);
props.setLook(wbKeyFilename);
wbKeyFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbKeyFilename = new FormData();
fdbKeyFilename.right = new FormAttachment(100, 0);
fdbKeyFilename.top = new FormAttachment(wUsePublicKey, 0);
wbKeyFilename.setLayoutData(fdbKeyFilename);
wKeyFilename = new TextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wKeyFilename.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.KeyFilename.Tooltip"));
props.setLook(wKeyFilename);
wKeyFilename.addModifyListener(lsMod);
FormData fdKeyFilename = new FormData();
fdKeyFilename.left = new FormAttachment(middle, 0);
fdKeyFilename.top = new FormAttachment(wUsePublicKey, margin);
fdKeyFilename.right = new FormAttachment(wbKeyFilename, -margin);
wKeyFilename.setLayoutData(fdKeyFilename);
wbKeyFilename.addListener(SWT.Selection, e -> BaseDialog.presentFileDialog(shell, wKeyFilename, variables, new String[] { "*.pem", "*" }, FILETYPES, true));
// keyfilePass line
wKeyFilePass = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionSftpPut.keyfilePass.Label"), BaseMessages.getString(PKG, "ActionSftpPut.keyfilePass.Tooltip"), true, false);
props.setLook(wKeyFilePass);
wKeyFilePass.addModifyListener(lsMod);
FormData fdkeyfilePass = new FormData();
fdkeyfilePass.left = new FormAttachment(0, -margin);
fdkeyfilePass.top = new FormAttachment(wKeyFilename, margin);
fdkeyfilePass.right = new FormAttachment(100, 0);
wKeyFilePass.setLayoutData(fdkeyfilePass);
Label wlProxyType = new Label(wServerSettings, SWT.RIGHT);
wlProxyType.setText(BaseMessages.getString(PKG, "ActionSftpPut.ProxyType.Label"));
props.setLook(wlProxyType);
FormData fdlProxyType = new FormData();
fdlProxyType.left = new FormAttachment(0, 0);
fdlProxyType.right = new FormAttachment(middle, -margin);
fdlProxyType.top = new FormAttachment(wKeyFilePass, 2 * margin);
wlProxyType.setLayoutData(fdlProxyType);
wProxyType = new CCombo(wServerSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wProxyType.add(SftpClient.PROXY_TYPE_HTTP);
wProxyType.add(SftpClient.PROXY_TYPE_SOCKS5);
// +1: starts at -1
wProxyType.select(0);
props.setLook(wProxyType);
FormData fdProxyType = new FormData();
fdProxyType.left = new FormAttachment(middle, 0);
fdProxyType.top = new FormAttachment(wKeyFilePass, 2 * margin);
fdProxyType.right = new FormAttachment(100, 0);
wProxyType.setLayoutData(fdProxyType);
wProxyType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setDefaultProxyPort();
}
});
// Proxy host line
wProxyHost = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionSftpPut.ProxyHost.Label"), BaseMessages.getString(PKG, "ActionSftpPut.ProxyHost.Tooltip"), false, false);
props.setLook(wProxyHost);
wProxyHost.addModifyListener(lsMod);
FormData fdProxyHost = new FormData();
fdProxyHost.left = new FormAttachment(0, -2 * margin);
fdProxyHost.top = new FormAttachment(wProxyType, margin);
fdProxyHost.right = new FormAttachment(100, 0);
wProxyHost.setLayoutData(fdProxyHost);
// Proxy port line
wProxyPort = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionSftpPut.ProxyPort.Label"), BaseMessages.getString(PKG, "ActionSftpPut.ProxyPort.Tooltip"), false, false);
props.setLook(wProxyPort);
wProxyPort.addModifyListener(lsMod);
FormData fdProxyPort = new FormData();
fdProxyPort.left = new FormAttachment(0, -2 * margin);
fdProxyPort.top = new FormAttachment(wProxyHost, margin);
fdProxyPort.right = new FormAttachment(100, 0);
wProxyPort.setLayoutData(fdProxyPort);
// Proxy username line
wProxyUsername = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionSftpPut.ProxyUsername.Label"), BaseMessages.getString(PKG, "ActionSftpPut.ProxyUsername.Tooltip"), false, false);
props.setLook(wProxyUsername);
wProxyUsername.addModifyListener(lsMod);
FormData fdProxyUsername = new FormData();
fdProxyUsername.left = new FormAttachment(0, -2 * margin);
fdProxyUsername.top = new FormAttachment(wProxyPort, margin);
fdProxyUsername.right = new FormAttachment(100, 0);
wProxyUsername.setLayoutData(fdProxyUsername);
// Proxy password line
wProxyPassword = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionSftpPut.ProxyPassword.Label"), BaseMessages.getString(PKG, "ActionSftpPut.ProxyPassword.Tooltip"), true, false);
props.setLook(wProxyPassword);
wProxyPassword.addModifyListener(lsMod);
FormData fdProxyPasswd = new FormData();
fdProxyPasswd.left = new FormAttachment(0, -2 * margin);
fdProxyPasswd.top = new FormAttachment(wProxyUsername, margin);
fdProxyPasswd.right = new FormAttachment(100, 0);
wProxyPassword.setLayoutData(fdProxyPasswd);
// Test connection button
Button wTest = new Button(wServerSettings, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "ActionSftpPut.TestConnection.Label"));
props.setLook(wTest);
FormData fdTest = new FormData();
wTest.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.TestConnection.Tooltip"));
fdTest.top = new FormAttachment(wProxyPassword, margin);
fdTest.right = new FormAttachment(100, 0);
wTest.setLayoutData(fdTest);
wTest.addListener(SWT.Selection, e -> test());
FormData fdServerSettings = new FormData();
fdServerSettings.left = new FormAttachment(0, margin);
fdServerSettings.top = new FormAttachment(wName, margin);
fdServerSettings.right = new FormAttachment(100, -margin);
wServerSettings.setLayoutData(fdServerSettings);
// ///////////////////////////////////////////////////////////
// / END OF SERVER SETTINGS GROUP
// ///////////////////////////////////////////////////////////
Label wlCompression = new Label(wGeneralComp, SWT.RIGHT);
wlCompression.setText(BaseMessages.getString(PKG, "ActionSftpPut.Compression.Label"));
props.setLook(wlCompression);
FormData fdlCompression = new FormData();
fdlCompression.left = new FormAttachment(0, -margin);
fdlCompression.right = new FormAttachment(middle, 0);
fdlCompression.top = new FormAttachment(wServerSettings, margin);
wlCompression.setLayoutData(fdlCompression);
wCompression = new CCombo(wGeneralComp, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wCompression.add("none");
wCompression.add("zlib");
// +1: starts at -1
wCompression.select(0);
props.setLook(wCompression);
FormData fdCompression = new FormData();
fdCompression.left = new FormAttachment(middle, margin);
fdCompression.top = new FormAttachment(wServerSettings, margin);
fdCompression.right = new FormAttachment(100, 0);
wCompression.setLayoutData(fdCompression);
FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Files TAB ///
// ////////////////////////
CTabItem wFilesTab = new CTabItem(wTabFolder, SWT.NONE);
wFilesTab.setText(BaseMessages.getString(PKG, "ActionSftpPut.Tab.Files.Label"));
Composite wFilesComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFilesComp);
FormLayout filesLayout = new FormLayout();
filesLayout.marginWidth = 3;
filesLayout.marginHeight = 3;
wFilesComp.setLayout(filesLayout);
// ////////////////////////
// START OF Source files GROUP///
// /
Group wgSourceFiles = new Group(wFilesComp, SWT.SHADOW_NONE);
props.setLook(wgSourceFiles);
wgSourceFiles.setText(BaseMessages.getString(PKG, "ActionSftpPut.SourceFiles.Group.Label"));
FormLayout sourceFilesGroupLayout = new FormLayout();
sourceFilesGroupLayout.marginWidth = 10;
sourceFilesGroupLayout.marginHeight = 10;
wgSourceFiles.setLayout(sourceFilesGroupLayout);
// Get arguments from previous result...
Label wlGetPrevious = new Label(wgSourceFiles, SWT.RIGHT);
wlGetPrevious.setText(BaseMessages.getString(PKG, "ActionSftpPut.getPrevious.Label"));
props.setLook(wlGetPrevious);
FormData fdlGetPrevious = new FormData();
fdlGetPrevious.left = new FormAttachment(0, 0);
fdlGetPrevious.top = new FormAttachment(0, margin);
fdlGetPrevious.right = new FormAttachment(middle, -margin);
wlGetPrevious.setLayoutData(fdlGetPrevious);
wGetPrevious = new Button(wgSourceFiles, SWT.CHECK);
props.setLook(wGetPrevious);
wGetPrevious.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.getPrevious.Tooltip"));
FormData fdGetPrevious = new FormData();
fdGetPrevious.left = new FormAttachment(middle, 0);
fdGetPrevious.top = new FormAttachment(wlGetPrevious, 0, SWT.CENTER);
fdGetPrevious.right = new FormAttachment(100, 0);
wGetPrevious.setLayoutData(fdGetPrevious);
wGetPrevious.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (wGetPrevious.getSelection()) {
// only one is allowed
wGetPreviousFiles.setSelection(false);
}
activeCopyFromPrevious();
action.setChanged();
}
});
// Get arguments from previous files result...
Label wlGetPreviousFiles = new Label(wgSourceFiles, SWT.RIGHT);
wlGetPreviousFiles.setText(BaseMessages.getString(PKG, "ActionSftpPut.getPreviousFiles.Label"));
props.setLook(wlGetPreviousFiles);
FormData fdlGetPreviousFiles = new FormData();
fdlGetPreviousFiles.left = new FormAttachment(0, 0);
fdlGetPreviousFiles.top = new FormAttachment(wlGetPrevious, 2 * margin);
fdlGetPreviousFiles.right = new FormAttachment(middle, -margin);
wlGetPreviousFiles.setLayoutData(fdlGetPreviousFiles);
wGetPreviousFiles = new Button(wgSourceFiles, SWT.CHECK);
props.setLook(wGetPreviousFiles);
wGetPreviousFiles.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.getPreviousFiles.Tooltip"));
FormData fdGetPreviousFiles = new FormData();
fdGetPreviousFiles.left = new FormAttachment(middle, 0);
fdGetPreviousFiles.top = new FormAttachment(wlGetPreviousFiles, 0, SWT.CENTER);
fdGetPreviousFiles.right = new FormAttachment(100, 0);
wGetPreviousFiles.setLayoutData(fdGetPreviousFiles);
wGetPreviousFiles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (wGetPreviousFiles.getSelection()) {
// only one is allowed
wGetPrevious.setSelection(false);
}
activeCopyFromPrevious();
action.setChanged();
}
});
// Local Directory line
wlLocalDirectory = new Label(wgSourceFiles, SWT.RIGHT);
wlLocalDirectory.setText(BaseMessages.getString(PKG, "ActionSftpPut.LocalDir.Label"));
props.setLook(wlLocalDirectory);
FormData fdlLocalDirectory = new FormData();
fdlLocalDirectory.left = new FormAttachment(0, 0);
fdlLocalDirectory.top = new FormAttachment(wlGetPreviousFiles, 2 * margin);
fdlLocalDirectory.right = new FormAttachment(middle, -margin);
wlLocalDirectory.setLayoutData(fdlLocalDirectory);
// Browse folders button ...
wbLocalDirectory = new Button(wgSourceFiles, SWT.PUSH | SWT.CENTER);
props.setLook(wbLocalDirectory);
wbLocalDirectory.setText(BaseMessages.getString(PKG, "ActionSftpPut.BrowseFolders.Label"));
FormData fdbLocalDirectory = new FormData();
fdbLocalDirectory.right = new FormAttachment(100, 0);
fdbLocalDirectory.top = new FormAttachment(wlLocalDirectory, 0, SWT.CENTER);
wbLocalDirectory.setLayoutData(fdbLocalDirectory);
wbLocalDirectory.addListener(SWT.Selection, e -> BaseDialog.presentDirectoryDialog(shell, wLocalDirectory, variables));
wLocalDirectory = new TextVar(variables, wgSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wLocalDirectory);
wLocalDirectory.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.LocalDir.Tooltip"));
wLocalDirectory.addModifyListener(lsMod);
FormData fdLocalDirectory = new FormData();
fdLocalDirectory.left = new FormAttachment(middle, 0);
fdLocalDirectory.top = new FormAttachment(wlLocalDirectory, 0, SWT.CENTER);
fdLocalDirectory.right = new FormAttachment(wbLocalDirectory, -margin);
wLocalDirectory.setLayoutData(fdLocalDirectory);
// Wildcard line
wlWildcard = new Label(wgSourceFiles, SWT.RIGHT);
wlWildcard.setText(BaseMessages.getString(PKG, "ActionSftpPut.Wildcard.Label"));
props.setLook(wlWildcard);
FormData fdlWildcard = new FormData();
fdlWildcard.left = new FormAttachment(0, 0);
fdlWildcard.top = new FormAttachment(wbLocalDirectory, margin);
fdlWildcard.right = new FormAttachment(middle, -margin);
wlWildcard.setLayoutData(fdlWildcard);
wWildcard = new TextVar(variables, wgSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wWildcard);
wWildcard.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.Wildcard.Tooltip"));
wWildcard.addModifyListener(lsMod);
FormData fdWildcard = new FormData();
fdWildcard.left = new FormAttachment(middle, 0);
fdWildcard.top = new FormAttachment(wbLocalDirectory, margin);
fdWildcard.right = new FormAttachment(100, 0);
wWildcard.setLayoutData(fdWildcard);
// Success when there is no file...
Label wlSuccessWhenNoFile = new Label(wgSourceFiles, SWT.RIGHT);
wlSuccessWhenNoFile.setText(BaseMessages.getString(PKG, "ActionSftpPut.SuccessWhenNoFile.Label"));
props.setLook(wlSuccessWhenNoFile);
FormData fdlSuccessWhenNoFile = new FormData();
fdlSuccessWhenNoFile.left = new FormAttachment(0, 0);
fdlSuccessWhenNoFile.top = new FormAttachment(wWildcard, margin);
fdlSuccessWhenNoFile.right = new FormAttachment(middle, -margin);
wlSuccessWhenNoFile.setLayoutData(fdlSuccessWhenNoFile);
wSuccessWhenNoFile = new Button(wgSourceFiles, SWT.CHECK);
props.setLook(wSuccessWhenNoFile);
wSuccessWhenNoFile.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.SuccessWhenNoFile.Tooltip"));
FormData fdSuccessWhenNoFile = new FormData();
fdSuccessWhenNoFile.left = new FormAttachment(middle, 0);
fdSuccessWhenNoFile.top = new FormAttachment(wlSuccessWhenNoFile, 0, SWT.CENTER);
fdSuccessWhenNoFile.right = new FormAttachment(100, 0);
wSuccessWhenNoFile.setLayoutData(fdSuccessWhenNoFile);
wSuccessWhenNoFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
action.setChanged();
}
});
// After FTP Put
Label wlAfterFtpPut = new Label(wgSourceFiles, SWT.RIGHT);
wlAfterFtpPut.setText(BaseMessages.getString(PKG, "ActionSftpPut.AfterFTPPut.Label"));
props.setLook(wlAfterFtpPut);
FormData fdlAfterFtpPut = new FormData();
fdlAfterFtpPut.left = new FormAttachment(0, 0);
fdlAfterFtpPut.right = new FormAttachment(middle, -margin);
fdlAfterFtpPut.top = new FormAttachment(wlSuccessWhenNoFile, 2 * margin);
wlAfterFtpPut.setLayoutData(fdlAfterFtpPut);
wAfterFtpPut = new CCombo(wgSourceFiles, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wAfterFtpPut.add(BaseMessages.getString(PKG, "ActionSftpPut.AfterSFTP.DoNothing.Label"));
wAfterFtpPut.add(BaseMessages.getString(PKG, "ActionSftpPut.AfterSFTP.Delete.Label"));
wAfterFtpPut.add(BaseMessages.getString(PKG, "ActionSftpPut.AfterSFTP.Move.Label"));
// +1: starts at -1
wAfterFtpPut.select(0);
props.setLook(wAfterFtpPut);
FormData fdAfterFtpPut = new FormData();
fdAfterFtpPut.left = new FormAttachment(middle, 0);
fdAfterFtpPut.top = new FormAttachment(wSuccessWhenNoFile, 2 * margin);
fdAfterFtpPut.right = new FormAttachment(100, -margin);
wAfterFtpPut.setLayoutData(fdAfterFtpPut);
wAfterFtpPut.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
afterFtpPutActivate();
}
});
// moveTo Directory
wlDestinationFolder = new Label(wgSourceFiles, SWT.RIGHT);
wlDestinationFolder.setText(BaseMessages.getString(PKG, "ActionSftpPut.DestinationFolder.Label"));
props.setLook(wlDestinationFolder);
FormData fdlDestinationFolder = new FormData();
fdlDestinationFolder.left = new FormAttachment(0, 0);
fdlDestinationFolder.top = new FormAttachment(wAfterFtpPut, margin);
fdlDestinationFolder.right = new FormAttachment(middle, -margin);
wlDestinationFolder.setLayoutData(fdlDestinationFolder);
// Browse folders button ...
wbMovetoDirectory = new Button(wgSourceFiles, SWT.PUSH | SWT.CENTER);
props.setLook(wbMovetoDirectory);
wbMovetoDirectory.setText(BaseMessages.getString(PKG, "ActionSftpPut.BrowseFolders.Label"));
FormData fdbMovetoDirectory = new FormData();
fdbMovetoDirectory.right = new FormAttachment(100, 0);
fdbMovetoDirectory.top = new FormAttachment(wAfterFtpPut, margin);
wbMovetoDirectory.setLayoutData(fdbMovetoDirectory);
wbMovetoDirectory.addListener(SWT.Selection, e -> BaseDialog.presentDirectoryDialog(shell, wDestinationFolder, variables));
wDestinationFolder = new TextVar(variables, wgSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ActionSftpPut.DestinationFolder.Tooltip"));
props.setLook(wDestinationFolder);
wDestinationFolder.addModifyListener(lsMod);
FormData fdDestinationFolder = new FormData();
fdDestinationFolder.left = new FormAttachment(middle, 0);
fdDestinationFolder.top = new FormAttachment(wAfterFtpPut, margin);
fdDestinationFolder.right = new FormAttachment(wbMovetoDirectory, -margin);
wDestinationFolder.setLayoutData(fdDestinationFolder);
// Whenever something changes, set the tooltip to the expanded version:
wDestinationFolder.addModifyListener(e -> wDestinationFolder.setToolTipText(variables.resolve(wDestinationFolder.getText())));
// Create destination folder if necessary ...
wlCreateDestinationFolder = new Label(wgSourceFiles, SWT.RIGHT);
wlCreateDestinationFolder.setText(BaseMessages.getString(PKG, "ActionSftpPut.CreateDestinationFolder.Label"));
props.setLook(wlCreateDestinationFolder);
FormData fdlCreateDestinationFolder = new FormData();
fdlCreateDestinationFolder.left = new FormAttachment(0, 0);
fdlCreateDestinationFolder.top = new FormAttachment(wDestinationFolder, margin);
fdlCreateDestinationFolder.right = new FormAttachment(middle, -margin);
wlCreateDestinationFolder.setLayoutData(fdlCreateDestinationFolder);
wCreateDestinationFolder = new Button(wgSourceFiles, SWT.CHECK);
wCreateDestinationFolder.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.CreateDestinationFolder.Tooltip"));
props.setLook(wCreateDestinationFolder);
FormData fdCreateDestinationFolder = new FormData();
fdCreateDestinationFolder.left = new FormAttachment(middle, 0);
fdCreateDestinationFolder.top = new FormAttachment(wlCreateDestinationFolder, 0, SWT.CENTER);
fdCreateDestinationFolder.right = new FormAttachment(100, 0);
wCreateDestinationFolder.setLayoutData(fdCreateDestinationFolder);
// Add filenames to result filenames...
wlAddFilenameToResult = new Label(wgSourceFiles, SWT.RIGHT);
wlAddFilenameToResult.setText(BaseMessages.getString(PKG, "ActionSftpPut.AddfilenametoResult.Label"));
props.setLook(wlAddFilenameToResult);
FormData fdlAddFilenameToResult = new FormData();
fdlAddFilenameToResult.left = new FormAttachment(0, 0);
fdlAddFilenameToResult.top = new FormAttachment(wlCreateDestinationFolder, 2 * margin);
fdlAddFilenameToResult.right = new FormAttachment(middle, -margin);
wlAddFilenameToResult.setLayoutData(fdlAddFilenameToResult);
wAddFilenameToResult = new Button(wgSourceFiles, SWT.CHECK);
wAddFilenameToResult.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.AddfilenametoResult.Tooltip"));
props.setLook(wAddFilenameToResult);
FormData fdAddFilenameToResult = new FormData();
fdAddFilenameToResult.left = new FormAttachment(middle, 0);
fdAddFilenameToResult.top = new FormAttachment(wlAddFilenameToResult, 0, SWT.CENTER);
fdAddFilenameToResult.right = new FormAttachment(100, 0);
wAddFilenameToResult.setLayoutData(fdAddFilenameToResult);
FormData fdSourceFiles = new FormData();
fdSourceFiles.left = new FormAttachment(0, margin);
fdSourceFiles.top = new FormAttachment(wServerSettings, 2 * margin);
fdSourceFiles.right = new FormAttachment(100, -margin);
wgSourceFiles.setLayoutData(fdSourceFiles);
// ///////////////////////////////////////////////////////////
// / END OF Source files GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Target files GROUP///
// /
Group wTargetFiles = new Group(wFilesComp, SWT.SHADOW_NONE);
props.setLook(wTargetFiles);
wTargetFiles.setText(BaseMessages.getString(PKG, "ActionSftpPut.TargetFiles.Group.Label"));
FormLayout targetFilesgroupLayout = new FormLayout();
targetFilesgroupLayout.marginWidth = 10;
targetFilesgroupLayout.marginHeight = 10;
wTargetFiles.setLayout(targetFilesgroupLayout);
// FtpDirectory line
Label wlScpDirectory = new Label(wTargetFiles, SWT.RIGHT);
wlScpDirectory.setText(BaseMessages.getString(PKG, "ActionSftpPut.RemoteDir.Label"));
props.setLook(wlScpDirectory);
FormData fdlScpDirectory = new FormData();
fdlScpDirectory.left = new FormAttachment(0, 0);
fdlScpDirectory.top = new FormAttachment(wgSourceFiles, margin);
fdlScpDirectory.right = new FormAttachment(middle, -margin);
wlScpDirectory.setLayoutData(fdlScpDirectory);
// Test remote folder button ...
wbTestChangeFolderExists = new Button(wTargetFiles, SWT.PUSH | SWT.CENTER);
props.setLook(wbTestChangeFolderExists);
wbTestChangeFolderExists.setText(BaseMessages.getString(PKG, "ActionSftpPut.TestFolderExists.Label"));
FormData fdbTestChangeFolderExists = new FormData();
fdbTestChangeFolderExists.right = new FormAttachment(100, 0);
fdbTestChangeFolderExists.top = new FormAttachment(wgSourceFiles, margin);
wbTestChangeFolderExists.setLayoutData(fdbTestChangeFolderExists);
wbTestChangeFolderExists.addListener(SWT.Selection, e -> checkRemoteFolder());
// Target (remote) folder
wScpDirectory = new TextVar(variables, wTargetFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wScpDirectory);
wScpDirectory.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.RemoteDir.Tooltip"));
wScpDirectory.addModifyListener(lsMod);
FormData fdScpDirectory = new FormData();
fdScpDirectory.left = new FormAttachment(middle, 0);
fdScpDirectory.top = new FormAttachment(wgSourceFiles, margin);
fdScpDirectory.right = new FormAttachment(wbTestChangeFolderExists, -margin);
wScpDirectory.setLayoutData(fdScpDirectory);
// CreateRemoteFolder files after retrieval...
Label wlCreateRemoteFolder = new Label(wTargetFiles, SWT.RIGHT);
wlCreateRemoteFolder.setText(BaseMessages.getString(PKG, "ActionSftpPut.CreateRemoteFolderFiles.Label"));
props.setLook(wlCreateRemoteFolder);
FormData fdlCreateRemoteFolder = new FormData();
fdlCreateRemoteFolder.left = new FormAttachment(0, 0);
fdlCreateRemoteFolder.top = new FormAttachment(wScpDirectory, margin);
fdlCreateRemoteFolder.right = new FormAttachment(middle, -margin);
wlCreateRemoteFolder.setLayoutData(fdlCreateRemoteFolder);
wCreateRemoteFolder = new Button(wTargetFiles, SWT.CHECK);
props.setLook(wCreateRemoteFolder);
FormData fdCreateRemoteFolder = new FormData();
wCreateRemoteFolder.setToolTipText(BaseMessages.getString(PKG, "ActionSftpPut.CreateRemoteFolderFiles.Tooltip"));
fdCreateRemoteFolder.left = new FormAttachment(middle, 0);
fdCreateRemoteFolder.top = new FormAttachment(wlCreateRemoteFolder, 0, SWT.CENTER);
fdCreateRemoteFolder.right = new FormAttachment(100, 0);
wCreateRemoteFolder.setLayoutData(fdCreateRemoteFolder);
wCreateRemoteFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
action.setChanged();
}
});
FormData fdTargetFiles = new FormData();
fdTargetFiles.left = new FormAttachment(0, margin);
fdTargetFiles.top = new FormAttachment(wgSourceFiles, margin);
fdTargetFiles.right = new FormAttachment(100, -margin);
wTargetFiles.setLayoutData(fdTargetFiles);
// ///////////////////////////////////////////////////////////
// / END OF Target files GROUP
// ///////////////////////////////////////////////////////////
FormData fdFilesComp = new FormData();
fdFilesComp.left = new FormAttachment(0, 0);
fdFilesComp.top = new FormAttachment(0, 0);
fdFilesComp.right = new FormAttachment(100, 0);
fdFilesComp.bottom = new FormAttachment(100, 0);
wFilesComp.setLayoutData(fdFilesComp);
wFilesComp.layout();
wFilesTab.setControl(wFilesComp);
props.setLook(wFilesComp);
// ///////////////////////////////////////////////////////////
// / END OF Files TAB
// ///////////////////////////////////////////////////////////
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOk, -2 * margin);
wTabFolder.setLayoutData(fdTabFolder);
wTabFolder.setSelection(0);
getData();
activeCopyFromPrevious();
activeUseKey();
afterFtpPutActivate();
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return action;
}
use of org.apache.hop.workflow.actions.sftp.SftpClient in project hop by apache.
the class ActionFtpDeleteDialog method open.
@Override
public IAction open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.RESIZE);
props.setLook(shell);
WorkflowDialog.setShellImage(shell, action);
WorkflowMeta workflowMeta = getWorkflowMeta();
ModifyListener lsMod = e -> {
pwdFolder = null;
ftpclient = null;
sftpclient = null;
action.setChanged();
};
changed = action.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "ActionFtpDelete.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Action name line
wName = new LabelText(shell, BaseMessages.getString(PKG, "ActionFtpDelete.Name.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Name.Tooltip"));
wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.top = new FormAttachment(0, 0);
fdName.left = new FormAttachment(0, 0);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
// The buttons at the bottom...
//
Button wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
Button wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
// The tab folder between the name and the buttons
//
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "ActionFtpDelete.Tab.General.Label"));
Composite wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// ////////////////////////
// START OF SERVER SETTINGS GROUP///
// /
Group wServerSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wServerSettings);
wServerSettings.setText(BaseMessages.getString(PKG, "ActionFtpDelete.ServerSettings.Group.Label"));
FormLayout serverSettingsgroupLayout = new FormLayout();
serverSettingsgroupLayout.marginWidth = 10;
serverSettingsgroupLayout.marginHeight = 10;
wServerSettings.setLayout(serverSettingsgroupLayout);
// Protocol
Label wlProtocol = new Label(wServerSettings, SWT.RIGHT);
wlProtocol.setText(BaseMessages.getString(PKG, "ActionFtpDelete.Protocol.Label"));
props.setLook(wlProtocol);
FormData fdlProtocol = new FormData();
fdlProtocol.left = new FormAttachment(0, 0);
fdlProtocol.top = new FormAttachment(wName, margin);
fdlProtocol.right = new FormAttachment(middle, 0);
wlProtocol.setLayoutData(fdlProtocol);
wProtocol = new Combo(wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wProtocol.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.Protocol.Tooltip"));
wProtocol.add(ActionFtpDelete.PROTOCOL_FTP);
wProtocol.add(ActionFtpDelete.PROTOCOL_SFTP);
props.setLook(wProtocol);
FormData fdProtocol = new FormData();
fdProtocol.left = new FormAttachment(middle, margin);
fdProtocol.top = new FormAttachment(wName, margin);
fdProtocol.right = new FormAttachment(100, 0);
wProtocol.setLayoutData(fdProtocol);
wProtocol.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeFtpProtocol();
action.setChanged();
}
});
// ServerName line
wServerName = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.Server.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Server.Tooltip"), false, false);
props.setLook(wServerName);
wServerName.addModifyListener(lsMod);
FormData fdServerName = new FormData();
fdServerName.left = new FormAttachment(0, 0);
fdServerName.top = new FormAttachment(wProtocol, margin);
fdServerName.right = new FormAttachment(100, 0);
wServerName.setLayoutData(fdServerName);
// Proxy port line
wPort = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.Port.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Port.Tooltip"), false, false);
props.setLook(wPort);
wPort.addModifyListener(lsMod);
FormData fdPort = new FormData();
fdPort.left = new FormAttachment(0, 0);
fdPort.top = new FormAttachment(wServerName, margin);
fdPort.right = new FormAttachment(100, 0);
wPort.setLayoutData(fdPort);
// UserName line
wUserName = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.User.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.User.Tooltip"), false, false);
props.setLook(wUserName);
wUserName.addModifyListener(lsMod);
FormData fdUserName = new FormData();
fdUserName.left = new FormAttachment(0, 0);
fdUserName.top = new FormAttachment(wPort, margin);
fdUserName.right = new FormAttachment(100, 0);
wUserName.setLayoutData(fdUserName);
// Password line
wPassword = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.Password.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Password.Tooltip"), true, false);
props.setLook(wPassword);
wPassword.addModifyListener(lsMod);
FormData fdPassword = new FormData();
fdPassword.left = new FormAttachment(0, 0);
fdPassword.top = new FormAttachment(wUserName, margin);
fdPassword.right = new FormAttachment(100, 0);
wPassword.setLayoutData(fdPassword);
// Use proxy...
Label wlUseProxy = new Label(wServerSettings, SWT.RIGHT);
wlUseProxy.setText(BaseMessages.getString(PKG, "ActionFtpDelete.useProxy.Label"));
props.setLook(wlUseProxy);
FormData fdlUseProxy = new FormData();
fdlUseProxy.left = new FormAttachment(0, 0);
fdlUseProxy.top = new FormAttachment(wPassword, margin);
fdlUseProxy.right = new FormAttachment(middle, 0);
wlUseProxy.setLayoutData(fdlUseProxy);
wUseProxy = new Button(wServerSettings, SWT.CHECK);
props.setLook(wUseProxy);
wUseProxy.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.useProxy.Tooltip"));
FormData fdUseProxy = new FormData();
fdUseProxy.left = new FormAttachment(middle, margin);
fdUseProxy.top = new FormAttachment(wlUseProxy, 0, SWT.CENTER);
fdUseProxy.right = new FormAttachment(100, 0);
wUseProxy.setLayoutData(fdUseProxy);
wUseProxy.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeProxy();
action.setChanged();
}
});
// Proxy host line
wProxyHost = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.ProxyHost.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.ProxyHost.Tooltip"), false, false);
props.setLook(wProxyHost);
wProxyHost.addModifyListener(lsMod);
FormData fdProxyHost = new FormData();
fdProxyHost.left = new FormAttachment(0, 0);
fdProxyHost.top = new FormAttachment(wlUseProxy, 2 * margin);
fdProxyHost.right = new FormAttachment(100, 0);
wProxyHost.setLayoutData(fdProxyHost);
// Proxy port line
wProxyPort = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.ProxyPort.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.ProxyPort.Tooltip"), false, false);
props.setLook(wProxyPort);
wProxyPort.addModifyListener(lsMod);
FormData fdProxyPort = new FormData();
fdProxyPort.left = new FormAttachment(0, 0);
fdProxyPort.top = new FormAttachment(wProxyHost, margin);
fdProxyPort.right = new FormAttachment(100, 0);
wProxyPort.setLayoutData(fdProxyPort);
// Proxy username line
wProxyUsername = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.ProxyUsername.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.ProxyUsername.Tooltip"), false, false);
props.setLook(wProxyUsername);
wProxyUsername.addModifyListener(lsMod);
FormData fdProxyUsername = new FormData();
fdProxyUsername.left = new FormAttachment(0, 0);
fdProxyUsername.top = new FormAttachment(wProxyPort, margin);
fdProxyUsername.right = new FormAttachment(100, 0);
wProxyUsername.setLayoutData(fdProxyUsername);
// Proxy password line
wProxyPassword = new LabelTextVar(variables, wServerSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.ProxyPassword.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.ProxyPassword.Tooltip"), true, false);
props.setLook(wProxyPassword);
wProxyPassword.addModifyListener(lsMod);
FormData fdProxyPasswd = new FormData();
fdProxyPasswd.left = new FormAttachment(0, 0);
fdProxyPasswd.top = new FormAttachment(wProxyUsername, margin);
fdProxyPasswd.right = new FormAttachment(100, 0);
wProxyPassword.setLayoutData(fdProxyPasswd);
// usePublicKey
wlUsePublicKey = new Label(wServerSettings, SWT.RIGHT);
wlUsePublicKey.setText(BaseMessages.getString(PKG, "ActionFtpDelete.usePublicKeyFiles.Label"));
props.setLook(wlUsePublicKey);
FormData fdlusePublicKey = new FormData();
fdlusePublicKey.left = new FormAttachment(0, 0);
fdlusePublicKey.top = new FormAttachment(wProxyPassword, margin);
fdlusePublicKey.right = new FormAttachment(middle, 0);
wlUsePublicKey.setLayoutData(fdlusePublicKey);
wUsePublicKey = new Button(wServerSettings, SWT.CHECK);
wUsePublicKey.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.usePublicKeyFiles.Tooltip"));
props.setLook(wUsePublicKey);
FormData fdusePublicKey = new FormData();
fdusePublicKey.left = new FormAttachment(middle, margin);
fdusePublicKey.top = new FormAttachment(wlUsePublicKey, 0, SWT.CENTER);
fdusePublicKey.right = new FormAttachment(100, 0);
wUsePublicKey.setLayoutData(fdusePublicKey);
wUsePublicKey.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeUsePublicKey();
action.setChanged();
}
});
// Key File
wlKeyFilename = new Label(wServerSettings, SWT.RIGHT);
wlKeyFilename.setText(BaseMessages.getString(PKG, "ActionFtpDelete.KeyFilename.Label"));
props.setLook(wlKeyFilename);
FormData fdlKeyFilename = new FormData();
fdlKeyFilename.left = new FormAttachment(0, 0);
fdlKeyFilename.top = new FormAttachment(wlUsePublicKey, 2 * margin);
fdlKeyFilename.right = new FormAttachment(middle, -margin);
wlKeyFilename.setLayoutData(fdlKeyFilename);
wbKeyFilename = new Button(wServerSettings, SWT.PUSH | SWT.CENTER);
props.setLook(wbKeyFilename);
wbKeyFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbKeyFilename = new FormData();
fdbKeyFilename.right = new FormAttachment(100, 0);
fdbKeyFilename.top = new FormAttachment(wlKeyFilename, 0, SWT.CENTER);
wbKeyFilename.setLayoutData(fdbKeyFilename);
wKeyFilename = new TextVar(variables, wServerSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wKeyFilename.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.KeyFilename.Tooltip"));
props.setLook(wKeyFilename);
wKeyFilename.addModifyListener(lsMod);
FormData fdKeyFilename = new FormData();
fdKeyFilename.left = new FormAttachment(middle, margin);
fdKeyFilename.top = new FormAttachment(wlKeyFilename, 0, SWT.CENTER);
fdKeyFilename.right = new FormAttachment(wbKeyFilename, -margin);
wKeyFilename.setLayoutData(fdKeyFilename);
// Whenever something changes, set the tooltip to the expanded version:
wKeyFilename.addModifyListener(e -> wKeyFilename.setToolTipText(variables.resolve(wKeyFilename.getText())));
wbKeyFilename.addListener(SWT.Selection, e -> BaseDialog.presentFileDialog(shell, wKeyFilename, variables, new String[] { "*.pem", "*" }, FILETYPES, true));
// keyfilePass line
wKeyFilePass = new LabelTextVar(variables, wServerSettings, BaseMessages.getString(PKG, "ActionFtpDelete.keyfilePass.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.keyfilePass.Tooltip"), true);
props.setLook(wKeyFilePass);
wKeyFilePass.addModifyListener(lsMod);
FormData fdkeyfilePass = new FormData();
fdkeyfilePass.left = new FormAttachment(0, 0);
fdkeyfilePass.top = new FormAttachment(wKeyFilename, margin);
fdkeyfilePass.right = new FormAttachment(100, 0);
wKeyFilePass.setLayoutData(fdkeyfilePass);
// Test connection button
Button wTest = new Button(wServerSettings, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "ActionFtpDelete.TestConnection.Label"));
props.setLook(wTest);
FormData fdTest = new FormData();
wTest.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.TestConnection.Tooltip"));
fdTest.top = new FormAttachment(wKeyFilePass, margin);
fdTest.right = new FormAttachment(100, 0);
wTest.setLayoutData(fdTest);
wTest.addListener(SWT.Selection, e -> test());
FormData fdServerSettings = new FormData();
fdServerSettings.left = new FormAttachment(0, margin);
fdServerSettings.top = new FormAttachment(wName, margin);
fdServerSettings.right = new FormAttachment(100, -margin);
wServerSettings.setLayoutData(fdServerSettings);
// ///////////////////////////////////////////////////////////
// / END OF SERVER SETTINGS GROUP
// ///////////////////////////////////////////////////////////
FormData fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Advanced TAB ///
// ////////////////////////
CTabItem wFilesTab = new CTabItem(wTabFolder, SWT.NONE);
wFilesTab.setText(BaseMessages.getString(PKG, "ActionFtpDelete.Tab.Files.Label"));
Composite wFilesComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wFilesComp);
FormLayout advancedLayout = new FormLayout();
advancedLayout.marginWidth = 3;
advancedLayout.marginHeight = 3;
wFilesComp.setLayout(advancedLayout);
// ////////////////////////
// START OF Advanced SETTINGS GROUP///
// /
Group wAdvancedSettings = new Group(wFilesComp, SWT.SHADOW_NONE);
props.setLook(wAdvancedSettings);
wAdvancedSettings.setText(BaseMessages.getString(PKG, "ActionFtpDelete.AdvancedSettings.Group.Label"));
FormLayout advancedSettingsgroupLayout = new FormLayout();
advancedSettingsgroupLayout.marginWidth = 10;
advancedSettingsgroupLayout.marginHeight = 10;
wAdvancedSettings.setLayout(advancedSettingsgroupLayout);
// Timeout line
wTimeout = new LabelTextVar(variables, wAdvancedSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.Timeout.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Timeout.Tooltip"), false, false);
props.setLook(wTimeout);
wTimeout.addModifyListener(lsMod);
FormData fdTimeout = new FormData();
fdTimeout.left = new FormAttachment(0, 0);
fdTimeout.top = new FormAttachment(wActive, margin);
fdTimeout.right = new FormAttachment(100, 0);
wTimeout.setLayoutData(fdTimeout);
// active connection?
Label wlActive = new Label(wAdvancedSettings, SWT.RIGHT);
wlActive.setText(BaseMessages.getString(PKG, "ActionFtpDelete.ActiveConns.Label"));
props.setLook(wlActive);
FormData fdlActive = new FormData();
fdlActive.left = new FormAttachment(0, 0);
fdlActive.top = new FormAttachment(wTimeout, margin);
fdlActive.right = new FormAttachment(middle, 0);
wlActive.setLayoutData(fdlActive);
wActive = new Button(wAdvancedSettings, SWT.CHECK);
wActive.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.ActiveConns.Tooltip"));
props.setLook(wActive);
FormData fdActive = new FormData();
fdActive.left = new FormAttachment(middle, margin);
fdActive.top = new FormAttachment(wlActive, 0, SWT.CENTER);
fdActive.right = new FormAttachment(100, 0);
wActive.setLayoutData(fdActive);
FormData fdAdvancedSettings = new FormData();
fdAdvancedSettings.left = new FormAttachment(0, margin);
fdAdvancedSettings.top = new FormAttachment(0, margin);
fdAdvancedSettings.right = new FormAttachment(100, -margin);
wAdvancedSettings.setLayoutData(fdAdvancedSettings);
// ///////////////////////////////////////////////////////////
// / END OF Advanced SETTINGS GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Remote SETTINGS GROUP///
// /
Group wRemoteSettings = new Group(wFilesComp, SWT.SHADOW_NONE);
props.setLook(wRemoteSettings);
wRemoteSettings.setText(BaseMessages.getString(PKG, "ActionFtpDelete.RemoteSettings.Group.Label"));
FormLayout remoteSettinsgroupLayout = new FormLayout();
remoteSettinsgroupLayout.marginWidth = 10;
remoteSettinsgroupLayout.marginHeight = 10;
wRemoteSettings.setLayout(remoteSettinsgroupLayout);
// Get arguments from previous result...
Label wlGetPrevious = new Label(wRemoteSettings, SWT.RIGHT);
wlGetPrevious.setText(BaseMessages.getString(PKG, "ActionFtpDelete.getPrevious.Label"));
props.setLook(wlGetPrevious);
FormData fdlGetPrevious = new FormData();
fdlGetPrevious.left = new FormAttachment(0, 0);
fdlGetPrevious.top = new FormAttachment(wAdvancedSettings, margin);
fdlGetPrevious.right = new FormAttachment(middle, 0);
wlGetPrevious.setLayoutData(fdlGetPrevious);
wGetPrevious = new Button(wRemoteSettings, SWT.CHECK);
props.setLook(wGetPrevious);
wGetPrevious.setToolTipText(BaseMessages.getString(PKG, "ActionFtpDelete.getPrevious.Tooltip"));
FormData fdGetPrevious = new FormData();
fdGetPrevious.left = new FormAttachment(middle, margin);
fdGetPrevious.top = new FormAttachment(wlGetPrevious, 0, SWT.CENTER);
fdGetPrevious.right = new FormAttachment(100, 0);
wGetPrevious.setLayoutData(fdGetPrevious);
wGetPrevious.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeCopyFromPrevious();
action.setChanged();
}
});
// FTP directory
wlFtpDirectory = new Label(wRemoteSettings, SWT.RIGHT);
wlFtpDirectory.setText(BaseMessages.getString(PKG, "ActionFtpDelete.RemoteDir.Label"));
props.setLook(wlFtpDirectory);
FormData fdlFtpDirectory = new FormData();
fdlFtpDirectory.left = new FormAttachment(0, 0);
fdlFtpDirectory.top = new FormAttachment(wlGetPrevious, 2 * margin);
fdlFtpDirectory.right = new FormAttachment(middle, 0);
wlFtpDirectory.setLayoutData(fdlFtpDirectory);
// Test remote folder button ...
wbTestChangeFolderExists = new Button(wRemoteSettings, SWT.PUSH | SWT.CENTER);
props.setLook(wbTestChangeFolderExists);
wbTestChangeFolderExists.setText(BaseMessages.getString(PKG, "ActionFtpDelete.TestFolderExists.Label"));
FormData fdbTestChangeFolderExists = new FormData();
fdbTestChangeFolderExists.right = new FormAttachment(100, 0);
fdbTestChangeFolderExists.top = new FormAttachment(wGetPrevious, margin);
wbTestChangeFolderExists.setLayoutData(fdbTestChangeFolderExists);
wbTestChangeFolderExists.addListener(SWT.Selection, e -> checkFtpFolder());
wFtpDirectory = new TextVar(variables, wRemoteSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ActionFtpDelete.RemoteDir.Tooltip"));
props.setLook(wFtpDirectory);
wFtpDirectory.addModifyListener(lsMod);
FormData fdFtpDirectory = new FormData();
fdFtpDirectory.left = new FormAttachment(middle, margin);
fdFtpDirectory.top = new FormAttachment(wGetPrevious, margin);
fdFtpDirectory.right = new FormAttachment(wbTestChangeFolderExists, -margin);
wFtpDirectory.setLayoutData(fdFtpDirectory);
// Wildcard line
wWildcard = new LabelTextVar(variables, wRemoteSettings, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.Wildcard.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.Wildcard.Tooltip"), false, false);
props.setLook(wWildcard);
wWildcard.addModifyListener(lsMod);
FormData fdWildcard = new FormData();
fdWildcard.left = new FormAttachment(0, 0);
fdWildcard.top = new FormAttachment(wFtpDirectory, margin);
fdWildcard.right = new FormAttachment(100, 0);
wWildcard.setLayoutData(fdWildcard);
FormData fdRemoteSettings = new FormData();
fdRemoteSettings.left = new FormAttachment(0, margin);
fdRemoteSettings.top = new FormAttachment(wAdvancedSettings, margin);
fdRemoteSettings.right = new FormAttachment(100, -margin);
wRemoteSettings.setLayoutData(fdRemoteSettings);
// ///////////////////////////////////////////////////////////
// / END OF Remote SETTINGSGROUP
// ///////////////////////////////////////////////////////////
// SuccessOngrouping?
// ////////////////////////
// START OF SUCCESS ON GROUP///
// /
Group wSuccessOn = new Group(wFilesComp, SWT.SHADOW_NONE);
props.setLook(wSuccessOn);
wSuccessOn.setText(BaseMessages.getString(PKG, "ActionFtpDelete.SuccessOn.Group.Label"));
FormLayout successongroupLayout = new FormLayout();
successongroupLayout.marginWidth = 10;
successongroupLayout.marginHeight = 10;
wSuccessOn.setLayout(successongroupLayout);
// Success Condition
Label wlSuccessCondition = new Label(wSuccessOn, SWT.RIGHT);
wlSuccessCondition.setText(BaseMessages.getString(PKG, "ActionFtpDelete.SuccessCondition.Label") + " ");
props.setLook(wlSuccessCondition);
FormData fdlSuccessCondition = new FormData();
fdlSuccessCondition.left = new FormAttachment(0, 0);
fdlSuccessCondition.right = new FormAttachment(middle, 0);
fdlSuccessCondition.top = new FormAttachment(wRemoteSettings, margin);
wlSuccessCondition.setLayoutData(fdlSuccessCondition);
wSuccessCondition = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wSuccessCondition.add(BaseMessages.getString(PKG, "ActionFtpDelete.SuccessWhenAllWorksFine.Label"));
wSuccessCondition.add(BaseMessages.getString(PKG, "ActionFtpDelete.SuccessWhenAtLeat.Label"));
wSuccessCondition.add(BaseMessages.getString(PKG, "ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label"));
// +1: starts at -1
wSuccessCondition.select(0);
props.setLook(wSuccessCondition);
FormData fdSuccessCondition = new FormData();
fdSuccessCondition.left = new FormAttachment(middle, 0);
fdSuccessCondition.top = new FormAttachment(wRemoteSettings, margin);
fdSuccessCondition.right = new FormAttachment(100, 0);
wSuccessCondition.setLayoutData(fdSuccessCondition);
wSuccessCondition.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeSuccessCondition();
}
});
// Success when number of errors less than
wlNrErrorsLessThan = new Label(wSuccessOn, SWT.RIGHT);
wlNrErrorsLessThan.setText(BaseMessages.getString(PKG, "ActionFtpDelete.NrBadFormedLessThan.Label") + " ");
props.setLook(wlNrErrorsLessThan);
FormData fdlNrErrorsLessThan = new FormData();
fdlNrErrorsLessThan.left = new FormAttachment(0, 0);
fdlNrErrorsLessThan.top = new FormAttachment(wSuccessCondition, margin);
fdlNrErrorsLessThan.right = new FormAttachment(middle, -margin);
wlNrErrorsLessThan.setLayoutData(fdlNrErrorsLessThan);
wNrErrorsLessThan = new TextVar(variables, wSuccessOn, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ActionFtpDelete.NrBadFormedLessThan.Tooltip"));
props.setLook(wNrErrorsLessThan);
wNrErrorsLessThan.addModifyListener(lsMod);
FormData fdNrErrorsLessThan = new FormData();
fdNrErrorsLessThan.left = new FormAttachment(middle, 0);
fdNrErrorsLessThan.top = new FormAttachment(wSuccessCondition, margin);
fdNrErrorsLessThan.right = new FormAttachment(100, -margin);
wNrErrorsLessThan.setLayoutData(fdNrErrorsLessThan);
FormData fdSuccessOn = new FormData();
fdSuccessOn.left = new FormAttachment(0, margin);
fdSuccessOn.top = new FormAttachment(wRemoteSettings, margin);
fdSuccessOn.right = new FormAttachment(100, -margin);
wSuccessOn.setLayoutData(fdSuccessOn);
// ///////////////////////////////////////////////////////////
// / END OF Success ON GROUP
// ///////////////////////////////////////////////////////////
FormData fdFilesComp = new FormData();
fdFilesComp.left = new FormAttachment(0, 0);
fdFilesComp.top = new FormAttachment(0, 0);
fdFilesComp.right = new FormAttachment(100, 0);
fdFilesComp.bottom = new FormAttachment(100, 0);
wFilesComp.setLayoutData(fdFilesComp);
wFilesComp.layout();
wFilesTab.setControl(wFilesComp);
props.setLook(wFilesComp);
// ///////////////////////////////////////////////////////////
// / END OF Advanced TAB
// ///////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////
// Start of Socks Proxy Tab
// ///////////////////////////////////////////////////////////
CTabItem wSocksProxyTab = new CTabItem(wTabFolder, SWT.NONE);
wSocksProxyTab.setText(BaseMessages.getString(PKG, "ActionFtpDelete.Tab.Socks.Label"));
Composite wSocksProxyComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSocksProxyComp);
FormLayout soxProxyLayout = new FormLayout();
soxProxyLayout.marginWidth = 3;
soxProxyLayout.marginHeight = 3;
wSocksProxyComp.setLayout(soxProxyLayout);
// ////////////////////////////////////////////////////////
// Start of Proxy Group
// ////////////////////////////////////////////////////////
wSocksProxy = new Group(wSocksProxyComp, SWT.SHADOW_NONE);
props.setLook(wSocksProxy);
wSocksProxy.setText(BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxy.Group.Label"));
FormLayout socksProxyGroupLayout = new FormLayout();
socksProxyGroupLayout.marginWidth = 10;
socksProxyGroupLayout.marginHeight = 10;
wSocksProxy.setLayout(socksProxyGroupLayout);
// host line
wSocksProxyHost = new LabelTextVar(variables, wSocksProxy, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyHost.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyHost.Tooltip"), false, false);
props.setLook(wSocksProxyHost);
wSocksProxyHost.addModifyListener(lsMod);
FormData fdSocksProxyHost = new FormData();
fdSocksProxyHost.left = new FormAttachment(0, 0);
fdSocksProxyHost.top = new FormAttachment(wName, margin);
fdSocksProxyHost.right = new FormAttachment(100, margin);
wSocksProxyHost.setLayoutData(fdSocksProxyHost);
// port line
wSocksProxyPort = new LabelTextVar(variables, wSocksProxy, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyPort.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyPort.Tooltip"), false, false);
props.setLook(wSocksProxyPort);
wSocksProxyPort.addModifyListener(lsMod);
FormData fdSocksProxyPort = new FormData();
fdSocksProxyPort.left = new FormAttachment(0, 0);
fdSocksProxyPort.top = new FormAttachment(wSocksProxyHost, margin);
fdSocksProxyPort.right = new FormAttachment(100, margin);
wSocksProxyPort.setLayoutData(fdSocksProxyPort);
// username line
wSocksProxyUsername = new LabelTextVar(variables, wSocksProxy, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyUsername.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyPassword.Tooltip"), false, false);
props.setLook(wSocksProxyUsername);
wSocksProxyUsername.addModifyListener(lsMod);
FormData fdSocksProxyUsername = new FormData();
fdSocksProxyUsername.left = new FormAttachment(0, 0);
fdSocksProxyUsername.top = new FormAttachment(wSocksProxyPort, margin);
fdSocksProxyUsername.right = new FormAttachment(100, margin);
wSocksProxyUsername.setLayoutData(fdSocksProxyUsername);
// password line
wSocksProxyPassword = new LabelTextVar(variables, wSocksProxy, SWT.NONE, BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyPassword.Label"), BaseMessages.getString(PKG, "ActionFtpDelete.SocksProxyPassword.Tooltip"), true, false);
props.setLook(wSocksProxyPort);
wSocksProxyPassword.addModifyListener(lsMod);
FormData fdSocksProxyPassword = new FormData();
fdSocksProxyPassword.left = new FormAttachment(0, 0);
fdSocksProxyPassword.top = new FormAttachment(wSocksProxyUsername, margin);
fdSocksProxyPassword.right = new FormAttachment(100, margin);
wSocksProxyPassword.setLayoutData(fdSocksProxyPassword);
// ///////////////////////////////////////////////////////////////
// End of socks proxy group
// ///////////////////////////////////////////////////////////////
FormData fdSocksProxyComp = new FormData();
fdSocksProxyComp.left = new FormAttachment(0, margin);
fdSocksProxyComp.top = new FormAttachment(0, margin);
fdSocksProxyComp.right = new FormAttachment(100, -margin);
wSocksProxy.setLayoutData(fdSocksProxyComp);
wSocksProxyComp.layout();
wSocksProxyTab.setControl(wSocksProxyComp);
props.setLook(wSocksProxyComp);
// ////////////////////////////////////////////////////////
// End of Socks Proxy Tab
// ////////////////////////////////////////////////////////
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOk, -2 * margin);
wTabFolder.setLayoutData(fdTabFolder);
getData();
activeSuccessCondition();
activeUsePublicKey();
activeProxy();
activeFtpProtocol();
activeCopyFromPrevious();
wTabFolder.setSelection(0);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return action;
}
use of org.apache.hop.workflow.actions.sftp.SftpClient in project hop by apache.
the class ActionFtpDelete method sftpConnect.
private void sftpConnect(String realservername, String realusername, int realport, String realpassword, String realFtpDirectory) throws Exception {
// Create sftp client to host ...
sftpclient = new SftpClient(InetAddress.getByName(realservername), realport, realusername);
// login to ftp host ...
sftpclient.login(realpassword);
// move to spool dir ...
if (!Utils.isEmpty(realFtpDirectory)) {
sftpclient.chdir(realFtpDirectory);
if (isDetailed()) {
logDetailed("Changed to directory [" + realFtpDirectory + "]");
}
}
}
use of org.apache.hop.workflow.actions.sftp.SftpClient in project hop by apache.
the class ActionFtpDeleteDialog method connectToSftp.
private boolean connectToSftp() {
boolean retval = false;
try {
WorkflowMeta workflowMeta = getWorkflowMeta();
if (sftpclient == null) {
// Create sftp client to host ...
sftpclient = new SftpClient(InetAddress.getByName(variables.resolve(wServerName.getText())), Const.toInt(variables.resolve(wPort.getText()), 22), variables.resolve(wUserName.getText()));
// login to ftp host ...
sftpclient.login(Utils.resolvePassword(variables, wPassword.getText()));
pwdFolder = sftpclient.pwd();
}
retval = true;
} catch (Exception e) {
if (sftpclient != null) {
try {
sftpclient.disconnect();
} catch (Exception ignored) {
// We've tried quitting the SFTP Client exception
// nothing else to be done if the SFTP Client was already disconnected
}
sftpclient = null;
}
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "ActionFtpDelete.ErrorConnect.NOK", e.getMessage()) + Const.CR);
mb.setText(BaseMessages.getString(PKG, "ActionFtpDelete.ErrorConnect.Title.Bad"));
mb.open();
}
return retval;
}
Aggregations