Search in sources :

Example 1 with ExpressionPersistance

use of org.talend.expressionbuilder.ExpressionPersistance in project tdi-studio-se by Talend.

the class PigExpressionBuilderDialog method openDialog.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.expressionbuilder.ui.IExpressionBuilderDialogController#openDialog()
     */
@Override
public void openDialog(Object obj) {
    if (obj instanceof IExpressionDataBean) {
        List<Variable> vars = new ArrayList<Variable>();
        IExpressionDataBean bean = (IExpressionDataBean) obj;
        setDefaultExpression(bean.getExpression());
        if (bean.getVariables() != null) {
            vars.addAll(bean.getVariables());
        }
        ExpressionPersistance persistance = ExpressionPersistance.getInstance();
        persistance.setOwnerId(bean.getOwnerId());
        persistance.setPath(getExpressionStorePath());
        for (Variable var1 : persistance.loadExpression().getVariables()) {
            boolean needAdd = true;
            for (Variable var2 : vars) {
                if (var1.getName() != null && var1.getName().equals(var2.getName())) {
                    needAdd = false;
                    break;
                }
            }
            if (var1.getName() != null && needAdd) {
                vars.add(var1);
            }
        }
    }
    open();
    setBlockOnOpen(true);
}
Also used : IExpressionDataBean(org.talend.commons.ui.runtime.expressionbuilder.IExpressionDataBean) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) ExpressionPersistance(org.talend.expressionbuilder.ExpressionPersistance) ArrayList(java.util.ArrayList)

Example 2 with ExpressionPersistance

use of org.talend.expressionbuilder.ExpressionPersistance in project tdi-studio-se by Talend.

the class BatchExpressionBuilderDialog method openDialog.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.expressionbuilder.ui.IExpressionBuilderDialogController#openDialog()
     */
@Override
public void openDialog(Object obj) {
    if (obj instanceof IExpressionDataBean) {
        IExpressionDataBean bean = (IExpressionDataBean) obj;
        setDefaultExpression(bean.getExpression());
        ExpressionPersistance persistance = ExpressionPersistance.getInstance();
        persistance.setOwnerId(bean.getOwnerId());
        persistance.setPath(getExpressionStorePath());
    }
    open();
    setBlockOnOpen(true);
}
Also used : IExpressionDataBean(org.talend.commons.ui.runtime.expressionbuilder.IExpressionDataBean) ExpressionPersistance(org.talend.expressionbuilder.ExpressionPersistance)

Example 3 with ExpressionPersistance

use of org.talend.expressionbuilder.ExpressionPersistance in project tdi-studio-se by Talend.

the class ExpressionBuilderDialog method openDialog.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.expressionbuilder.ui.IExpressionBuilderDialogController#openDialog()
     */
@Override
public void openDialog(Object obj) {
    if (obj instanceof IExpressionDataBean) {
        List<Variable> vars = new ArrayList<Variable>();
        IExpressionDataBean bean = (IExpressionDataBean) obj;
        setDefaultExpression(bean.getExpression());
        ExpressionPersistance persistance = ExpressionPersistance.getInstance();
        persistance.setOwnerId(bean.getOwnerId());
        persistance.setPath(getExpressionStorePath());
        List<Variable> varList = new ArrayList<Variable>(persistance.loadExpression().getVariables());
        vars.addAll(varList);
        if (bean.getVariables() != null) {
            for (Variable var1 : bean.getVariables()) {
                boolean needAdd = true;
                for (Variable var2 : varList) {
                    if (var1.getName() != null && var1.getName().equals(var2.getName())) {
                        needAdd = false;
                        break;
                    }
                }
                if (var1.getName() != null && needAdd) {
                    vars.add(var1);
                }
            }
        }
        addVariables(vars);
    }
    open();
    setBlockOnOpen(true);
}
Also used : IExpressionDataBean(org.talend.commons.ui.runtime.expressionbuilder.IExpressionDataBean) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) ExpressionPersistance(org.talend.expressionbuilder.ExpressionPersistance) ArrayList(java.util.ArrayList)

Aggregations

IExpressionDataBean (org.talend.commons.ui.runtime.expressionbuilder.IExpressionDataBean)3 ExpressionPersistance (org.talend.expressionbuilder.ExpressionPersistance)3 ArrayList (java.util.ArrayList)2 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)2