Search in sources :

Example 1 with AbstractEventStatement

use of com.twinsoft.convertigo.beans.statements.AbstractEventStatement in project convertigo by convertigo.

the class EventStatementGenerator method addInputCheckbox.

public void addInputCheckbox(String selectBy, String selectType, boolean checked) {
    String xpath = getXPath("INPUT", selectBy, selectType);
    AbstractEventStatement stat = new InputHtmlSetCheckedStatement(xpath, checked);
    addStatement(stat);
}
Also used : InputHtmlSetCheckedStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetCheckedStatement) AbstractEventStatement(com.twinsoft.convertigo.beans.statements.AbstractEventStatement)

Example 2 with AbstractEventStatement

use of com.twinsoft.convertigo.beans.statements.AbstractEventStatement in project convertigo by convertigo.

the class EventStatementGenerator method addSelect.

public void addSelect(String selectBy, String selectType, boolean[] checks, String[] values, String[] contents) {
    String comment = "";
    String value = null;
    for (int i = 0; i < checks.length; i++) {
        comment += Integer.toString(i) + " -> value: '" + values[i] + "'\ncontent: '" + contents[i] + "'\n";
        if (checks[i]) {
            if (value == null) {
                value = Integer.toString(i);
            } else {
                if (value.startsWith("["))
                    value = value.substring(1, value.length() - 1);
                value = "[" + value + ", " + Integer.toString(i) + "]";
            }
        }
    }
    String var_name = addVariableFormPrefixe(selectType, value);
    String xpath = getXPath("SELECT", selectBy, selectType);
    if (value.startsWith("["))
        var_name = "eval(''+" + var_name + ")";
    AbstractEventStatement stat = new InputHtmlSetSelectedStatement(xpath, var_name, InputSelectEvent.MOD_INDEX);
    stat.setComment(comment);
    addStatement(stat);
}
Also used : InputHtmlSetSelectedStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetSelectedStatement) AbstractEventStatement(com.twinsoft.convertigo.beans.statements.AbstractEventStatement)

Example 3 with AbstractEventStatement

use of com.twinsoft.convertigo.beans.statements.AbstractEventStatement in project convertigo by convertigo.

the class EventStatementGenerator method addInputRadio.

public void addInputRadio(String selectBy, String selectType, int check_index, String[] values) {
    String comment = "";
    for (int i = 0; i < values.length; i++) comment += Integer.toString(i + 1) + " -> '" + values[i] + "'\n";
    String var_name = addVariableFormPrefixe(selectType, Integer.toString(check_index + 1));
    String xpath = null;
    if (elementXpath == null) {
        xpath = (formName == null ? "'" : formName + " + '");
    } else {
        xpath = "'" + elementXpath + "/ancestor::FORM[1]";
    }
    xpath = "'(' + " + xpath + "//INPUT[@" + selectBy + "=\"" + selectType + "\" and @type=\"radio\"])['+" + var_name + "+']'";
    AbstractEventStatement stat = new InputHtmlSetCheckedStatement(xpath, true);
    stat.setComment(comment);
    addStatement(stat);
}
Also used : InputHtmlSetCheckedStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetCheckedStatement) AbstractEventStatement(com.twinsoft.convertigo.beans.statements.AbstractEventStatement)

Example 4 with AbstractEventStatement

use of com.twinsoft.convertigo.beans.statements.AbstractEventStatement in project convertigo by convertigo.

the class EventStatementGenerator method addStatement.

protected void addStatement(AbstractEventStatement stat) {
    if (stat != null) {
        try {
            List<Statement> stats = block.getStatements();
            boolean goodName = false;
            String currentName = stat.getName();
            while (!goodName) {
                goodName = true;
                for (int i = 0; i < stats.size() && goodName; i++) {
                    DatabaseObject obj = (DatabaseObject) stats.get(i);
                    goodName = !(obj.getName().equals(currentName));
                }
                if (!goodName) {
                    String base = currentName;
                    int count = 1;
                    int i_ = currentName.lastIndexOf("_");
                    if (i_ != -1 && i_ + 1 < currentName.length()) {
                        String end = currentName.substring(i_ + 1);
                        try {
                            count = Integer.parseInt(end) + 1;
                            base = currentName.substring(0, i_);
                        } catch (NumberFormatException e) {
                        }
                    }
                    currentName = base + "_" + count;
                }
            }
            if (!StringUtils.isNormalized(currentName))
                throw new EngineException("Statement name is not normalized : \"" + currentName + "\"");
            stat.setName(currentName);
            stat.hasChanged = true;
            stat.bNew = true;
            block.addStatement(stat);
            block.hasChanged = true;
        } catch (EngineException e) {
            ConvertigoPlugin.logException(e, "Error when adding an '" + stat.getClass().getName() + "' statement.");
        }
    }
}
Also used : MouseStatement(com.twinsoft.convertigo.beans.statements.MouseStatement) InputHtmlSetValueStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetValueStatement) InputHtmlSetSelectedStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetSelectedStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) InputHtmlSetCheckedStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetCheckedStatement) AbstractEventStatement(com.twinsoft.convertigo.beans.statements.AbstractEventStatement) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 5 with AbstractEventStatement

use of com.twinsoft.convertigo.beans.statements.AbstractEventStatement in project convertigo by convertigo.

the class EventStatementGenerator method addInputText.

public void addInputText(String selectBy, String selectType, String tagName, String value) {
    String var_name = addVariableFormPrefixe(selectType, value);
    String xpath = getXPath(tagName.toUpperCase(), selectBy, selectType);
    AbstractEventStatement stat = new InputHtmlSetValueStatement(xpath, var_name);
    addStatement(stat);
}
Also used : InputHtmlSetValueStatement(com.twinsoft.convertigo.beans.statements.InputHtmlSetValueStatement) AbstractEventStatement(com.twinsoft.convertigo.beans.statements.AbstractEventStatement)

Aggregations

AbstractEventStatement (com.twinsoft.convertigo.beans.statements.AbstractEventStatement)6 InputHtmlSetCheckedStatement (com.twinsoft.convertigo.beans.statements.InputHtmlSetCheckedStatement)3 InputHtmlSetSelectedStatement (com.twinsoft.convertigo.beans.statements.InputHtmlSetSelectedStatement)2 InputHtmlSetValueStatement (com.twinsoft.convertigo.beans.statements.InputHtmlSetValueStatement)2 MouseStatement (com.twinsoft.convertigo.beans.statements.MouseStatement)2 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Statement (com.twinsoft.convertigo.beans.core.Statement)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1