JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / appletgui / JVDialog.js
1 Clazz.declarePackage ("jalview.appletgui");\r
2 Clazz.load (["java.awt.Dialog", "java.awt.event.ActionListener", "awt2swing.Button"], "jalview.appletgui.JVDialog", ["awt2swing.Panel", "java.awt.FlowLayout"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.ap = null;\r
5 this.buttonPanel = null;\r
6 this.ok = null;\r
7 this.cancel = null;\r
8 this.accept = false;\r
9 this.owner = null;\r
10 Clazz.instantialize (this, arguments);\r
11 }, jalview.appletgui, "JVDialog", java.awt.Dialog, java.awt.event.ActionListener);\r
12 Clazz.prepareFields (c$, function () {\r
13 this.ok =  new awt2swing.Button ("Accept");\r
14 this.cancel =  new awt2swing.Button ("Cancel");\r
15 });\r
16 Clazz.makeConstructor (c$, \r
17 function (owner, title, modal, width, height) {\r
18 Clazz.superConstructor (this, jalview.appletgui.JVDialog, [owner, title, modal]);\r
19 this.owner = owner;\r
20 height += owner.getInsets ().top + this.getInsets ().bottom;\r
21 this.setBounds (owner.getBounds ().x + Clazz.doubleToInt ((owner.getSize ().width - width) / 2), owner.getBounds ().y + Clazz.doubleToInt ((owner.getSize ().height - height) / 2), width, height);\r
22 }, "awt2swing.Frame,~S,~B,~N,~N");\r
23 Clazz.defineMethod (c$, "setMainPanel", \r
24 function (panel) {\r
25 this.add (panel, "North");\r
26 this.buttonPanel =  new awt2swing.Panel ( new java.awt.FlowLayout ());\r
27 this.buttonPanel.add (this.ok);\r
28 this.buttonPanel.add (this.cancel);\r
29 this.ok.addActionListener (this);\r
30 this.cancel.addActionListener (this);\r
31 this.add (this.buttonPanel, "South");\r
32 this.pack ();\r
33 }, "awt2swing.Panel");\r
34 Clazz.overrideMethod (c$, "actionPerformed", \r
35 function (evt) {\r
36 if (evt.getSource () === this.ok) {\r
37 this.accept = true;\r
38 }this.setVisible (false);\r
39 }, "java.awt.event.ActionEvent");\r
40 });\r