01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.mapinput.peerdelegate;
22:
23: import java.awt.AWTEvent;
24: import java.util.Map;
25: import org.onemind.awtbridge.event.BridgeEventQueue;
26: import org.onemind.awtbridge.input.BridgeInputContext;
27: import org.onemind.awtbridge.input.InputException;
28: import org.onemind.awtbridge.peer.BridgePeer;
29:
30: /**
31: * The default map input delegate
32: * @author TiongHiang Lee (thlee@onemindsoft.org)
33: *
34: */
35: public class DefaultMapInputDelegate extends MapInputDelegate {
36:
37: /** the instance **/
38: public static MapInputDelegate INSTANCE = new DefaultMapInputDelegate();
39:
40: /**
41: * {@inheritDoc}
42: */
43: public boolean hasEvent(BridgePeer peer, Map form) {
44: return form.containsKey(peer.getId());
45: }
46:
47: /**
48: * {@inheritDoc}
49: */
50: public void processInput(BridgePeer peer,
51: BridgeInputContext context, Map inputForm)
52: throws InputException {
53: //do nothing
54: }
55:
56: /**
57: * Post an event
58: * @param context the context
59: * @param peer the peer
60: * @param evt the event
61: */
62: protected final void postEvent(BridgeInputContext context,
63: AWTEvent evt) {
64: BridgeEventQueue q = (BridgeEventQueue) context.getEventQueue();
65: q.postEvent(evt);
66: }
67:
68: /**
69: * Post an event with specific priority
70: * @param context the context
71: * @param peer the peer
72: * @param disp the event dispatcher
73: * @param evt the event
74: * @param priority the priority
75: */
76: protected final void postEvent(BridgeInputContext context,
77: AWTEvent evt, int priority) {
78: BridgeEventQueue q = (BridgeEventQueue) context.getEventQueue();
79: q.postEvent(evt, priority);
80: }
81: }
|