use of org.pentaho.di.ui.core.dialog.EnterNumberDialog in project pentaho-kettle by pentaho.
the class GaInputStepDialog method preview.
// Preview the data
private void preview() {
// Create the XML input step
GaInputStepMeta oneMeta = new GaInputStepMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GoogleAnalyticsDialog.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.EnterNumberDialog in project pentaho-kettle by pentaho.
the class SapInputDialog method preview.
// Preview the data
// unused
// preserve for later
private void preview() {
// Create the XML input step
SapInputMeta oneMeta = new SapInputMeta();
getInfo(oneMeta);
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
transMeta.getVariable("Internal.Transformation.Filename.Directory");
previewMeta.getVariable("Internal.Transformation.Filename.Directory");
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "CsvInputDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "CsvInputDialog.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.EnterNumberDialog in project pentaho-kettle by pentaho.
the class XMLInputDialog method get.
private void get() {
boolean finished = false;
int elementsFound = 0;
try {
XMLInputMeta meta = new XMLInputMeta();
getInfo(meta);
// check if the path is given
if (!checkInputPositionsFilled(meta)) {
return;
}
EnterNumberDialog dialog = new EnterNumberDialog(shell, 1000, "Number of elements to scan", "Enter the number of elements to scan (0=all)");
int maxElements = dialog.open();
// OK, let's try to walk through the complete tree
// no fields found...
RowMetaInterface row = new RowMeta();
// Keep the list of positions
// ArrayList of XMLInputFieldPosition
List<XMLInputFieldPosition> path = new ArrayList<XMLInputFieldPosition>();
FileInputList inputList = meta.getFiles(transMeta);
for (int f = 0; f < inputList.getFiles().size() && !finished; f++) {
// Open the file...
Node rootNode = XMLHandler.loadXMLFile(inputList.getFile(f), transMeta.environmentSubstitute(meta.getFileBaseURI()), meta.isIgnoreEntities(), meta.isNamespaceAware());
// Position to the repeating item
for (int p = 0; rootNode != null && p < meta.getInputPosition().length - 1; p++) {
rootNode = XMLHandler.getSubNode(rootNode, meta.getInputPosition()[p]);
}
if (rootNode == null) {
// Specified node not found: return!
return;
}
if (meta.getInputPosition().length > 1) {
// Count the number of rootnodes
String itemElement = meta.getInputPosition()[meta.getInputPosition().length - 1];
int nrItems = XMLHandler.countNodes(rootNode, itemElement);
for (int i = 0; i < nrItems && !finished; i++) {
Node itemNode = XMLHandler.getSubNodeByNr(rootNode, itemElement, i, false);
if (i >= meta.getNrRowsToSkip()) {
getValues(itemNode, row, path, 0);
elementsFound++;
if (elementsFound >= maxElements && maxElements > 0) {
finished = true;
}
}
}
} else {
// Only search the root node
//
getValues(rootNode, row, path, 0);
elementsFound++;
if (elementsFound >= maxElements && maxElements > 0) {
finished = true;
}
}
}
// add the values to the grid...
for (int i = 0; i < row.size(); i++) {
ValueMetaInterface v = row.getValueMeta(i);
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, v.getName());
item.setText(2, v.getTypeDesc());
item.setText(11, v.getOrigin());
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "XMLInputDialog.ErrorParsingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorParsingData.DialogMessage"), e);
}
}
use of org.pentaho.di.ui.core.dialog.EnterNumberDialog in project pentaho-kettle by pentaho.
the class XMLInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the XML input step
XMLInputMeta oneMeta = new XMLInputMeta();
getInfo(oneMeta);
// check if the path is given
if (!checkInputPositionsFilled(oneMeta)) {
return;
}
TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.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, "XMLInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "XMLInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.pentaho.di.ui.core.dialog.EnterNumberDialog in project pentaho-kettle by pentaho.
the class SpoonSlave method sniff.
protected void sniff() {
TreeItem[] ti = wTree.getSelection();
if (ti.length == 1) {
TreeItem treeItem = ti[0];
String[] path = ConstUI.getTreeStrings(treeItem);
// Make sure we're positioned on a step
if (path.length <= 2) {
return;
}
String name = path[1];
String step = path[2];
String copy = treeItem.getText(1);
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, PropsUI.getInstance().getDefaultPreviewSize(), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffSizeQuestion.Message"));
int lines = numberDialog.open();
if (lines <= 0) {
return;
}
EnterSelectionDialog selectionDialog = new EnterSelectionDialog(shell, new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT }, BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Title"), BaseMessages.getString(PKG, "SpoonSlave.SniffTypeQuestion.Message"));
String type = selectionDialog.open(1);
if (type == null) {
return;
}
try {
String xml = slaveServer.sniffStep(name, step, copy, lines, type);
Document doc = XMLHandler.loadXMLString(xml);
Node node = XMLHandler.getSubNode(doc, SniffStepServlet.XML_TAG);
Node metaNode = XMLHandler.getSubNode(node, RowMeta.XML_META_TAG);
RowMetaInterface rowMeta = new RowMeta(metaNode);
int nrRows = Const.toInt(XMLHandler.getTagValue(node, "nr_rows"), 0);
List<Object[]> rowBuffer = new ArrayList<Object[]>();
for (int i = 0; i < nrRows; i++) {
Node dataNode = XMLHandler.getSubNodeByNr(node, RowMeta.XML_DATA_TAG, i);
Object[] row = rowMeta.getRow(dataNode);
rowBuffer.add(row);
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer);
prd.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Title"), BaseMessages.getString(PKG, "SpoonSlave.ErrorSniffingStep.Message"), e);
}
}
}
Aggregations