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.java.awt;
22:
23: import java.awt.Window;
24: import java.util.Map;
25: import java.util.logging.Logger;
26: import org.onemind.awtbridge.input.BridgeInputContext;
27: import org.onemind.awtbridge.input.InputException;
28: import org.onemind.awtbridge.peer.BridgeComponentPeer;
29: import org.onemind.awtbridge.peer.BridgePeer;
30: import org.onemind.commons.java.util.StringUtils;
31: import org.onemind.swingweb.mapinput.peerdelegate.MapInputDelegate;
32:
33: /**
34: * The frame input delegate
35: * @author TiongHiang Lee (thlee@onemindsoft.org)
36: *
37: */
38: public class WindowInputDelegate extends ContainerInputDelegate {
39:
40: /** the logger **/
41: private static final Logger _logger = Logger
42: .getLogger(WindowInputDelegate.class.getName());
43:
44: /** the instance **/
45: public static MapInputDelegate INSTANCE = new WindowInputDelegate();
46:
47: /**
48: * {@inheritDoc}
49: */
50: public void processInput(BridgeComponentPeer peer,
51: BridgeInputContext context, Map inputForm)
52: throws InputException {
53: if (hasWindowEvent(peer, inputForm)) {
54: processWindowEvent(peer, context, inputForm);
55: } else {
56: super .processInput(peer, context, inputForm);
57: }
58: }
59:
60: public void processWindowEvent(BridgeComponentPeer peer,
61: BridgeInputContext context, Map inputForm) {
62: Window w = (Window) peer.getComponent();
63: String value = (String) inputForm.get(peer.getId());
64: if ("close".equals(value)) {
65: w.dispose();
66: } else {
67: _logger.warning("Unknown action " + value + " to " + w);
68: }
69: return;
70: }
71:
72: /**
73: * {@inheritDoc}
74: */
75: public boolean hasWindowEvent(BridgePeer peer, Map form) {
76: return !StringUtils.isNullOrEmpty(form.get(peer.getId()));
77: }
78: }
|