* will be added.
* @param node the <code>GraphicsNode</code>.
*/
public static void addDOMListener(BridgeContext ctx,
Element eee) {
SVGElement element = null;
EventTarget target = null;
try {
element = (SVGElement)eee;
// ability for scripts to be called
target = (EventTarget)element;
} catch (ClassCastException e) {
// will not work on this one!
return;
}
SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
if (svgElement == null) {
if (element.getLocalName().equals(SVG_SVG_TAG)) {
svgElement = (SVGSVGElement)element;
} else {
// something goes wrong => disable scripting
return;
}
}
String language = svgElement.getContentScriptType();
Interpreter interpret = null;
String script = null;
if (element.getLocalName().equals(SVG_SVG_TAG)) {
for (int i = 0; i < EVENT_ATTRIBUTES_SVG.length; i++) {
if (!(script = element.getAttribute(EVENT_ATTRIBUTES_SVG[i])).
equals("")) {
if (interpret == null) {
// try to get the intepreter only if we have
// a reason to do it!
interpret = ctx.getInterpreterPool().
getInterpreter(element.getOwnerDocument(), language);
// the interpreter is not avaible => stop it now!
if (interpret == null) {
UserAgent ua = ctx.getUserAgent();
if (ua != null)
ua.displayError(new Exception("unknow language: "+
language));
break;
}
}
// <!> TODO this will stop working if someone change
// the content of the event attribute
addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
new ScriptCaller(ctx.getUserAgent(),
script, interpret));
}
}
// continue
} else
if (element.getLocalName().equals("set") ||
element.getLocalName().startsWith("animate")) {
for (int i = 0; i < EVENT_ATTRIBUTES_ANIMATION.length; i++) {
if (!(script =
element.getAttribute(EVENT_ATTRIBUTES_ANIMATION[i])).
equals("")) {
if (interpret == null) {
// try to get the intepreter only if we have
// a reason to do it!
interpret = ctx.getInterpreterPool().
getInterpreter(element.getOwnerDocument(),
language);
// the interpreter is not avaible => stop it now!
if (interpret == null) {
UserAgent ua = ctx.getUserAgent();
if (ua != null)
ua.displayError(new Exception("unknow language: "+
language));
break;
}
}
// <!> TODO this will stop working if someone change
// the content of the event attribute
addScriptCaller(target, EVENT_NAMES[i+
FIRST_ANIMATION_EVENT],
new ScriptCaller(ctx.getUserAgent(),
script, interpret));
}
}
// not other stuff to do on this kind of events
return;
}
for (int i = 0; i < EVENT_ATTRIBUTES_GRAPHICS.length; i++) {
if (!(script = element.getAttribute(EVENT_ATTRIBUTES_GRAPHICS[i])).
equals("")) {
if (interpret == null) {
// try to get the intepreter only if we have
// a reason to do it!
interpret = ctx.getInterpreterPool().
getInterpreter(element.getOwnerDocument(), language);
// the interpreter is not avaible => stop it now!
if (interpret == null) {
UserAgent ua = ctx.getUserAgent();
if (ua != null)
ua.displayError(new Exception("unknow language: "+