use of org.mozilla.javascript.Function in project LoboEvolution by LoboEvolution.
the class WindowImpl method setTimeout.
/**
* {@inheritDoc}
*/
@Override
public int setTimeout(final Object function, final double millis) {
if (millis > Integer.MAX_VALUE || millis < 0) {
throw new IllegalArgumentException("Timeout value " + millis + " is not supported.");
}
final int timeID = generateTimerID();
final Integer timeIDInt = timeID;
ActionListener task = null;
if (function instanceof Function) {
Function fun = (Function) function;
task = new FunctionTimerTask(this, timeIDInt, fun, true);
}
if (function instanceof String) {
String expr = (String) function;
task = new ExpressionTimerTask(this, timeIDInt, expr, true);
}
int t = (int) millis;
if (t < 1) {
t = 1;
}
final Timer timer = new Timer(t, task);
timer.setRepeats(false);
putAndStartTask(timeIDInt, timer, function);
return timeID;
}
use of org.mozilla.javascript.Function in project LoboEvolution by LoboEvolution.
the class HtmlController method onMouseOver.
/**
* <p>onMouseOver.</p>
*
* @param renderable a {@link org.loboevolution.html.renderer.BaseBoundableRenderable} object.
* @param nodeStart a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
* @param limit a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
*/
public void onMouseOver(final BaseBoundableRenderable renderable, final ModelNode nodeStart, final MouseEvent event, final int x, final int y, final ModelNode limit) {
ModelNode node = nodeStart;
while (node != null) {
if (node == limit) {
break;
}
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
uiElement.setMouseOver(true);
final Function f = uiElement.getOnmouseover();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("mouseover", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
Executor.executeFunction(uiElement, f, evt, new Object[0]);
}
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
if (rcontext != null) {
rcontext.onMouseOver(uiElement, event);
}
}
node = node.getParentModelNode();
}
setMouseOnMouseOver(renderable, nodeStart, limit);
}
use of org.mozilla.javascript.Function in project LoboEvolution by LoboEvolution.
the class HtmlController method onDoubleClick.
/**
* <p>onDoubleClick.</p>
*
* @return True to propagate further, false if consumed.
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
*/
public boolean onDoubleClick(ModelNode node, MouseEvent event, int x, int y) {
if (logger.isLoggable(Level.INFO)) {
logger.info("onDoubleClick(): node=" + node + ",class=" + node.getClass().getName());
}
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
final Function f = uiElement.getOndblclick();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("dblclick", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
if (!Executor.executeFunction(uiElement, f, evt, new Object[0])) {
return false;
}
}
final HtmlRendererContext rcontext = uiElement.getHtmlRendererContext();
if (rcontext != null) {
if (!rcontext.onDoubleClick(uiElement, event)) {
return false;
}
}
}
final ModelNode parent = node.getParentModelNode();
if (parent == null) {
return true;
}
return onDoubleClick(parent, event, 0, 0);
}
use of org.mozilla.javascript.Function in project LoboEvolution by LoboEvolution.
the class HtmlController method onMouseDown.
/**
* <p>onMouseDown.</p>
*
* @return True to propagate further, false if consumed.
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @param event a {@link java.awt.event.MouseEvent} object.
* @param x a int.
* @param y a int.
*/
public boolean onMouseDown(ModelNode node, MouseEvent event, int x, int y) {
boolean pass = true;
if (node instanceof HTMLElementImpl) {
final HTMLElementImpl uiElement = (HTMLElementImpl) node;
final Function f = uiElement.getOnmousedown();
if (f != null) {
final MouseEventImpl evt = new MouseEventImpl();
evt.initMouseEvent("mousedown", false, false, null, 0, 0, 0, x, y, true, true, true, true, (short) 0, null);
evt.setIe(event);
pass = Executor.executeFunction(uiElement, f, evt, new Object[0]);
}
}
if (node instanceof HTMLLinkElementImpl) {
((HTMLLinkElementImpl) node).getCurrentStyle().setOverlayColor("#9090FF80");
return false;
}
if (!pass) {
return false;
}
final ModelNode parent = node.getParentModelNode();
if (parent == null) {
return true;
}
return onMouseDown(parent, event, 0, 0);
}
use of org.mozilla.javascript.Function in project LoboEvolution by LoboEvolution.
the class HtmlController method onChange.
/**
* <p>onChange.</p>
*
* @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
* @return a boolean.
*/
public boolean onChange(ModelNode node) {
if (node instanceof HTMLSelectElementImpl) {
final HTMLSelectElementImpl uiElement = (HTMLSelectElementImpl) node;
final Function f = uiElement.getOnchange();
if (f != null) {
final EventImpl evt = new EventImpl();
evt.initEvent("change", false, false);
if (!Executor.executeFunction(uiElement, f, evt, new Object[0])) {
return false;
}
}
}
return false;
}
Aggregations