Search in sources :

Example 1 with ConditionEditor

use of org.apache.hop.ui.core.widget.ConditionEditor in project hop by apache.

the class TransformDebugLevelDialog method open.

public boolean open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GuiResource.getInstance().getImageServer());
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN + 2;
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setText("Transform debug Level");
    shell.setLayout(formLayout);
    // The name
    Label wlName = new Label(shell, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText("Log level to set ");
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, margin);
    // First one in the left top corner
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    wlName.setLayoutData(fdlName);
    wLogLevel = new Combo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wLogLevel.setItems(LogLevel.getLogLevelDescriptions());
    props.setLook(wLogLevel);
    FormData fdName = new FormData();
    fdName.top = new FormAttachment(wlName, 0, SWT.CENTER);
    // To the right of the label
    fdName.left = new FormAttachment(middle, 0);
    fdName.right = new FormAttachment(100, 0);
    wLogLevel.setLayoutData(fdName);
    Control lastControl = wLogLevel;
    // Start row option
    Label wlStartRow = new Label(shell, SWT.RIGHT);
    props.setLook(wlStartRow);
    wlStartRow.setText("Start row ");
    FormData fdlStartRow = new FormData();
    fdlStartRow.top = new FormAttachment(lastControl, margin);
    // First one in the left top corner
    fdlStartRow.left = new FormAttachment(0, 0);
    fdlStartRow.right = new FormAttachment(middle, -margin);
    wlStartRow.setLayoutData(fdlStartRow);
    wStartRow = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wStartRow);
    FormData fdStartRow = new FormData();
    fdStartRow.top = new FormAttachment(wlStartRow, 0, SWT.CENTER);
    // To the right of the label
    fdStartRow.left = new FormAttachment(middle, 0);
    fdStartRow.right = new FormAttachment(100, 0);
    wStartRow.setLayoutData(fdStartRow);
    lastControl = wStartRow;
    // End row
    Label wlEndRow = new Label(shell, SWT.RIGHT);
    props.setLook(wlEndRow);
    wlEndRow.setText("End row ");
    FormData fdlEndRow = new FormData();
    fdlEndRow.top = new FormAttachment(lastControl, margin);
    // First one in the left top corner
    fdlEndRow.left = new FormAttachment(0, 0);
    fdlEndRow.right = new FormAttachment(middle, -margin);
    wlEndRow.setLayoutData(fdlEndRow);
    wEndRow = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEndRow);
    FormData fdEndRow = new FormData();
    fdEndRow.top = new FormAttachment(wlEndRow, 0, SWT.CENTER);
    // To the right of the label
    fdEndRow.left = new FormAttachment(middle, 0);
    fdEndRow.right = new FormAttachment(100, 0);
    wEndRow.setLayoutData(fdEndRow);
    lastControl = wEndRow;
    // Buttons
    Button wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOK.addListener(SWT.Selection, e -> ok());
    Button wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(SWT.Selection, e -> cancel());
    Button[] buttons = new Button[] { wOK, wCancel };
    BaseTransformDialog.positionBottomButtons(shell, buttons, margin, null);
    // Condition
    Label wlCondition = new Label(shell, SWT.RIGHT);
    wlCondition.setText("Condition : ");
    props.setLook(wlCondition);
    FormData fdlCondition = new FormData();
    fdlCondition.top = new FormAttachment(lastControl, margin);
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.right = new FormAttachment(middle, -margin);
    wlCondition.setLayoutData(fdlCondition);
    ConditionEditor wCondition = new ConditionEditor(shell, SWT.NONE, debugLevel.getCondition(), inputRowMeta);
    props.setLook(wCondition);
    FormData fdCondition = new FormData();
    fdCondition.top = new FormAttachment(lastControl, margin);
    fdCondition.left = new FormAttachment(middle, 0);
    fdCondition.right = new FormAttachment(100, 0);
    fdCondition.bottom = new FormAttachment(wOK, 0);
    wCondition.setLayoutData(fdCondition);
    getData();
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
    return ok;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with ConditionEditor

