/** Copy information from the input buffer to the dialog fields. */ private void getData() { int i, c; for (i = 0; i < buffer.size(); i++) { Row row = (Row) buffer.get(i); for (c = 0; c < row.size(); c++) { Value v = row.getValue(c); String show; if (v.isNumeric()) show = v.toString(true); else show = v.toString(false); wFields.table.getItem(i).setText(c + 1, show); } } wFields.optWidth(true); }
public FormulaMetaFunction(Node calcnode) { fieldName = XMLHandler.getTagValue(calcnode, "field_name"); formula = XMLHandler.getTagValue(calcnode, "formula_string"); valueType = Value.getType(XMLHandler.getTagValue(calcnode, "value_type")); valueLength = Const.toInt(XMLHandler.getTagValue(calcnode, "value_length"), -1); valuePrecision = Const.toInt(XMLHandler.getTagValue(calcnode, "value_precision"), -1); removedFromResult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "remove")); }
public FormulaMetaFunction(Repository rep, long id_step, int nr) throws KettleException { fieldName = rep.getStepAttributeString(id_step, nr, "field_name"); formula = rep.getStepAttributeString(id_step, nr, "formula_string"); valueType = Value.getType(rep.getStepAttributeString(id_step, nr, "value_type")); valueLength = (int) rep.getStepAttributeInteger(id_step, nr, "value_length"); valuePrecision = (int) rep.getStepAttributeInteger(id_step, nr, "value_precision"); removedFromResult = rep.getStepAttributeBoolean(id_step, nr, "remove"); }
public void saveRep(Repository rep, long id_transformation, long id_step, int nr) throws KettleException { rep.saveStepAttribute(id_transformation, id_step, nr, "field_name", fieldName); rep.saveStepAttribute(id_transformation, id_step, nr, "formula_string", formula); rep.saveStepAttribute( id_transformation, id_step, nr, "value_type", Value.getTypeDesc(valueType)); rep.saveStepAttribute(id_transformation, id_step, nr, "value_length", valueLength); rep.saveStepAttribute(id_transformation, id_step, nr, "value_precision", valuePrecision); rep.saveStepAttribute(id_transformation, id_step, nr, "remove", removedFromResult); }
public String getXML() { String xml = ""; xml += "<" + XML_TAG + ">"; xml += XMLHandler.addTagValue("field_name", fieldName); xml += XMLHandler.addTagValue("formula_string", formula); xml += XMLHandler.addTagValue("value_type", Value.getTypeDesc(valueType)); xml += XMLHandler.addTagValue("value_length", valueLength); xml += XMLHandler.addTagValue("value_precision", valuePrecision); xml += XMLHandler.addTagValue("remove", removedFromResult); xml += "</" + XML_TAG + ">"; return xml; }
public Row open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX); props.setLook(shell); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; if (title == null) title = Messages.getString("SelectRowDialog.Title"); shell.setLayout(formLayout); shell.setText(title); int margin = Const.MARGIN; if (buffer == null || buffer.size() == 0) return null; Row row = (Row) buffer.get(0); int FieldsRows = buffer.size(); ColumnInfo[] colinf = new ColumnInfo[row.size()]; for (int i = 0; i < row.size(); i++) { Value v = row.getValue(i); colinf[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, false); colinf[i].setToolTip(v.toStringMeta()); colinf[i].setReadOnly(true); } wFields = new TableView( shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, null, props); wOK = new Button(shell, SWT.PUSH); wOK.setText(Messages.getString("System.Button.OK")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(Messages.getString("System.Button.Cancel")); BaseStepDialog.positionBottomButtons(shell, new Button[] {wOK, wCancel}, margin, null); fdFields = new FormData(); fdFields.left = new FormAttachment(0, 0); fdFields.top = new FormAttachment(wlFields, margin); fdFields.right = new FormAttachment(100, 0); fdFields.bottom = new FormAttachment(wOK, -margin); wFields.setLayoutData(fdFields); // Add listeners lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wOK.addListener(SWT.Selection, lsOK); lsCancel = new Listener() { public void handleEvent(Event e) { close(); } }; wCancel.addListener(SWT.Selection, lsCancel); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { close(); } }); getData(); BaseStepDialog.setSize(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } return selection; }