use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.
the class JobEntryTruncateTablesDialog method getTableName.
private void getTableName() {
DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
try {
database.connect();
String[] Tablenames = database.getTablenames();
Arrays.sort(Tablenames);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, Tablenames, BaseMessages.getString(PKG, "JobTruncateTables.SelectTables.Title"), BaseMessages.getString(PKG, "JobTruncateTables.SelectTables.Message"));
dialog.setMulti(true);
dialog.setAvoidQuickSearch();
if (dialog.open() != null) {
int[] idx = dialog.getSelectionIndeces();
for (int i = 0; i < idx.length; i++) {
TableItem tableItem = new TableItem(wFields.table, SWT.NONE);
tableItem.setText(1, Tablenames[idx[i]]);
}
}
} catch (KettleDatabaseException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobEntryTruncateTables.ConnectionError.DialogMessage"), e);
} finally {
if (database != null) {
database.disconnect();
}
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
}
}
use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.
the class JobEntryMssqlBulkLoadDialog method getListColumns.
/**
* Get a list of columns, comma separated, allow the user to select from it.
*/
private void getListColumns() {
if (!Utils.isEmpty(wTablename.getText())) {
DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
database.shareVariablesWith(jobMeta);
try {
database.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
RowMetaInterface row = database.getTableFields(schemaTable);
String[] available = row.getFieldNames();
String[] source = wOrderBy.getText().split(",");
for (int i = 0; i < source.length; i++) {
source[i] = Const.trim(source[i]);
}
int[] idxSource = Const.indexsOfStrings(source, available);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobMssqlBulkLoad.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMssqlBulkLoad.SelectColumns.Message"));
dialog.setMulti(true);
dialog.setAvoidQuickSearch();
dialog.setSelectedNrs(idxSource);
if (dialog.open() != null) {
String columns = "";
int[] idx = dialog.getSelectionIndeces();
for (int i = 0; i < idx.length; i++) {
if (i > 0) {
columns += ", ";
}
columns += available[idx[i]];
}
wOrderBy.setText(columns);
}
} catch (KettleDatabaseException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMssqlBulkLoad.ConnectionError2.DialogMessage"), e);
} finally {
database.disconnect();
}
}
}
}
use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.
the class JobEntryMysqlBulkLoadDialog method getListColumns.
/**
* Get a list of columns, comma separated, allow the user to select from it.
*/
private void getListColumns() {
if (!Utils.isEmpty(wTablename.getText())) {
DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
database.shareVariablesWith(jobMeta);
try {
database.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
RowMetaInterface row = database.getTableFields(schemaTable);
String[] available = row.getFieldNames();
String[] source = wListattribut.getText().split(",");
for (int i = 0; i < source.length; i++) {
source[i] = Const.trim(source[i]);
}
int[] idxSource = Const.indexsOfStrings(source, available);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobMysqlBulkLoad.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMysqlBulkLoad.SelectColumns.Message"));
dialog.setMulti(true);
dialog.setAvoidQuickSearch();
dialog.setSelectedNrs(idxSource);
if (dialog.open() != null) {
String columns = "";
int[] idx = dialog.getSelectionIndeces();
for (int i = 0; i < idx.length; i++) {
if (i > 0) {
columns += ", ";
}
columns += available[idx[i]];
}
wListattribut.setText(columns);
}
} catch (KettleDatabaseException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMysqlBulkLoad.ConnectionError2.DialogMessage"), e);
} finally {
database.disconnect();
}
}
}
}
use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.
the class JobEntryZipFileDialog method open.
public JobEntryInterface open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, props.getJobsDialogStyle());
props.setLook(shell);
JobDialog.setShellImage(shell, jobEntry);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
jobEntry.setChanged();
}
};
changed = jobEntry.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JobZipFiles.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// ZipFilename line
wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "JobZipFiles.Name.Label"));
props.setLook(wlName);
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);
fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "JobZipFiles.Tab.General.Label"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// SourceFile grouping?
// ////////////////////////
// START OF SourceFile GROUP///
// /
wSourceFiles = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wSourceFiles);
wSourceFiles.setText(BaseMessages.getString(PKG, "JobZipFiles.SourceFiles.Group.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wSourceFiles.setLayout(groupLayout);
// Get Result from previous?
wlgetFromPrevious = new Label(wSourceFiles, SWT.RIGHT);
wlgetFromPrevious.setText(BaseMessages.getString(PKG, "JobZipFiles.getFromPrevious.Label"));
props.setLook(wlgetFromPrevious);
fdlgetFromPrevious = new FormData();
fdlgetFromPrevious.left = new FormAttachment(0, 0);
fdlgetFromPrevious.top = new FormAttachment(wName, margin);
fdlgetFromPrevious.right = new FormAttachment(middle, -margin);
wlgetFromPrevious.setLayoutData(fdlgetFromPrevious);
wgetFromPrevious = new Button(wSourceFiles, SWT.CHECK);
props.setLook(wgetFromPrevious);
wgetFromPrevious.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.getFromPrevious.Tooltip"));
fdgetFromPrevious = new FormData();
fdgetFromPrevious.left = new FormAttachment(middle, 0);
fdgetFromPrevious.top = new FormAttachment(wName, margin);
fdgetFromPrevious.right = new FormAttachment(100, 0);
wgetFromPrevious.setLayoutData(fdgetFromPrevious);
wgetFromPrevious.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
setGetFromPrevious();
}
});
// TargetDirectory line
wlSourceDirectory = new Label(wSourceFiles, SWT.RIGHT);
wlSourceDirectory.setText(BaseMessages.getString(PKG, "JobZipFiles.SourceDir.Label"));
props.setLook(wlSourceDirectory);
fdlSourceDirectory = new FormData();
fdlSourceDirectory.left = new FormAttachment(0, 0);
fdlSourceDirectory.top = new FormAttachment(wgetFromPrevious, margin);
fdlSourceDirectory.right = new FormAttachment(middle, -margin);
wlSourceDirectory.setLayoutData(fdlSourceDirectory);
// Browse folders button ...
wbSourceDirectory = new Button(wSourceFiles, SWT.PUSH | SWT.CENTER);
props.setLook(wbSourceDirectory);
wbSourceDirectory.setText(BaseMessages.getString(PKG, "JobZipFiles.BrowseFolders.Label"));
fdbSourceDirectory = new FormData();
fdbSourceDirectory.right = new FormAttachment(100, 0);
fdbSourceDirectory.top = new FormAttachment(wgetFromPrevious, margin);
wbSourceDirectory.setLayoutData(fdbSourceDirectory);
// Browse Destination file browse button ...
wbSourceFile = new Button(wSourceFiles, SWT.PUSH | SWT.CENTER);
props.setLook(wbSourceFile);
wbSourceFile.setText(BaseMessages.getString(PKG, "JobZipFiles.BrowseFiles.Label"));
fdbSourceFile = new FormData();
fdbSourceFile.right = new FormAttachment(wbSourceDirectory, -margin);
fdbSourceFile.top = new FormAttachment(wgetFromPrevious, margin);
wbSourceFile.setLayoutData(fdbSourceFile);
wSourceDirectory = new TextVar(jobMeta, wSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobZipFiles.SourceDir.Tooltip"));
props.setLook(wSourceDirectory);
wSourceDirectory.addModifyListener(lsMod);
fdSourceDirectory = new FormData();
fdSourceDirectory.left = new FormAttachment(middle, 0);
fdSourceDirectory.top = new FormAttachment(wgetFromPrevious, margin);
fdSourceDirectory.right = new FormAttachment(wbSourceFile, -margin);
wSourceDirectory.setLayoutData(fdSourceDirectory);
// Wildcard line
wlWildcard = new Label(wSourceFiles, SWT.RIGHT);
wlWildcard.setText(BaseMessages.getString(PKG, "JobZipFiles.Wildcard.Label"));
props.setLook(wlWildcard);
fdlWildcard = new FormData();
fdlWildcard.left = new FormAttachment(0, 0);
fdlWildcard.top = new FormAttachment(wSourceDirectory, margin);
fdlWildcard.right = new FormAttachment(middle, -margin);
wlWildcard.setLayoutData(fdlWildcard);
wWildcard = new TextVar(jobMeta, wSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobZipFiles.Wildcard.Tooltip"));
props.setLook(wWildcard);
wWildcard.addModifyListener(lsMod);
fdWildcard = new FormData();
fdWildcard.left = new FormAttachment(middle, 0);
fdWildcard.top = new FormAttachment(wSourceDirectory, margin);
fdWildcard.right = new FormAttachment(100, 0);
wWildcard.setLayoutData(fdWildcard);
// Wildcard to exclude
wlWildcardExclude = new Label(wSourceFiles, SWT.RIGHT);
wlWildcardExclude.setText(BaseMessages.getString(PKG, "JobZipFiles.WildcardExclude.Label"));
props.setLook(wlWildcardExclude);
fdlWildcardExclude = new FormData();
fdlWildcardExclude.left = new FormAttachment(0, 0);
fdlWildcardExclude.top = new FormAttachment(wWildcard, margin);
fdlWildcardExclude.right = new FormAttachment(middle, -margin);
wlWildcardExclude.setLayoutData(fdlWildcardExclude);
wWildcardExclude = new TextVar(jobMeta, wSourceFiles, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobZipFiles.WildcardExclude.Tooltip"));
props.setLook(wWildcardExclude);
wWildcardExclude.addModifyListener(lsMod);
fdWildcardExclude = new FormData();
fdWildcardExclude.left = new FormAttachment(middle, 0);
fdWildcardExclude.top = new FormAttachment(wWildcard, margin);
fdWildcardExclude.right = new FormAttachment(100, 0);
wWildcardExclude.setLayoutData(fdWildcardExclude);
// Include sub-folders?
//
wlIncludeSubfolders = new Label(wSourceFiles, SWT.RIGHT);
wlIncludeSubfolders.setText(BaseMessages.getString(PKG, "JobZipFiles.IncludeSubfolders.Label"));
props.setLook(wlIncludeSubfolders);
fdlIncludeSubfolders = new FormData();
fdlIncludeSubfolders.left = new FormAttachment(0, 0);
fdlIncludeSubfolders.top = new FormAttachment(wWildcardExclude, margin);
fdlIncludeSubfolders.right = new FormAttachment(middle, -margin);
wlIncludeSubfolders.setLayoutData(fdlIncludeSubfolders);
wIncludeSubfolders = new Button(wSourceFiles, SWT.CHECK);
props.setLook(wIncludeSubfolders);
wIncludeSubfolders.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.IncludeSubfolders.Tooltip"));
fdIncludeSubfolders = new FormData();
fdIncludeSubfolders.left = new FormAttachment(middle, 0);
fdIncludeSubfolders.top = new FormAttachment(wWildcardExclude, margin);
fdIncludeSubfolders.right = new FormAttachment(100, 0);
wIncludeSubfolders.setLayoutData(fdIncludeSubfolders);
wIncludeSubfolders.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
fdSourceFiles = new FormData();
fdSourceFiles.left = new FormAttachment(0, margin);
fdSourceFiles.top = new FormAttachment(wName, margin);
fdSourceFiles.right = new FormAttachment(100, -margin);
wSourceFiles.setLayoutData(fdSourceFiles);
// ///////////////////////////////////////////////////////////
// / END OF SourceFile GROUP
// ///////////////////////////////////////////////////////////
// ZipFile grouping?
// ////////////////////////
// START OF ZipFile GROUP///
// /
wZipFile = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wZipFile);
wZipFile.setText(BaseMessages.getString(PKG, "JobZipFiles.ZipFile.Group.Label"));
FormLayout groupLayoutzipfile = new FormLayout();
groupLayoutzipfile.marginWidth = 10;
groupLayoutzipfile.marginHeight = 10;
wZipFile.setLayout(groupLayoutzipfile);
// ZipFilename line
wlZipFilename = new Label(wZipFile, SWT.RIGHT);
wlZipFilename.setText(BaseMessages.getString(PKG, "JobZipFiles.ZipFilename.Label"));
props.setLook(wlZipFilename);
fdlZipFilename = new FormData();
fdlZipFilename.left = new FormAttachment(0, 0);
fdlZipFilename.top = new FormAttachment(wSourceFiles, margin);
fdlZipFilename.right = new FormAttachment(middle, -margin);
wlZipFilename.setLayoutData(fdlZipFilename);
wbZipFilename = new Button(wZipFile, SWT.PUSH | SWT.CENTER);
props.setLook(wbZipFilename);
wbZipFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbZipFilename = new FormData();
fdbZipFilename.right = new FormAttachment(100, 0);
fdbZipFilename.top = new FormAttachment(wSourceFiles, 0);
wbZipFilename.setLayoutData(fdbZipFilename);
wZipFilename = new TextVar(jobMeta, wZipFile, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wZipFilename);
wZipFilename.addModifyListener(lsMod);
fdZipFilename = new FormData();
fdZipFilename.left = new FormAttachment(middle, 0);
fdZipFilename.top = new FormAttachment(wSourceFiles, margin);
fdZipFilename.right = new FormAttachment(wbZipFilename, -margin);
wZipFilename.setLayoutData(fdZipFilename);
// Whenever something changes, set the tooltip to the expanded version:
wZipFilename.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wZipFilename.setToolTipText(jobMeta.environmentSubstitute(wZipFilename.getText()));
}
});
wbZipFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
// dialog.setFilterExtensions(new String[] {"*"});
dialog.setFilterExtensions(new String[] { "*.zip;*.ZIP", "*" });
if (wZipFilename.getText() != null) {
dialog.setFileName(jobMeta.environmentSubstitute(wZipFilename.getText()));
}
dialog.setFilterNames(FILETYPES);
if (dialog.open() != null) {
wZipFilename.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
}
}
});
// Create Parent Folder
wlCreateParentFolder = new Label(wZipFile, SWT.RIGHT);
wlCreateParentFolder.setText(BaseMessages.getString(PKG, "JobZipFiles.CreateParentFolder.Label"));
props.setLook(wlCreateParentFolder);
fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wZipFilename, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wZipFile, SWT.CHECK);
wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.CreateParentFolder.Tooltip"));
props.setLook(wCreateParentFolder);
fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wZipFilename, margin);
fdCreateParentFolder.right = new FormAttachment(100, 0);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wZipFile, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "JobZipFiles.AddDate.Label"));
props.setLook(wlAddDate);
fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wCreateParentFolder, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wZipFile, SWT.CHECK);
props.setLook(wAddDate);
wAddDate.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.AddDate.Tooltip"));
fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, 0);
fdAddDate.top = new FormAttachment(wCreateParentFolder, margin);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Create multi-part file?
wlAddTime = new Label(wZipFile, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "JobZipFiles.AddTime.Label"));
props.setLook(wlAddTime);
fdlAddTime = new FormData();
fdlAddTime.left = new FormAttachment(0, 0);
fdlAddTime.top = new FormAttachment(wAddDate, margin);
fdlAddTime.right = new FormAttachment(middle, -margin);
wlAddTime.setLayoutData(fdlAddTime);
wAddTime = new Button(wZipFile, SWT.CHECK);
props.setLook(wAddTime);
wAddTime.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.AddTime.Tooltip"));
fdAddTime = new FormData();
fdAddTime.left = new FormAttachment(middle, 0);
fdAddTime.top = new FormAttachment(wAddDate, margin);
fdAddTime.right = new FormAttachment(100, 0);
wAddTime.setLayoutData(fdAddTime);
wAddTime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Specify date time format?
wlSpecifyFormat = new Label(wZipFile, SWT.RIGHT);
wlSpecifyFormat.setText(BaseMessages.getString(PKG, "JobZipFiles.SpecifyFormat.Label"));
props.setLook(wlSpecifyFormat);
fdlSpecifyFormat = new FormData();
fdlSpecifyFormat.left = new FormAttachment(0, 0);
fdlSpecifyFormat.top = new FormAttachment(wAddTime, margin);
fdlSpecifyFormat.right = new FormAttachment(middle, -margin);
wlSpecifyFormat.setLayoutData(fdlSpecifyFormat);
wSpecifyFormat = new Button(wZipFile, SWT.CHECK);
props.setLook(wSpecifyFormat);
wSpecifyFormat.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.SpecifyFormat.Tooltip"));
fdSpecifyFormat = new FormData();
fdSpecifyFormat.left = new FormAttachment(middle, 0);
fdSpecifyFormat.top = new FormAttachment(wAddTime, margin);
fdSpecifyFormat.right = new FormAttachment(100, 0);
wSpecifyFormat.setLayoutData(fdSpecifyFormat);
wSpecifyFormat.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
setDateTimeFormat();
}
});
// Prepare a list of possible DateTimeFormats...
String[] dats = Const.getDateFormats();
// DateTimeFormat
wlDateTimeFormat = new Label(wZipFile, SWT.RIGHT);
wlDateTimeFormat.setText(BaseMessages.getString(PKG, "JobZipFiles.DateTimeFormat.Label"));
props.setLook(wlDateTimeFormat);
fdlDateTimeFormat = new FormData();
fdlDateTimeFormat.left = new FormAttachment(0, 0);
fdlDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdlDateTimeFormat.right = new FormAttachment(middle, -margin);
wlDateTimeFormat.setLayoutData(fdlDateTimeFormat);
wDateTimeFormat = new CCombo(wZipFile, SWT.BORDER | SWT.READ_ONLY);
wDateTimeFormat.setEditable(true);
props.setLook(wDateTimeFormat);
wDateTimeFormat.addModifyListener(lsMod);
fdDateTimeFormat = new FormData();
fdDateTimeFormat.left = new FormAttachment(middle, 0);
fdDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdDateTimeFormat.right = new FormAttachment(100, 0);
wDateTimeFormat.setLayoutData(fdDateTimeFormat);
for (int x = 0; x < dats.length; x++) {
wDateTimeFormat.add(dats[x]);
}
wbShowFiles = new Button(wZipFile, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "JobZipFiles.ShowFile.Button"));
fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.top = new FormAttachment(wDateTimeFormat, margin * 2);
wbShowFiles.setLayoutData(fdbShowFiles);
wbShowFiles.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (!Utils.isEmpty(wZipFilename.getText())) {
JobEntryZipFile jobEntry = new JobEntryZipFile();
String[] filename = new String[1];
filename[0] = jobEntry.getFullFilename(wZipFilename.getText(), wAddDate.getSelection(), wAddTime.getSelection(), wSpecifyFormat.getSelection(), wDateTimeFormat.getText());
if (filename != null && filename.length > 0) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, filename, BaseMessages.getString(PKG, "JobZipFiles.SelectOutputFiles.DialogTitle"), BaseMessages.getString(PKG, "JobZipFiles.SelectOutputFiles.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "JobZipFiles.NoFilesFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
}
}
});
fdZipFile = new FormData();
fdZipFile.left = new FormAttachment(0, margin);
fdZipFile.top = new FormAttachment(wSourceFiles, margin);
fdZipFile.right = new FormAttachment(100, -margin);
wZipFile.setLayoutData(fdZipFile);
// ///////////////////////////////////////////////////////////
// END OF ZipFile GROUP
// ///////////////////////////////////////////////////////////
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(500, -margin);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF ADVANCED TAB ///
// ////////////////////////
wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE);
wAdvancedTab.setText(BaseMessages.getString(PKG, "JobZipFiles.Tab.Advanced.Label"));
wAdvancedComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wAdvancedComp);
FormLayout advancedLayout = new FormLayout();
advancedLayout.marginWidth = 3;
advancedLayout.marginHeight = 3;
wAdvancedComp.setLayout(advancedLayout);
// ////////////////////////////
// START OF Settings GROUP
//
wSettings = new Group(wAdvancedComp, SWT.SHADOW_NONE);
props.setLook(wSettings);
wSettings.setText(BaseMessages.getString(PKG, "JobZipFiles.Advanced.Group.Label"));
FormLayout groupLayoutSettings = new FormLayout();
groupLayoutSettings.marginWidth = 10;
groupLayoutSettings.marginHeight = 10;
wSettings.setLayout(groupLayoutSettings);
// Compression Rate
wlCompressionRate = new Label(wSettings, SWT.RIGHT);
wlCompressionRate.setText(BaseMessages.getString(PKG, "JobZipFiles.CompressionRate.Label"));
props.setLook(wlCompressionRate);
fdlCompressionRate = new FormData();
fdlCompressionRate.left = new FormAttachment(0, -margin);
fdlCompressionRate.right = new FormAttachment(middle, -margin);
fdlCompressionRate.top = new FormAttachment(wZipFile, margin);
wlCompressionRate.setLayoutData(fdlCompressionRate);
wCompressionRate = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wCompressionRate.add(BaseMessages.getString(PKG, "JobZipFiles.NO_COMP_CompressionRate.Label"));
wCompressionRate.add(BaseMessages.getString(PKG, "JobZipFiles.DEF_COMP_CompressionRate.Label"));
wCompressionRate.add(BaseMessages.getString(PKG, "JobZipFiles.BEST_COMP_CompressionRate.Label"));
wCompressionRate.add(BaseMessages.getString(PKG, "JobZipFiles.BEST_SPEED_CompressionRate.Label"));
// +1: starts at -1
wCompressionRate.select(1);
props.setLook(wCompressionRate);
fdCompressionRate = new FormData();
fdCompressionRate.left = new FormAttachment(middle, 0);
fdCompressionRate.top = new FormAttachment(wZipFile, margin);
fdCompressionRate.right = new FormAttachment(100, 0);
wCompressionRate.setLayoutData(fdCompressionRate);
// If File Exists
wlIfFileExists = new Label(wSettings, SWT.RIGHT);
wlIfFileExists.setText(BaseMessages.getString(PKG, "JobZipFiles.IfZipFileExists.Label"));
props.setLook(wlIfFileExists);
fdlIfFileExists = new FormData();
fdlIfFileExists.left = new FormAttachment(0, -margin);
fdlIfFileExists.right = new FormAttachment(middle, -margin);
fdlIfFileExists.top = new FormAttachment(wCompressionRate, margin);
wlIfFileExists.setLayoutData(fdlIfFileExists);
wIfFileExists = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wIfFileExists.add(BaseMessages.getString(PKG, "JobZipFiles.Create_NewFile_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobZipFiles.Append_File_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobZipFiles.Do_Nothing_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobZipFiles.Fail_IfFileExists.Label"));
// +1: starts at -1
wIfFileExists.select(3);
props.setLook(wIfFileExists);
fdIfFileExists = new FormData();
fdIfFileExists.left = new FormAttachment(middle, 0);
fdIfFileExists.top = new FormAttachment(wCompressionRate, margin);
fdIfFileExists.right = new FormAttachment(100, 0);
wIfFileExists.setLayoutData(fdIfFileExists);
// After Zipping
wlAfterZip = new Label(wSettings, SWT.RIGHT);
wlAfterZip.setText(BaseMessages.getString(PKG, "JobZipFiles.AfterZip.Label"));
props.setLook(wlAfterZip);
fdlAfterZip = new FormData();
fdlAfterZip.left = new FormAttachment(0, -margin);
fdlAfterZip.right = new FormAttachment(middle, -margin);
fdlAfterZip.top = new FormAttachment(wIfFileExists, margin);
wlAfterZip.setLayoutData(fdlAfterZip);
wAfterZip = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wAfterZip.add(BaseMessages.getString(PKG, "JobZipFiles.Do_Nothing_AfterZip.Label"));
wAfterZip.add(BaseMessages.getString(PKG, "JobZipFiles.Delete_Files_AfterZip.Label"));
wAfterZip.add(BaseMessages.getString(PKG, "JobZipFiles.Move_Files_AfterZip.Label"));
// +1: starts at -1
wAfterZip.select(0);
props.setLook(wAfterZip);
fdAfterZip = new FormData();
fdAfterZip.left = new FormAttachment(middle, 0);
fdAfterZip.top = new FormAttachment(wIfFileExists, margin);
fdAfterZip.right = new FormAttachment(100, 0);
wAfterZip.setLayoutData(fdAfterZip);
wAfterZip.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
AfterZipActivate();
}
});
// moveTo Directory
wlMovetoDirectory = new Label(wSettings, SWT.RIGHT);
wlMovetoDirectory.setText(BaseMessages.getString(PKG, "JobZipFiles.MovetoDirectory.Label"));
props.setLook(wlMovetoDirectory);
fdlMovetoDirectory = new FormData();
fdlMovetoDirectory.left = new FormAttachment(0, 0);
fdlMovetoDirectory.top = new FormAttachment(wAfterZip, margin);
fdlMovetoDirectory.right = new FormAttachment(middle, -margin);
wlMovetoDirectory.setLayoutData(fdlMovetoDirectory);
// Browse folders button ...
wbMovetoDirectory = new Button(wSettings, SWT.PUSH | SWT.CENTER);
props.setLook(wbMovetoDirectory);
wbMovetoDirectory.setText(BaseMessages.getString(PKG, "JobZipFiles.BrowseFolders.Label"));
fdbMovetoDirectory = new FormData();
fdbMovetoDirectory.right = new FormAttachment(100, 0);
fdbMovetoDirectory.top = new FormAttachment(wAfterZip, margin);
wbMovetoDirectory.setLayoutData(fdbMovetoDirectory);
wMovetoDirectory = new TextVar(jobMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobZipFiles.MovetoDirectory.Tooltip"));
props.setLook(wMovetoDirectory);
wMovetoDirectory.addModifyListener(lsMod);
fdMovetoDirectory = new FormData();
fdMovetoDirectory.left = new FormAttachment(middle, 0);
fdMovetoDirectory.top = new FormAttachment(wAfterZip, margin);
fdMovetoDirectory.right = new FormAttachment(wbMovetoDirectory, -margin);
wMovetoDirectory.setLayoutData(fdMovetoDirectory);
// create moveto folder
wlCreateMoveToDirectory = new Label(wSettings, SWT.RIGHT);
wlCreateMoveToDirectory.setText(BaseMessages.getString(PKG, "JobZipFiles.createMoveToDirectory.Label"));
props.setLook(wlCreateMoveToDirectory);
fdlCreateMoveToDirectory = new FormData();
fdlCreateMoveToDirectory.left = new FormAttachment(0, 0);
fdlCreateMoveToDirectory.top = new FormAttachment(wMovetoDirectory, margin);
fdlCreateMoveToDirectory.right = new FormAttachment(middle, -margin);
wlCreateMoveToDirectory.setLayoutData(fdlCreateMoveToDirectory);
wCreateMoveToDirectory = new Button(wSettings, SWT.CHECK);
props.setLook(wCreateMoveToDirectory);
wCreateMoveToDirectory.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.createMoveToDirectory.Tooltip"));
fdCreateMoveToDirectory = new FormData();
fdCreateMoveToDirectory.left = new FormAttachment(middle, 0);
fdCreateMoveToDirectory.top = new FormAttachment(wMovetoDirectory, margin);
fdCreateMoveToDirectory.right = new FormAttachment(100, 0);
wCreateMoveToDirectory.setLayoutData(fdCreateMoveToDirectory);
wCreateMoveToDirectory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
wlStoredSourcePathDepth = new Label(wSettings, SWT.RIGHT);
wlStoredSourcePathDepth.setText(BaseMessages.getString(PKG, "JobZipFiles.StoredSourcePathDepth.Label"));
props.setLook(wlStoredSourcePathDepth);
fdlStoredSourcePathDepth = new FormData();
fdlStoredSourcePathDepth.left = new FormAttachment(0, 0);
fdlStoredSourcePathDepth.top = new FormAttachment(wCreateMoveToDirectory, margin);
fdlStoredSourcePathDepth.right = new FormAttachment(middle, -margin);
wlStoredSourcePathDepth.setLayoutData(fdlStoredSourcePathDepth);
wStoredSourcePathDepth = new ComboVar(jobMeta, wSettings, SWT.SINGLE | SWT.BORDER);
props.setLook(wStoredSourcePathDepth);
wStoredSourcePathDepth.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.StoredSourcePathDepth.Tooltip"));
fdStoredSourcePathDepth = new FormData();
fdStoredSourcePathDepth.left = new FormAttachment(middle, 0);
fdStoredSourcePathDepth.top = new FormAttachment(wCreateMoveToDirectory, margin);
fdStoredSourcePathDepth.right = new FormAttachment(100, 0);
wStoredSourcePathDepth.setLayoutData(fdStoredSourcePathDepth);
wStoredSourcePathDepth.setItems(new String[] { "0 : /pentaho/work/transfer/input/project/file.txt", "1 : file.txt", "2 : project/file.txt", "3 : input/project/file.txt", "4 : transfer/input/project/file.txt", "5 : work/transfer/input/project/file.txt", "6 : pentaho/work/transfer/input/project/file.txt", "7 : pentaho/work/transfer/input/project/file.txt", "8 : pentaho/work/transfer/input/project/file.txt" });
fdSettings = new FormData();
fdSettings.left = new FormAttachment(0, margin);
fdSettings.top = new FormAttachment(wZipFile, margin);
fdSettings.right = new FormAttachment(100, -margin);
wSettings.setLayoutData(fdSettings);
// ///////////////////////////////////////////////////////////
// / END OF Settings GROUP
// ///////////////////////////////////////////////////////////
// fileresult grouping?
// ////////////////////////
// START OF LOGGING GROUP///
// /
wFileResult = new Group(wAdvancedComp, SWT.SHADOW_NONE);
props.setLook(wFileResult);
wFileResult.setText(BaseMessages.getString(PKG, "JobZipFiles.FileResult.Group.Label"));
FormLayout groupLayoutresult = new FormLayout();
groupLayoutresult.marginWidth = 10;
groupLayoutresult.marginHeight = 10;
wFileResult.setLayout(groupLayoutresult);
// Add file to result
wlAddFileToResult = new Label(wFileResult, SWT.RIGHT);
wlAddFileToResult.setText(BaseMessages.getString(PKG, "JobZipFiles.AddFileToResult.Label"));
props.setLook(wlAddFileToResult);
fdlAddFileToResult = new FormData();
fdlAddFileToResult.left = new FormAttachment(0, 0);
fdlAddFileToResult.top = new FormAttachment(wSettings, margin);
fdlAddFileToResult.right = new FormAttachment(middle, -margin);
wlAddFileToResult.setLayoutData(fdlAddFileToResult);
wAddFileToResult = new Button(wFileResult, SWT.CHECK);
props.setLook(wAddFileToResult);
wAddFileToResult.setToolTipText(BaseMessages.getString(PKG, "JobZipFiles.AddFileToResult.Tooltip"));
fdAddFileToResult = new FormData();
fdAddFileToResult.left = new FormAttachment(middle, 0);
fdAddFileToResult.top = new FormAttachment(wSettings, margin);
fdAddFileToResult.right = new FormAttachment(100, 0);
wAddFileToResult.setLayoutData(fdAddFileToResult);
wAddFileToResult.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
fdFileResult = new FormData();
fdFileResult.left = new FormAttachment(0, margin);
fdFileResult.top = new FormAttachment(wSettings, margin);
fdFileResult.right = new FormAttachment(100, -margin);
wFileResult.setLayoutData(fdFileResult);
// ///////////////////////////////////////////////////////////
// / END OF FILE RESULT GROUP
// ///////////////////////////////////////////////////////////
fdAdvancedComp = new FormData();
fdAdvancedComp.left = new FormAttachment(0, 0);
fdAdvancedComp.top = new FormAttachment(0, 0);
fdAdvancedComp.right = new FormAttachment(100, 0);
fdAdvancedComp.bottom = new FormAttachment(500, -margin);
wAdvancedComp.setLayoutData(fdAdvancedComp);
wAdvancedComp.layout();
wAdvancedTab.setControl(wAdvancedComp);
props.setLook(wAdvancedComp);
// ///////////////////////////////////////////////////////////
// / END OF Advanced TAB
// ///////////////////////////////////////////////////////////
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(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wTabFolder);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wbSourceDirectory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog ddialog = new DirectoryDialog(shell, SWT.OPEN);
if (wSourceDirectory.getText() != null) {
ddialog.setFilterPath(jobMeta.environmentSubstitute(wSourceDirectory.getText()));
}
// Calling open() will open and run the dialog.
// It will return the selected directory, or
// null if user cancels
String dir = ddialog.open();
if (dir != null) {
// Set the text box to the new selection
wSourceDirectory.setText(dir);
}
}
});
wbMovetoDirectory.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog ddialog = new DirectoryDialog(shell, SWT.OPEN);
if (wMovetoDirectory.getText() != null) {
ddialog.setFilterPath(jobMeta.environmentSubstitute(wMovetoDirectory.getText()));
}
// Calling open() will open and run the dialog.
// It will return the selected directory, or
// null if user cancels
String dir = ddialog.open();
if (dir != null) {
// Set the text box to the new selection
wMovetoDirectory.setText(dir);
}
}
});
wbSourceFile.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*" });
if (wSourceDirectory.getText() != null) {
dialog.setFileName(jobMeta.environmentSubstitute(wSourceDirectory.getText()));
}
dialog.setFilterNames(FILETYPES);
if (dialog.open() != null) {
wSourceDirectory.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
}
}
});
wName.addSelectionListener(lsDef);
wZipFilename.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
setGetFromPrevious();
AfterZipActivate();
setDateTimeFormat();
wTabFolder.setSelection(0);
BaseStepDialog.setSize(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobEntry;
}
use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-cassandra-plugin by pentaho.
the class CassandraOutputDialog method showEnterSelectionDialog.
protected void showEnterSelectionDialog() {
StepMeta stepMeta = transMeta.findStep(stepname);
String[] choices = null;
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
if (row.size() == 0) {
MessageDialog.openError(shell, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputData.Message.NoIncomingFields.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputData.Message.NoIncomingFields"));
return;
}
choices = new String[row.size()];
for (int i = 0; i < row.size(); i++) {
ValueMetaInterface vm = row.getValueMeta(i);
choices[i] = vm.getName();
}
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, choices, BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputDialog.SelectKeyFieldsDialog.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, "CassandraOutputDialog.SelectKeyFieldsDialog.Message"));
dialog.setMulti(true);
if (!Utils.isEmpty(m_keyFieldCombo.getText())) {
String current = m_keyFieldCombo.getText();
// $NON-NLS-1$
String[] parts = current.split(",");
int[] currentSelection = new int[parts.length];
int count = 0;
for (String s : parts) {
int index = row.indexOfValue(s.trim());
if (index >= 0) {
currentSelection[count++] = index;
}
}
dialog.setSelectedNrs(currentSelection);
}
dialog.open();
// SIC
int[] selected = dialog.getSelectionIndeces();
if (selected != null && selected.length > 0) {
StringBuilder newSelection = new StringBuilder();
boolean first = true;
for (int i : selected) {
if (first) {
newSelection.append(choices[i]);
first = false;
} else {
// $NON-NLS-1$
newSelection.append(",").append(choices[i]);
}
}
m_keyFieldCombo.setText(newSelection.toString());
}
} catch (KettleException ex) {
MessageDialog.openError(shell, BaseMessages.getString(PKG, "CassandraOutputData.Message.NoIncomingFields.Title"), // $NON-NLS-1$
BaseMessages.getString(PKG, // $NON-NLS-1$
"CassandraOutputData.Message.NoIncomingFields"));
}
}
}
Aggregations