use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.
the class GetSubFoldersDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
GetSubFoldersMeta oneMeta = new GetSubFoldersMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "GetSubFoldersDialog.ErrorInPreview.DialogMessage"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
}
use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.
the class TextFileInputDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
TextFileInputMeta oneMeta = new TextFileInputMeta();
getInfo(oneMeta, true);
if (oneMeta.inputFiles.acceptingFilenames) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Message"));
mb.setText(BaseMessages.getString(PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Title"));
mb.open();
return;
}
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "TextFileInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "TextFileInputDialog.PreviewSize.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
progressDialog.open();
Trans trans = progressDialog.getTrans();
String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled()) {
if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
prd.open();
}
}
use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog 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);
}
}
use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.
the class DataOverrideHandler method showFeatureList.
public void showFeatureList() {
Shell parent = getShell();
DatabaseMeta dbinfo = new DatabaseMeta();
getInfo(dbinfo);
try {
java.util.List<RowMetaAndData> buffer = dbinfo.getFeatureSummary();
if (buffer.size() > 0) {
RowMetaInterface rowMeta = buffer.get(0).getRowMeta();
java.util.List<Object[]> rowData = new ArrayList<Object[]>();
for (RowMetaAndData row : buffer) {
rowData.add(row.getData());
}
PreviewRowsDialog prd = new PreviewRowsDialog(parent, dbinfo, SWT.NONE, null, rowMeta, rowData);
prd.setTitleMessage(BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureList.title"));
prd.open();
}
} catch (Exception e) {
new ErrorDialog(parent, BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.title"), BaseMessages.getString(PKG, "DatabaseDialog.FeatureListError.description"), e);
}
}
use of org.pentaho.di.ui.core.dialog.PreviewRowsDialog in project pentaho-kettle by pentaho.
the class XulDatabaseExplorerController method preview.
public void preview(boolean askLimit) {
if (model.getTable() == null) {
return;
}
try {
PromptCallback theCallback = new PromptCallback();
@SuppressWarnings("unused") boolean execute = true;
int limit = 100;
if (askLimit) {
XulPromptBox thePromptBox = (XulPromptBox) this.document.createElement("promptbox");
thePromptBox.setModalParent(this.dbExplorerDialog.getShell());
thePromptBox.setTitle("Enter Max Rows");
thePromptBox.setMessage("Max Rows:");
thePromptBox.addDialogCallback(theCallback);
thePromptBox.open();
execute = theCallback.getLimit() != -1;
limit = theCallback.getLimit();
}
// if (execute) {
// XulPreviewRowsDialog thePreviewRowsDialog = new XulPreviewRowsDialog(this.shell, SWT.NONE,
// this.model.getDatabaseMeta(), this.model.getTable(), theCallback.getLimit());
// thePreviewRowsDialog.open();
// }
GetPreviewTableProgressDialog pd = new GetPreviewTableProgressDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), model.getSchema(), model.getTable(), limit);
List<Object[]> rows = pd.open();
if (rows != null) {
if (rows.size() > 0) {
PreviewRowsDialog prd = new PreviewRowsDialog(this.dbExplorerDialog.getShell(), this.model.getDatabaseMeta(), SWT.None, this.model.getTable(), pd.getRowMeta(), rows);
prd.open();
} else {
MessageBox mb = new MessageBox(this.dbExplorerDialog.getShell(), SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Message"));
mb.setText(BaseMessages.getString(PKG, "DatabaseExplorerDialog.NoRows.Title"));
mb.open();
}
}
} catch (Exception e) {
LogChannel.GENERAL.logError("Error previewing rows", e);
}
}
Aggregations