use of org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesScript in project pentaho-kettle by pentaho.
the class ScriptValuesModDialog method getInfo.
private void getInfo(ScriptValuesMetaMod meta) {
meta.setCompatible(wCompatible.getSelection());
meta.setOptimizationLevel(wOptimizationLevel.getText());
int nrfields = wFields.nrNonEmpty();
meta.allocate(nrfields);
// CHECKSTYLE:Indentation:OFF
for (int i = 0; i < nrfields; i++) {
TableItem item = wFields.getNonEmpty(i);
meta.getFieldname()[i] = item.getText(1);
meta.getRename()[i] = item.getText(2);
if (meta.getRename()[i] == null || meta.getRename()[i].length() == 0 || meta.getRename()[i].equalsIgnoreCase(meta.getFieldname()[i])) {
meta.getRename()[i] = meta.getFieldname()[i];
}
meta.getType()[i] = ValueMetaFactory.getIdForValueMeta(item.getText(3));
String slen = item.getText(4);
String sprc = item.getText(5);
meta.getLength()[i] = Const.toInt(slen, -1);
meta.getPrecision()[i] = Const.toInt(sprc, -1);
meta.getReplace()[i] = YES_NO_COMBO[1].equalsIgnoreCase(item.getText(6));
}
// input.setActiveJSScript(strActiveScript);
CTabItem[] cTabs = folder.getItems();
if (cTabs.length > 0) {
ScriptValuesScript[] jsScripts = new ScriptValuesScript[cTabs.length];
for (int i = 0; i < cTabs.length; i++) {
ScriptValuesScript jsScript = new ScriptValuesScript(ScriptValuesScript.NORMAL_SCRIPT, cTabs[i].getText(), getStyledTextComp(cTabs[i]).getText());
if (cTabs[i].getImage().equals(imageActiveScript)) {
jsScript.setScriptType(ScriptValuesScript.TRANSFORM_SCRIPT);
} else if (cTabs[i].getImage().equals(imageActiveStartScript)) {
jsScript.setScriptType(ScriptValuesScript.START_SCRIPT);
} else if (cTabs[i].getImage().equals(imageActiveEndScript)) {
jsScript.setScriptType(ScriptValuesScript.END_SCRIPT);
}
jsScripts[i] = jsScript;
}
meta.setJSScripts(jsScripts);
}
}
use of org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesScript in project pentaho-kettle by pentaho.
the class ScriptValuesModDialog method getData.
/**
* Copy information from the meta-data input to the dialog fields.
*/
public void getData() {
wCompatible.setSelection(input.isCompatible());
if (!Utils.isEmpty(Const.trim(input.getOptimizationLevel()))) {
wOptimizationLevel.setText(input.getOptimizationLevel().trim());
} else {
wOptimizationLevel.setText(ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT);
}
for (int i = 0; i < input.getFieldname().length; i++) {
if (input.getFieldname()[i] != null && input.getFieldname()[i].length() > 0) {
TableItem item = wFields.table.getItem(i);
item.setText(1, input.getFieldname()[i]);
if (input.getRename()[i] != null && !input.getFieldname()[i].equals(input.getRename()[i])) {
item.setText(2, input.getRename()[i]);
}
item.setText(3, ValueMetaFactory.getValueMetaName(input.getType()[i]));
if (input.getLength()[i] >= 0) {
item.setText(4, "" + input.getLength()[i]);
}
if (input.getPrecision()[i] >= 0) {
item.setText(5, "" + input.getPrecision()[i]);
}
item.setText(6, input.getReplace()[i] ? YES_NO_COMBO[1] : YES_NO_COMBO[0]);
}
}
ScriptValuesScript[] jsScripts = input.getJSScripts();
if (jsScripts.length > 0) {
for (int i = 0; i < jsScripts.length; i++) {
if (jsScripts[i].isTransformScript()) {
strActiveScript = jsScripts[i].getScriptName();
} else if (jsScripts[i].isStartScript()) {
strActiveStartScript = jsScripts[i].getScriptName();
} else if (jsScripts[i].isEndScript()) {
strActiveEndScript = jsScripts[i].getScriptName();
}
addCtab(jsScripts[i].getScriptName(), jsScripts[i].getScript(), ADD_DEFAULT);
}
} else {
addCtab("", "", ADD_DEFAULT);
}
setActiveCtab(strActiveScript);
refresh();
wFields.setRowNums();
wFields.optWidth(true);
wStepname.selectAll();
wStepname.setFocus();
}
Aggregations