JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / swingjs / j2s / javax / swing / ProgressMonitor.js
1 Clazz.declarePackage ("javax.swing");\r
2 Clazz.load (["javax.swing.JOptionPane"], "javax.swing.ProgressMonitor", ["java.awt.BorderLayout", "$.Frame", "java.awt.event.WindowAdapter", "java.beans.PropertyChangeListener", "javax.swing.JDialog", "$.JLabel", "$.JProgressBar", "$.SwingUtilities", "javax.swing.SwingUtilities.SharedOwnerFrame", "javax.swing.UIManager"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.root = null;\r
5 this.dialog = null;\r
6 this.pane = null;\r
7 this.myBar = null;\r
8 this.noteLabel = null;\r
9 this.parentComponent = null;\r
10 this.note = null;\r
11 this.cancelOption = null;\r
12 this.message = null;\r
13 this.T0 = 0;\r
14 this.millisToDecideToPopup = 500;\r
15 this.millisToPopup = 2000;\r
16 this.min = 0;\r
17 this.max = 0;\r
18 if (!Clazz.isClassDefined ("javax.swing.ProgressMonitor.ProgressOptionPane")) {\r
19 javax.swing.ProgressMonitor.$ProgressMonitor$ProgressOptionPane$ ();\r
20 }\r
21 Clazz.instantialize (this, arguments);\r
22 }, javax.swing, "ProgressMonitor");\r
23 Clazz.makeConstructor (c$, \r
24 function (parentComponent, message, note, min, max) {\r
25 this.construct (parentComponent, message, note, min, max, null);\r
26 }, "java.awt.Component,~O,~S,~N,~N");\r
27 Clazz.makeConstructor (c$, \r
28  function (parentComponent, message, note, min, max, group) {\r
29 this.min = min;\r
30 this.max = max;\r
31 this.parentComponent = parentComponent;\r
32 this.cancelOption =  new Array (1);\r
33 this.cancelOption[0] = javax.swing.UIManager.getString ("OptionPane.cancelButtonText");\r
34 this.message = message;\r
35 this.note = note;\r
36 if (group != null) {\r
37 this.root = (group.root != null) ? group.root : group;\r
38 this.T0 = this.root.T0;\r
39 this.dialog = this.root.dialog;\r
40 } else {\r
41 this.T0 = System.currentTimeMillis ();\r
42 }}, "java.awt.Component,~O,~S,~N,~N,javax.swing.ProgressMonitor");\r
43 Clazz.defineMethod (c$, "setProgress", \r
44 function (nv) {\r
45 if (nv >= this.max) {\r
46 this.close ();\r
47 } else {\r
48 if (this.myBar != null) {\r
49 this.myBar.setValue (nv);\r
50 } else {\r
51 var T = System.currentTimeMillis ();\r
52 var dT = (T - this.T0);\r
53 if (dT >= this.millisToDecideToPopup) {\r
54 var predictedCompletionTime;\r
55 if (nv > this.min) {\r
56 predictedCompletionTime = (Clazz.doubleToInt (dT * (this.max - this.min) / (nv - this.min)));\r
57 } else {\r
58 predictedCompletionTime = this.millisToPopup;\r
59 }if (predictedCompletionTime >= this.millisToPopup) {\r
60 this.myBar =  new javax.swing.JProgressBar ();\r
61 this.myBar.setMinimum (this.min);\r
62 this.myBar.setMaximum (this.max);\r
63 this.myBar.setValue (nv);\r
64 if (this.note != null) this.noteLabel =  new javax.swing.JLabel (this.note);\r
65 this.pane = Clazz.innerTypeInstance (javax.swing.ProgressMonitor.ProgressOptionPane, this, null,  Clazz.newArray (-1, [this.message, this.noteLabel, this.myBar]));\r
66 this.dialog = this.pane.createDialog (this.parentComponent, javax.swing.UIManager.getString ("ProgressMonitor.progressText"));\r
67 this.dialog.show ();\r
68 }}}}}, "~N");\r
69 Clazz.defineMethod (c$, "close", \r
70 function () {\r
71 if (this.dialog != null) {\r
72 this.dialog.setVisible (false);\r
73 this.dialog.dispose ();\r
74 this.dialog = null;\r
75 this.pane = null;\r
76 this.myBar = null;\r
77 }});\r
78 Clazz.defineMethod (c$, "getMinimum", \r
79 function () {\r
80 return this.min;\r
81 });\r
82 Clazz.defineMethod (c$, "setMinimum", \r
83 function (m) {\r
84 if (this.myBar != null) {\r
85 this.myBar.setMinimum (m);\r
86 }this.min = m;\r
87 }, "~N");\r
88 Clazz.defineMethod (c$, "getMaximum", \r
89 function () {\r
90 return this.max;\r
91 });\r
92 Clazz.defineMethod (c$, "setMaximum", \r
93 function (m) {\r
94 if (this.myBar != null) {\r
95 this.myBar.setMaximum (m);\r
96 }this.max = m;\r
97 }, "~N");\r
98 Clazz.defineMethod (c$, "isCanceled", \r
99 function () {\r
100 if (this.pane == null) return false;\r
101 var v = this.pane.getValue ();\r
102 return ((v != null) && (this.cancelOption.length == 1) && (v.equals (this.cancelOption[0])));\r
103 });\r
104 Clazz.defineMethod (c$, "setMillisToDecideToPopup", \r
105 function (millisToDecideToPopup) {\r
106 this.millisToDecideToPopup = millisToDecideToPopup;\r
107 }, "~N");\r
108 Clazz.defineMethod (c$, "getMillisToDecideToPopup", \r
109 function () {\r
110 return this.millisToDecideToPopup;\r
111 });\r
112 Clazz.defineMethod (c$, "setMillisToPopup", \r
113 function (millisToPopup) {\r
114 this.millisToPopup = millisToPopup;\r
115 }, "~N");\r
116 Clazz.defineMethod (c$, "getMillisToPopup", \r
117 function () {\r
118 return this.millisToPopup;\r
119 });\r
120 Clazz.defineMethod (c$, "setNote", \r
121 function (note) {\r
122 this.note = note;\r
123 if (this.noteLabel != null) {\r
124 this.noteLabel.setText (note);\r
125 }}, "~S");\r
126 Clazz.defineMethod (c$, "getNote", \r
127 function () {\r
128 return this.note;\r
129 });\r
130 c$.$ProgressMonitor$ProgressOptionPane$ = function () {\r
131 Clazz.pu$h(self.c$);\r
132 c$ = Clazz.decorateAsClass (function () {\r
133 Clazz.prepareCallback (this, arguments);\r
134 Clazz.instantialize (this, arguments);\r
135 }, javax.swing.ProgressMonitor, "ProgressOptionPane", javax.swing.JOptionPane);\r
136 Clazz.makeConstructor (c$, \r
137 function (a) {\r
138 Clazz.superConstructor (this, javax.swing.ProgressMonitor.ProgressOptionPane, [a, 1, -1, null, this.b$["javax.swing.ProgressMonitor"].cancelOption, null]);\r
139 }, "~O");\r
140 Clazz.overrideMethod (c$, "getMaxCharactersPerLineCount", \r
141 function () {\r
142 return 60;\r
143 });\r
144 Clazz.defineMethod (c$, "createDialog", \r
145 function (a, b) {\r
146 var $private = Clazz.checkPrivateMethod (arguments);\r
147 if ($private != null) {\r
148 return $private.apply (this, arguments);\r
149 }\r
150 var c;\r
151 var d = javax.swing.JOptionPane.getWindowForComponent (a);\r
152 if (Clazz.instanceOf (d, java.awt.Frame)) {\r
153 c =  new javax.swing.JDialog (d, b, false);\r
154 } else {\r
155 c =  new javax.swing.JDialog (d, b, false);\r
156 }if (Clazz.instanceOf (d, javax.swing.SwingUtilities.SharedOwnerFrame)) {\r
157 var e = javax.swing.SwingUtilities.getSharedOwnerFrameShutdownListener ();\r
158 c.addWindowListener (e);\r
159 }var e = c.getContentPane ();\r
160 e.setLayout ( new java.awt.BorderLayout ());\r
161 e.add (this, "Center");\r
162 c.pack ();\r
163 c.setLocationRelativeTo (a);\r
164 c.addWindowListener (((Clazz.isClassDefined ("javax.swing.ProgressMonitor$ProgressOptionPane$1") ? 0 : javax.swing.ProgressMonitor.ProgressOptionPane.$ProgressMonitor$ProgressOptionPane$1$ ()), Clazz.innerTypeInstance (javax.swing.ProgressMonitor$ProgressOptionPane$1, this, null)));\r
165 this.addPropertyChangeListener (((Clazz.isClassDefined ("javax.swing.ProgressMonitor$ProgressOptionPane$2") ? 0 : javax.swing.ProgressMonitor.ProgressOptionPane.$ProgressMonitor$ProgressOptionPane$2$ ()), Clazz.innerTypeInstance (javax.swing.ProgressMonitor$ProgressOptionPane$2, this, Clazz.cloneFinals ("c", c))));\r
166 return c;\r
167 }, "java.awt.Component,~S");\r
168 c$.$ProgressMonitor$ProgressOptionPane$1$ = function () {\r
169 Clazz.pu$h(self.c$);\r
170 c$ = Clazz.decorateAsClass (function () {\r
171 Clazz.prepareCallback (this, arguments);\r
172 this.gotFocus = false;\r
173 Clazz.instantialize (this, arguments);\r
174 }, javax.swing, "ProgressMonitor$ProgressOptionPane$1", java.awt.event.WindowAdapter);\r
175 Clazz.overrideMethod (c$, "windowClosing", \r
176 function (a) {\r
177 this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"].setValue (this.b$["javax.swing.ProgressMonitor"].cancelOption[0]);\r
178 }, "java.awt.event.WindowEvent");\r
179 Clazz.overrideMethod (c$, "windowActivated", \r
180 function (a) {\r
181 if (!this.gotFocus) {\r
182 this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"].selectInitialValue ();\r
183 this.gotFocus = true;\r
184 }}, "java.awt.event.WindowEvent");\r
185 c$ = Clazz.p0p ();\r
186 };\r
187 c$.$ProgressMonitor$ProgressOptionPane$2$ = function () {\r
188 Clazz.pu$h(self.c$);\r
189 c$ = Clazz.declareAnonymous (javax.swing, "ProgressMonitor$ProgressOptionPane$2", null, java.beans.PropertyChangeListener);\r
190 Clazz.overrideMethod (c$, "propertyChange", \r
191 function (a) {\r
192 if (this.f$.c.isVisible () && a.getSource () === this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"] && (a.getPropertyName ().equals ("value") || a.getPropertyName ().equals ("inputValue"))) {\r
193 this.f$.c.setVisible (false);\r
194 this.f$.c.dispose ();\r
195 }}, "java.beans.PropertyChangeEvent");\r
196 c$ = Clazz.p0p ();\r
197 };\r
198 c$ = Clazz.p0p ();\r
199 };\r
200 });\r