use of org.apache.hop.ui.core.widget.ConditionEditor in project hop by apache.

the class PipelineDebugDialog method showTransformDebugInformation.

private void showTransformDebugInformation() {
    // 
    for (Control control : wComposite.getChildren()) {
        control.dispose();
    }
    wComposite.layout(true, true);
    int[] selectionIndices = wTransforms.table.getSelectionIndices();
    if (selectionIndices == null || selectionIndices.length != 1) {
        return;
    }
    previousIndex = selectionIndices[0];
    // What transform did we click on?
    // 
    final TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(selectionIndices[0]);
    // What is the transform debugging metadata?
    // --> This can be null (most likely scenario)
    // 
    final TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
    // 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, "PipelineDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "PipelineDebugDialog.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, "PipelineDebugDialog.FirstRows.Label"));
    wFirstRows.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.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, "PipelineDebugDialog.PauseBreakPoint.Label"));
    wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.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 (transformDebugMeta != null) {
        condition = transformDebugMeta.getCondition();
    }
    if (condition == null) {
        condition = new Condition();
    }
    // The input fields...
    IRowMeta transformInputFields;
    try {
        transformInputFields = pipelineDebugMeta.getPipelineMeta().getTransformFields(variables, transformMeta);
    } catch (HopTransformException e) {
        transformInputFields = new RowMeta();
    }
    Label wlCondition = new Label(wComposite, SWT.RIGHT);
    props.setLook(wlCondition);
    wlCondition.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.Label"));
    wlCondition.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.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);
    ConditionEditor wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, transformInputFields);
    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);
    getTransformDebugData(transformDebugMeta);
    // 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, "PipelineDebugDialog.Clear.Label"));
    wClear.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.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 transform information for this transform...
            // 
            transformDebugMetaMap.remove(transformMeta);
            wTransforms.table.setSelection(new int[] {});
            previousIndex = -1;
            // refresh the transforms list...
            // 
            refreshTransformList();
            showTransformDebugInformation();
        }
    });
    wComposite.layout(true, true);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Condition(org.apache.hop.core.Condition) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) TransformDebugMeta(org.apache.hop.pipeline.debug.TransformDebugMeta) HopTransformException(org.apache.hop.core.exception.HopTransformException) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelText(org.apache.hop.ui.core.widget.LabelText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with ConditionEditor

use of org.apache.hop.ui.core.widget.ConditionEditor in project hop by apache.

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().getImageHopUi());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    int margin = props.getMargin() * 2;
    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
    Button wOk = new Button(shell, SWT.PUSH);
    wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOk.addListener(SWT.Selection, e -> ok());
    Button wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(SWT.Selection, e -> cancel());
    BaseTransformDialog.positionBottomButtons(shell, new Button[] { wOk, wCancel }, margin, null);
    FormData fdCond = new FormData();
    // 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(wOk, -2 * margin);
    wCond.setLayoutData(fdCond);
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> dispose());
    return condition;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with ConditionEditor

use of org.apache.hop.ui.core.widget.ConditionEditor in project hop by apache.

the class JoinRowsDialog method open.

