use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class NormaliserDialog 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, "NormaliserDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "NormaliserDialog.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
wlTypefield = new Label(shell, SWT.RIGHT);
wlTypefield.setText(BaseMessages.getString(PKG, "NormaliserDialog.TypeField.Label"));
props.setLook(wlTypefield);
fdlTypefield = new FormData();
fdlTypefield.left = new FormAttachment(0, 0);
fdlTypefield.right = new FormAttachment(middle, -margin);
fdlTypefield.top = new FormAttachment(wStepname, margin);
wlTypefield.setLayoutData(fdlTypefield);
wTypefield = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTypefield.setText("");
props.setLook(wTypefield);
wTypefield.addModifyListener(lsMod);
fdTypefield = new FormData();
fdTypefield.left = new FormAttachment(middle, 0);
fdTypefield.top = new FormAttachment(wStepname, margin);
fdTypefield.right = new FormAttachment(100, 0);
wTypefield.setLayoutData(fdTypefield);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "NormaliserDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wTypefield, margin);
wlFields.setLayoutData(fdlFields);
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, "NormaliserDialog.GetFields.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wGet }, margin, null);
final int fieldsCols = 3;
final int fieldsRows = input.getNormaliserFields().length;
colinf = new ColumnInfo[fieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Fieldname"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[2] = new ColumnInfo(BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.NewField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
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() {
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() {
public void handleEvent(Event e) {
ok();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGet.addListener(SWT.Selection, lsGet);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.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();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.ColumnInfo in project pentaho-kettle by pentaho.
the class NullIfDialog 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, "NullIfDialog.Shell.Label"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "NullIfDialog.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);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "NullIfDialog.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wStepname, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsCols = 2;
final int fieldsRows = input.getFields().length;
colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.Name"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.ValueToNull"), ColumnInfo.COLUMN_TYPE_TEXT, false);
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(100, -50);
wFields.setLayoutData(fdFields);
//
// 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(), Integer.valueOf(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Some buttons
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, wFields);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsGet = new Listener() {
public void handleEvent(Event e) {
get();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wGet.addListener(SWT.Selection, lsGet);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.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.ColumnInfo 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.ColumnInfo in project pentaho-kettle by pentaho.
the class PentahoReportingOutputDialog 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();
}
};
SelectionListener selMod = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent 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, "PentahoReportingOutputDialog.Shell.Text"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.top = new FormAttachment(0, margin);
fdlStepname.right = new FormAttachment(middle, -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);
// input file line (report definition)
wlInput = new Label(shell, SWT.RIGHT);
wlInput.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.InputFilename.Label"));
props.setLook(wlInput);
FormData fdlInput = new FormData();
fdlInput.left = new FormAttachment(0, 0);
fdlInput.top = new FormAttachment(wStepname, margin + 5);
fdlInput.right = new FormAttachment(middle, -margin);
wlInput.setLayoutData(fdlInput);
wInput = new Combo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wInput);
wInput.addModifyListener(lsMod);
FormData fdInput = new FormData();
fdInput.left = new FormAttachment(middle, 0);
fdInput.top = new FormAttachment(wStepname, margin + 5);
fdInput.right = new FormAttachment(100, 0);
wInput.setLayoutData(fdInput);
String[] fieldNames = new String[] {};
try {
fieldNames = Const.sortStrings(transMeta.getPrevStepFields(stepMeta).getFieldNames());
} catch (KettleException e) {
log.logError("Unexpected error getting fields from previous steps...", e);
}
wInput.setItems(fieldNames);
// output file line
wlOutput = new Label(shell, SWT.RIGHT);
wlOutput.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.OutputFilename.Label"));
props.setLook(wlOutput);
FormData fdlOutput = new FormData();
fdlOutput.left = new FormAttachment(0, 0);
fdlOutput.top = new FormAttachment(wInput, margin + 5);
fdlOutput.right = new FormAttachment(middle, -margin);
wlOutput.setLayoutData(fdlOutput);
wOutput = new Combo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wOutput);
wOutput.addModifyListener(lsMod);
FormData fdOutput = new FormData();
fdOutput.left = new FormAttachment(middle, 0);
fdOutput.top = new FormAttachment(wInput, margin + 5);
fdOutput.right = new FormAttachment(100, 0);
wOutput.setLayoutData(fdOutput);
wOutput.setItems(fieldNames);
// ParentFolder
wlParentFolder = new Label(shell, SWT.RIGHT);
wlParentFolder.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.ParentFolder.Label"));
props.setLook(wlParentFolder);
FormData fdlParentFolder = new FormData();
fdlParentFolder.left = new FormAttachment(10, 10);
fdlParentFolder.top = new FormAttachment(wlOutput, margin + 15);
fdlParentFolder.right = new FormAttachment(middle, -margin);
wlParentFolder.setLayoutData(fdlParentFolder);
wParentFolder = new Button(shell, SWT.CHECK);
props.setLook(wParentFolder);
wParentFolder.addSelectionListener(selMod);
FormData fdParentFolder = new FormData();
fdParentFolder.left = new FormAttachment(middle, 10);
fdParentFolder.top = new FormAttachment(wlOutput, margin + 15);
fdParentFolder.right = new FormAttachment(100, 10);
wParentFolder.setLayoutData(fdParentFolder);
wParentFolder.setSelection(input.getCreateParentfolder());
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PentahoReportingOutput.Column.ParameterName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "PentahoReportingOutput.Column.FieldName"), ColumnInfo.COLUMN_TYPE_CCOMBO, fieldNames, true) };
wFields = new TableView(transMeta, shell, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, colinf, 1, lsMod, props);
FormData fdFields = new FormData();
fdFields.top = new FormAttachment(wParentFolder, margin * 2);
fdFields.bottom = new FormAttachment(wParentFolder, 250);
fdFields.left = new FormAttachment(0, 0);
fdFields.right = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
// output types
//
wlProcessor = new Label(shell, SWT.RIGHT);
wlProcessor.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.Processor.Label"));
props.setLook(wlProcessor);
FormData fdlProcessor = new FormData();
fdlProcessor.left = new FormAttachment(0, 0);
fdlProcessor.top = new FormAttachment(wFields, margin + 5);
fdlProcessor.right = new FormAttachment(middle, -margin);
wlProcessor.setLayoutData(fdlProcessor);
wProcessor = new List(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wProcessor);
FormData fdProcessor = new FormData();
fdProcessor.left = new FormAttachment(middle, 0);
fdProcessor.top = new FormAttachment(wFields, margin + 5);
fdProcessor.right = new FormAttachment(100, 0);
wProcessor.setLayoutData(fdProcessor);
wProcessor.setItems(ProcessorType.getDescriptions());
wProcessor.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
input.setChanged();
}
});
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString("System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString("System.Button.Cancel"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "PentahoReportingOutputDialog.Button.GetParameters"));
setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, wProcessor);
// Add listeners
wOK.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
ok();
}
});
wCancel.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
cancel();
}
});
wGet.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
get();
}
});
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wInput.addSelectionListener(lsDef);
wOutput.addSelectionListener(lsDef);
wParentFolder.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
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.ColumnInfo 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;
}
Aggregations