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);
}
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);
}
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);
}
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.");
}
}
}
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);
}
Aggregations