Search in sources :

Example 1 with EnterConditionDialog

use of org.pentaho.di.ui.core.dialog.EnterConditionDialog in project pentaho-kettle by pentaho.

the class TableView method setFilter.

// Filtering...
public void setFilter() {
    if (condition == null) {
        condition = new Condition();
    }
    RowMetaInterface f = getRowWithoutValues();
    EnterConditionDialog ecd = new EnterConditionDialog(parent.getShell(), SWT.NONE, f, condition);
    Condition cond = ecd.open();
    if (cond != null) {
        ArrayList<Integer> tokeep = new ArrayList<Integer>();
        // Apply the condition to the TableView...
        int nr = table.getItemCount();
        for (int i = nr - 1; i >= 0; i--) {
            RowMetaAndData r = getRow(i);
            boolean keep = cond.evaluate(r.getRowMeta(), r.getData());
            if (keep) {
                tokeep.add(Integer.valueOf(i));
            }
        }
        int[] sels = new int[tokeep.size()];
        for (int i = 0; i < sels.length; i++) {
            sels[i] = (tokeep.get(i)).intValue();
        }
        table.setSelection(sels);
    }
}
Also used : Condition(org.pentaho.di.core.Condition) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) EnterConditionDialog(org.pentaho.di.ui.core.dialog.EnterConditionDialog) Point(org.eclipse.swt.graphics.Point)

Aggregations

ArrayList (java.util.ArrayList)1 Point (org.eclipse.swt.graphics.Point)1 Condition (org.pentaho.di.core.Condition)1 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)1 EnterConditionDialog (org.pentaho.di.ui.core.dialog.EnterConditionDialog)1