use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class ParGzipCsvInputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
Control lastControl = wStepname;
// See if the step receives input. If so, we don't ask for the filename, but for the filename field.
//
isReceivingInput = transMeta.findNrPrevSteps(stepMeta) > 0;
if (isReceivingInput) {
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ParGzipCsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "ParGzipCsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.FilenameField.Label"));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilenameField = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilename);
lastControl = wFilenameField;
// Checkbox to include the filename in the output...
//
Label wlIncludeFilename = new Label(shell, SWT.RIGHT);
wlIncludeFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.IncludeFilenameField.Label"));
props.setLook(wlIncludeFilename);
FormData fdlIncludeFilename = new FormData();
fdlIncludeFilename.top = new FormAttachment(lastControl, margin);
fdlIncludeFilename.left = new FormAttachment(0, 0);
fdlIncludeFilename.right = new FormAttachment(middle, -margin);
wlIncludeFilename.setLayoutData(fdlIncludeFilename);
wIncludeFilename = new Button(shell, SWT.CHECK);
props.setLook(wIncludeFilename);
wFilenameField.addModifyListener(lsMod);
FormData fdIncludeFilename = new FormData();
fdIncludeFilename.top = new FormAttachment(lastControl, margin);
fdIncludeFilename.left = new FormAttachment(middle, 0);
fdIncludeFilename.right = new FormAttachment(100, 0);
wIncludeFilename.setLayoutData(fdIncludeFilename);
lastControl = wIncludeFilename;
} else {
// Filename...
//
// The filename browse button
//
wbbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
FormData fdbFilename = new FormData();
fdbFilename.top = new FormAttachment(lastControl, margin);
fdbFilename.right = new FormAttachment(100, 0);
wbbFilename.setLayoutData(fdbFilename);
// The field itself...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Filename.Label"));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.top = new FormAttachment(lastControl, margin);
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wFilename = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.top = new FormAttachment(lastControl, margin);
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.right = new FormAttachment(wbbFilename, -margin);
wFilename.setLayoutData(fdFilename);
lastControl = wFilename;
}
// delimiter
Label wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
FormData fdlDelimiter = new FormData();
fdlDelimiter.top = new FormAttachment(lastControl, margin);
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wbDelimiter = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbDelimiter);
wbDelimiter.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Delimiter.Button"));
FormData fdbDelimiter = new FormData();
fdbDelimiter.top = new FormAttachment(lastControl, margin);
fdbDelimiter.right = new FormAttachment(100, 0);
wbDelimiter.setLayoutData(fdbDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
FormData fdDelimiter = new FormData();
fdDelimiter.top = new FormAttachment(lastControl, margin);
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.right = new FormAttachment(wbDelimiter, -margin);
wDelimiter.setLayoutData(fdDelimiter);
lastControl = wDelimiter;
// enclosure
Label wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
FormData fdlEnclosure = new FormData();
fdlEnclosure.top = new FormAttachment(lastControl, margin);
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
FormData fdEnclosure = new FormData();
fdEnclosure.top = new FormAttachment(lastControl, margin);
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
lastControl = wEnclosure;
// bufferSize
//
Label wlBufferSize = new Label(shell, SWT.RIGHT);
wlBufferSize.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.BufferSize.Label"));
props.setLook(wlBufferSize);
FormData fdlBufferSize = new FormData();
fdlBufferSize.top = new FormAttachment(lastControl, margin);
fdlBufferSize.left = new FormAttachment(0, 0);
fdlBufferSize.right = new FormAttachment(middle, -margin);
wlBufferSize.setLayoutData(fdlBufferSize);
wBufferSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBufferSize);
wBufferSize.addModifyListener(lsMod);
FormData fdBufferSize = new FormData();
fdBufferSize.top = new FormAttachment(lastControl, margin);
fdBufferSize.left = new FormAttachment(middle, 0);
fdBufferSize.right = new FormAttachment(100, 0);
wBufferSize.setLayoutData(fdBufferSize);
lastControl = wBufferSize;
// performingLazyConversion?
//
Label wlLazyConversion = new Label(shell, SWT.RIGHT);
wlLazyConversion.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.LazyConversion.Label"));
props.setLook(wlLazyConversion);
FormData fdlLazyConversion = new FormData();
fdlLazyConversion.top = new FormAttachment(lastControl, margin);
fdlLazyConversion.left = new FormAttachment(0, 0);
fdlLazyConversion.right = new FormAttachment(middle, -margin);
wlLazyConversion.setLayoutData(fdlLazyConversion);
wLazyConversion = new Button(shell, SWT.CHECK);
props.setLook(wLazyConversion);
FormData fdLazyConversion = new FormData();
fdLazyConversion.top = new FormAttachment(lastControl, margin);
fdLazyConversion.left = new FormAttachment(middle, 0);
fdLazyConversion.right = new FormAttachment(100, 0);
wLazyConversion.setLayoutData(fdLazyConversion);
lastControl = wLazyConversion;
// header row?
//
Label wlHeaderPresent = new Label(shell, SWT.RIGHT);
wlHeaderPresent.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.HeaderPresent.Label"));
props.setLook(wlHeaderPresent);
FormData fdlHeaderPresent = new FormData();
fdlHeaderPresent.top = new FormAttachment(lastControl, margin);
fdlHeaderPresent.left = new FormAttachment(0, 0);
fdlHeaderPresent.right = new FormAttachment(middle, -margin);
wlHeaderPresent.setLayoutData(fdlHeaderPresent);
wHeaderPresent = new Button(shell, SWT.CHECK);
props.setLook(wHeaderPresent);
FormData fdHeaderPresent = new FormData();
fdHeaderPresent.top = new FormAttachment(lastControl, margin);
fdHeaderPresent.left = new FormAttachment(middle, 0);
fdHeaderPresent.right = new FormAttachment(100, 0);
wHeaderPresent.setLayoutData(fdHeaderPresent);
lastControl = wHeaderPresent;
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wHeaderPresent, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wHeaderPresent, margin);
wAddResult.setLayoutData(fdAddResult);
lastControl = wAddResult;
// The field itself...
//
Label wlRowNumField = new Label(shell, SWT.RIGHT);
wlRowNumField.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.RowNumField.Label"));
props.setLook(wlRowNumField);
FormData fdlRowNumField = new FormData();
fdlRowNumField.top = new FormAttachment(lastControl, margin);
fdlRowNumField.left = new FormAttachment(0, 0);
fdlRowNumField.right = new FormAttachment(middle, -margin);
wlRowNumField.setLayoutData(fdlRowNumField);
wRowNumField = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRowNumField);
wRowNumField.addModifyListener(lsMod);
FormData fdRowNumField = new FormData();
fdRowNumField.top = new FormAttachment(lastControl, margin);
fdRowNumField.left = new FormAttachment(middle, 0);
fdRowNumField.right = new FormAttachment(100, 0);
wRowNumField.setLayoutData(fdRowNumField);
lastControl = wRowNumField;
// running in parallel?
//
Label wlRunningInParallel = new Label(shell, SWT.RIGHT);
wlRunningInParallel.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.RunningInParallel.Label"));
props.setLook(wlRunningInParallel);
FormData fdlRunningInParallel = new FormData();
fdlRunningInParallel.top = new FormAttachment(lastControl, margin);
fdlRunningInParallel.left = new FormAttachment(0, 0);
fdlRunningInParallel.right = new FormAttachment(middle, -margin);
wlRunningInParallel.setLayoutData(fdlRunningInParallel);
wRunningInParallel = new Button(shell, SWT.CHECK);
props.setLook(wRunningInParallel);
FormData fdRunningInParallel = new FormData();
fdRunningInParallel.top = new FormAttachment(lastControl, margin);
fdRunningInParallel.left = new FormAttachment(middle, 0);
wRunningInParallel.setLayoutData(fdRunningInParallel);
lastControl = wRunningInParallel;
// Encoding
Label wlEncoding = new Label(shell, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.Encoding.Label"));
props.setLook(wlEncoding);
FormData fdlEncoding = new FormData();
fdlEncoding.top = new FormAttachment(lastControl, margin);
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new ComboVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
FormData fdEncoding = new FormData();
fdEncoding.top = new FormAttachment(lastControl, margin);
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
lastControl = wEncoding;
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
// Some buttons first, so that the dialog scales nicely...
//
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"));
wPreview = new Button(shell, SWT.PUSH);
wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
wPreview.setEnabled(!isReceivingInput);
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wGet.setEnabled(!isReceivingInput);
setButtonPositions(new Button[] { wOK, wPreview, wGet, wCancel }, margin, null);
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.NameColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.TypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames(), true), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.FormatColumn.Column"), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.LengthColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.PrecisionColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.CurrencyColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.DecimalColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.GroupColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ParGzipCsvInputDialog.TrimTypeColumn.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc) };
colinf[2].setComboValuesSelectionListener(new ComboValuesSelectionListener() {
public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
String[] comboValues = new String[] {};
int type = ValueMetaFactory.getIdForValueMeta(tableItem.getText(colNr - 1));
switch(type) {
case ValueMetaInterface.TYPE_DATE:
comboValues = Const.getDateFormats();
break;
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
case ValueMetaInterface.TYPE_NUMBER:
comboValues = Const.getNumberFormats();
break;
default:
break;
}
return comboValues;
}
});
wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
FormData fdFields = new FormData();
fdFields.top = new FormAttachment(lastControl, margin * 2);
fdFields.bottom = new FormAttachment(wOK, -margin * 2);
fdFields.left = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsPreview = new Listener() {
public void handleEvent(Event e) {
preview();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
getCSV();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wPreview.addListener(SWT.Selection, lsPreview);
wGet.addListener(SWT.Selection, lsGet);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
if (wFilename != null) {
wFilename.addSelectionListener(lsDef);
}
if (wFilenameField != null) {
wFilenameField.addSelectionListener(lsDef);
}
wDelimiter.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wBufferSize.addSelectionListener(lsDef);
wRowNumField.addSelectionListener(lsDef);
// Allow the insertion of tabs as separator...
wbDelimiter.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
Text t = wDelimiter.getTextWidget();
if (t != null) {
t.insert("\t");
}
}
});
if (wbbFilename != null) {
// Listen to the browse button next to the file name
wbbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.txt;*.csv", "*.csv", "*.txt", "*" });
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.CSVFiles") + ", " + BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
});
}
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class PGBulkLoaderDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
FocusListener lsFocusLost = new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
setTableFieldCombo();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetSchema.Label"));
props.setLook(wlSchema);
fdlSchema = new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right = new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin * 2);
wlSchema.setLayoutData(fdlSchema);
wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.addFocusListener(lsFocusLost);
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin * 2);
fdSchema.right = new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsMod);
wTable.addFocusListener(lsFocusLost);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// Load Action line
wlLoadAction = new Label(shell, SWT.RIGHT);
wlLoadAction.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.LoadAction.Label"));
props.setLook(wlLoadAction);
fdlLoadAction = new FormData();
fdlLoadAction.left = new FormAttachment(0, 0);
fdlLoadAction.right = new FormAttachment(middle, -margin);
fdlLoadAction.top = new FormAttachment(wTable, margin);
wlLoadAction.setLayoutData(fdlLoadAction);
wLoadAction = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label"));
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label"));
// +1: starts at -1
wLoadAction.select(0);
wLoadAction.addModifyListener(lsMod);
props.setLook(wLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wTable, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wTable, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
// Db Name Override line
wlDbNameOverride = new Label(shell, SWT.RIGHT);
wlDbNameOverride.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.DbNameOverride.Label"));
props.setLook(wlDbNameOverride);
fdlDbNameOverride = new FormData();
fdlDbNameOverride.left = new FormAttachment(0, 0);
fdlDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdlDbNameOverride.right = new FormAttachment(middle, -margin);
wlDbNameOverride.setLayoutData(fdlDbNameOverride);
wDbNameOverride = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDbNameOverride);
wDbNameOverride.addModifyListener(lsMod);
fdDbNameOverride = new FormData();
fdDbNameOverride.left = new FormAttachment(middle, 0);
fdDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdDbNameOverride.right = new FormAttachment(100, 0);
wDbNameOverride.setLayoutData(fdDbNameOverride);
// Enclosure line
wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// Delimiter
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.top = new FormAttachment(wEnclosure, margin);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wEnclosure, margin);
fdDelimiter.right = new FormAttachment(100, 0);
wDelimiter.setLayoutData(fdDelimiter);
// Stop on Error line
wlStopOnError = new Label(shell, SWT.RIGHT);
wlStopOnError.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.StopOnError.Label"));
props.setLook(wlStopOnError);
fdlStopOnError = new FormData();
fdlStopOnError.left = new FormAttachment(0, 0);
fdlStopOnError.top = new FormAttachment(wDelimiter, margin);
fdlStopOnError.right = new FormAttachment(middle, -margin);
wlStopOnError.setLayoutData(fdlStopOnError);
wStopOnError = new Button(shell, SWT.CHECK);
props.setLook(wStopOnError);
fdStopOnError = new FormData();
fdStopOnError.left = new FormAttachment(middle, 0);
fdStopOnError.top = new FormAttachment(wDelimiter, margin);
fdStopOnError.right = new FormAttachment(100, 0);
wStopOnError.setLayoutData(fdStopOnError);
wStopOnError.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQL.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wSQL }, margin, null);
// The field Table
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Fields.Label"));
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wStopOnError, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getFieldTable() != null ? input.getFieldTable().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.DateMask"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "", BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label") }, true);
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.GetFields.Label"));
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.EditMapping.Label"));
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
// fix margin error
fdReturn.right = new FormAttachment(wDoMapping, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2 * margin);
wReturn.setLayoutData(fdReturn);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGetLU = new Listener() {
public void handleEvent(Event e) {
getUpdate();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
create();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wDbNameOverride.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wDelimiter.addSelectionListener(lsDef);
wStopOnError.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class SortRowsDialog method open.
@Override
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "SortRowsDialog.DialogTitle"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Temp directory for sorting
wlSortDir = new Label(shell, SWT.RIGHT);
wlSortDir.setText(BaseMessages.getString(PKG, "SortRowsDialog.SortDir.Label"));
props.setLook(wlSortDir);
fdlSortDir = new FormData();
fdlSortDir.left = new FormAttachment(0, 0);
fdlSortDir.right = new FormAttachment(middle, -margin);
fdlSortDir.top = new FormAttachment(wStepname, margin);
wlSortDir.setLayoutData(fdlSortDir);
wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbSortDir);
wbSortDir.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbSortDir = new FormData();
fdbSortDir.right = new FormAttachment(100, 0);
fdbSortDir.top = new FormAttachment(wStepname, margin);
wbSortDir.setLayoutData(fdbSortDir);
wSortDir = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wSortDir.setText("temp");
props.setLook(wSortDir);
wSortDir.addModifyListener(lsMod);
fdSortDir = new FormData();
fdSortDir.left = new FormAttachment(middle, 0);
fdSortDir.top = new FormAttachment(wStepname, margin);
fdSortDir.right = new FormAttachment(wbSortDir, -margin);
wSortDir.setLayoutData(fdSortDir);
wbSortDir.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
dd.setFilterPath(wSortDir.getText());
String dir = dd.open();
if (dir != null) {
wSortDir.setText(dir);
}
}
});
// Whenever something changes, set the tooltip to the expanded version:
wSortDir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
wSortDir.setToolTipText(transMeta.environmentSubstitute(wSortDir.getText()));
}
});
// Prefix of temporary file
wlPrefix = new Label(shell, SWT.RIGHT);
wlPrefix.setText(BaseMessages.getString(PKG, "SortRowsDialog.Prefix.Label"));
props.setLook(wlPrefix);
fdlPrefix = new FormData();
fdlPrefix.left = new FormAttachment(0, 0);
fdlPrefix.right = new FormAttachment(middle, -margin);
fdlPrefix.top = new FormAttachment(wbSortDir, margin * 2);
wlPrefix.setLayoutData(fdlPrefix);
wPrefix = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPrefix);
wPrefix.addModifyListener(lsMod);
fdPrefix = new FormData();
fdPrefix.left = new FormAttachment(middle, 0);
fdPrefix.top = new FormAttachment(wbSortDir, margin * 2);
fdPrefix.right = new FormAttachment(100, 0);
wPrefix.setLayoutData(fdPrefix);
wPrefix.setText("srt");
// Maximum number of lines to keep in memory before using temporary files
wlSortSize = new Label(shell, SWT.RIGHT);
wlSortSize.setText(BaseMessages.getString(PKG, "SortRowsDialog.SortSize.Label"));
props.setLook(wlSortSize);
fdlSortSize = new FormData();
fdlSortSize.left = new FormAttachment(0, 0);
fdlSortSize.right = new FormAttachment(middle, -margin);
fdlSortSize.top = new FormAttachment(wPrefix, margin * 2);
wlSortSize.setLayoutData(fdlSortSize);
wSortSize = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSortSize);
wSortSize.addModifyListener(lsMod);
fdSortSize = new FormData();
fdSortSize.left = new FormAttachment(middle, 0);
fdSortSize.top = new FormAttachment(wPrefix, margin * 2);
fdSortSize.right = new FormAttachment(100, 0);
wSortSize.setLayoutData(fdSortSize);
// Free Memory to keep
wlFreeMemory = new Label(shell, SWT.RIGHT);
wlFreeMemory.setText(BaseMessages.getString(PKG, "SortRowsDialog.FreeMemory.Label"));
wlFreeMemory.setToolTipText(BaseMessages.getString(PKG, "SortRowsDialog.FreeMemory.ToolTip"));
props.setLook(wlFreeMemory);
fdlFreeMemory = new FormData();
fdlFreeMemory.left = new FormAttachment(0, 0);
fdlFreeMemory.right = new FormAttachment(middle, -margin);
fdlFreeMemory.top = new FormAttachment(wSortSize, margin * 2);
wlFreeMemory.setLayoutData(fdlFreeMemory);
wFreeMemory = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wFreeMemory.setToolTipText(BaseMessages.getString(PKG, "SortRowsDialog.FreeMemory.ToolTip"));
props.setLook(wFreeMemory);
wFreeMemory.addModifyListener(lsMod);
fdFreeMemory = new FormData();
fdFreeMemory.left = new FormAttachment(middle, 0);
fdFreeMemory.top = new FormAttachment(wSortSize, margin * 2);
fdFreeMemory.right = new FormAttachment(100, 0);
wFreeMemory.setLayoutData(fdFreeMemory);
// Using compression for temporary files?
wlCompress = new Label(shell, SWT.RIGHT);
wlCompress.setText(BaseMessages.getString(PKG, "SortRowsDialog.Compress.Label"));
props.setLook(wlCompress);
fdlCompress = new FormData();
fdlCompress.left = new FormAttachment(0, 0);
fdlCompress.right = new FormAttachment(middle, -margin);
fdlCompress.top = new FormAttachment(wFreeMemory, margin * 2);
wlCompress.setLayoutData(fdlCompress);
wCompress = new CheckBoxVar(transMeta, shell, SWT.CHECK, "");
props.setLook(wCompress);
fdCompress = new FormData();
fdCompress.left = new FormAttachment(middle, 0);
fdCompress.top = new FormAttachment(wFreeMemory, margin * 2);
fdCompress.right = new FormAttachment(100, 0);
wCompress.setLayoutData(fdCompress);
wCompress.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
log.logDetailed("SortRowsDialog", "Selection Listener for compress: " + wCompress.getSelection());
input.setChanged();
}
});
// Using compression for temporary files?
wlUniqueRows = new Label(shell, SWT.RIGHT);
wlUniqueRows.setText(BaseMessages.getString(PKG, "SortRowsDialog.UniqueRows.Label"));
props.setLook(wlUniqueRows);
fdlUniqueRows = new FormData();
fdlUniqueRows.left = new FormAttachment(0, 0);
fdlUniqueRows.right = new FormAttachment(middle, -margin);
fdlUniqueRows.top = new FormAttachment(wCompress, margin);
wlUniqueRows.setLayoutData(fdlUniqueRows);
wUniqueRows = new Button(shell, SWT.CHECK);
wUniqueRows.setToolTipText(BaseMessages.getString(PKG, "SortRowsDialog.UniqueRows.Tooltip"));
props.setLook(wUniqueRows);
fdUniqueRows = new FormData();
fdUniqueRows.left = new FormAttachment(middle, 0);
fdUniqueRows.top = new FormAttachment(wCompress, margin);
fdUniqueRows.right = new FormAttachment(100, 0);
wUniqueRows.setLayoutData(fdUniqueRows);
wUniqueRows.addSelectionListener(new ComponentSelectionListener(input));
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
// Table with fields to sort and sort direction
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "SortRowsDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wUniqueRows, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsRows = input.getFieldName().length;
colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.Fieldname.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.Ascending.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }), new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.CaseInsensitive.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }), new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.CollatorDisabled.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }), new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.CollatorStrength.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Primary"), BaseMessages.getString(PKG, "System.Combo.Secondary"), BaseMessages.getString(PKG, "System.Combo.Tertiary"), BaseMessages.getString(PKG, "System.Combo.Identical") }, true), new ColumnInfo(BaseMessages.getString(PKG, "SortRowsDialog.PreSortedField.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { BaseMessages.getString(PKG, "System.Combo.Yes"), BaseMessages.getString(PKG, "System.Combo.No") }) };
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(wOK, -2 * margin);
wFields.setLayoutData(fdFields);
//
// Search the fields in the background
final Runnable runnable = new Runnable() {
@Override
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsOK = new Listener() {
@Override
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
@Override
public void handleEvent(Event e) {
get();
}
};
lsCancel = new Listener() {
@Override
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSortDir.addSelectionListener(lsDef);
wPrefix.addSelectionListener(lsDef);
wSortSize.addSelectionListener(lsDef);
wFreeMemory.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
cancel();
}
});
lsResize = new Listener() {
@Override
public void handleEvent(Event event) {
Point size = shell.getSize();
wFields.setSize(size.x - 10, size.y - 50);
wFields.table.setSize(size.x - 10, size.y - 50);
wFields.redraw();
}
};
shell.addListener(SWT.Resize, lsResize);
// Set the shell size, based upon previous time...
setSize();
getData();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class SplitFieldToRowsDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Typefield line
wlSplitfield = new Label(shell, SWT.RIGHT);
wlSplitfield.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.SplitField.Label"));
props.setLook(wlSplitfield);
fdlSplitfield = new FormData();
fdlSplitfield.left = new FormAttachment(0, 0);
fdlSplitfield.right = new FormAttachment(middle, -margin);
fdlSplitfield.top = new FormAttachment(wStepname, margin);
wlSplitfield.setLayoutData(fdlSplitfield);
wSplitfield = new ComboVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wSplitfield.setToolTipText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.UrlField.Tooltip"));
props.setLook(wSplitfield);
wSplitfield.addModifyListener(lsMod);
fdSplitfield = new FormData();
fdSplitfield.left = new FormAttachment(middle, 0);
fdSplitfield.top = new FormAttachment(wStepname, margin);
fdSplitfield.right = new FormAttachment(100, 0);
wSplitfield.setLayoutData(fdSplitfield);
wSplitfield.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
BaseStepDialog.getFieldsFromPrevious(wSplitfield, transMeta, stepMeta);
shell.setCursor(null);
busy.dispose();
}
});
// Delimiter line
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.right = new FormAttachment(middle, -margin);
fdlDelimiter.top = new FormAttachment(wSplitfield, margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wDelimiter.setText("");
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wSplitfield, margin);
fdDelimiter.right = new FormAttachment(100, 0);
wDelimiter.setLayoutData(fdDelimiter);
// Add File to the result files name
Label wlDelimiterIsRegex = new Label(shell, SWT.RIGHT);
wlDelimiterIsRegex.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.DelimiterIsRegex.Label"));
props.setLook(wlDelimiterIsRegex);
FormData fdlDelimiterIsRegex = new FormData();
fdlDelimiterIsRegex.left = new FormAttachment(0, 0);
fdlDelimiterIsRegex.top = new FormAttachment(wDelimiter);
fdlDelimiterIsRegex.right = new FormAttachment(middle, -margin);
wlDelimiterIsRegex.setLayoutData(fdlDelimiterIsRegex);
wDelimiterIsRegex = new Button(shell, SWT.CHECK);
wDelimiterIsRegex.setToolTipText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.DelimiterIsRegex.Tooltip"));
props.setLook(wDelimiterIsRegex);
FormData fdDelimiterIsRegex = new FormData();
fdDelimiterIsRegex.left = new FormAttachment(middle, 0);
fdDelimiterIsRegex.top = new FormAttachment(wDelimiter);
fdDelimiterIsRegex.right = new FormAttachment(100, 0);
wDelimiterIsRegex.setLayoutData(fdDelimiterIsRegex);
SelectionAdapter lsSelR = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wDelimiterIsRegex.addSelectionListener(lsSelR);
// ValName line
wlValName = new Label(shell, SWT.RIGHT);
wlValName.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.NewFieldName.Label"));
props.setLook(wlValName);
fdlValName = new FormData();
fdlValName.left = new FormAttachment(0, 0);
fdlValName.right = new FormAttachment(middle, -margin);
fdlValName.top = new FormAttachment(wDelimiterIsRegex, margin);
wlValName.setLayoutData(fdlValName);
wValName = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wValName.setText("");
props.setLook(wValName);
wValName.addModifyListener(lsMod);
fdValName = new FormData();
fdValName.left = new FormAttachment(middle, 0);
fdValName.right = new FormAttachment(100, 0);
fdValName.top = new FormAttachment(wDelimiterIsRegex, margin);
wValName.setLayoutData(fdValName);
// ///////////////////////////////
// START OF Additional Fields GROUP //
// ///////////////////////////////
wAdditionalFields = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wAdditionalFields);
wAdditionalFields.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.wAdditionalFields.Label"));
FormLayout AdditionalFieldsgroupLayout = new FormLayout();
AdditionalFieldsgroupLayout.marginWidth = 10;
AdditionalFieldsgroupLayout.marginHeight = 10;
wAdditionalFields.setLayout(AdditionalFieldsgroupLayout);
wlInclRownum = new Label(wAdditionalFields, SWT.RIGHT);
wlInclRownum.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.InclRownum.Label"));
props.setLook(wlInclRownum);
fdlInclRownum = new FormData();
fdlInclRownum.left = new FormAttachment(0, 0);
fdlInclRownum.top = new FormAttachment(wValName, margin);
fdlInclRownum.right = new FormAttachment(middle, -margin);
wlInclRownum.setLayoutData(fdlInclRownum);
wInclRownum = new Button(wAdditionalFields, SWT.CHECK);
props.setLook(wInclRownum);
wInclRownum.setToolTipText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.InclRownum.Tooltip"));
fdRownum = new FormData();
fdRownum.left = new FormAttachment(middle, 0);
fdRownum.top = new FormAttachment(wValName, margin);
wInclRownum.setLayoutData(fdRownum);
wInclRownum.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setIncludeRownum();
input.setChanged();
}
});
wlInclRownumField = new Label(wAdditionalFields, SWT.RIGHT);
wlInclRownumField.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.InclRownumField.Label"));
props.setLook(wlInclRownumField);
fdlInclRownumField = new FormData();
fdlInclRownumField.left = new FormAttachment(wInclRownum, margin);
fdlInclRownumField.top = new FormAttachment(wValName, margin);
wlInclRownumField.setLayoutData(fdlInclRownumField);
wInclRownumField = new TextVar(transMeta, wAdditionalFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wInclRownumField);
wInclRownumField.addModifyListener(lsMod);
fdInclRownumField = new FormData();
fdInclRownumField.left = new FormAttachment(wlInclRownumField, margin);
fdInclRownumField.top = new FormAttachment(wValName, margin);
fdInclRownumField.right = new FormAttachment(100, 0);
wInclRownumField.setLayoutData(fdInclRownumField);
wlResetRownum = new Label(wAdditionalFields, SWT.RIGHT);
wlResetRownum.setText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.ResetRownum.Label"));
props.setLook(wlResetRownum);
fdlResetRownum = new FormData();
fdlResetRownum.left = new FormAttachment(wInclRownum, margin);
fdlResetRownum.top = new FormAttachment(wInclRownumField, margin);
wlResetRownum.setLayoutData(fdlResetRownum);
wResetRownum = new Button(wAdditionalFields, SWT.CHECK);
props.setLook(wResetRownum);
wResetRownum.setToolTipText(BaseMessages.getString(PKG, "SplitFieldToRowsDialog.ResetRownum.Tooltip"));
fdRownum = new FormData();
fdRownum.left = new FormAttachment(wlResetRownum, margin);
fdRownum.top = new FormAttachment(wInclRownumField, margin);
wResetRownum.setLayoutData(fdRownum);
wResetRownum.addSelectionListener(new ComponentSelectionListener(input));
fdAdditionalFields = new FormData();
fdAdditionalFields.left = new FormAttachment(0, margin);
fdAdditionalFields.top = new FormAttachment(wValName, margin);
fdAdditionalFields.right = new FormAttachment(100, -margin);
wAdditionalFields.setLayoutData(fdAdditionalFields);
// ///////////////////////////////
// END OF Additional Fields GROUP //
// ///////////////////////////////
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, wAdditionalFields);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wValName.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class SQLFileOutputDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
backupChanged = input.hasChanged();
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.DialogTitle"));
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
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, "SQLFileOutputDialog.GeneralTab.TabTitle"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Connection grouping?
// ////////////////////////
// START OF Connection GROUP
//
wGConnection = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wGConnection);
wGConnection.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Group.ConnectionInfos.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wGConnection.setLayout(groupLayout);
// Connection line
wConnection = addConnectionLine(wGConnection, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
// Schema line...
wlSchema = new Label(wGConnection, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TargetSchema.Label"));
props.setLook(wlSchema);
fdlSchema = new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right = new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin);
wlSchema.setLayoutData(fdlSchema);
wSchema = new TextVar(transMeta, wGConnection, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TargetSchema.Tooltip"));
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin);
fdSchema.right = new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(wGConnection, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(wGConnection, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, wGConnection, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TargetTable.Tooltip"));
wTable.addModifyListener(lsMod);
fdTable = new FormData();
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.left = new FormAttachment(middle, 0);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
fdGConnection = new FormData();
fdGConnection.left = new FormAttachment(0, margin);
fdGConnection.top = new FormAttachment(wStepname, margin);
fdGConnection.right = new FormAttachment(100, -margin);
wGConnection.setLayoutData(fdGConnection);
// ///////////////////////////////////////////////////////////
// / END OF Connection GROUP
// ///////////////////////////////////////////////////////////
// Connection grouping?
// ////////////////////////
// START OF FileName GROUP
//
wFileName = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wFileName);
wFileName.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Group.File.Label"));
FormLayout groupFileLayout = new FormLayout();
groupFileLayout.marginWidth = 10;
groupFileLayout.marginHeight = 10;
wFileName.setLayout(groupFileLayout);
// Add Create table
wlAddCreate = new Label(wFileName, SWT.RIGHT);
wlAddCreate.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.CreateTable.Label"));
props.setLook(wlAddCreate);
fdlAddCreate = new FormData();
fdlAddCreate.left = new FormAttachment(0, 0);
fdlAddCreate.top = new FormAttachment(wGConnection, margin);
fdlAddCreate.right = new FormAttachment(middle, -margin);
wlAddCreate.setLayoutData(fdlAddCreate);
wAddCreate = new Button(wFileName, SWT.CHECK);
wAddCreate.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.CreateTable.Tooltip"));
props.setLook(wAddCreate);
fdAddCreate = new FormData();
fdAddCreate.left = new FormAttachment(middle, 0);
fdAddCreate.top = new FormAttachment(wGConnection, margin);
fdAddCreate.right = new FormAttachment(100, 0);
wAddCreate.setLayoutData(fdAddCreate);
SelectionAdapter lsSelMod = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
ActiveTruncate();
input.setChanged();
}
};
wAddCreate.addSelectionListener(lsSelMod);
// Truncate table
wlTruncate = new Label(wFileName, SWT.RIGHT);
wlTruncate.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TruncateTable.Label"));
props.setLook(wlTruncate);
fdlTruncate = new FormData();
fdlTruncate.left = new FormAttachment(0, 0);
fdlTruncate.top = new FormAttachment(wAddCreate, margin);
fdlTruncate.right = new FormAttachment(middle, -margin);
wlTruncate.setLayoutData(fdlTruncate);
wTruncate = new Button(wFileName, SWT.CHECK);
wTruncate.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.TruncateTable.Tooltip"));
props.setLook(wTruncate);
fdTruncate = new FormData();
fdTruncate.left = new FormAttachment(middle, 0);
fdTruncate.top = new FormAttachment(wAddCreate, margin);
fdTruncate.right = new FormAttachment(100, 0);
wTruncate.setLayoutData(fdTruncate);
SelectionAdapter lsSelTMod = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wTruncate.addSelectionListener(lsSelTMod);
// Start New Line For each statement
wlStartNewLine = new Label(wFileName, SWT.RIGHT);
wlStartNewLine.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.StartNewLine.Label"));
props.setLook(wlStartNewLine);
fdlStartNewLine = new FormData();
fdlStartNewLine.left = new FormAttachment(0, 0);
fdlStartNewLine.top = new FormAttachment(wTruncate, margin);
fdlStartNewLine.right = new FormAttachment(middle, -margin);
wlStartNewLine.setLayoutData(fdlStartNewLine);
wStartNewLine = new Button(wFileName, SWT.CHECK);
wStartNewLine.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.StartNewLine.Label"));
props.setLook(wStartNewLine);
fdStartNewLine = new FormData();
fdStartNewLine.left = new FormAttachment(middle, 0);
fdStartNewLine.top = new FormAttachment(wTruncate, margin);
fdStartNewLine.right = new FormAttachment(100, 0);
wStartNewLine.setLayoutData(fdStartNewLine);
SelectionAdapter lsSelSMod = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wStartNewLine.addSelectionListener(lsSelSMod);
// Filename line
wlFilename = new Label(wFileName, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Filename.Label"));
props.setLook(wlFilename);
fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wStartNewLine, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbFilename = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wStartNewLine, 0);
wbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(transMeta, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.top = new FormAttachment(wStartNewLine, margin);
fdFilename.right = new FormAttachment(wbFilename, -margin);
wFilename.setLayoutData(fdFilename);
// Create Parent Folder
wlCreateParentFolder = new Label(wFileName, SWT.RIGHT);
wlCreateParentFolder.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.CreateParentFolder.Label"));
props.setLook(wlCreateParentFolder);
fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wFilename, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wFileName, SWT.CHECK);
wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.CreateParentFolder.Tooltip"));
props.setLook(wCreateParentFolder);
fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wFilename, margin);
fdCreateParentFolder.right = new FormAttachment(100, 0);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Open new File at Init
wlDoNotOpenNewFileInit = new Label(wFileName, SWT.RIGHT);
wlDoNotOpenNewFileInit.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.DoNotOpenNewFileInit.Label"));
props.setLook(wlDoNotOpenNewFileInit);
fdlDoNotOpenNewFileInit = new FormData();
fdlDoNotOpenNewFileInit.left = new FormAttachment(0, 0);
fdlDoNotOpenNewFileInit.top = new FormAttachment(wCreateParentFolder, margin);
fdlDoNotOpenNewFileInit.right = new FormAttachment(middle, -margin);
wlDoNotOpenNewFileInit.setLayoutData(fdlDoNotOpenNewFileInit);
wDoNotOpenNewFileInit = new Button(wFileName, SWT.CHECK);
wDoNotOpenNewFileInit.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.DoNotOpenNewFileInit.Tooltip"));
props.setLook(wDoNotOpenNewFileInit);
fdDoNotOpenNewFileInit = new FormData();
fdDoNotOpenNewFileInit.left = new FormAttachment(middle, 0);
fdDoNotOpenNewFileInit.top = new FormAttachment(wCreateParentFolder, margin);
fdDoNotOpenNewFileInit.right = new FormAttachment(100, 0);
wDoNotOpenNewFileInit.setLayoutData(fdDoNotOpenNewFileInit);
wDoNotOpenNewFileInit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Extension line
wlExtension = new Label(wFileName, SWT.RIGHT);
wlExtension.setText(BaseMessages.getString(PKG, "System.Label.Extension"));
props.setLook(wlExtension);
fdlExtension = new FormData();
fdlExtension.left = new FormAttachment(0, 0);
fdlExtension.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
fdlExtension.right = new FormAttachment(middle, -margin);
wlExtension.setLayoutData(fdlExtension);
wExtension = new TextVar(transMeta, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wExtension);
wExtension.addModifyListener(lsMod);
fdExtension = new FormData();
fdExtension.left = new FormAttachment(middle, 0);
fdExtension.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
fdExtension.right = new FormAttachment(100, -margin);
wExtension.setLayoutData(fdExtension);
// Create multi-part file?
wlAddStepnr = new Label(wFileName, SWT.RIGHT);
wlAddStepnr.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.AddStepnr.Label"));
props.setLook(wlAddStepnr);
fdlAddStepnr = new FormData();
fdlAddStepnr.left = new FormAttachment(0, 0);
fdlAddStepnr.top = new FormAttachment(wExtension, 2 * margin);
fdlAddStepnr.right = new FormAttachment(middle, -margin);
wlAddStepnr.setLayoutData(fdlAddStepnr);
wAddStepnr = new Button(wFileName, SWT.CHECK);
props.setLook(wAddStepnr);
fdAddStepnr = new FormData();
fdAddStepnr.left = new FormAttachment(middle, 0);
fdAddStepnr.top = new FormAttachment(wExtension, 2 * margin);
fdAddStepnr.right = new FormAttachment(100, 0);
wAddStepnr.setLayoutData(fdAddStepnr);
wAddStepnr.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wFileName, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.AddDate.Label"));
props.setLook(wlAddDate);
fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wAddStepnr, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wFileName, SWT.CHECK);
props.setLook(wAddDate);
fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, 0);
fdAddDate.top = new FormAttachment(wAddStepnr, margin);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddTime = new Label(wFileName, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.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(wFileName, SWT.CHECK);
props.setLook(wAddTime);
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) {
input.setChanged();
}
});
// Append to end of file?
wlAppend = new Label(wFileName, SWT.RIGHT);
wlAppend.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Append.Label"));
props.setLook(wlAppend);
fdlAppend = new FormData();
fdlAppend.left = new FormAttachment(0, 0);
fdlAppend.top = new FormAttachment(wAddTime, margin);
fdlAppend.right = new FormAttachment(middle, -margin);
wlAppend.setLayoutData(fdlAppend);
wAppend = new Button(wFileName, SWT.CHECK);
wAppend.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Append.Tooltip"));
props.setLook(wAppend);
fdAppend = new FormData();
fdAppend.left = new FormAttachment(middle, 0);
fdAppend.top = new FormAttachment(wAddTime, margin);
fdAppend.right = new FormAttachment(100, 0);
wAppend.setLayoutData(fdAppend);
wAppend.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wlSplitEvery = new Label(wFileName, SWT.RIGHT);
wlSplitEvery.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.SplitEvery.Label"));
props.setLook(wlSplitEvery);
fdlSplitEvery = new FormData();
fdlSplitEvery.left = new FormAttachment(0, 0);
fdlSplitEvery.top = new FormAttachment(wAppend, margin);
fdlSplitEvery.right = new FormAttachment(middle, -margin);
wlSplitEvery.setLayoutData(fdlSplitEvery);
wSplitEvery = new Text(wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSplitEvery);
wSplitEvery.addModifyListener(lsMod);
fdSplitEvery = new FormData();
fdSplitEvery.left = new FormAttachment(middle, 0);
fdSplitEvery.top = new FormAttachment(wAppend, margin);
fdSplitEvery.right = new FormAttachment(100, 0);
wSplitEvery.setLayoutData(fdSplitEvery);
wbShowFiles = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.ShowFiles.Button"));
fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.top = new FormAttachment(wSplitEvery, margin * 2);
wbShowFiles.setLayoutData(fdbShowFiles);
wbShowFiles.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
SQLFileOutputMeta tfoi = new SQLFileOutputMeta();
getInfo(tfoi);
String[] files = tfoi.getFiles(transMeta.environmentSubstitute(wFilename.getText()));
if (files != null && files.length > 0) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, files, BaseMessages.getString(PKG, "SQLFileOutputDialog.SelectOutputFiles.DialogTitle"), BaseMessages.getString(PKG, "SQLFileOutputDialog.SelectOutputFiles.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "SQLFileOutputDialog.NoFilesFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.DialogTitle.Error"));
mb.open();
}
}
});
// Add File to the result files name
wlAddToResult = new Label(wFileName, SWT.RIGHT);
wlAddToResult.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.AddFileToResult.Label"));
props.setLook(wlAddToResult);
fdlAddToResult = new FormData();
fdlAddToResult.left = new FormAttachment(0, 0);
fdlAddToResult.top = new FormAttachment(wbShowFiles, margin);
fdlAddToResult.right = new FormAttachment(middle, -margin);
wlAddToResult.setLayoutData(fdlAddToResult);
wAddToResult = new Button(wFileName, SWT.CHECK);
wAddToResult.setToolTipText(BaseMessages.getString(PKG, "SQLFileOutputDialog.AddFileToResult.Tooltip"));
props.setLook(wAddToResult);
fdAddToResult = new FormData();
fdAddToResult.left = new FormAttachment(middle, 0);
fdAddToResult.top = new FormAttachment(wbShowFiles, margin);
fdAddToResult.right = new FormAttachment(100, 0);
wAddToResult.setLayoutData(fdAddToResult);
SelectionAdapter lsSelR = new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wAddToResult.addSelectionListener(lsSelR);
fdFileName = new FormData();
fdFileName.left = new FormAttachment(0, margin);
fdFileName.top = new FormAttachment(wGConnection, 2 * margin);
fdFileName.right = new FormAttachment(100, -margin);
wFileName.setLayoutData(fdFileName);
// ///////////////////////////////////////////////////////////
// / END OF FileName 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(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Prepare a list of possible formats...
String[] dats = Const.getDateFormats();
// format
wlFormat = new Label(wContentComp, SWT.RIGHT);
wlFormat.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.DateFormat.Label"));
props.setLook(wlFormat);
fdlFormat = new FormData();
fdlFormat.left = new FormAttachment(0, 0);
fdlFormat.top = new FormAttachment(0, margin);
fdlFormat.right = new FormAttachment(middle, -margin);
wlFormat.setLayoutData(fdlFormat);
wFormat = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wFormat.setEditable(true);
props.setLook(wFormat);
wFormat.addModifyListener(lsMod);
fdFormat = new FormData();
fdFormat.left = new FormAttachment(middle, 0);
fdFormat.top = new FormAttachment(0, margin);
fdFormat.right = new FormAttachment(100, 0);
wFormat.setLayoutData(fdFormat);
for (int x = 0; x < dats.length; x++) {
wFormat.add(dats[x]);
}
// Encoding
wlEncoding = new Label(wContentComp, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "SQLFileOutputDialog.Encoding.Label"));
props.setLook(wlEncoding);
fdlEncoding = new FormData();
fdlEncoding.left = new FormAttachment(0, 0);
fdlEncoding.top = new FormAttachment(wFormat, margin);
fdlEncoding.right = new FormAttachment(middle, -margin);
wlEncoding.setLayoutData(fdlEncoding);
wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wEncoding.setEditable(true);
props.setLook(wEncoding);
wEncoding.addModifyListener(lsMod);
fdEncoding = new FormData();
fdEncoding.left = new FormAttachment(middle, 0);
fdEncoding.top = new FormAttachment(wFormat, margin);
fdEncoding.right = new FormAttachment(100, 0);
wEncoding.setLayoutData(fdEncoding);
wEncoding.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
setEncodings();
shell.setCursor(null);
busy.dispose();
}
});
fdContentComp = new FormData();
fdContentComp.left = new FormAttachment(0, 0);
fdContentComp.top = new FormAttachment(0, 0);
fdContentComp.right = new FormAttachment(100, 0);
fdContentComp.bottom = new FormAttachment(100, 0);
wContentComp.setLayoutData(wContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
// Some buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCreate = new Button(shell, SWT.PUSH);
wCreate.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCreate, wCancel }, margin, wTabFolder);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCreate = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCreate.addListener(SWT.Selection, lsCreate);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
wbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.txt", "*.TXT", "*" });
if (wFilename.getText() != null) {
dialog.setFileName(transMeta.environmentSubstitute(wFilename.getText()));
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String extension = wExtension.getText();
if (extension != null && dialog.getFileName() != null && dialog.getFileName().endsWith("." + extension)) {
// The extension is filled in and matches the end
// of the selected file => Strip off the extension.
String fileName = dialog.getFileName();
wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + fileName.substring(0, fileName.length() - (extension.length() + 1)));
} else {
wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
}
}
}
});
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
lsResize = new Listener() {
public void handleEvent(Event event) {
// Point size = shell.getSize();
}
};
shell.addListener(SWT.Resize, lsResize);
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
ActiveTruncate();
// backupChanged);
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations