01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.core.event.fromserv.dom;
15:
16: import org.itsnat.core.event.DOMEvent;
17: import org.itsnat.impl.core.ItsNatDocumentImpl;
18: import org.itsnat.impl.core.event.fromserv.ServerDOMBasedEventImpl;
19: import org.w3c.dom.DOMException;
20: import org.w3c.dom.events.Event;
21:
22: /**
23: * Sirve para dos tipos de eventos:
24: * 1) Eventos creados en el servidor y enviados al cliente: El objeto evento no será "dispatched"
25: * a los listeners por lo que algunos métodos (getCurrentTarget() etc) no son útiles
26: * 2) Eventos creados en el servidor y "dispatched" localmente: hay que simular
27: * que el evento viene del cliente lo más posible.
28: *
29: * @author jmarranz
30: */
31: public abstract class ServerDOMEventImpl extends
32: ServerDOMBasedEventImpl implements DOMEvent {
33: /**
34: * Creates a new instance of ServerDOMEventImpl
35: */
36: public ServerDOMEventImpl(ItsNatDocumentImpl itsNatDoc) {
37: super (itsNatDoc);
38: }
39:
40: public static Event createDOMEvent(String eventGroup,
41: ItsNatDocumentImpl itsNatDoc) throws DOMException {
42: // http://developer.mozilla.org/en/docs/DOM:document.createEvent
43:
44: if ("UIEvents".equals(eventGroup)
45: || "UIEvent".equals(eventGroup))
46: return new ServerUIEventImpl(itsNatDoc);
47: else if ("MouseEvents".equals(eventGroup)
48: || "MouseEvent".equals(eventGroup))
49: return new ServerMouseEventImpl(itsNatDoc);
50: else if ("KeyEvents".equals(eventGroup)
51: || "KeyEvent".equals(eventGroup))
52: return new ServerKeyEventImpl(itsNatDoc);
53: else if ("MutationEvents".equals(eventGroup)
54: || "MutationEvent".equals(eventGroup))
55: return new ServerMutationEventImpl(itsNatDoc);
56: else if ("HTMLEvents".equals(eventGroup)
57: || "HTMLEvent".equals(eventGroup))
58: return new ServerHTMLEventImpl(itsNatDoc);
59: else if ("Events".equals(eventGroup)
60: || "Event".equals(eventGroup))
61: return new ServerDOMEventDefaultImpl(itsNatDoc);
62:
63: throw new DOMException(
64: DOMException.NOT_SUPPORTED_ERR,
65: "NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.");
66: }
67:
68: }
|