@Override
public String open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = 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 = props.getMargin();
    // TransformName line
    wlTransformName = new Label(shell, SWT.RIGHT);
    wlTransformName.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TransformName.Label"));
    props.setLook(wlTransformName);
    fdlTransformName = new FormData();
    fdlTransformName.left = new FormAttachment(0, 0);
    fdlTransformName.right = new FormAttachment(middle, -margin);
    fdlTransformName.top = new FormAttachment(0, margin);
    wlTransformName.setLayoutData(fdlTransformName);
    wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wTransformName.setText(transformName);
    props.setLook(wTransformName);
    wTransformName.addModifyListener(lsMod);
    fdTransformName = new FormData();
    fdTransformName.left = new FormAttachment(middle, 0);
    fdTransformName.top = new FormAttachment(0, margin);
    fdTransformName.right = new FormAttachment(100, 0);
    wTransformName.setLayoutData(fdTransformName);
    // Connection line
    Label wlSortDir = new Label(shell, SWT.RIGHT);
    wlSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempDir.Label"));
    props.setLook(wlSortDir);
    FormData fdlSortDir = new FormData();
    fdlSortDir.left = new FormAttachment(0, 0);
    fdlSortDir.right = new FormAttachment(middle, -margin);
    fdlSortDir.top = new FormAttachment(wTransformName, margin);
    wlSortDir.setLayoutData(fdlSortDir);
    Button wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSortDir);
    wbSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Browse.Button"));
    FormData fdbSortDir = new FormData();
    fdbSortDir.right = new FormAttachment(100, 0);
    fdbSortDir.top = new FormAttachment(wTransformName, margin);
    wbSortDir.setLayoutData(fdbSortDir);
    wSortDir = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Temp.Label"));
    props.setLook(wSortDir);
    wSortDir.addModifyListener(lsMod);
    FormData fdSortDir = new FormData();
    fdSortDir.left = new FormAttachment(middle, 0);
    fdSortDir.top = new FormAttachment(wTransformName, margin);
    fdSortDir.right = new FormAttachment(wbSortDir, -margin);
    wSortDir.setLayoutData(fdSortDir);
    wbSortDir.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
            dd.setFilterPath(wSortDir.getText());
            String dir = dd.open();
            if (dir != null) {
                wSortDir.setText(dir);
            }
        }
    });
    // Whenever something changes, set the tooltip to the expanded version:
    wSortDir.addModifyListener(e -> wSortDir.setToolTipText(variables.resolve(wSortDir.getText())));
    // Table line...
    Label wlPrefix = new Label(shell, SWT.RIGHT);
    wlPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempFilePrefix.Label"));
    props.setLook(wlPrefix);
    FormData 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);
    FormData 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"));
    // ICache size...
    Label wlCache = new Label(shell, SWT.RIGHT);
    wlCache.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Cache.Label"));
    props.setLook(wlCache);
    FormData 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);
    FormData 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...
    Label wlMainTransform = new Label(shell, SWT.RIGHT);
    wlMainTransform.setText(BaseMessages.getString(PKG, "JoinRowsDialog.MainTransform.Label"));
    props.setLook(wlMainTransform);
    FormData fdlMainTransform = new FormData();
    fdlMainTransform.left = new FormAttachment(0, 0);
    fdlMainTransform.right = new FormAttachment(middle, -margin);
    fdlMainTransform.top = new FormAttachment(wCache, margin);
    wlMainTransform.setLayoutData(fdlMainTransform);
    wMainTransform = new CCombo(shell, SWT.BORDER);
    props.setLook(wMainTransform);
    List<TransformMeta> prevTransforms = pipelineMeta.findPreviousTransforms(pipelineMeta.findTransform(transformName));
    for (TransformMeta transformMeta : prevTransforms) {
        wMainTransform.add(transformMeta.getName());
    }
    wMainTransform.addModifyListener(lsMod);
    FormData fdMainTransform = new FormData();
    fdMainTransform.left = new FormAttachment(middle, 0);
    fdMainTransform.top = new FormAttachment(wCache, margin);
    fdMainTransform.right = new FormAttachment(100, 0);
    wMainTransform.setLayoutData(fdMainTransform);
    // Condition widget...
    Label wlCondition = new Label(shell, SWT.NONE);
    wlCondition.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Condition.Label"));
    props.setLook(wlCondition);
    FormData fdlCondition = new FormData();
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.top = new FormAttachment(wMainTransform, margin);
    wlCondition.setLayoutData(fdlCondition);
    IRowMeta inputfields = null;
    try {
        inputfields = pipelineMeta.getPrevTransformFields(variables, transformName);
    } catch (HopException 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);
    FormData 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
    wOk.addListener(SWT.Selection, e -> ok());
    wCancel.addListener(SWT.Selection, e -> cancel());
    getData();
    input.setChanged(changed);
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
    return transformName;
}
Also used : Utils(org.apache.hop.core.util.Utils) RowMeta(org.apache.hop.core.row.RowMeta) IVariables(org.apache.hop.core.variables.IVariables) HopException(org.apache.hop.core.exception.HopException) ITransformDialog(org.apache.hop.pipeline.transform.ITransformDialog) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) Condition(org.apache.hop.core.Condition) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) CCombo(org.eclipse.swt.custom.CCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IRowMeta(org.apache.hop.core.row.IRowMeta) BaseMessages(org.apache.hop.i18n.BaseMessages) FormLayout(org.eclipse.swt.layout.FormLayout) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) org.eclipse.swt.widgets(org.eclipse.swt.widgets) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) TextVar(org.apache.hop.ui.core.widget.TextVar) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) HopException(org.apache.hop.core.exception.HopException) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) TextVar(org.apache.hop.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with ConditionEditor

use of org.apache.hop.ui.core.widget.ConditionEditor in project hop by apache.

the class FilterRowsDialog method open.

@Override
public String open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = 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 = props.getMargin();
    // TransformName line
    wlTransformName = new Label(shell, SWT.RIGHT);
    wlTransformName.setText(BaseMessages.getString(PKG, "FilterRowsDialog.TransformName.Label"));
    props.setLook(wlTransformName);
    fdlTransformName = new FormData();
    fdlTransformName.left = new FormAttachment(0, 0);
    fdlTransformName.right = new FormAttachment(middle, -margin);
    fdlTransformName.top = new FormAttachment(0, margin);
    wlTransformName.setLayoutData(fdlTransformName);
    wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wTransformName.setText(transformName);
    props.setLook(wTransformName);
    wTransformName.addModifyListener(lsMod);
    fdTransformName = new FormData();
    fdTransformName.left = new FormAttachment(middle, 0);
    fdTransformName.top = new FormAttachment(0, margin);
    fdTransformName.right = new FormAttachment(100, 0);
    wTransformName.setLayoutData(fdTransformName);
    // Send 'True' data to...
    Label wlTrueTo = new Label(shell, SWT.RIGHT);
    wlTrueTo.setText(BaseMessages.getString(PKG, "FilterRowsDialog.SendTrueTo.Label"));
    props.setLook(wlTrueTo);
    FormData fdlTrueTo = new FormData();
    fdlTrueTo.left = new FormAttachment(0, 0);
    fdlTrueTo.right = new FormAttachment(middle, -margin);
    fdlTrueTo.top = new FormAttachment(wTransformName, margin);
    wlTrueTo.setLayoutData(fdlTrueTo);
    wTrueTo = new CCombo(shell, SWT.BORDER);
    props.setLook(wTrueTo);
    TransformMeta transforminfo = pipelineMeta.findTransform(transformName);
    if (transforminfo != null) {
        List<TransformMeta> nextTransforms = pipelineMeta.findNextTransforms(transforminfo);
        for (TransformMeta transformMeta : nextTransforms) {
            wTrueTo.add(transformMeta.getName());
        }
    }
    wTrueTo.addModifyListener(lsMod);
    FormData fdTrueTo = new FormData();
    fdTrueTo.left = new FormAttachment(middle, 0);
    fdTrueTo.top = new FormAttachment(wTransformName, margin);
    fdTrueTo.right = new FormAttachment(100, 0);
    wTrueTo.setLayoutData(fdTrueTo);
    // Send 'False' data to...
    Label wlFalseTo = new Label(shell, SWT.RIGHT);
    wlFalseTo.setText(BaseMessages.getString(PKG, "FilterRowsDialog.SendFalseTo.Label"));
    props.setLook(wlFalseTo);
    FormData 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);
    transforminfo = pipelineMeta.findTransform(transformName);
    if (transforminfo != null) {
        List<TransformMeta> nextTransforms = pipelineMeta.findNextTransforms(transforminfo);
        for (TransformMeta transformMeta : nextTransforms) {
            wFalseTo.add(transformMeta.getName());
        }
    }
    wFalseTo.addModifyListener(lsMod);
    FormData fdFalseFrom = new FormData();
    fdFalseFrom.left = new FormAttachment(middle, 0);
    fdFalseFrom.top = new FormAttachment(wTrueTo, margin);
    fdFalseFrom.right = new FormAttachment(100, 0);
    wFalseTo.setLayoutData(fdFalseFrom);
    Label wlCondition = new Label(shell, SWT.NONE);
    wlCondition.setText(BaseMessages.getString(PKG, "FilterRowsDialog.Condition.Label"));
    props.setLook(wlCondition);
    FormData fdlCondition = new FormData();
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.top = new FormAttachment(wFalseTo, margin);
    wlCondition.setLayoutData(fdlCondition);
    IRowMeta inputfields = null;
    try {
        inputfields = pipelineMeta.getPrevTransformFields(variables, transformName);
    } catch (HopException 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);
    FormData 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
    wCancel.addListener(SWT.Selection, e -> cancel());
    wOk.addListener(SWT.Selection, e -> ok());
    getData();
    input.setChanged(backupChanged);
    BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
    return transformName;
}
Also used : Utils(org.apache.hop.core.util.Utils) RowMeta(org.apache.hop.core.row.RowMeta) IVariables(org.apache.hop.core.variables.IVariables) HopException(org.apache.hop.core.exception.HopException) ITransformDialog(org.apache.hop.pipeline.transform.ITransformDialog) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) Condition(org.apache.hop.core.Condition) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) CCombo(org.eclipse.swt.custom.CCombo) IStream(org.apache.hop.pipeline.transform.stream.IStream) IRowMeta(org.apache.hop.core.row.IRowMeta) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) BaseMessages(org.apache.hop.i18n.BaseMessages) Button(org.eclipse.swt.widgets.Button) FormLayout(org.eclipse.swt.layout.FormLayout) BaseDialog(org.apache.hop.ui.core.dialog.BaseDialog) FormData(org.eclipse.swt.layout.FormData) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment) Const(org.apache.hop.core.Const) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) List(java.util.List) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) BaseTransformDialog(org.apache.hop.ui.pipeline.transform.BaseTransformDialog) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ModifyListener(org.eclipse.swt.events.ModifyListener) HopException(org.apache.hop.core.exception.HopException) RowMeta(org.apache.hop.core.row.RowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) IRowMeta(org.apache.hop.core.row.IRowMeta) ConditionEditor(org.apache.hop.ui.core.widget.ConditionEditor) Label(org.eclipse.swt.widgets.Label) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) BaseTransformMeta(org.apache.hop.pipeline.transform.BaseTransformMeta) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ConditionEditor (org.apache.hop.ui.core.widget.ConditionEditor)5 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 FormLayout (org.eclipse.swt.layout.FormLayout)4 Condition (org.apache.hop.core.Condition)3 IRowMeta (org.apache.hop.core.row.IRowMeta)3 RowMeta (org.apache.hop.core.row.RowMeta)3 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)3 List (java.util.List)2 Const (org.apache.hop.core.Const)2 HopException (org.apache.hop.core.exception.HopException)2 Utils (org.apache.hop.core.util.Utils)2 IVariables (org.apache.hop.core.variables.IVariables)2 BaseMessages (org.apache.hop.i18n.BaseMessages)2 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)2 BaseTransformMeta (org.apache.hop.pipeline.transform.BaseTransformMeta)2 ITransformDialog (org.apache.hop.pipeline.transform.ITransformDialog)2 BaseDialog (org.apache.hop.ui.core.dialog.BaseDialog)2 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)2 BaseTransformDialog (org.apache.hop.ui.pipeline.transform.BaseTransformDialog)2