use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.
the class EnterStringsDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
if (strings != null) {
for (int i = 0; i < strings.getRowMeta().size(); i++) {
ValueMetaInterface valueMeta = strings.getRowMeta().getValueMeta(i);
Object valueData = strings.getData()[i];
String string;
try {
string = valueMeta.getString(valueData);
} catch (KettleValueException e) {
string = "";
// TODO: can this ever be a meaningful exception? We're editing strings almost by definition
}
TableItem item = wFields.table.getItem(i);
item.setText(1, valueMeta.getName());
if (!Utils.isEmpty(string)) {
item.setText(2, string);
}
}
}
wFields.sortTable(1);
wFields.setRowNums();
wFields.optWidth(true);
}
use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.
the class EnterValueDialog method getData.
public void getData() {
wValueType.setText(valueMeta.getTypeDesc());
try {
if (valueData != null) {
String value = valueMeta.getString(valueData);
if (value != null) {
wInputString.setText(value);
}
}
} catch (KettleValueException e) {
wInputString.setText(valueMeta.toString());
}
setFormats();
int index = -1;
// we need to add that mask to the combo box
if (!Utils.isEmpty(valueMeta.getConversionMask())) {
index = wFormat.indexOf(valueMeta.getConversionMask());
if (index < 0) {
wFormat.add(valueMeta.getConversionMask());
index = wFormat.indexOf(valueMeta.getConversionMask());
}
}
if (index >= 0) {
wFormat.select(index);
}
wLength.setText(Integer.toString(valueMeta.getLength()));
wPrecision.setText(Integer.toString(valueMeta.getPrecision()));
setFormats();
wInputString.setFocus();
wInputString.selectAll();
}
use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.
the class EnterValueDialog method test.
/**
* Test the entered value
*/
public void test() {
try {
ValueMetaAndData v = getValue(valueMeta.getName());
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
StringBuilder result = new StringBuilder();
result.append(Const.CR).append(Const.CR).append(" ").append(v.toString());
result.append(Const.CR).append(" ").append(v.toStringMeta());
mb.setMessage(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Message", result.toString()));
mb.setText(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Title"));
mb.open();
} catch (KettleValueException e) {
new ErrorDialog(shell, "Error", "There was an error during data type conversion: ", e);
}
}
use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.
the class PreviewRowsDialog method getDataForRow.
protected int getDataForRow(TableItem item, Object[] row) {
int nrErrors = 0;
if (row == null) {
// no row to process
return nrErrors;
}
// Display the correct line item...
//
String strNr;
lineNr++;
try {
strNr = wFields.getNumberColumn().getValueMeta().getString(new Long(lineNr));
} catch (Exception e) {
strNr = Integer.toString(lineNr);
}
item.setText(0, strNr);
for (int c = 0; c < rowMeta.size(); c++) {
ValueMetaInterface v = rowMeta.getValueMeta(c);
String show;
try {
show = v.getString(row[c]);
if (v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE) {
// We want to limit the size of the strings during preview to keep all SWT widgets happy.
//
show = show.substring(0, MAX_BINARY_STRING_PREVIEW_SIZE);
}
} catch (KettleValueException e) {
nrErrors++;
if (nrErrors < 25) {
log.logError(Const.getStackTracker(e));
}
show = null;
} catch (ArrayIndexOutOfBoundsException e) {
nrErrors++;
if (nrErrors < 25) {
log.logError(Const.getStackTracker(e));
}
show = null;
}
if (show != null) {
item.setText(c + 1, show);
item.setForeground(c + 1, GUIResource.getInstance().getColorBlack());
} else {
// Set null value
item.setText(c + 1, "<null>");
item.setForeground(c + 1, GUIResource.getInstance().getColorBlue());
}
}
return nrErrors;
}
use of org.pentaho.di.core.exception.KettleValueException in project pentaho-kettle by pentaho.
the class SubjectDataBrowserDialog method getDataForRow.
protected int getDataForRow(TableItem item, RowMetaInterface rowMeta, Object[] row, int lineNr) {
int nrErrors = 0;
// Display the correct line item...
//
String strNr;
try {
strNr = wFields.getNumberColumn().getValueMeta().getString(new Long(lineNr));
} catch (Exception e) {
strNr = Integer.toString(lineNr);
}
item.setText(0, strNr);
for (int c = 0; c < rowMeta.size(); c++) {
ValueMetaInterface v = rowMeta.getValueMeta(c);
String show;
try {
show = v.getString(row[c]);
if (v.isBinary() && show != null && show.length() > MAX_BINARY_STRING_PREVIEW_SIZE) {
// We want to limit the size of the strings during preview to keep all SWT widgets happy.
//
show = show.substring(0, MAX_BINARY_STRING_PREVIEW_SIZE);
}
} catch (KettleValueException e) {
nrErrors++;
if (nrErrors < 25) {
log.logError(Const.getStackTracker(e));
}
show = null;
} catch (ArrayIndexOutOfBoundsException e) {
nrErrors++;
if (nrErrors < 25) {
log.logError(Const.getStackTracker(e));
}
show = null;
}
if (show != null) {
item.setText(c + 1, show);
item.setForeground(c + 1, GUIResource.getInstance().getColorBlack());
} else {
// Set null value
item.setText(c + 1, "<null>");
item.setForeground(c + 1, GUIResource.getInstance().getColorBlue());
}
}
return nrErrors;
}
Aggregations