use of com.twinsoft.convertigo.engine.parsers.HtmlParser in project convertigo by convertigo.
the class BrowserPropertyChangeStatement method execute.
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.execute(javascriptContext, scope)) {
if (convertigoMode == ConvertigoMode.both || convertigoMode == ConvertigoMode.studio && Engine.isStudioMode() || convertigoMode == ConvertigoMode.engine && Engine.isEngineMode()) {
HtmlTransaction htmlTransaction = (HtmlTransaction) getParentTransaction();
HtmlConnector htmlConnector = (HtmlConnector) htmlTransaction.getParent();
HtmlParser htmlParser = htmlConnector.getHtmlParser();
if (javascriptMode == JavascriptMode.forceOn)
htmlParser.setAllowJavascript(htmlTransaction.context, true);
else if (javascriptMode == JavascriptMode.forceOff)
htmlParser.setAllowJavascript(htmlTransaction.context, false);
if (imageMode == ImageMode.forceOn)
htmlParser.setAllowImage(htmlTransaction.context, true);
else if (imageMode == ImageMode.forceOff)
htmlParser.setAllowImage(htmlTransaction.context, false);
if (pluginMode == PluginMode.forceOn)
htmlParser.setAllowPlugin(htmlTransaction.context, true);
else if (pluginMode == PluginMode.forceOff)
htmlParser.setAllowPlugin(htmlTransaction.context, false);
if (attachmentMode == AttachmentMode.forceOn)
htmlParser.setAllowAttachment(htmlTransaction.context, true);
else if (attachmentMode == AttachmentMode.forceOff)
htmlParser.setAllowAttachment(htmlTransaction.context, false);
if (windowOpenMode == WindowOpenMode.forceOnNewWindow)
htmlParser.setWindowOpenState(htmlTransaction.context, IWebViewer.windowOpenNewWindow);
else if (windowOpenMode == WindowOpenMode.forceOnSameWindow)
htmlParser.setWindowOpenState(htmlTransaction.context, IWebViewer.windowOpenSameWindow);
else if (windowOpenMode == WindowOpenMode.forceOff)
htmlParser.setWindowOpenState(htmlTransaction.context, IWebViewer.windowOpenCancel);
if (bClearCookies) {
htmlConnector.resetHttpState(htmlTransaction.context);
}
}
return true;
}
}
return false;
}
use of com.twinsoft.convertigo.engine.parsers.HtmlParser 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;
}
use of com.twinsoft.convertigo.engine.parsers.HtmlParser in project convertigo by convertigo.
the class HtmlConnector method prepareForTransaction.
/* (non-Javadoc)
* @see com.twinsoft.convertigo.beans.connectors.HttpConnector#prepareForTransaction(com.twinsoft.convertigo.engine.Context)
*/
@Override
public void prepareForTransaction(Context context) throws EngineException {
if (!Engine.hasXulRunner()) {
throw new EngineException("This configuration doesn't have XulRunner for the HTML Connector (32 bits version have).");
}
Engine.logBeans.trace("(HtmlConnector) Retrieving or Initializing HtmlParser");
// Engine mode : retrieve HtmlParser from context
if (Engine.isEngineMode()) {
if (this.htmlParser == null) {
Engine.logBeans.trace("(HtmlConnector) Creating new HtmlParser for context id " + context.contextID);
HtmlParser htmlParser = new HtmlParser(null);
this.addHttpStateListener(htmlParser);
setHtmlParser(htmlParser);
} else
Engine.logBeans.trace("(HtmlConnector) Using HtmlParser of HTML Connector for context id " + context.contextID);
} else // Studio mode
{
if (this.htmlParser == null) {
throw new EngineException("Studio mode: the HTML connector must be open in order to execute transactions");
}
Engine.logBeans.trace("(HtmlConnector) Using HtmlParser of Studio for context id " + context.contextID);
}
if (context.requestedObject != null && context.requestedObject instanceof HtmlTransaction) {
HtmlTransaction htmlTransaction = (HtmlTransaction) context.requestedObject;
if (!htmlTransaction.isStateFull())
getHtmlParser().resetBrowserProperty(context);
}
super.prepareForTransaction(context);
}
use of com.twinsoft.convertigo.engine.parsers.HtmlParser in project convertigo by convertigo.
the class NavigationBarStatement 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();
NavigationBarEvent evt;
if (action.equalsIgnoreCase(NavigationBarEvent.ACTION_GOTO)) {
evaluate(javascriptContext, scope, jsUrl, "jsUrl", false);
String url = evaluated.toString();
evt = new NavigationBarEvent(action, url);
} else {
evt = new NavigationBarEvent(action);
}
HtmlParser htmlParser = htmlConnector.getHtmlParser();
boolean success = htmlParser.dispatchEvent(evt, htmlTransaction.context, trigger.getTrigger());
if (!success)
Engine.logBeans.debug("NavigationBarStatement has failed");
success = true;
return success;
}
}
return false;
}
use of com.twinsoft.convertigo.engine.parsers.HtmlParser in project convertigo by convertigo.
the class HtmlConnectorDesignComposite method close.
public void close() {
// Stop learning if needed
stopLearn();
// Remove ProjectExplorerView from listeners current composite view
if (projectExplorerView != null) {
projectExplorerView.removeSelectionChangedListener(this);
removeCompositeListener(projectExplorerView);
}
// Deregister as Engine listener
Engine.theApp.removeEngineListener(this);
// Release parser and remove it from HttpState listeners
HtmlParser htmlParser = htmlConnector.getHtmlParser();
if (htmlParser != null) {
htmlConnector.removeHttpStateListener(htmlParser);
htmlParser.release();
}
// Reset
htmlConnector.context = null;
htmlConnector.setCurrentXmlDocument(null);
htmlConnector.setHtmlParser(null);
}
Aggregations