if(listener.getProfileNames().length == 0) {
MainWindow.message("Please first define a Profile", SWT.ICON_WARNING);
return;
}
FTPProfile profile = listener.getCurrProfile();
sos.net.SOSFileTransfer p = profile.connect();
if(p != null && p.isConnected()) {
HashMap h = profile.changeDirectory(ftpProfilePicker.getSelectedProfilename(), txtDir.getText());
if(profile.isLoggedIn()) {
butOpenOrSave.setEnabled(profile.isLoggedIn() && txtFilename.getText().length() > 0);
fillTable(h);
table.setSortDirection(SWT.UP);
sort(newColumnTableColumn_2);
_setEnabled(true);
}
}
} catch (Exception ex) {
try {
MainWindow.message("error while connecting: " + ex.toString(), SWT.ICON_WARNING);
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), ex);
} catch(Exception ee) {
//tu nichts
}
}
Utils.stopCursor(schedulerConfigurationShell);
}
});
butSite.setText("Connect");
/*String selectProfile = Options.getProperty("last_profile");
if(selectProfile != null && selectProfile.length() > 0) {
if(listener == null)
listener = ftpProfilePicker.getListener();
if( listener.getProfiles().get(selectProfile) != null) {
listener.setCurrProfileName(selectProfile);
if(txtDir != null) {
txtDir.setText(listener.getCurrProfile() != null && listener.getCurrProfile().getRoot() != null ? listener.getCurrProfile().getRoot() : "");
_setEnabled(false);
}
}
} */
txtDir = new Text(schedulerGroup, SWT.BORDER);
txtDir.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent e) {
try {
if (e.keyCode == SWT.CR) {
FTPProfile profile = listener.getCurrProfile();
HashMap h = profile.changeDirectory(txtDir.getText());
fillTable(h);
}
} catch (Exception r) {
MainWindow.message("error while change Directory: " + e.toString(), SWT.ICON_WARNING);
try {
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
} catch(Exception ee) {
//tu nichts
}
}
}
});
txtDir.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
butChangeDir = new Button(schedulerGroup, SWT.NONE);
butChangeDir.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
try {
Utils.startCursor(schedulerConfigurationShell);
//HashMap h = listener.changeDirectory( cboConnectname.getText(), txtDir.getText());
HashMap h = listener.getCurrProfile().changeDirectory( ftpProfilePicker.getSelectedProfilename(), txtDir.getText());
fillTable(h);
Utils.stopCursor(schedulerConfigurationShell);
} catch (Exception r) {
MainWindow.message("error: " + e.toString(), SWT.ICON_WARNING);
try {
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
} catch(Exception ee) {
//tu nichts
}
}
}
});
butChangeDir.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butChangeDir.setText("Change Directory ");
table = new Table(schedulerGroup, SWT.FULL_SELECTION | SWT.BORDER);
table.setSortDirection(SWT.DOWN);
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
try {
if(table.getSelectionCount() > 0) {
TableItem item = table.getSelection()[0];
if(item.getData("type").equals("file") ||
type.equalsIgnoreCase(OPEN_HOT_FOLDER) ||
type.equalsIgnoreCase(SAVE_AS_HOT_FOLDER))
txtFilename.setText(item.getText(0));
else
txtFilename.setText("");
}
butOpenOrSave.setEnabled(listener.getCurrProfile().isLoggedIn() && txtFilename.getText().length() > 0);
} catch (Exception ex) {
System.err.println(ex.toString());
}
}});
table.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(final MouseEvent e) {
try {
if(table.getSelectionCount() > 0) {
TableItem item = table.getSelection()[0];
if(item.getData("type").equals("dir")) {
txtDir.setText((txtDir.getText().endsWith("/") ? txtDir.getText() :txtDir.getText() + "/") + item.getText());
fillTable(listener.getCurrProfile().changeDirectory(txtDir.getText()));
} else if (item.getData("type").equals("dir_up")) {
String parentPath = new java.io.File(txtDir.getText()).getParent();
if(parentPath != null)
txtDir.setText(parentPath.replaceAll("\\\\", "/"));
else
txtDir.setText(".");
//test 1 fillTable(listener.cdUP());
fillTable(listener.getCurrProfile().cdUP());
} else if(item.getData("type").equals("file")){
openOrSave();
}
txtFilename.setText("");
}
} catch (Exception r) {
try {
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
} catch(Exception ee) {
//tu nichts
}
}
}
});
table.setHeaderVisible(true);
table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 3));
newColumnTableColumn_2 = new TableColumn(table, SWT.NONE);
newColumnTableColumn_2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
sort(newColumnTableColumn_2);
}
});
table.setSortColumn(newColumnTableColumn_2);
newColumnTableColumn_2.setMoveable(true);
newColumnTableColumn_2.setWidth(176);
newColumnTableColumn_2.setText("Name");
final TableColumn newColumnTableColumn = new TableColumn(table, SWT.NONE);
newColumnTableColumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
sort(newColumnTableColumn);
}
});
newColumnTableColumn.setWidth(117);
newColumnTableColumn.setText("Size");
newColumnTableColumn_1 = new TableColumn(table, SWT.NONE);
newColumnTableColumn_1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
sort(newColumnTableColumn_1);
}
});
newColumnTableColumn_1.setWidth(100);
newColumnTableColumn_1.setText("Type");
butRefresh = new Button(schedulerGroup, SWT.NONE);
butRefresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
refresh();
}
});
butRefresh.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
butRefresh.setText("Refresh");
butNewFolder = new Button(schedulerGroup, SWT.NONE);
butNewFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
openDialog();
}
});
butNewFolder.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butNewFolder.setText("New Folder");
butRemove = new Button(schedulerGroup, SWT.NONE);
butRemove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if(txtFilename.getText() != null) {
Utils.startCursor(schedulerConfigurationShell);
try {
FTPProfile profile = listener.getCurrProfile();
profile.removeFile(txtFilename.getText());
HashMap h = profile.changeDirectory(txtDir.getText());
fillTable(h);
} catch (Exception r) {
try {
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), r);
} catch(Exception ee) {