01: /*
02: * Copyright 2006 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13:
14: package org.wings.script;
15:
16: import org.wings.SComponent;
17: import org.wings.SPopup;
18: import org.wings.plaf.css.PopupCG;
19:
20: /**
21: * A JavaScript listener to handle SPopup.
22: * @author Christian Schyma
23: */
24: public class PopupListener extends JavaScriptDOMListener {
25:
26: public static final int SHOW = 0;
27: public static final int HIDE = 1;
28:
29: /**
30: * This one is needed because SPopup is not nested in the component
31: * hierarchy and would otherwise be collected by the GC.
32: */
33: private final SPopup popup;
34:
35: /**
36: * @param event one of JavaScriptEvent (e.g. JavaScriptEvent.ON_CLICK) to act on
37: * @param popup SPopup component
38: * @param action PopupListener.SHOW | PopupListener.HIDE
39: * @param component the component this listener is associated with
40: */
41: public PopupListener(String event, SPopup popup, int action,
42: SComponent component) {
43: super (event, selectFunction(((PopupCG) popup.getCG()), action),
44: component);
45: this .popup = popup;
46: }
47:
48: private static String selectFunction(PopupCG popupCG, int action) {
49: switch (action) {
50: case SHOW:
51: return popupCG.getJsShowFunction();
52: case HIDE:
53: return popupCG.getJsHideFunction();
54: default:
55: return popupCG.getJsHideFunction();
56: }
57: }
58:
59: }
|