use of org.pentaho.di.ui.core.dialog.DialogClosedListener in project pentaho-kettle by pentaho.
the class TransGraph method sniff.
public void sniff(final boolean input, final boolean output, final boolean error) {
StepMeta stepMeta = getCurrentStep();
if (stepMeta == null || trans == null) {
return;
}
final StepInterface runThread = trans.findRunThread(stepMeta.getName());
if (runThread != null) {
List<Object[]> rows = new ArrayList<>();
final PreviewRowsDialog dialog = new PreviewRowsDialog(shell, trans, SWT.NONE, stepMeta.getName(), null, rows);
dialog.setDynamic(true);
// Add a row listener that sends the rows over to the dialog...
//
final RowListener rowListener = new RowListener() {
@Override
public void rowReadEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
if (input) {
try {
dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
} catch (KettleValueException e) {
throw new KettleStepException(e);
}
}
}
@Override
public void rowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
if (output) {
try {
dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
} catch (KettleValueException e) {
throw new KettleStepException(e);
}
}
}
@Override
public void errorRowWrittenEvent(RowMetaInterface rowMeta, Object[] row) throws KettleStepException {
if (error) {
try {
dialog.addDataRow(rowMeta, rowMeta.cloneRow(row));
} catch (KettleValueException e) {
throw new KettleStepException(e);
}
}
}
};
// When the dialog is closed, make sure to remove the listener!
//
dialog.addDialogClosedListener(new DialogClosedListener() {
@Override
public void dialogClosed() {
runThread.removeRowListener(rowListener);
}
});
// Open the dialog in a separate thread to make sure it doesn't block
//
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
dialog.open();
}
});
runThread.addRowListener(rowListener);
}
}
Aggregations