01: /*
02: * Copyright 2000,2005 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: package org.wings.plaf.css;
14:
15: import org.wings.*;
16: import org.wings.io.Device;
17: import org.wings.plaf.css.script.OnPageRenderedScript;
18: import org.wings.session.ScriptManager;
19:
20: import java.io.IOException;
21:
22: public class DialogCG extends WindowCG implements
23: org.wings.plaf.DialogCG {
24:
25: public void writeInternal(Device device, SComponent component)
26: throws IOException {
27:
28: SDialog dialog = (SDialog) component;
29: SRootContainer owner = dialog.getOwner();
30:
31: String name = dialog.getName();
32:
33: device.print("\n\n"
34: + "<div id=\""
35: + name
36: + "\">\n"
37: + " <div class=\"hd\">"
38: + (dialog.getTitle() != null ? dialog.getTitle()
39: : " ") + "</div>\n"
40: + " <div class=\"bd\">");
41:
42: super .writeInternal(device, dialog);
43:
44: device.print(" </div>\n" + "</div>\n");
45:
46: StringBuilder sb = new StringBuilder();
47: sb.append("var dialog_").append(name).append(
48: " = new wingS.dialog.SDialog(\"").append(name).append(
49: "\"").append(", {");
50:
51: if (dialog.getX() > -1 && dialog.getY() > -1) {
52: sb.append("x:").append(dialog.getX()).append(",").append(
53: "y:").append(dialog.getY()).append(",");
54: } else {
55: sb.append("fixedcenter:true").append(",");
56: }
57:
58: if (!(owner instanceof SFrame))
59: sb.append("viewportelement:\"").append(owner.getName())
60: .append("\",");
61:
62: sb.append("visible:").append(dialog.isVisible()).append(",")
63: .append("modal:").append(dialog.isModal()).append(",")
64: .append("draggable:").append(dialog.isDraggable())
65: .append(",").append("close:").append(
66: dialog.isClosable()).append(",").append(
67: "constraintoviewport:true").append(
68: "}); dialog_").append(name).append(
69: ".render();\n");
70:
71: // sb.append("var resize = new YAHOO.util.Resize(\"").append("dialog_").append(name).append("\", {")
72: // .append("handles: ['br'],")
73: // .append("autoRatio: false,")
74: // .append("minWidth: 300,")
75: // .append("minHeight: 100,")
76: // .append("status: true")
77: // .append("});");
78:
79: ScriptManager.getInstance().addScriptListener(
80: new OnPageRenderedScript(sb.toString()));
81: }
82: }
|