use of com.twinsoft.convertigo.engine.parsers.events.TabManagementEvent in project convertigo by convertigo.
the class TabManagementStatement method execute.
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.execute(javascriptContext, scope)) {
HtmlTransaction htmlTransaction = (HtmlTransaction) getParentTransaction();
HtmlConnector htmlConnector = (HtmlConnector) htmlTransaction.getParent();
TabManagementEvent evt;
if (action.equalsIgnoreCase(TabManagementEvent.ACTION_SETINDEX)) {
try {
evaluate(javascriptContext, scope, jsIndex, "jsIndex", false);
int index = (int) Double.parseDouble(evaluated.toString());
evt = new TabManagementEvent(action, index);
} catch (Exception e) {
throw new EngineException("Tab index value isn't good.", e);
}
} else {
evt = new TabManagementEvent(action);
}
HtmlParser htmlParser = htmlConnector.getHtmlParser();
boolean success = htmlParser.dispatchEvent(evt, htmlTransaction.context, null);
if (!success)
Engine.logBeans.debug("NavigationBarStatement has failed");
else {
if (action.equalsIgnoreCase(TabManagementEvent.ACTION_GETINDEX)) {
String code = getIndexVarname + "=" + evt.getIndex();
evaluate(javascriptContext, scope, code, "ContextGet", true);
} else if (action.equalsIgnoreCase(TabManagementEvent.ACTION_GETNBTAB)) {
String code = getIndexVarname + "=" + evt.getNbTab();
evaluate(javascriptContext, scope, code, "ContextGet", true);
}
}
success = true;
return success;
}
}
return false;
}
Aggregations