use of org.pentaho.di.ui.core.widget.ConditionEditor in project pentaho-kettle by pentaho.
the class JoinRowsDialog 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();
backupCondition = (Condition) condition.clone();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "JoinRowsDialog.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
wlSortDir = new Label(shell, SWT.RIGHT);
wlSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempDir.Label"));
props.setLook(wlSortDir);
fdlSortDir = new FormData();
fdlSortDir.left = new FormAttachment(0, 0);
fdlSortDir.right = new FormAttachment(middle, -margin);
fdlSortDir.top = new FormAttachment(wStepname, margin);
wlSortDir.setLayoutData(fdlSortDir);
wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbSortDir);
wbSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Browse.Button"));
fdbSortDir = new FormData();
fdbSortDir.right = new FormAttachment(100, 0);
fdbSortDir.top = new FormAttachment(wStepname, margin);
wbSortDir.setLayoutData(fdbSortDir);
wSortDir = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Temp.Label"));
props.setLook(wSortDir);
wSortDir.addModifyListener(lsMod);
fdSortDir = new FormData();
fdSortDir.left = new FormAttachment(middle, 0);
fdSortDir.top = new FormAttachment(wStepname, margin);
fdSortDir.right = new FormAttachment(wbSortDir, -margin);
wSortDir.setLayoutData(fdSortDir);
wbSortDir.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
dd.setFilterPath(wSortDir.getText());
String dir = dd.open();
if (dir != null) {
wSortDir.setText(dir);
}
}
});
// Whenever something changes, set the tooltip to the expanded version:
wSortDir.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wSortDir.setToolTipText(transMeta.environmentSubstitute(wSortDir.getText()));
}
});
// Table line...
wlPrefix = new Label(shell, SWT.RIGHT);
wlPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempFilePrefix.Label"));
props.setLook(wlPrefix);
fdlPrefix = new FormData();
fdlPrefix.left = new FormAttachment(0, 0);
fdlPrefix.right = new FormAttachment(middle, -margin);
fdlPrefix.top = new FormAttachment(wbSortDir, margin * 2);
wlPrefix.setLayoutData(fdlPrefix);
wPrefix = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wPrefix);
wPrefix.addModifyListener(lsMod);
fdPrefix = new FormData();
fdPrefix.left = new FormAttachment(middle, 0);
fdPrefix.top = new FormAttachment(wbSortDir, margin * 2);
fdPrefix.right = new FormAttachment(100, 0);
wPrefix.setLayoutData(fdPrefix);
wPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Prefix.Label"));
// Cache size...
wlCache = new Label(shell, SWT.RIGHT);
wlCache.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Cache.Label"));
props.setLook(wlCache);
fdlCache = new FormData();
fdlCache.left = new FormAttachment(0, 0);
fdlCache.right = new FormAttachment(middle, -margin);
fdlCache.top = new FormAttachment(wPrefix, margin * 2);
wlCache.setLayoutData(fdlCache);
wCache = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCache);
wCache.addModifyListener(lsMod);
fdCache = new FormData();
fdCache.left = new FormAttachment(middle, 0);
fdCache.top = new FormAttachment(wPrefix, margin * 2);
fdCache.right = new FormAttachment(100, 0);
wCache.setLayoutData(fdCache);
// Read date from...
wlMainStep = new Label(shell, SWT.RIGHT);
wlMainStep.setText(BaseMessages.getString(PKG, "JoinRowsDialog.MainStep.Label"));
props.setLook(wlMainStep);
fdlMainStep = new FormData();
fdlMainStep.left = new FormAttachment(0, 0);
fdlMainStep.right = new FormAttachment(middle, -margin);
fdlMainStep.top = new FormAttachment(wCache, margin);
wlMainStep.setLayoutData(fdlMainStep);
wMainStep = new CCombo(shell, SWT.BORDER);
props.setLook(wMainStep);
List<StepMeta> prevSteps = transMeta.findPreviousSteps(transMeta.findStep(stepname));
for (StepMeta stepMeta : prevSteps) {
wMainStep.add(stepMeta.getName());
}
wMainStep.addModifyListener(lsMod);
fdMainStep = new FormData();
fdMainStep.left = new FormAttachment(middle, 0);
fdMainStep.top = new FormAttachment(wCache, margin);
fdMainStep.right = new FormAttachment(100, 0);
wMainStep.setLayoutData(fdMainStep);
// Condition widget...
wlCondition = new Label(shell, SWT.NONE);
wlCondition.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Condition.Label"));
props.setLook(wlCondition);
fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.top = new FormAttachment(wMainStep, margin);
wlCondition.setLayoutData(fdlCondition);
RowMetaInterface inputfields = null;
try {
inputfields = transMeta.getPrevStepFields(stepname);
} catch (KettleException ke) {
inputfields = new RowMeta();
new ErrorDialog(shell, BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogMessage"), ke);
}
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, null);
wCondition = new ConditionEditor(shell, SWT.BORDER, condition, inputfields);
fdCondition = new FormData();
fdCondition.left = new FormAttachment(0, 0);
fdCondition.top = new FormAttachment(wlCondition, margin);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.bottom = new FormAttachment(wOK, -2 * margin);
wCondition.setLayoutData(fdCondition);
wCondition.addModifyListener(lsMod);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wSortDir.addSelectionListener(lsDef);
wPrefix.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.ConditionEditor in project pentaho-kettle by pentaho.
the class TransDebugDialog method showStepDebugInformation.
private void showStepDebugInformation() {
//
for (Control control : wComposite.getChildren()) {
control.dispose();
}
wComposite.layout(true, true);
int[] selectionIndices = wSteps.table.getSelectionIndices();
if (selectionIndices == null || selectionIndices.length != 1) {
return;
}
previousIndex = selectionIndices[0];
// What step did we click on?
//
final StepMeta stepMeta = transDebugMeta.getTransMeta().getStep(selectionIndices[0]);
// What is the step debugging metadata?
// --> This can be null (most likely scenario)
//
final StepDebugMeta stepDebugMeta = stepDebugMetaMap.get(stepMeta);
// At the top we'll put a few common items like first[x], etc.
//
// The row count (e.g. number of rows to keep)
//
wRowCount = new LabelText(wComposite, BaseMessages.getString(PKG, "TransDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "TransDebugDialog.RowCount.ToolTip"));
FormData fdRowCount = new FormData();
fdRowCount.left = new FormAttachment(0, 0);
fdRowCount.right = new FormAttachment(100, 0);
fdRowCount.top = new FormAttachment(0, 0);
wRowCount.setLayoutData(fdRowCount);
wRowCount.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
ok(false);
}
});
// Do we retrieve the first rows passing?
//
wFirstRows = new Button(wComposite, SWT.CHECK);
props.setLook(wFirstRows);
wFirstRows.setText(BaseMessages.getString(PKG, "TransDebugDialog.FirstRows.Label"));
wFirstRows.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.FirstRows.ToolTip"));
FormData fdFirstRows = new FormData();
fdFirstRows.left = new FormAttachment(middle, 0);
fdFirstRows.right = new FormAttachment(100, 0);
fdFirstRows.top = new FormAttachment(wRowCount, margin);
wFirstRows.setLayoutData(fdFirstRows);
// Do we pause on break point, when the condition is met?
//
wPauseBreakPoint = new Button(wComposite, SWT.CHECK);
props.setLook(wPauseBreakPoint);
wPauseBreakPoint.setText(BaseMessages.getString(PKG, "TransDebugDialog.PauseBreakPoint.Label"));
wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.PauseBreakPoint.ToolTip"));
FormData fdPauseBreakPoint = new FormData();
fdPauseBreakPoint.left = new FormAttachment(middle, 0);
fdPauseBreakPoint.right = new FormAttachment(100, 0);
fdPauseBreakPoint.top = new FormAttachment(wFirstRows, margin);
wPauseBreakPoint.setLayoutData(fdPauseBreakPoint);
// The condition to pause for...
//
condition = null;
if (stepDebugMeta != null) {
condition = stepDebugMeta.getCondition();
}
if (condition == null) {
condition = new Condition();
}
// The input fields...
try {
stepInputFields = transDebugMeta.getTransMeta().getStepFields(stepMeta);
} catch (KettleStepException e) {
stepInputFields = new RowMeta();
}
wlCondition = new Label(wComposite, SWT.RIGHT);
props.setLook(wlCondition);
wlCondition.setText(BaseMessages.getString(PKG, "TransDebugDialog.Condition.Label"));
wlCondition.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.Condition.ToolTip"));
FormData fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.right = new FormAttachment(middle, -margin);
fdlCondition.top = new FormAttachment(wPauseBreakPoint, margin);
wlCondition.setLayoutData(fdlCondition);
wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, stepInputFields);
FormData fdCondition = new FormData();
fdCondition.left = new FormAttachment(middle, 0);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.top = new FormAttachment(wPauseBreakPoint, margin);
fdCondition.bottom = new FormAttachment(100, 0);
wCondition.setLayoutData(fdCondition);
getStepDebugData(stepDebugMeta);
// Add a "clear" button at the bottom on the left...
//
Button wClear = new Button(wComposite, SWT.PUSH);
props.setLook(wClear);
wClear.setText(BaseMessages.getString(PKG, "TransDebugDialog.Clear.Label"));
wClear.setToolTipText(BaseMessages.getString(PKG, "TransDebugDialog.Clear.ToolTip"));
FormData fdClear = new FormData();
fdClear.left = new FormAttachment(0, 0);
fdClear.bottom = new FormAttachment(100, 0);
wClear.setLayoutData(fdClear);
wClear.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Clear the preview step information for this step...
//
stepDebugMetaMap.remove(stepMeta);
wSteps.table.setSelection(new int[] {});
previousIndex = -1;
// refresh the steps list...
//
refreshStepList();
showStepDebugInformation();
}
});
wComposite.layout(true, true);
}
use of org.pentaho.di.ui.core.widget.ConditionEditor in project pentaho-kettle by pentaho.
the class EnterConditionDialog method open.
public Condition open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
shell.setText(BaseMessages.getString(PKG, "EnterConditionDialog.Title"));
shell.setImage(GUIResource.getInstance().getImageLogoSmall());
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
// Condition widget
wCond = new ConditionEditor(shell, SWT.NONE, condition, fields);
props.setLook(wCond, Props.WIDGET_STYLE_FIXED);
if (!getData()) {
return null;
}
// 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"));
FormData fdCond = new FormData();
int margin = Const.MARGIN * 2;
// To the right of the label
fdCond.left = new FormAttachment(0, 0);
fdCond.top = new FormAttachment(0, 0);
fdCond.right = new FormAttachment(100, 0);
fdCond.bottom = new FormAttachment(100, -50);
wCond.setLayoutData(fdCond);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null);
// Add listeners
wCancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
condition = null;
dispose();
}
});
wOK.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
handleOK();
}
});
BaseStepDialog.setSize(shell);
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return condition;
}
use of org.pentaho.di.ui.core.widget.ConditionEditor in project pentaho-kettle by pentaho.
the class FilterRowsDialog 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, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
backupChanged = input.hasChanged();
backupCondition = (Condition) condition.clone();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "FilterRowsDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "FilterRowsDialog.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);
// Send 'True' data to...
wlTrueTo = new Label(shell, SWT.RIGHT);
wlTrueTo.setText(BaseMessages.getString(PKG, "FilterRowsDialog.SendTrueTo.Label"));
props.setLook(wlTrueTo);
fdlTrueTo = new FormData();
fdlTrueTo.left = new FormAttachment(0, 0);
fdlTrueTo.right = new FormAttachment(middle, -margin);
fdlTrueTo.top = new FormAttachment(wStepname, margin);
wlTrueTo.setLayoutData(fdlTrueTo);
wTrueTo = new CCombo(shell, SWT.BORDER);
props.setLook(wTrueTo);
StepMeta stepinfo = transMeta.findStep(stepname);
if (stepinfo != null) {
List<StepMeta> nextSteps = transMeta.findNextSteps(stepinfo);
for (int i = 0; i < nextSteps.size(); i++) {
StepMeta stepMeta = nextSteps.get(i);
wTrueTo.add(stepMeta.getName());
}
}
wTrueTo.addModifyListener(lsMod);
fdTrueTo = new FormData();
fdTrueTo.left = new FormAttachment(middle, 0);
fdTrueTo.top = new FormAttachment(wStepname, margin);
fdTrueTo.right = new FormAttachment(100, 0);
wTrueTo.setLayoutData(fdTrueTo);
// Send 'False' data to...
wlFalseTo = new Label(shell, SWT.RIGHT);
wlFalseTo.setText(BaseMessages.getString(PKG, "FilterRowsDialog.SendFalseTo.Label"));
props.setLook(wlFalseTo);
fdlFalseTo = new FormData();
fdlFalseTo.left = new FormAttachment(0, 0);
fdlFalseTo.right = new FormAttachment(middle, -margin);
fdlFalseTo.top = new FormAttachment(wTrueTo, margin);
wlFalseTo.setLayoutData(fdlFalseTo);
wFalseTo = new CCombo(shell, SWT.BORDER);
props.setLook(wFalseTo);
stepinfo = transMeta.findStep(stepname);
if (stepinfo != null) {
List<StepMeta> nextSteps = transMeta.findNextSteps(stepinfo);
for (int i = 0; i < nextSteps.size(); i++) {
StepMeta stepMeta = nextSteps.get(i);
wFalseTo.add(stepMeta.getName());
}
}
wFalseTo.addModifyListener(lsMod);
fdFalseFrom = new FormData();
fdFalseFrom.left = new FormAttachment(middle, 0);
fdFalseFrom.top = new FormAttachment(wTrueTo, margin);
fdFalseFrom.right = new FormAttachment(100, 0);
wFalseTo.setLayoutData(fdFalseFrom);
wlCondition = new Label(shell, SWT.NONE);
wlCondition.setText(BaseMessages.getString(PKG, "FilterRowsDialog.Condition.Label"));
props.setLook(wlCondition);
fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.top = new FormAttachment(wFalseTo, margin);
wlCondition.setLayoutData(fdlCondition);
RowMetaInterface inputfields = null;
try {
inputfields = transMeta.getPrevStepFields(stepname);
} catch (KettleException ke) {
inputfields = new RowMeta();
new ErrorDialog(shell, BaseMessages.getString(PKG, "FilterRowsDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "FilterRowsDialog.FailedToGetFields.DialogMessage"), ke);
}
// 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, null);
wCondition = new ConditionEditor(shell, SWT.BORDER, condition, inputfields);
fdCondition = new FormData();
fdCondition.left = new FormAttachment(0, 0);
fdCondition.top = new FormAttachment(wlCondition, margin);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.bottom = new FormAttachment(wOK, -2 * margin);
wCondition.setLayoutData(fdCondition);
wCondition.addModifyListener(lsMod);
// 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(backupChanged);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations