Search in sources :

Example 1 with TabManagementEvent

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;
}
Also used : HtmlParser(com.twinsoft.convertigo.engine.parsers.HtmlParser) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) TabManagementEvent(com.twinsoft.convertigo.engine.parsers.events.TabManagementEvent) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) EngineException(com.twinsoft.convertigo.engine.EngineException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)1 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1 HtmlParser (com.twinsoft.convertigo.engine.parsers.HtmlParser)1 TabManagementEvent (com.twinsoft.convertigo.engine.parsers.events.TabManagementEvent)1