use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.
the class CsvInputDialog 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();
ModifyListener lsContent = new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
// asyncUpdatePreview();
}
};
initializing = true;
previewBusy = new AtomicBoolean(false);
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "CsvInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "CsvInputDialog.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, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "CsvInputDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
Label wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, inputMeta.getDescription("FILENAME_FIELD")));
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, inputMeta.getDescription("INCLUDE_FILENAME")));
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, inputMeta.getDescription("FILENAME")));
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);
/*
* wFilename.addFocusListener(new FocusAdapter() {
*
* @Override public void focusLost(FocusEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wFilename;
}
// delimiter
Label wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, inputMeta.getDescription("DELIMITER")));
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, "CsvInputDialog.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);
wDelimiter.addModifyListener(lsContent);
lastControl = wDelimiter;
// enclosure
Label wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCLOSURE")));
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);
wEnclosure.addModifyListener(lsContent);
lastControl = wEnclosure;
// bufferSize
//
Label wlBufferSize = new Label(shell, SWT.RIGHT);
wlBufferSize.setText(BaseMessages.getString(PKG, inputMeta.getDescription("BUFFERSIZE")));
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, inputMeta.getDescription("LAZY_CONVERSION")));
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, inputMeta.getDescription("HEADER_PRESENT")));
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);
/*
* wHeaderPresent.addSelectionListener(new SelectionAdapter() {
*
* @Override public void widgetSelected(SelectionEvent arg0) { asyncUpdatePreview(); } });
*/
lastControl = wHeaderPresent;
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ADD_FILENAME_RESULT")));
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, inputMeta.getTooltip("ADD_FILENAME_RESULT")));
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, inputMeta.getDescription("ROW_NUM_FIELD")));
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?
//
wlRunningInParallel = new Label(shell, SWT.RIGHT);
wlRunningInParallel.setText(BaseMessages.getString(PKG, inputMeta.getDescription("PARALLEL")));
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;
// Is a new line possible in a field?
//
Label wlNewlinePossible = new Label(shell, SWT.RIGHT);
wlNewlinePossible.setText(BaseMessages.getString(PKG, inputMeta.getDescription("NEWLINE_POSSIBLE")));
props.setLook(wlNewlinePossible);
FormData fdlNewlinePossible = new FormData();
fdlNewlinePossible.top = new FormAttachment(lastControl, margin);
fdlNewlinePossible.left = new FormAttachment(0, 0);
fdlNewlinePossible.right = new FormAttachment(middle, -margin);
wlNewlinePossible.setLayoutData(fdlNewlinePossible);
wNewlinePossible = new Button(shell, SWT.CHECK);
props.setLook(wNewlinePossible);
FormData fdNewlinePossible = new FormData();
fdNewlinePossible.top = new FormAttachment(lastControl, margin);
fdNewlinePossible.left = new FormAttachment(middle, 0);
wNewlinePossible.setLayoutData(fdNewlinePossible);
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
wNewlinePossible.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
asyncUpdatePreview();
}
});
lastControl = wNewlinePossible;
// Encoding
Label wlEncoding = new Label(shell, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, inputMeta.getDescription("ENCODING")));
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);
wEncoding.addModifyListener(lsContent);
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, wGet, wPreview, wCancel }, margin, null);
// Fields
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_NAME")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TYPE")), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames(), true), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_FORMAT")), ColumnInfo.COLUMN_TYPE_FORMAT, 2), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_LENGTH")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_PRECISION")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_CURRENCY")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_DECIMAL")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_GROUP")), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, inputMeta.getDescription("FIELD_TRIM_TYPE")), 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);
wFields.setContentListener(lsContent);
// 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);
initializing = false;
// Update the preview window.
//
// asyncUpdatePreview();
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 CubeInputDialog 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, "CubeInputDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "CubeInputDialog.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);
// Filename line
wlFilename = new Label(shell, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "CubeInputDialog.Filename.Label"));
props.setLook(wlFilename);
fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wStepname, margin + 5);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "CubeInputDialog.FilenameButton.Label"));
fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wStepname, margin + 5);
wbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(transMeta, shell, 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(wStepname, margin + 5);
fdFilename.right = new FormAttachment(wbFilename, -margin);
wFilename.setLayoutData(fdFilename);
// Limit input ...
wlLimit = new Label(shell, SWT.RIGHT);
wlLimit.setText(BaseMessages.getString(PKG, "CubeInputDialog.Limit.Label"));
props.setLook(wlLimit);
fdlLimit = new FormData();
fdlLimit.left = new FormAttachment(0, 0);
fdlLimit.right = new FormAttachment(middle, -margin);
fdlLimit.top = new FormAttachment(wFilename, margin);
wlLimit.setLayoutData(fdlLimit);
wLimit = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wLimit);
wLimit.addModifyListener(lsMod);
fdLimit = new FormData();
fdLimit.left = new FormAttachment(middle, 0);
fdLimit.top = new FormAttachment(wFilename, margin);
fdLimit.right = new FormAttachment(100, 0);
wLimit.setLayoutData(fdLimit);
// Add filename to result filenames
wlAddResult = new Label(shell, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "CubeInputDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wLimit, 2 * margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(shell, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "CubeInputDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wLimit, 2 * margin);
wAddResult.setLayoutData(fdAddResult);
wAddResult.addSelectionListener(new ComponentSelectionListener(input));
// Some buttons
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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, wAddResult);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.cube", "*" });
if (wFilename.getText() != null) {
dialog.setFileName(wFilename.getText());
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "CubeInputDialog.FilterNames.CubeFiles"), BaseMessages.getString(PKG, "CubeInputDialog.FilterNames.AllFiles") });
if (dialog.open() != null) {
wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
}
}
});
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wLimit.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
input.setChanged(changed);
// Set the shell size, based upon previous time...
setSize();
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 ScriptValuesModDialog 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);
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, "ScriptValuesDialogMod.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Filename line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.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);
wSash = new SashForm(shell, SWT.VERTICAL);
// Top sash form
//
wTop = new Composite(wSash, SWT.NONE);
props.setLook(wTop);
FormLayout topLayout = new FormLayout();
topLayout.marginWidth = Const.FORM_MARGIN;
topLayout.marginHeight = Const.FORM_MARGIN;
wTop.setLayout(topLayout);
// Script line
wlScriptFunctions = new Label(wTop, SWT.NONE);
wlScriptFunctions.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.JavascriptFunctions.Label"));
props.setLook(wlScriptFunctions);
fdlScriptFunctions = new FormData();
fdlScriptFunctions.left = new FormAttachment(0, 0);
fdlScriptFunctions.top = new FormAttachment(0, 0);
wlScriptFunctions.setLayoutData(fdlScriptFunctions);
// Tree View Test
wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
props.setLook(wTree);
fdlTree = new FormData();
fdlTree.left = new FormAttachment(0, 0);
fdlTree.top = new FormAttachment(wlScriptFunctions, margin);
fdlTree.right = new FormAttachment(20, 0);
fdlTree.bottom = new FormAttachment(100, -margin);
wTree.setLayoutData(fdlTree);
// Script line
wlScript = new Label(wTop, SWT.NONE);
wlScript.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Javascript.Label"));
props.setLook(wlScript);
fdlScript = new FormData();
fdlScript.left = new FormAttachment(wTree, margin);
fdlScript.top = new FormAttachment(0, 0);
wlScript.setLayoutData(fdlScript);
folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
folder.setSimple(false);
folder.setUnselectedImageVisible(true);
folder.setUnselectedCloseVisible(true);
fdScript = new FormData();
fdScript.left = new FormAttachment(wTree, margin);
fdScript.top = new FormAttachment(wlScript, margin);
fdScript.right = new FormAttachment(100, -5);
fdScript.bottom = new FormAttachment(100, -50);
folder.setLayoutData(fdScript);
wlPosition = new Label(wTop, SWT.NONE);
wlPosition.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Position.Label"));
props.setLook(wlPosition);
fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(wTree, margin);
fdlPosition.right = new FormAttachment(30, 0);
fdlPosition.top = new FormAttachment(folder, margin);
wlPosition.setLayoutData(fdlPosition);
Label wlCompatible = new Label(wTop, SWT.NONE);
wlCompatible.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Compatible.Label"));
props.setLook(wlCompatible);
FormData fdlCompatible = new FormData();
fdlCompatible.left = new FormAttachment(wTree, margin);
fdlCompatible.right = new FormAttachment(middle, 0);
fdlCompatible.top = new FormAttachment(wlPosition, margin);
wlCompatible.setLayoutData(fdlCompatible);
wCompatible = new Button(wTop, SWT.CHECK);
wCompatible.setToolTipText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Compatible.Tooltip"));
props.setLook(wCompatible);
FormData fdCompatible = new FormData();
fdCompatible.left = new FormAttachment(wlCompatible, margin);
fdCompatible.top = new FormAttachment(wlPosition, margin);
wCompatible.setLayoutData(fdCompatible);
wCompatible.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setInputOutputFields();
input.setChanged(true);
}
});
Label wlOptimizationLevel = new Label(wTop, SWT.NONE);
wlOptimizationLevel.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OptimizationLevel.Label"));
props.setLook(wlOptimizationLevel);
FormData fdlOptimizationLevel = new FormData();
fdlOptimizationLevel.left = new FormAttachment(wCompatible, margin * 2);
fdlOptimizationLevel.top = new FormAttachment(wlPosition, margin);
wlOptimizationLevel.setLayoutData(fdlOptimizationLevel);
wOptimizationLevel = new TextVar(transMeta, wTop, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wOptimizationLevel.setToolTipText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OptimizationLevel.Tooltip"));
props.setLook(wOptimizationLevel);
FormData fdOptimizationLevel = new FormData();
fdOptimizationLevel.left = new FormAttachment(wlOptimizationLevel, margin);
fdOptimizationLevel.top = new FormAttachment(wlPosition, margin);
fdOptimizationLevel.right = new FormAttachment(100, margin);
wOptimizationLevel.setLayoutData(fdOptimizationLevel);
wOptimizationLevel.addModifyListener(lsMod);
wlHelpLabel = new Text(wTop, SWT.V_SCROLL | SWT.LEFT);
wlHelpLabel.setEditable(false);
wlHelpLabel.setText("Hallo");
props.setLook(wlHelpLabel);
fdHelpLabel = new FormData();
fdHelpLabel.left = new FormAttachment(wlPosition, margin);
fdHelpLabel.top = new FormAttachment(folder, margin);
fdHelpLabel.right = new FormAttachment(100, -5);
fdHelpLabel.bottom = new FormAttachment(100, 0);
wlHelpLabel.setLayoutData(fdHelpLabel);
wlHelpLabel.setVisible(false);
fdTop = new FormData();
fdTop.left = new FormAttachment(0, 0);
fdTop.top = new FormAttachment(0, 0);
fdTop.right = new FormAttachment(100, 0);
fdTop.bottom = new FormAttachment(100, 0);
wTop.setLayoutData(fdTop);
wBottom = new Composite(wSash, SWT.NONE);
props.setLook(wBottom);
FormLayout bottomLayout = new FormLayout();
bottomLayout.marginWidth = Const.FORM_MARGIN;
bottomLayout.marginHeight = Const.FORM_MARGIN;
wBottom.setLayout(bottomLayout);
wSeparator = new Label(wBottom, SWT.SEPARATOR | SWT.HORIZONTAL);
fdSeparator = new FormData();
fdSeparator.left = new FormAttachment(0, 0);
fdSeparator.right = new FormAttachment(100, 0);
fdSeparator.top = new FormAttachment(0, -margin + 2);
wSeparator.setLayoutData(fdSeparator);
wlFields = new Label(wBottom, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Fields.Label"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wSeparator, 0);
wlFields.setLayoutData(fdlFields);
final int FieldsRows = input.getFieldname().length;
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Filename"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.RenameTo"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ColumnInfo.Replace"), ColumnInfo.COLUMN_TYPE_CCOMBO, YES_NO_COMBO) };
wFields = new TableView(transMeta, wBottom, 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, 0);
wFields.setLayoutData(fdFields);
fdBottom = new FormData();
fdBottom.left = new FormAttachment(0, 0);
fdBottom.top = new FormAttachment(0, 0);
fdBottom.right = new FormAttachment(100, 0);
fdBottom.bottom = new FormAttachment(100, 0);
wBottom.setLayoutData(fdBottom);
fdSash = new FormData();
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wStepname, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(100, -50);
wSash.setLayoutData(fdSash);
wSash.setWeights(new int[] { 75, 25 });
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wVars = new Button(shell, SWT.PUSH);
wVars.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GetVariables.Button"));
wTest = new Button(shell, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TestScript.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wVars, wTest }, margin, null);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
// lsGet = new Listener() { public void handleEvent(Event e) { get(); } };
lsTest = new Listener() {
public void handleEvent(Event e) {
newTest();
}
};
lsVars = new Listener() {
public void handleEvent(Event e) {
test(true, true);
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsTree = new Listener() {
public void handleEvent(Event e) {
treeDblClick(e);
}
};
// lsHelp = new Listener(){public void handleEvent(Event e){ wlHelpLabel.setVisible(true); }};
wCancel.addListener(SWT.Selection, lsCancel);
// wGet.addListener (SWT.Selection, lsGet );
wTest.addListener(SWT.Selection, lsTest);
wVars.addListener(SWT.Selection, lsVars);
wOK.addListener(SWT.Selection, lsOK);
wTree.addListener(SWT.MouseDoubleClick, lsTree);
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) {
if (!cancel()) {
e.doit = false;
}
}
});
folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void close(CTabFolderEvent event) {
CTabItem cItem = (CTabItem) event.item;
event.doit = false;
if (cItem != null && folder.getItemCount() > 1) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
messageBox.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.DeleteItem.Label"));
messageBox.setMessage(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ConfirmDeleteItem.Label", cItem.getText()));
switch(messageBox.open()) {
case SWT.YES:
modifyScriptTree(cItem, DELETE_ITEM);
event.doit = true;
break;
default:
break;
}
}
}
});
cMenu = new Menu(shell, SWT.POP_UP);
buildingFolderMenu();
tMenu = new Menu(shell, SWT.POP_UP);
buildingTreeMenu();
// Adding the Default Transform Scripts Item to the Tree
wTreeScriptsItem = new TreeItem(wTree, SWT.NULL);
wTreeScriptsItem.setImage(guiresource.getImageBol());
wTreeScriptsItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.TransformScript.Label"));
// Set the shell size, based upon previous time...
setSize();
getData();
// Adding the Rest (Functions, InputItems, etc.) to the Tree
buildSpecialFunctionsTree();
// Input Fields
iteminput = new TreeItem(wTree, SWT.NULL);
iteminput.setImage(imageInputFields);
iteminput.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.InputFields.Label"));
// Output Fields
itemoutput = new TreeItem(wTree, SWT.NULL);
itemoutput.setImage(imageOutputFields);
itemoutput.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.OutputFields.Label"));
// Display waiting message for input
itemWaitFieldsIn = new TreeItem(iteminput, SWT.NULL);
itemWaitFieldsIn.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GettingFields.Label"));
itemWaitFieldsIn.setForeground(guiresource.getColorDirectory());
iteminput.setExpanded(true);
// Display waiting message for output
itemWaitFieldsOut = new TreeItem(itemoutput, SWT.NULL);
itemWaitFieldsOut.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.GettingFields.Label"));
itemWaitFieldsOut.setForeground(guiresource.getColorDirectory());
itemoutput.setExpanded(true);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
rowPrevStepFields = transMeta.getPrevStepFields(stepMeta);
if (rowPrevStepFields != null) {
setInputOutputFields();
} else {
// Can not get fields...end of wait message
iteminput.removeAll();
itemoutput.removeAll();
}
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// rebuildInputFieldsTree();
// buildOutputFieldsTree();
buildAddClassesListTree();
addRenameTowTreeScriptItems();
input.setChanged(changed);
// Create the drag source on the tree
DragSource ds = new DragSource(wTree, DND.DROP_MOVE);
ds.setTransfer(new Transfer[] { TextTransfer.getInstance() });
ds.addDragListener(new DragSourceAdapter() {
public void dragStart(DragSourceEvent event) {
TreeItem item = wTree.getSelection()[0];
// Qualifikation where the Drag Request Comes from
if (item != null && item.getParentItem() != null) {
if (item.getParentItem().equals(wTreeScriptsItem)) {
event.doit = false;
} else if (!item.getData().equals("Function")) {
String strInsert = (String) item.getData();
if (strInsert.equals("jsFunction")) {
event.doit = true;
} else {
event.doit = false;
}
} else {
event.doit = false;
}
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = wTree.getSelection()[0].getText();
}
});
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 SimpleMappingDialog 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, mappingMeta);
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
mappingMeta.setChanged();
}
};
changed = mappingMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 15;
formLayout.marginHeight = 15;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Shell.Title"));
Label wicon = new Label(shell, SWT.RIGHT);
wicon.setImage(getImage());
FormData fdlicon = new FormData();
fdlicon.top = new FormAttachment(0, 0);
fdlicon.right = new FormAttachment(100, 0);
wicon.setLayoutData(fdlicon);
props.setLook(wicon);
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.top = new FormAttachment(0, 0);
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.width = 250;
fdStepname.left = new FormAttachment(0, 0);
fdStepname.top = new FormAttachment(wlStepname, 5);
wStepname.setLayoutData(fdStepname);
Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
FormData fdSpacer = new FormData();
fdSpacer.left = new FormAttachment(0, 0);
fdSpacer.top = new FormAttachment(wStepname, 15);
fdSpacer.right = new FormAttachment(100, 0);
spacer.setLayoutData(fdSpacer);
wlPath = new Label(shell, SWT.LEFT);
props.setLook(wlPath);
wlPath.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Transformation.Label"));
FormData fdlTransformation = new FormData();
fdlTransformation.left = new FormAttachment(0, 0);
fdlTransformation.top = new FormAttachment(spacer, 20);
fdlTransformation.right = new FormAttachment(50, 0);
wlPath.setLayoutData(fdlTransformation);
wPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPath);
FormData fdTransformation = new FormData();
fdTransformation.left = new FormAttachment(0, 0);
fdTransformation.top = new FormAttachment(wlPath, 5);
fdTransformation.width = 350;
wPath.setLayoutData(fdTransformation);
wbBrowse = new Button(shell, SWT.PUSH);
props.setLook(wbBrowse);
wbBrowse.setText(BaseMessages.getString(PKG, "SimpleMappingDialog.Browse.Label"));
FormData fdBrowse = new FormData();
fdBrowse.left = new FormAttachment(wPath, 5);
fdBrowse.top = new FormAttachment(wlPath, Const.isOSX() ? 0 : 5);
wbBrowse.setLayoutData(fdBrowse);
wbBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (repository != null) {
selectRepositoryTrans();
} else {
selectFileTrans();
}
}
});
//
// Add a tab folder for the parameters and various input and output
// streams
//
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
wTabFolder.setUnselectedCloseVisible(true);
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
FormData fdCancel = new FormData();
fdCancel.right = new FormAttachment(100, 0);
fdCancel.bottom = new FormAttachment(100, 0);
wCancel.setLayoutData(fdCancel);
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
FormData fdOk = new FormData();
fdOk.right = new FormAttachment(wCancel, -5);
fdOk.bottom = new FormAttachment(100, 0);
wOK.setLayoutData(fdOk);
Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
FormData fdhSpacer = new FormData();
fdhSpacer.left = new FormAttachment(0, 0);
fdhSpacer.bottom = new FormAttachment(wCancel, -15);
fdhSpacer.right = new FormAttachment(100, 0);
hSpacer.setLayoutData(fdhSpacer);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wPath, 20);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
wTabFolder.setLayoutData(fdTabFolder);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wPath.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(shell, 670, 690);
getData();
mappingMeta.setChanged(changed);
wTabFolder.setSelection(0);
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 TextFileInputDialog method addContentTab.
private void addContentTab() {
// ////////////////////////
// START OF CONTENT TAB///
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "TextFileInputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentSComp = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
wContentSComp.setLayout(new FillLayout());
wContentComp = new Composite(wContentSComp, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Filetype line
wlFiletype = new Label(wContentComp, SWT.RIGHT);
wlFiletype.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Filetype.Label"));
props.setLook(wlFiletype);
fdlFiletype = new FormData();
fdlFiletype.left = new FormAttachment(0, 0);
fdlFiletype.top = new FormAttachment(0, 0);
fdlFiletype.right = new FormAttachment(middle, -margin);
wlFiletype.setLayoutData(fdlFiletype);
wFiletype = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wFiletype.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Filetype.Label"));
props.setLook(wFiletype);
wFiletype.add("CSV");
wFiletype.add("Fixed");
wFiletype.select(0);
wFiletype.addModifyListener(lsMod);
fdFiletype = new FormData();
fdFiletype.left = new FormAttachment(middle, 0);
fdFiletype.top = new FormAttachment(0, 0);
fdFiletype.right = new FormAttachment(100, 0);
wFiletype.setLayoutData(fdFiletype);
wlSeparator = new Label(wContentComp, SWT.RIGHT);
wlSeparator.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Separator.Label"));
props.setLook(wlSeparator);
fdlSeparator = new FormData();
fdlSeparator.left = new FormAttachment(0, 0);
fdlSeparator.top = new FormAttachment(wFiletype, margin);
fdlSeparator.right = new FormAttachment(middle, -margin);
wlSeparator.setLayoutData(fdlSeparator);
wbSeparator = new Button(wContentComp, SWT.PUSH | SWT.CENTER);
wbSeparator.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Delimiter.Button"));
props.setLook(wbSeparator);
fdbSeparator = new FormData();
fdbSeparator.right = new FormAttachment(100, 0);
fdbSeparator.top = new FormAttachment(wFiletype, 0);
wbSeparator.setLayoutData(fdbSeparator);
wSeparator = new TextVar(transMeta, wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSeparator);
wSeparator.addModifyListener(lsMod);
fdSeparator = new FormData();
fdSeparator.top = new FormAttachment(wFiletype, margin);
fdSeparator.left = new FormAttachment(middle, 0);
fdSeparator.right = new FormAttachment(wbSeparator, -margin);
wSeparator.setLayoutData(fdSeparator);
// Enclosure
wlEnclosure = new Label(wContentComp, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wSeparator, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new Text(wContentComp, 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(wSeparator, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// Allow Enclosure breaks checkbox
wlEnclBreaks = new Label(wContentComp, SWT.RIGHT);
wlEnclBreaks.setText(BaseMessages.getString(PKG, "TextFileInputDialog.EnclBreaks.Label"));
props.setLook(wlEnclBreaks);
fdlEnclBreaks = new FormData();
fdlEnclBreaks.left = new FormAttachment(0, 0);
fdlEnclBreaks.top = new FormAttachment(wEnclosure, margin);
fdlEnclBreaks.right = new FormAttachment(middle, -margin);
wlEnclBreaks.setLayoutData(fdlEnclBreaks);
wEnclBreaks = new Button(wContentComp, SWT.CHECK);
props.setLook(wEnclBreaks);
fdEnclBreaks = new FormData();
fdEnclBreaks.left = new FormAttachment(middle, 0);
fdEnclBreaks.top = new FormAttachment(wEnclosure, margin);
wEnclBreaks.setLayoutData(fdEnclBreaks);
// Disable until the logic works...
wlEnclBreaks.setEnabled(false);
wEnclBreaks.setEnabled(false);
// Escape
wlEscape = new Label(wContentComp, SWT.RIGHT);
wlEscape.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Escape.Label"));
props.setLook(wlEscape);
fdlEscape = new FormData();
fdlEscape.left = new FormAttachment(0, 0);
fdlEscape.top = new FormAttachment(wEnclBreaks, margin);
fdlEscape.right = new FormAttachment(middle, -margin);
wlEscape.setLayoutData(fdlEscape);
wEscape = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEscape);
wEscape.addModifyListener(lsMod);
fdEscape = new FormData();
fdEscape.left = new FormAttachment(middle, 0);
fdEscape.top = new FormAttachment(wEnclBreaks, margin);
fdEscape.right = new FormAttachment(100, 0);
wEscape.setLayoutData(fdEscape);
// Header checkbox
wlHeader = new Label(wContentComp, SWT.RIGHT);
wlHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Header.Label"));
props.setLook(wlHeader);
fdlHeader = new FormData();
fdlHeader.left = new FormAttachment(0, 0);
fdlHeader.top = new FormAttachment(wEscape, margin);
fdlHeader.right = new FormAttachment(middle, -margin);
wlHeader.setLayoutData(fdlHeader);
wHeader = new Button(wContentComp, SWT.CHECK);
props.setLook(wHeader);
fdHeader = new FormData();
fdHeader.left = new FormAttachment(middle, 0);
fdHeader.top = new FormAttachment(wEscape, margin);
wHeader.setLayoutData(fdHeader);
// NrHeader
wlNrHeader = new Label(wContentComp, SWT.RIGHT);
wlNrHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrHeader.Label"));
props.setLook(wlNrHeader);
fdlNrHeader = new FormData();
fdlNrHeader.left = new FormAttachment(wHeader, margin);
fdlNrHeader.top = new FormAttachment(wEscape, margin);
wlNrHeader.setLayoutData(fdlNrHeader);
wNrHeader = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNrHeader.setTextLimit(3);
props.setLook(wNrHeader);
wNrHeader.addModifyListener(lsMod);
fdNrHeader = new FormData();
fdNrHeader.left = new FormAttachment(wlNrHeader, margin);
fdNrHeader.top = new FormAttachment(wEscape, margin);
fdNrHeader.right = new FormAttachment(100, 0);
wNrHeader.setLayoutData(fdNrHeader);
wlFooter = new Label(wContentComp, SWT.RIGHT);
wlFooter.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Footer.Label"));
props.setLook(wlFooter);
fdlFooter = new FormData();
fdlFooter.left = new FormAttachment(0, 0);
fdlFooter.top = new FormAttachment(wHeader, margin);
fdlFooter.right = new FormAttachment(middle, -margin);
wlFooter.setLayoutData(fdlFooter);
wFooter = new Button(wContentComp, SWT.CHECK);
props.setLook(wFooter);
fdFooter = new FormData();
fdFooter.left = new FormAttachment(middle, 0);
fdFooter.top = new FormAttachment(wHeader, margin);
wFooter.setLayoutData(fdFooter);
// NrFooter
wlNrFooter = new Label(wContentComp, SWT.RIGHT);
wlNrFooter.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrFooter.Label"));
props.setLook(wlNrFooter);
fdlNrFooter = new FormData();
fdlNrFooter.left = new FormAttachment(wFooter, margin);
fdlNrFooter.top = new FormAttachment(wHeader, margin);
wlNrFooter.setLayoutData(fdlNrFooter);
wNrFooter = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNrFooter.setTextLimit(3);
props.setLook(wNrFooter);
wNrFooter.addModifyListener(lsMod);
fdNrFooter = new FormData();
fdNrFooter.left = new FormAttachment(wlNrFooter, margin);
fdNrFooter.top = new FormAttachment(wHeader, margin);
fdNrFooter.right = new FormAttachment(100, 0);
wNrFooter.setLayoutData(fdNrFooter);
// Wraps
wlWraps = new Label(wContentComp, SWT.RIGHT);
wlWraps.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Wraps.Label"));
props.setLook(wlWraps);
fdlWraps = new FormData();
fdlWraps.left = new FormAttachment(0, 0);
fdlWraps.top = new FormAttachment(wFooter, margin);
fdlWraps.right = new FormAttachment(middle, -margin);
wlWraps.setLayoutData(fdlWraps);
wWraps = new Button(wContentComp, SWT.CHECK);
props.setLook(wWraps);
fdWraps = new FormData();
fdWraps.left = new FormAttachment(middle, 0);
fdWraps.top = new FormAttachment(wFooter, margin);
wWraps.setLayoutData(fdWraps);
// NrWraps
wlNrWraps = new Label(wContentComp, SWT.RIGHT);
wlNrWraps.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrWraps.Label"));
props.setLook(wlNrWraps);
fdlNrWraps = new FormData();
fdlNrWraps.left = new FormAttachment(wWraps, margin);
fdlNrWraps.top = new FormAttachment(wFooter, margin);
wlNrWraps.setLayoutData(fdlNrWraps);
wNrWraps = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNrWraps.setTextLimit(3);
props.setLook(wNrWraps);
wNrWraps.addModifyListener(lsMod);
fdNrWraps = new FormData();
fdNrWraps.left = new FormAttachment(wlNrWraps, margin);
fdNrWraps.top = new FormAttachment(wFooter, margin);
fdNrWraps.right = new FormAttachment(100, 0);
wNrWraps.setLayoutData(fdNrWraps);
// Pages
wlLayoutPaged = new Label(wContentComp, SWT.RIGHT);
wlLayoutPaged.setText(BaseMessages.getString(PKG, "TextFileInputDialog.LayoutPaged.Label"));
props.setLook(wlLayoutPaged);
fdlLayoutPaged = new FormData();
fdlLayoutPaged.left = new FormAttachment(0, 0);
fdlLayoutPaged.top = new FormAttachment(wWraps, margin);
fdlLayoutPaged.right = new FormAttachment(middle, -margin);
wlLayoutPaged.setLayoutData(fdlLayoutPaged);
wLayoutPaged = new Button(wContentComp, SWT.CHECK);
props.setLook(wLayoutPaged);
fdLayoutPaged = new FormData();
fdLayoutPaged.left = new FormAttachment(middle, 0);
fdLayoutPaged.top = new FormAttachment(wWraps, margin);
wLayoutPaged.setLayoutData(fdLayoutPaged);
// Nr of lines per page
wlNrLinesPerPage = new Label(wContentComp, SWT.RIGHT);
wlNrLinesPerPage.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrLinesPerPage.Label"));
props.setLook(wlNrLinesPerPage);
fdlNrLinesPerPage = new FormData();
fdlNrLinesPerPage.left = new FormAttachment(wLayoutPaged, margin);
fdlNrLinesPerPage.top = new FormAttachment(wWraps, margin);
wlNrLinesPerPage.setLayoutData(fdlNrLinesPerPage);
wNrLinesPerPage = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNrLinesPerPage.setTextLimit(3);
props.setLook(wNrLinesPerPage);
wNrLinesPerPage.addModifyListener(lsMod);
fdNrLinesPerPage = new FormData();
fdNrLinesPerPage.left = new FormAttachment(wlNrLinesPerPage, margin);
fdNrLinesPerPage.top = new FormAttachment(wWraps, margin);
fdNrLinesPerPage.right = new FormAttachment(100, 0);
wNrLinesPerPage.setLayoutData(fdNrLinesPerPage);
// NrPages
wlNrLinesDocHeader = new Label(wContentComp, SWT.RIGHT);
wlNrLinesDocHeader.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NrLinesDocHeader.Label"));
props.setLook(wlNrLinesDocHeader);
fdlNrLinesDocHeader = new FormData();
fdlNrLinesDocHeader.left = new FormAttachment(wLayoutPaged, margin);
fdlNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);
wlNrLinesDocHeader.setLayoutData(fdlNrLinesDocHeader);
wNrLinesDocHeader = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wNrLinesDocHeader.setTextLimit(3);
props.setLook(wNrLinesDocHeader);
wNrLinesDocHeader.addModifyListener(lsMod);
fdNrLinesDocHeader = new FormData();
fdNrLinesDocHeader.left = new FormAttachment(wlNrLinesPerPage, margin);
fdNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);
fdNrLinesDocHeader.right = new FormAttachment(100, 0);
wNrLinesDocHeader.setLayoutData(fdNrLinesDocHeader);
// Compression type (None, Zip or GZip
wlCompression = new Label(wContentComp, SWT.RIGHT);
wlCompression.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Label"));
props.setLook(wlCompression);
fdlCompression = new FormData();
fdlCompression.left = new FormAttachment(0, 0);
fdlCompression.top = new FormAttachment(wNrLinesDocHeader, margin);
fdlCompression.right = new FormAttachment(middle, -margin);
wlCompression.setLayoutData(fdlCompression);
wCompression = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wCompression.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Label"));
wCompression.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.Compression.Tooltip"));
props.setLook(wCompression);
wCompression.setItems(CompressionProviderFactory.getInstance().getCompressionProviderNames());
wCompression.addModifyListener(lsMod);
fdCompression = new FormData();
fdCompression.left = new FormAttachment(middle, 0);
fdCompression.top = new FormAttachment(wNrLinesDocHeader, margin);
fdCompression.right = new FormAttachment(100, 0);
wCompression.setLayoutData(fdCompression);
wlNoempty = new Label(wContentComp, SWT.RIGHT);
wlNoempty.setText(BaseMessages.getString(PKG, "TextFileInputDialog.NoEmpty.Label"));
props.setLook(wlNoempty);
fdlNoempty = new FormData();
fdlNoempty.left = new FormAttachment(0, 0);
fdlNoempty.top = new FormAttachment(wCompression, margin);
fdlNoempty.right = new FormAttachment(middle, -margin);
wlNoempty.setLayoutData(fdlNoempty);
wNoempty = new Button(wContentComp, SWT.CHECK);
props.setLook(wNoempty);
wNoempty.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.NoEmpty.Tooltip"));
fdNoempty = new FormData();
fdNoempty.left = new FormAttachment(middle, 0);
fdNoempty.top = new FormAttachment(wCompression, margin);
fdNoempty.right = new FormAttachment(100, 0);
wNoempty.setLayoutData(fdNoempty);
wlInclFilename = new Label(wContentComp, SWT.RIGHT);
wlInclFilename.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilename.Label"));
props.setLook(wlInclFilename);
fdlInclFilename = new FormData();
fdlInclFilename.left = new FormAttachment(0, 0);
fdlInclFilename.top = new FormAttachment(wNoempty, margin);
fdlInclFilename.right = new FormAttachment(middle, -margin);
wlInclFilename.setLayoutData(fdlInclFilename);
wInclFilename = new Button(wContentComp, SWT.CHECK);
props.setLook(wInclFilename);
wInclFilename.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilename.Tooltip"));
fdInclFilename = new FormData();
fdInclFilename.left = new FormAttachment(middle, 0);
fdInclFilename.top = new FormAttachment(wNoempty, margin);
wInclFilename.setLayoutData(fdInclFilename);
wlInclFilenameField = new Label(wContentComp, SWT.LEFT);
wlInclFilenameField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclFilenameField.Label"));
props.setLook(wlInclFilenameField);
fdlInclFilenameField = new FormData();
fdlInclFilenameField.left = new FormAttachment(wInclFilename, margin);
fdlInclFilenameField.top = new FormAttachment(wNoempty, margin);
wlInclFilenameField.setLayoutData(fdlInclFilenameField);
wInclFilenameField = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wInclFilenameField);
wInclFilenameField.addModifyListener(lsMod);
fdInclFilenameField = new FormData();
fdInclFilenameField.left = new FormAttachment(wlInclFilenameField, margin);
fdInclFilenameField.top = new FormAttachment(wNoempty, margin);
fdInclFilenameField.right = new FormAttachment(100, 0);
wInclFilenameField.setLayoutData(fdInclFilenameField);
wlInclRownum = new Label(wContentComp, SWT.RIGHT);
wlInclRownum.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownum.Label"));
props.setLook(wlInclRownum);
fdlInclRownum = new FormData();
fdlInclRownum.left = new FormAttachment(0, 0);
fdlInclRownum.top = new FormAttachment(wInclFilenameField, margin);
fdlInclRownum.right = new FormAttachment(middle, -margin);
wlInclRownum.setLayoutData(fdlInclRownum);
wInclRownum = new Button(wContentComp, SWT.CHECK);
props.setLook(wInclRownum);
wInclRownum.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownum.Tooltip"));
fdRownum = new FormData();
fdRownum.left = new FormAttachment(middle, 0);
fdRownum.top = new FormAttachment(wInclFilenameField, margin);
wInclRownum.setLayoutData(fdRownum);
wlInclRownumField = new Label(wContentComp, SWT.RIGHT);
wlInclRownumField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.InclRownumField.Label"));
props.setLook(wlInclRownumField);
fdlInclRownumField = new FormData();
fdlInclRownumField.left = new FormAttachment(wInclRownum, margin);
fdlInclRownumField.top = new FormAttachment(wInclFilenameField, margin);
wlInclRownumField.setLayoutData(fdlInclRownumField);
wInclRownumField = new Text(wContentComp, 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(wInclFilenameField, margin);
fdInclRownumField.right = new FormAttachment(100, 0);
wInclRownumField.setLayoutData(fdInclRownumField);
wlRownumByFileField = new Label(wContentComp, SWT.RIGHT);
wlRownumByFileField.setText(BaseMessages.getString(PKG, "TextFileInputDialog.RownumByFile.Label"));
props.setLook(wlRownumByFileField);
fdlRownumByFile = new FormData();
fdlRownumByFile.left = new FormAttachment(wInclRownum, margin);
fdlRownumByFile.top = new FormAttachment(wInclRownumField, margin);
wlRownumByFileField.setLayoutData(fdlRownumByFile);
wRownumByFile = new Button(wContentComp, SWT.CHECK);
props.setLook(wRownumByFile);
wRownumByFile.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.RownumByFile.Tooltip"));
fdRownumByFile = new FormData();
fdRownumByFile.left = new FormAttachment(wlRownumByFileField, margin);
fdRownumByFile.top = new FormAttachment(wInclRownumField, margin);
wRownumByFile.setLayoutData(fdRownumByFile);
wlFormat = new Label(wContentComp, SWT.RIGHT);
wlFormat.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Format.Label"));
props.setLook(wlFormat);
fdlFormat = new FormData();
fdlFormat.left = new FormAttachment(0, 0);
fdlFormat.top = new FormAttachment(wRownumByFile, margin * 2);
fdlFormat.right = new FormAttachment(middle, -margin);
wlFormat.setLayoutData(fdlFormat);
wFormat = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
wFormat.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Format.Label"));
props.setLook(wFormat);
wFormat.add("DOS");
wFormat.add("Unix");
wFormat.add("mixed");
wFormat.select(0);
wFormat.addModifyListener(lsMod);
fdFormat = new FormData();
fdFormat.left = new FormAttachment(middle, 0);
fdFormat.top = new FormAttachment(wRownumByFile, margin * 2);
fdFormat.right = new FormAttachment(100, 0);
wFormat.setLayoutData(fdFormat);
wlEncoding = new Label(wContentComp, SWT.RIGHT);
wlEncoding.setText(BaseMessages.getString(PKG, "TextFileInputDialog.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();
}
});
wlLimit = new Label(wContentComp, SWT.RIGHT);
wlLimit.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Limit.Label"));
props.setLook(wlLimit);
fdlLimit = new FormData();
fdlLimit.left = new FormAttachment(0, 0);
fdlLimit.top = new FormAttachment(wEncoding, margin);
fdlLimit.right = new FormAttachment(middle, -margin);
wlLimit.setLayoutData(fdlLimit);
wLimit = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wLimit);
wLimit.addModifyListener(lsMod);
fdLimit = new FormData();
fdLimit.left = new FormAttachment(middle, 0);
fdLimit.top = new FormAttachment(wEncoding, margin);
fdLimit.right = new FormAttachment(100, 0);
wLimit.setLayoutData(fdLimit);
// Date Lenient checkbox
wlDateLenient = new Label(wContentComp, SWT.RIGHT);
wlDateLenient.setText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLenient.Label"));
props.setLook(wlDateLenient);
fdlDateLenient = new FormData();
fdlDateLenient.left = new FormAttachment(0, 0);
fdlDateLenient.top = new FormAttachment(wLimit, margin);
fdlDateLenient.right = new FormAttachment(middle, -margin);
wlDateLenient.setLayoutData(fdlDateLenient);
wDateLenient = new Button(wContentComp, SWT.CHECK);
wDateLenient.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLenient.Tooltip"));
props.setLook(wDateLenient);
fdDateLenient = new FormData();
fdDateLenient.left = new FormAttachment(middle, 0);
fdDateLenient.top = new FormAttachment(wLimit, margin);
wDateLenient.setLayoutData(fdDateLenient);
wlDateLocale = new Label(wContentComp, SWT.RIGHT);
wlDateLocale.setText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLocale.Label"));
props.setLook(wlDateLocale);
fdlDateLocale = new FormData();
fdlDateLocale.left = new FormAttachment(0, 0);
fdlDateLocale.top = new FormAttachment(wDateLenient, margin);
fdlDateLocale.right = new FormAttachment(middle, -margin);
wlDateLocale.setLayoutData(fdlDateLocale);
wDateLocale = new CCombo(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wDateLocale.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.DateLocale.Tooltip"));
props.setLook(wDateLocale);
wDateLocale.addModifyListener(lsMod);
fdDateLocale = new FormData();
fdDateLocale.left = new FormAttachment(middle, 0);
fdDateLocale.top = new FormAttachment(wDateLenient, margin);
fdDateLocale.right = new FormAttachment(100, 0);
wDateLocale.setLayoutData(fdDateLocale);
wDateLocale.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);
setLocales();
shell.setCursor(null);
busy.dispose();
}
});
// ///////////////////////////////
// START OF AddFileResult GROUP //
// ///////////////////////////////
wAddFileResult = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wAddFileResult);
wAddFileResult.setText(BaseMessages.getString(PKG, "TextFileInputDialog.wAddFileResult.Label"));
FormLayout AddFileResultgroupLayout = new FormLayout();
AddFileResultgroupLayout.marginWidth = 10;
AddFileResultgroupLayout.marginHeight = 10;
wAddFileResult.setLayout(AddFileResultgroupLayout);
wlAddResult = new Label(wAddFileResult, SWT.RIGHT);
wlAddResult.setText(BaseMessages.getString(PKG, "TextFileInputDialog.AddResult.Label"));
props.setLook(wlAddResult);
fdlAddResult = new FormData();
fdlAddResult.left = new FormAttachment(0, 0);
fdlAddResult.top = new FormAttachment(wDateLocale, margin);
fdlAddResult.right = new FormAttachment(middle, -margin);
wlAddResult.setLayoutData(fdlAddResult);
wAddResult = new Button(wAddFileResult, SWT.CHECK);
props.setLook(wAddResult);
wAddResult.setToolTipText(BaseMessages.getString(PKG, "TextFileInputDialog.AddResult.Tooltip"));
fdAddResult = new FormData();
fdAddResult.left = new FormAttachment(middle, 0);
fdAddResult.top = new FormAttachment(wDateLocale, margin);
wAddResult.setLayoutData(fdAddResult);
fdAddFileResult = new FormData();
fdAddFileResult.left = new FormAttachment(0, margin);
fdAddFileResult.top = new FormAttachment(wDateLocale, margin);
fdAddFileResult.right = new FormAttachment(100, -margin);
wAddFileResult.setLayoutData(fdAddFileResult);
// ///////////////////////////////////////////////////////////
// / END OF AddFileResult GROUP
// ///////////////////////////////////////////////////////////
wContentComp.pack();
// What's the size:
Rectangle bounds = wContentComp.getBounds();
wContentSComp.setContent(wContentComp);
wContentSComp.setExpandHorizontal(true);
wContentSComp.setExpandVertical(true);
wContentSComp.setMinWidth(bounds.width);
wContentSComp.setMinHeight(bounds.height);
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(fdContentComp);
wContentTab.setControl(wContentSComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
}
Aggregations