01: /*
02: #IFNDEF ALT_LICENSE
03: ThinWire(R) RIA Ajax Framework
04: Copyright (C) 2003-2007 Custom Credit Systems
05:
06: This library is free software; you can redistribute it and/or modify it under
07: the terms of the GNU Lesser General Public License as published by the Free
08: Software Foundation; either version 2.1 of the License, or (at your option) any
09: later version.
10:
11: This library is distributed in the hope that it will be useful, but WITHOUT ANY
12: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14:
15: You should have received a copy of the GNU Lesser General Public License along
16: with this library; if not, write to the Free Software Foundation, Inc., 59
17: Temple Place, Suite 330, Boston, MA 02111-1307 USA
18:
19: Users who would rather have a commercial license, warranty or support should
20: contact the following company who invented, built and supports the technology:
21:
22: Custom Credit Systems, Richardson, TX 75081, USA.
23: email: info@thinwire.com ph: +1 (888) 644-6405
24: http://www.thinwire.com
25: #ENDIF
26: [ v1.2_RC2 ]
27: */
28: package thinwire.render.web;
29:
30: import thinwire.ui.Component;
31: import thinwire.ui.Dialog;
32: import thinwire.ui.event.PropertyChangeEvent;
33:
34: /**
35: * @author Joshua J. Gertzen
36: */
37: final class DialogRenderer extends WindowRenderer {
38: private static final String DIALOG_CLASS = "tw_Dialog";
39: private static final String SET_RESIZE_ALLOWED = "setResizeAllowed";
40: private static final String SET_REPOSITION_ALLOWED = "setRepositionAllowed";
41: private static final String SET_MODAL = "setModal";
42:
43: void render(WindowRenderer wr, Component c,
44: ComponentRenderer container) {
45: init(DIALOG_CLASS, wr, c, container);
46: Dialog d = (Dialog) c;
47: addInitProperty(Dialog.PROPERTY_RESIZE_ALLOWED, d
48: .isResizeAllowed());
49: addInitProperty(Dialog.PROPERTY_REPOSITION_ALLOWED, d
50: .isRepositionAllowed());
51:
52: if (!d.isModal()) {
53: for (Dialog diag : wr.ai.getFrame().getDialogs()) {
54: if (diag != d && diag.isModal()) {
55: throw new IllegalStateException(
56: "You cannot display a non-modal dialog while a modal dialog is visible.");
57: }
58: }
59: }
60:
61: addInitProperty(Dialog.PROPERTY_MODAL, d.isModal());
62: addClientSideProperty(Component.PROPERTY_X);
63: addClientSideProperty(Component.PROPERTY_Y);
64: addClientSideProperty(Component.PROPERTY_WIDTH);
65: addClientSideProperty(Component.PROPERTY_HEIGHT);
66: super .render(wr, c, container);
67: }
68:
69: public void propertyChange(PropertyChangeEvent pce) {
70: if (pce.getPropertyName()
71: .equals(Dialog.PROPERTY_RESIZE_ALLOWED)) {
72: postClientEvent(SET_RESIZE_ALLOWED, pce.getNewValue());
73: } else if (pce.getPropertyName().equals(
74: Dialog.PROPERTY_REPOSITION_ALLOWED)) {
75: postClientEvent(SET_REPOSITION_ALLOWED, pce.getNewValue());
76: } else if (pce.getPropertyName().equals(Dialog.PROPERTY_MODAL)) {
77: postClientEvent(SET_MODAL, pce.getNewValue());
78: } else {
79: super .propertyChange(pce);
80: }
81: }
82:
83: public void componentChange(WebComponentEvent event) {
84: String name = event.getName();
85: Dialog d = (Dialog) comp;
86:
87: if (name.equals("closeClick")) {
88: d.setVisible(false);
89: } else {
90: super.componentChange(event);
91: }
92: }
93: }
|