use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class RandomValueDialog 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, "RandomValueDialog.DialogTitle"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "RandomValueDialog.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.getFieldName().length;
final String[] functionDesc = new String[RandomValueMeta.functions.length - 1];
for (int i = 1; i < RandomValueMeta.functions.length; i++) {
functionDesc[i - 1] = RandomValueMeta.functions[i].getDescription();
}
ColumnInfo[] colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "RandomValueDialog.NameColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "RandomValueDialog.TypeColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[1].setSelectionAdapter(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, functionDesc, BaseMessages.getString(PKG, "RandomValueDialog.SelectInfoType.DialogTitle"), BaseMessages.getString(PKG, "RandomValueDialog.SelectInfoType.DialogMessage"));
String string = esd.open();
if (string != null) {
TableView tv = (TableView) e.widget;
tv.setText(string, e.x, e.y);
input.setChanged();
}
}
});
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);
// 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, wFields);
// 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);
// 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.TableView in project pentaho-kettle by pentaho.
the class RegexEvalDialog 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();
}
};
SelectionListener lsSel = new SelectionAdapter() {
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, "RegexEvalDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Filename line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "RegexEvalDialog.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);
wTabFolder = new CTabFolder(wSash, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.GeneralTab.TabTitle"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Step Settings grouping?
// ////////////////////////
// START OF Step Settings GROUP
//
wStepSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wStepSettings);
wStepSettings.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Group.StepSettings.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wStepSettings.setLayout(groupLayout);
// fieldevaluate
wlfieldevaluate = new Label(wStepSettings, SWT.RIGHT);
wlfieldevaluate.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Matcher.Label"));
props.setLook(wlfieldevaluate);
fdlfieldevaluate = new FormData();
fdlfieldevaluate.left = new FormAttachment(0, 0);
fdlfieldevaluate.top = new FormAttachment(wStepname, margin);
fdlfieldevaluate.right = new FormAttachment(middle, -margin);
wlfieldevaluate.setLayoutData(fdlfieldevaluate);
wfieldevaluate = new CCombo(wStepSettings, SWT.BORDER | SWT.READ_ONLY);
wfieldevaluate.setEditable(true);
props.setLook(wfieldevaluate);
wfieldevaluate.addModifyListener(lsMod);
fdfieldevaluate = new FormData();
fdfieldevaluate.left = new FormAttachment(middle, margin);
fdfieldevaluate.top = new FormAttachment(wStepname, margin);
fdfieldevaluate.right = new FormAttachment(100, -margin);
wfieldevaluate.setLayoutData(fdfieldevaluate);
wfieldevaluate.addSelectionListener(lsSel);
wfieldevaluate.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);
getPreviousFields();
shell.setCursor(null);
busy.dispose();
}
});
// Output Fieldame
wResultField = new LabelTextVar(transMeta, wStepSettings, BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Label"), BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Tooltip"));
props.setLook(wResultField);
wResultField.addModifyListener(lsMod);
fdResultField = new FormData();
fdResultField.left = new FormAttachment(0, 0);
fdResultField.top = new FormAttachment(wfieldevaluate, margin);
fdResultField.right = new FormAttachment(100, 0);
wResultField.setLayoutData(fdResultField);
// Allow capture groups?
wlAllowCaptureGroups = new Label(wStepSettings, SWT.RIGHT);
wlAllowCaptureGroups.setText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Label"));
props.setLook(wlAllowCaptureGroups);
FormData fdlAllowCaptureGroups = new FormData();
fdlAllowCaptureGroups.left = new FormAttachment(0, 0);
fdlAllowCaptureGroups.top = new FormAttachment(wResultField, margin);
fdlAllowCaptureGroups.right = new FormAttachment(middle, -margin);
wlAllowCaptureGroups.setLayoutData(fdlAllowCaptureGroups);
wAllowCaptureGroups = new Button(wStepSettings, SWT.CHECK);
wAllowCaptureGroups.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Tooltip"));
props.setLook(wAllowCaptureGroups);
FormData fdAllowCaptureGroups = new FormData();
fdAllowCaptureGroups.left = new FormAttachment(middle, margin);
fdAllowCaptureGroups.top = new FormAttachment(wResultField, margin);
fdAllowCaptureGroups.right = new FormAttachment(100, 0);
wAllowCaptureGroups.setLayoutData(fdAllowCaptureGroups);
wAllowCaptureGroups.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setFieldsEnabledStatus();
input.setChanged();
}
});
// Replace fields?
wlReplaceFields = new Label(wStepSettings, SWT.RIGHT);
wlReplaceFields.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Label"));
props.setLook(wlReplaceFields);
FormData fdlReplaceFields = new FormData();
fdlReplaceFields.left = new FormAttachment(0, 0);
fdlReplaceFields.top = new FormAttachment(wAllowCaptureGroups, margin);
fdlReplaceFields.right = new FormAttachment(middle, -margin);
wlReplaceFields.setLayoutData(fdlReplaceFields);
wReplaceFields = new Button(wStepSettings, SWT.CHECK);
wReplaceFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Tooltip"));
props.setLook(wReplaceFields);
FormData fdReplaceFields = new FormData();
fdReplaceFields.left = new FormAttachment(middle, margin);
fdReplaceFields.top = new FormAttachment(wAllowCaptureGroups, margin);
fdReplaceFields.right = new FormAttachment(100, 0);
wReplaceFields.setLayoutData(fdReplaceFields);
wReplaceFields.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// settings layout
fdStepSettings = new FormData();
fdStepSettings.left = new FormAttachment(0, margin);
fdStepSettings.top = new FormAttachment(wStepname, margin);
fdStepSettings.right = new FormAttachment(100, -margin);
wStepSettings.setLayoutData(fdStepSettings);
// ///////////////////////////////////////////////////////////
// / END OF STEP SETTINGS GROUP
// ///////////////////////////////////////////////////////////
// Script line
wlScript = new Label(wGeneralComp, SWT.NONE);
wlScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Javascript.Label"));
props.setLook(wlScript);
fdlScript = new FormData();
fdlScript.left = new FormAttachment(0, 0);
fdlScript.top = new FormAttachment(wStepSettings, margin);
wlScript.setLayoutData(fdlScript);
wbTestRegExScript = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbTestRegExScript);
wbTestRegExScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.TestScript.Label"));
fdbTestRegExScript = new FormData();
fdbTestRegExScript.right = new FormAttachment(100, -margin);
fdbTestRegExScript.top = new FormAttachment(wStepSettings, margin);
wbTestRegExScript.setLayoutData(fdbTestRegExScript);
wScript = new StyledTextComp(transMeta, wGeneralComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
wScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Script.Label"));
props.setLook(wScript, Props.WIDGET_STYLE_FIXED);
wScript.addModifyListener(lsMod);
fdScript = new FormData();
fdScript.left = new FormAttachment(0, 0);
fdScript.top = new FormAttachment(wbTestRegExScript, margin);
fdScript.right = new FormAttachment(100, -10);
fdScript.bottom = new FormAttachment(100, -25);
wScript.setLayoutData(fdScript);
// SelectionAdapter lsVar = VariableButtonListenerFactory.getSelectionAdapter(shell, wScript);
// wScript.addKeyListener(TextVar.getControlSpaceKeyListener(wScript, lsVar));
// Variable substitution?
wlUseVar = new Label(wGeneralComp, SWT.NONE);
wlUseVar.setText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Label"));
props.setLook(wlUseVar);
FormData fdlUseVar = new FormData();
fdlUseVar.left = new FormAttachment(0, margin);
fdlUseVar.top = new FormAttachment(wScript, margin);
wlUseVar.setLayoutData(fdlUseVar);
wUseVar = new Button(wGeneralComp, SWT.CHECK);
wUseVar.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Tooltip"));
props.setLook(wUseVar);
FormData fdUseVar = new FormData();
fdUseVar.left = new FormAttachment(wlUseVar, margin);
fdUseVar.top = new FormAttachment(wScript, margin);
wUseVar.setLayoutData(fdUseVar);
wUseVar.addSelectionListener(lsSel);
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, "RegexEvalDialog.Fields.Label"));
wlFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Fields.Tooltip"));
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[] columnInfo = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.NewField"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Format"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Group"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Decimal"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Currency"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Nullif"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.IfNull"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.TrimType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc, true) };
wFields = new TableView(transMeta, wBottom, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columnInfo, 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);
fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Step RegexSettings grouping?
// ////////////////////////
// START OF RegexSettings GROUP
//
wRegexSettings = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wRegexSettings);
wRegexSettings.setText("Regex Settings");
FormLayout regexLayout = new FormLayout();
regexLayout.marginWidth = 10;
regexLayout.marginHeight = 10;
wRegexSettings.setLayout(regexLayout);
// Canon_Eq?
wlCanonEq = new Label(wRegexSettings, SWT.RIGHT);
wlCanonEq.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Label"));
props.setLook(wlCanonEq);
FormData fdlCanonEq = new FormData();
fdlCanonEq.left = new FormAttachment(0, 0);
fdlCanonEq.top = new FormAttachment(wStepSettings, margin);
fdlCanonEq.right = new FormAttachment(middle, -margin);
wlCanonEq.setLayoutData(fdlCanonEq);
wCanonEq = new Button(wRegexSettings, SWT.CHECK);
wCanonEq.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Tooltip"));
props.setLook(wCanonEq);
FormData fdCanonEq = new FormData();
fdCanonEq.left = new FormAttachment(middle, 0);
fdCanonEq.top = new FormAttachment(wStepSettings, margin);
fdCanonEq.right = new FormAttachment(100, 0);
wCanonEq.setLayoutData(fdCanonEq);
wCanonEq.addSelectionListener(lsSel);
// CASE_INSENSITIVE?
wlCaseInsensitive = new Label(wRegexSettings, SWT.RIGHT);
wlCaseInsensitive.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Label"));
props.setLook(wlCaseInsensitive);
FormData fdlCaseInsensitive = new FormData();
fdlCaseInsensitive.left = new FormAttachment(0, 0);
fdlCaseInsensitive.top = new FormAttachment(wCanonEq, margin);
fdlCaseInsensitive.right = new FormAttachment(middle, -margin);
wlCaseInsensitive.setLayoutData(fdlCaseInsensitive);
wCaseInsensitive = new Button(wRegexSettings, SWT.CHECK);
wCaseInsensitive.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Tooltip"));
props.setLook(wCaseInsensitive);
FormData fdCaseInsensitive = new FormData();
fdCaseInsensitive.left = new FormAttachment(middle, 0);
fdCaseInsensitive.top = new FormAttachment(wCanonEq, margin);
fdCaseInsensitive.right = new FormAttachment(100, 0);
wCaseInsensitive.setLayoutData(fdCaseInsensitive);
wCaseInsensitive.addSelectionListener(lsSel);
// COMMENT?
wlComment = new Label(wRegexSettings, SWT.RIGHT);
wlComment.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Label"));
props.setLook(wlComment);
FormData fdlComment = new FormData();
fdlComment.left = new FormAttachment(0, 0);
fdlComment.top = new FormAttachment(wCaseInsensitive, margin);
fdlComment.right = new FormAttachment(middle, -margin);
wlComment.setLayoutData(fdlComment);
wComment = new Button(wRegexSettings, SWT.CHECK);
wComment.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Tooltip"));
props.setLook(wComment);
FormData fdComment = new FormData();
fdComment.left = new FormAttachment(middle, 0);
fdComment.top = new FormAttachment(wCaseInsensitive, margin);
fdComment.right = new FormAttachment(100, 0);
wComment.setLayoutData(fdComment);
wComment.addSelectionListener(lsSel);
// DOTALL?
wlDotAll = new Label(wRegexSettings, SWT.RIGHT);
wlDotAll.setText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Label"));
props.setLook(wlDotAll);
FormData fdlDotAll = new FormData();
fdlDotAll.left = new FormAttachment(0, 0);
fdlDotAll.top = new FormAttachment(wComment, margin);
fdlDotAll.right = new FormAttachment(middle, -margin);
wlDotAll.setLayoutData(fdlDotAll);
wDotAll = new Button(wRegexSettings, SWT.CHECK);
wDotAll.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Tooltip"));
props.setLook(wDotAll);
FormData fdDotAll = new FormData();
fdDotAll.left = new FormAttachment(middle, 0);
fdDotAll.top = new FormAttachment(wComment, margin);
fdDotAll.right = new FormAttachment(100, 0);
wDotAll.setLayoutData(fdDotAll);
wDotAll.addSelectionListener(lsSel);
// MULTILINE?
wlMultiline = new Label(wRegexSettings, SWT.RIGHT);
wlMultiline.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Label"));
props.setLook(wlMultiline);
FormData fdlMultiline = new FormData();
fdlMultiline.left = new FormAttachment(0, 0);
fdlMultiline.top = new FormAttachment(wDotAll, margin);
fdlMultiline.right = new FormAttachment(middle, -margin);
wlMultiline.setLayoutData(fdlMultiline);
wMultiline = new Button(wRegexSettings, SWT.CHECK);
wMultiline.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Tooltip"));
props.setLook(wMultiline);
FormData fdMultiline = new FormData();
fdMultiline.left = new FormAttachment(middle, 0);
fdMultiline.top = new FormAttachment(wDotAll, margin);
fdMultiline.right = new FormAttachment(100, 0);
wMultiline.setLayoutData(fdMultiline);
wMultiline.addSelectionListener(lsSel);
// UNICODE?
wlUnicode = new Label(wRegexSettings, SWT.RIGHT);
wlUnicode.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Label"));
props.setLook(wlUnicode);
FormData fdlUnicode = new FormData();
fdlUnicode.left = new FormAttachment(0, 0);
fdlUnicode.top = new FormAttachment(wMultiline, margin);
fdlUnicode.right = new FormAttachment(middle, -margin);
wlUnicode.setLayoutData(fdlUnicode);
wUnicode = new Button(wRegexSettings, SWT.CHECK);
wUnicode.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Tooltip"));
props.setLook(wUnicode);
FormData fdUnicode = new FormData();
fdUnicode.left = new FormAttachment(middle, 0);
fdUnicode.top = new FormAttachment(wMultiline, margin);
fdUnicode.right = new FormAttachment(100, 0);
wUnicode.setLayoutData(fdUnicode);
wUnicode.addSelectionListener(lsSel);
// UNIX?
wlUnix = new Label(wRegexSettings, SWT.RIGHT);
wlUnix.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Label"));
props.setLook(wlUnix);
FormData fdlUnix = new FormData();
fdlUnix.left = new FormAttachment(0, 0);
fdlUnix.top = new FormAttachment(wUnicode, margin);
fdlUnix.right = new FormAttachment(middle, -margin);
wlUnix.setLayoutData(fdlUnix);
wUnix = new Button(wRegexSettings, SWT.CHECK);
wUnix.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Tooltip"));
props.setLook(wUnix);
FormData fdUnix = new FormData();
fdUnix.left = new FormAttachment(middle, 0);
fdUnix.top = new FormAttachment(wUnicode, margin);
fdUnix.right = new FormAttachment(100, 0);
wUnix.setLayoutData(fdUnix);
wUnix.addSelectionListener(lsSel);
fdRegexSettings = new FormData();
fdRegexSettings.left = new FormAttachment(0, margin);
fdRegexSettings.top = new FormAttachment(wStepSettings, margin);
fdRegexSettings.right = new FormAttachment(100, -margin);
wRegexSettings.setLayoutData(fdRegexSettings);
// ///////////////////////////////////////////////////////////
// / END OF RegexSettings GROUP
// ///////////////////////////////////////////////////////////
fdContentComp = new FormData();
fdContentComp.left = new FormAttachment(0, 0);
fdContentComp.top = new FormAttachment(0, 0);
fdContentComp.right = new FormAttachment(100, 0);
fdContentComp.bottom = new FormAttachment(100, 0);
wContentComp.setLayoutData(wContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
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[] { 60, 40 });
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"));
lsbTestRegExScript = new Listener() {
public void handleEvent(Event e) {
testRegExScript();
}
};
wbTestRegExScript.addListener(SWT.Selection, lsbTestRegExScript);
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// 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);
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
setFieldsEnabledStatus();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class ReplaceStringDialog 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, "ReplaceStringDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ReplaceStringDialog.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);
wlKey = new Label(shell, SWT.NONE);
wlKey.setText(BaseMessages.getString(PKG, "ReplaceStringDialog.Fields.Label"));
props.setLook(wlKey);
fdlKey = new FormData();
fdlKey.left = new FormAttachment(0, 0);
fdlKey.top = new FormAttachment(wStepname, 2 * margin);
wlKey.setLayoutData(fdlKey);
int nrFieldCols = 10;
int nrFieldRows = (input.getFieldInStream() != null ? input.getFieldInStream().length : 1);
ciKey = new ColumnInfo[nrFieldCols];
ciKey[0] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.InStreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[1] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.OutStreamField"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[2] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.useRegEx"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.flagDescriptor);
ciKey[3] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.Replace"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[4] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.By"), ColumnInfo.COLUMN_TYPE_TEXT, false);
ciKey[5] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.SetEmptyString"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.flagDescriptor);
ciKey[6] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.FieldReplaceBy"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciKey[7] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.WholeWord"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.flagDescriptor);
ciKey[8] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.CaseSensitive"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.flagDescriptor);
ciKey[9] = new ColumnInfo(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.IsUnicode"), ColumnInfo.COLUMN_TYPE_CCOMBO, ReplaceStringMeta.flagDescriptor);
ciKey[1].setToolTip(BaseMessages.getString(PKG, "ReplaceStringDialog.ColumnInfo.OutStreamField.Tooltip"));
ciKey[1].setUsingVariables(true);
ciKey[3].setUsingVariables(true);
ciKey[4].setUsingVariables(true);
wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, nrFieldRows, lsMod, props);
fdKey = new FormData();
fdKey.left = new FormAttachment(0, 0);
fdKey.top = new FormAttachment(wlKey, margin);
fdKey.right = new FormAttachment(100, -margin);
fdKey.bottom = new FormAttachment(100, -30);
wFields.setLayoutData(fdKey);
//
// 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(), new Integer(i));
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "ReplaceString.Error.CanNotGetFields"));
}
}
}
};
new Thread(runnable).start();
// THE 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"));
wGet = new Button(shell, SWT.PUSH);
wGet.setText(BaseMessages.getString(PKG, "ReplaceStringDialog.GetFields.Button"));
fdGet = new FormData();
fdGet.right = new FormAttachment(100, 0);
fdGet.top = new FormAttachment(wStepname, 3 * middle);
wGet.setLayoutData(fdGet);
setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, null);
// 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();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class PGBulkLoaderDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
FocusListener lsFocusLost = new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
setTableFieldCombo();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
// Connection line
wConnection = addConnectionLine(shell, wStepname, middle, margin);
if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
// Schema line...
wlSchema = new Label(shell, SWT.RIGHT);
wlSchema.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetSchema.Label"));
props.setLook(wlSchema);
fdlSchema = new FormData();
fdlSchema.left = new FormAttachment(0, 0);
fdlSchema.right = new FormAttachment(middle, -margin);
fdlSchema.top = new FormAttachment(wConnection, margin * 2);
wlSchema.setLayoutData(fdlSchema);
wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchema);
wSchema.addModifyListener(lsMod);
wSchema.addFocusListener(lsFocusLost);
fdSchema = new FormData();
fdSchema.left = new FormAttachment(middle, 0);
fdSchema.top = new FormAttachment(wConnection, margin * 2);
fdSchema.right = new FormAttachment(100, 0);
wSchema.setLayoutData(fdSchema);
// Table line...
wlTable = new Label(shell, SWT.RIGHT);
wlTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TargetTable.Label"));
props.setLook(wlTable);
fdlTable = new FormData();
fdlTable.left = new FormAttachment(0, 0);
fdlTable.right = new FormAttachment(middle, -margin);
fdlTable.top = new FormAttachment(wSchema, margin);
wlTable.setLayoutData(fdlTable);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Browse.Button"));
fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchema, margin);
wbTable.setLayoutData(fdbTable);
wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTable);
wTable.addModifyListener(lsMod);
wTable.addFocusListener(lsFocusLost);
fdTable = new FormData();
fdTable.left = new FormAttachment(middle, 0);
fdTable.top = new FormAttachment(wSchema, margin);
fdTable.right = new FormAttachment(wbTable, -margin);
wTable.setLayoutData(fdTable);
// Load Action line
wlLoadAction = new Label(shell, SWT.RIGHT);
wlLoadAction.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.LoadAction.Label"));
props.setLook(wlLoadAction);
fdlLoadAction = new FormData();
fdlLoadAction.left = new FormAttachment(0, 0);
fdlLoadAction.right = new FormAttachment(middle, -margin);
fdlLoadAction.top = new FormAttachment(wTable, margin);
wlLoadAction.setLayoutData(fdlLoadAction);
wLoadAction = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.InsertLoadAction.Label"));
wLoadAction.add(BaseMessages.getString(PKG, "PGBulkLoaderDialog.TruncateLoadAction.Label"));
// +1: starts at -1
wLoadAction.select(0);
wLoadAction.addModifyListener(lsMod);
props.setLook(wLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wTable, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
fdLoadAction = new FormData();
fdLoadAction.left = new FormAttachment(middle, 0);
fdLoadAction.top = new FormAttachment(wTable, margin);
fdLoadAction.right = new FormAttachment(100, 0);
wLoadAction.setLayoutData(fdLoadAction);
// Db Name Override line
wlDbNameOverride = new Label(shell, SWT.RIGHT);
wlDbNameOverride.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.DbNameOverride.Label"));
props.setLook(wlDbNameOverride);
fdlDbNameOverride = new FormData();
fdlDbNameOverride.left = new FormAttachment(0, 0);
fdlDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdlDbNameOverride.right = new FormAttachment(middle, -margin);
wlDbNameOverride.setLayoutData(fdlDbNameOverride);
wDbNameOverride = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDbNameOverride);
wDbNameOverride.addModifyListener(lsMod);
fdDbNameOverride = new FormData();
fdDbNameOverride.left = new FormAttachment(middle, 0);
fdDbNameOverride.top = new FormAttachment(wLoadAction, margin);
fdDbNameOverride.right = new FormAttachment(100, 0);
wDbNameOverride.setLayoutData(fdDbNameOverride);
// Enclosure line
wlEnclosure = new Label(shell, SWT.RIGHT);
wlEnclosure.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Enclosure.Label"));
props.setLook(wlEnclosure);
fdlEnclosure = new FormData();
fdlEnclosure.left = new FormAttachment(0, 0);
fdlEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdlEnclosure.right = new FormAttachment(middle, -margin);
wlEnclosure.setLayoutData(fdlEnclosure);
wEnclosure = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wEnclosure);
wEnclosure.addModifyListener(lsMod);
fdEnclosure = new FormData();
fdEnclosure.left = new FormAttachment(middle, 0);
fdEnclosure.top = new FormAttachment(wDbNameOverride, margin);
fdEnclosure.right = new FormAttachment(100, 0);
wEnclosure.setLayoutData(fdEnclosure);
// Delimiter
wlDelimiter = new Label(shell, SWT.RIGHT);
wlDelimiter.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Delimiter.Label"));
props.setLook(wlDelimiter);
fdlDelimiter = new FormData();
fdlDelimiter.left = new FormAttachment(0, 0);
fdlDelimiter.top = new FormAttachment(wEnclosure, margin);
fdlDelimiter.right = new FormAttachment(middle, -margin);
wlDelimiter.setLayoutData(fdlDelimiter);
wDelimiter = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wDelimiter);
wDelimiter.addModifyListener(lsMod);
fdDelimiter = new FormData();
fdDelimiter.left = new FormAttachment(middle, 0);
fdDelimiter.top = new FormAttachment(wEnclosure, margin);
fdDelimiter.right = new FormAttachment(100, 0);
wDelimiter.setLayoutData(fdDelimiter);
// Stop on Error line
wlStopOnError = new Label(shell, SWT.RIGHT);
wlStopOnError.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.StopOnError.Label"));
props.setLook(wlStopOnError);
fdlStopOnError = new FormData();
fdlStopOnError.left = new FormAttachment(0, 0);
fdlStopOnError.top = new FormAttachment(wDelimiter, margin);
fdlStopOnError.right = new FormAttachment(middle, -margin);
wlStopOnError.setLayoutData(fdlStopOnError);
wStopOnError = new Button(shell, SWT.CHECK);
props.setLook(wStopOnError);
fdStopOnError = new FormData();
fdStopOnError.left = new FormAttachment(middle, 0);
fdStopOnError.top = new FormAttachment(wDelimiter, margin);
fdStopOnError.right = new FormAttachment(100, 0);
wStopOnError.setLayoutData(fdStopOnError);
wStopOnError.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.SQL.Button"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wSQL }, margin, null);
// The field Table
wlReturn = new Label(shell, SWT.NONE);
wlReturn.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.Fields.Label"));
props.setLook(wlReturn);
fdlReturn = new FormData();
fdlReturn.left = new FormAttachment(0, 0);
fdlReturn.top = new FormAttachment(wStopOnError, margin);
wlReturn.setLayoutData(fdlReturn);
int UpInsCols = 3;
int UpInsRows = (input.getFieldTable() != null ? input.getFieldTable().length : 1);
ciReturn = new ColumnInfo[UpInsCols];
ciReturn[0] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.TableField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[1] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.StreamField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
ciReturn[2] = new ColumnInfo(BaseMessages.getString(PKG, "PGBulkLoaderDialog.ColumnInfo.DateMask"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "", BaseMessages.getString(PKG, "PGBulkLoaderDialog.PassThrough.Label"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateMask.Label"), BaseMessages.getString(PKG, "PGBulkLoaderDialog.DateTimeMask.Label") }, true);
tableFieldColumns.add(ciReturn[0]);
wReturn = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, UpInsRows, lsMod, props);
wGetLU = new Button(shell, SWT.PUSH);
wGetLU.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.GetFields.Label"));
fdGetLU = new FormData();
fdGetLU.top = new FormAttachment(wlReturn, margin);
fdGetLU.right = new FormAttachment(100, 0);
wGetLU.setLayoutData(fdGetLU);
wDoMapping = new Button(shell, SWT.PUSH);
wDoMapping.setText(BaseMessages.getString(PKG, "PGBulkLoaderDialog.EditMapping.Label"));
fdDoMapping = new FormData();
fdDoMapping.top = new FormAttachment(wGetLU, margin);
fdDoMapping.right = new FormAttachment(100, 0);
wDoMapping.setLayoutData(fdDoMapping);
wDoMapping.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
generateMappings();
}
});
fdReturn = new FormData();
fdReturn.left = new FormAttachment(0, 0);
fdReturn.top = new FormAttachment(wlReturn, margin);
// fix margin error
fdReturn.right = new FormAttachment(wDoMapping, -margin);
fdReturn.bottom = new FormAttachment(wOK, -2 * margin);
wReturn.setLayoutData(fdReturn);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
// Remember these fields...
for (int i = 0; i < row.size(); i++) {
inputFields.put(row.getValueMeta(i).getName(), i);
}
setComboBoxes();
} catch (KettleException e) {
logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
}
}
}
};
new Thread(runnable).start();
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsGetLU = new Listener() {
public void handleEvent(Event e) {
getUpdate();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
create();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wGetLU.addListener(SWT.Selection, lsGetLU);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSchema.addSelectionListener(lsDef);
wTable.addSelectionListener(lsDef);
wDbNameOverride.addSelectionListener(lsDef);
wEnclosure.addSelectionListener(lsDef);
wDelimiter.addSelectionListener(lsDef);
wStopOnError.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
setTableFieldCombo();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.TableView in project pentaho-kettle by pentaho.
the class JmsProducerDialog method buildPropertiesTable.
private void buildPropertiesTable(Composite parentWidget) {
ColumnInfo[] columns = getPropertiesColumns();
int fieldCount = meta.getPropertyValuesByName().size();
propertiesTable = new TableView(transMeta, parentWidget, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columns, fieldCount, false, lsMod, props, false);
propertiesTable.setSortable(false);
propertiesTable.getTable().addListener(SWT.Resize, event -> {
Table table = (Table) event.widget;
table.getColumn(1).setWidth(215);
table.getColumn(2).setWidth(215);
});
populateProperties();
FormData fdData = new FormData();
fdData.left = new FormAttachment(0, 0);
fdData.top = new FormAttachment(0, 0);
fdData.right = new FormAttachment(100, 0);
fdData.bottom = new FormAttachment(100, 0);
// resize the columns to fit the data in them
Arrays.stream(propertiesTable.getTable().getColumns()).forEach(column -> {
if (column.getWidth() > 0) {
// don't pack anything with a 0 width, it will resize it to make it visible (like the index column)
column.setWidth(120);
}
});
propertiesTable.setLayoutData(fdData);
}
Aggregations