use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class FixedInputDialog method getFirst.
// Grab the first x lines from the given file...
//
private List<String> getFirst(FixedInputMeta meta, int limit) throws IOException, KettleValueException {
List<String> lines = new ArrayList<String>();
FixedInputMeta oneMeta = new FixedInputMeta();
getInfo(oneMeta);
// Add a single field with the width of the line...
//
int lineWidth = Integer.parseInt(oneMeta.getLineWidth());
if (lineWidth <= 0) {
throw new IOException("The width of a line can not be 0 or less.");
}
oneMeta.allocate(1);
FixedFileInputField field = new FixedFileInputField();
field.setName("Field1");
field.setType(ValueMetaInterface.TYPE_STRING);
field.setWidth(lineWidth);
// CHECKSTYLE:Indentation:OFF
oneMeta.getFieldDefinition()[0] = field;
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { limit });
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();
}
}
// The rows are in the transformation...
//
RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta(wStepname.getText());
List<Object[]> previewRowsData = progressDialog.getPreviewRows(wStepname.getText());
for (int i = 0; i < previewRowsData.size(); i++) {
String line = previewRowsMeta.getString(previewRowsData.get(i), 0);
lines.add(line);
}
return lines;
}
use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class FixedInputDialog method preview.
// Preview the data
private void preview() {
// execute a complete preview transformation in the background.
// This is how we do it...
//
FixedInputMeta oneMeta = new FixedInputMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "FixedInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "FixedInputDialog.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.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class GetFileNamesDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
GetFileNamesMeta oneMeta = new GetFileNamesMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetFileNamesDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetFileNamesDialog.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, "GetFileNamesDialog.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.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class GetFilesRowsCountDialog method preview.
// Preview the data
private void preview() {
try {
GetFilesRowsCountMeta oneMeta = new GetFilesRowsCountMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetFilesRowsCountDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "GetFilesRowsCountDialog.NumberRows.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.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();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GetFilesRowsCountDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "GetFilesRowsCountDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog in project pentaho-kettle by pentaho.
the class GetRepositoryNamesDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
GetRepositoryNamesMeta oneMeta = new GetRepositoryNamesMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
previewMeta.setRepository(repository);
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetRepositoryNamesDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetRepositoryNamesDialog.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, "GetRepositoryNamesDialog.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();
}
}
}
Aggregations