Search in sources :

Example 1 with ScriptValuesScript

use of org.pentaho.di.trans.steps.script.ScriptValuesScript in project pentaho-kettle by pentaho.

the class ScriptDialog method getInfo.

private void getInfo(ScriptMeta meta) {
    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);
    }
}
Also used : ScriptValuesScript(org.pentaho.di.trans.steps.script.ScriptValuesScript) TableItem(org.eclipse.swt.widgets.TableItem) CTabItem(org.eclipse.swt.custom.CTabItem) Point(org.eclipse.swt.graphics.Point)

Aggregations

CTabItem (org.eclipse.swt.custom.CTabItem)1 Point (org.eclipse.swt.graphics.Point)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ScriptValuesScript (org.pentaho.di.trans.steps.script.ScriptValuesScript)1