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.client2serv;
15:
16: import org.itsnat.core.event.RemoteControlEvent;
17: import org.itsnat.impl.core.client.ClientDocumentInvitedRemoteCtrlImpl;
18: import org.itsnat.impl.core.ItsNatServletRequestImpl;
19: import org.itsnat.impl.core.listener.RemoteControlEventListenerWrapperImpl;
20:
21: /**
22: *
23: * @author jmarranz
24: */
25: public abstract class RemoteControlEventImpl extends ItsNatEventImpl
26: implements RemoteControlEvent {
27: protected boolean accepted = false;
28: protected int syncMode;
29: protected int phase;
30: protected long ajaxTimeout;
31:
32: /**
33: * Creates a new instance of RemoteControlEventImpl
34: */
35: public RemoteControlEventImpl(
36: RemoteControlEventListenerWrapperImpl listenerWrapper,
37: ItsNatServletRequestImpl request) {
38: super (listenerWrapper, request);
39:
40: this .accepted = true; // No estamos en la fase REQUEST, ya fue aceptada
41: }
42:
43: public RemoteControlEventImpl(int syncMode, long ajaxTimeout,
44: ItsNatServletRequestImpl request) {
45: super (null, request);
46:
47: this .phase = REQUEST;
48: this .syncMode = syncMode;
49: this .ajaxTimeout = ajaxTimeout;
50: }
51:
52: public RemoteControlEventListenerWrapperImpl getRemoteControlEventListenerWrapper() {
53: return (RemoteControlEventListenerWrapperImpl) listenerWrapper;
54: }
55:
56: public int getSyncMode() {
57: if (listenerWrapper != null)
58: return listenerWrapper.getSyncMode();
59: else
60: return syncMode;
61: }
62:
63: public int getPhase() {
64: if (listenerWrapper != null)
65: return getRemoteControlEventListenerWrapper().getPhase();
66: else
67: return phase;
68: }
69:
70: public long getAJAXTimeout() {
71: if (listenerWrapper != null)
72: return getRemoteControlEventListenerWrapper()
73: .getAJAXTimeout();
74: else
75: return ajaxTimeout;
76: }
77:
78: public boolean isAccepted() {
79: return accepted;
80: }
81:
82: public void setAccepted(boolean accepted) {
83: if (!accepted && (listenerWrapper != null)) {
84: ClientDocumentInvitedRemoteCtrlImpl observer = getRemoteControlEventListenerWrapper()
85: .getClientDocumentInvitedRemoteCtrl();
86: observer.setPhase(RemoteControlEvent.UNLOAD);
87: // De esta manera en cualquier momento podemos hacer terminar
88: // el observador desde el servidor.
89: }
90:
91: this.accepted = accepted;
92: }
93:
94: }
|