JAL-1807 test
[jalviewjs.git] / bin / javajs / swing / JDialog.js
1 Clazz.declarePackage ("javajs.swing");
2 Clazz.load (["javajs.awt.Container"], "javajs.swing.JDialog", ["javajs.awt.Color", "javajs.swing.JContentPane", "javajs.util.SB"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.defaultWidth = 600;
5 this.defaultHeight = 300;
6 this.contentPane = null;
7 this.title = null;
8 this.html = null;
9 this.zIndex = 9000;
10 this.loc = null;
11 Clazz.instantialize (this, arguments);
12 }, javajs.swing, "JDialog", javajs.awt.Container);
13 Clazz.defineMethod (c$, "setZIndex", 
14 function (zIndex) {
15 this.zIndex = zIndex;
16 }, "~N");
17 Clazz.makeConstructor (c$, 
18 function () {
19 Clazz.superConstructor (this, javajs.swing.JDialog, ["JD"]);
20 this.add (this.contentPane =  new javajs.swing.JContentPane ());
21 this.setBackground (javajs.awt.Color.get3 (210, 210, 240));
22 this.contentPane.setBackground (javajs.awt.Color.get3 (230, 230, 230));
23 });
24 Clazz.defineMethod (c$, "setLocation", 
25 function (loc) {
26 this.loc = loc;
27 }, "~A");
28 Clazz.defineMethod (c$, "getContentPane", 
29 function () {
30 return this.contentPane;
31 });
32 Clazz.defineMethod (c$, "setTitle", 
33 function (title) {
34 this.title = title;
35 }, "~S");
36 Clazz.defineMethod (c$, "pack", 
37 function () {
38 this.html = null;
39 });
40 Clazz.defineMethod (c$, "validate", 
41 function () {
42 this.html = null;
43 });
44 Clazz.defineMethod (c$, "setVisible", 
45 function (tf) {
46 if (tf && this.html == null) this.setDialog ();
47 Clazz.superCall (this, javajs.swing.JDialog, "setVisible", [tf]);
48 }, "~B");
49 Clazz.defineMethod (c$, "dispose", 
50 function () {
51 {
52 {
53 SwingController.dispose(this);
54 }}});
55 Clazz.overrideMethod (c$, "repaint", 
56 function () {
57 this.setDialog ();
58 });
59 Clazz.defineMethod (c$, "setDialog", 
60 ($fz = function () {
61 this.html = this.toHTML ();
62 {
63 SwingController.setDialog(this);
64 }}, $fz.isPrivate = true, $fz));
65 Clazz.overrideMethod (c$, "toHTML", 
66 function () {
67 this.renderWidth = this.getSubcomponentWidth ();
68 if (this.renderWidth == 0) this.renderWidth = this.defaultWidth;
69 this.renderHeight = this.contentPane.getSubcomponentHeight ();
70 if (this.renderHeight == 0) this.renderHeight = this.defaultHeight;
71 var h = this.renderHeight - 25;
72 var sb =  new javajs.util.SB ();
73 sb.append ("\n<div id='" + this.id + "' class='JDialog' style='" + this.getCSSstyle (0, 0) + "z-index:" + this.zIndex + ";position:relative;top:0px;left:0px;reize:both;'>\n");
74 sb.append ("\n<div id='" + this.id + "_title' class='JDialogTitle' style='width:100%;height:25px;padding:5px 5px 5px 5px;height:" + 25 + "px'>" + "<span style='text-align:center;'>" + this.title + "</span><span style='position:absolute;text-align:right;right:1px;'>" + "<input type=button id='" + this.id + "_closer' onclick='SwingController.windowClosing(this)' value='x' /></span></div>\n");
75 sb.append ("\n<div id='" + this.id + "_body' class='JDialogBody' style='width:100%;height:" + h + "px;" + "position: relative;left:0px;top:0px'>\n");
76 sb.append (this.contentPane.toHTML ());
77 sb.append ("\n</div></div>\n");
78 return sb.toString ();
79 });
80 Clazz.defineStatics (c$,
81 "headerHeight", 25);
82 });