1 Clazz.declarePackage ("javax.swing");
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 () {
3 c$ = Clazz.decorateAsClass (function () {
9 this.parentComponent = null;
11 this.cancelOption = null;
14 this.millisToDecideToPopup = 500;
15 this.millisToPopup = 2000;
18 if (!Clazz.isClassDefined ("javax.swing.ProgressMonitor.ProgressOptionPane")) {
19 javax.swing.ProgressMonitor.$ProgressMonitor$ProgressOptionPane$ ();
21 Clazz.instantialize (this, arguments);
22 }, javax.swing, "ProgressMonitor");
23 Clazz.makeConstructor (c$,
24 function (parentComponent, message, note, min, max) {
25 this.construct (parentComponent, message, note, min, max, null);
26 }, "java.awt.Component,~O,~S,~N,~N");
27 Clazz.makeConstructor (c$,
28 function (parentComponent, message, note, min, max, group) {
31 this.parentComponent = parentComponent;
32 this.cancelOption = new Array (1);
33 this.cancelOption[0] = javax.swing.UIManager.getString ("OptionPane.cancelButtonText");
34 this.message = message;
37 this.root = (group.root != null) ? group.root : group;
38 this.T0 = this.root.T0;
39 this.dialog = this.root.dialog;
41 this.T0 = System.currentTimeMillis ();
42 }}, "java.awt.Component,~O,~S,~N,~N,javax.swing.ProgressMonitor");
43 Clazz.defineMethod (c$, "setProgress",
48 if (this.myBar != null) {
49 this.myBar.setValue (nv);
51 var T = System.currentTimeMillis ();
52 var dT = (T - this.T0);
53 if (dT >= this.millisToDecideToPopup) {
54 var predictedCompletionTime;
56 predictedCompletionTime = (Clazz.doubleToInt (dT * (this.max - this.min) / (nv - this.min)));
58 predictedCompletionTime = this.millisToPopup;
59 }if (predictedCompletionTime >= this.millisToPopup) {
60 this.myBar = new javax.swing.JProgressBar ();
61 this.myBar.setMinimum (this.min);
62 this.myBar.setMaximum (this.max);
63 this.myBar.setValue (nv);
64 if (this.note != null) this.noteLabel = new javax.swing.JLabel (this.note);
65 this.pane = Clazz.innerTypeInstance (javax.swing.ProgressMonitor.ProgressOptionPane, this, null, Clazz.newArray (-1, [this.message, this.noteLabel, this.myBar]));
66 this.dialog = this.pane.createDialog (this.parentComponent, javax.swing.UIManager.getString ("ProgressMonitor.progressText"));
69 Clazz.defineMethod (c$, "close",
71 if (this.dialog != null) {
72 this.dialog.setVisible (false);
73 this.dialog.dispose ();
78 Clazz.defineMethod (c$, "getMinimum",
82 Clazz.defineMethod (c$, "setMinimum",
84 if (this.myBar != null) {
85 this.myBar.setMinimum (m);
88 Clazz.defineMethod (c$, "getMaximum",
92 Clazz.defineMethod (c$, "setMaximum",
94 if (this.myBar != null) {
95 this.myBar.setMaximum (m);
98 Clazz.defineMethod (c$, "isCanceled",
100 if (this.pane == null) return false;
101 var v = this.pane.getValue ();
102 return ((v != null) && (this.cancelOption.length == 1) && (v.equals (this.cancelOption[0])));
104 Clazz.defineMethod (c$, "setMillisToDecideToPopup",
105 function (millisToDecideToPopup) {
106 this.millisToDecideToPopup = millisToDecideToPopup;
108 Clazz.defineMethod (c$, "getMillisToDecideToPopup",
110 return this.millisToDecideToPopup;
112 Clazz.defineMethod (c$, "setMillisToPopup",
113 function (millisToPopup) {
114 this.millisToPopup = millisToPopup;
116 Clazz.defineMethod (c$, "getMillisToPopup",
118 return this.millisToPopup;
120 Clazz.defineMethod (c$, "setNote",
123 if (this.noteLabel != null) {
124 this.noteLabel.setText (note);
126 Clazz.defineMethod (c$, "getNote",
130 c$.$ProgressMonitor$ProgressOptionPane$ = function () {
132 c$ = Clazz.decorateAsClass (function () {
133 Clazz.prepareCallback (this, arguments);
134 Clazz.instantialize (this, arguments);
135 }, javax.swing.ProgressMonitor, "ProgressOptionPane", javax.swing.JOptionPane);
136 Clazz.makeConstructor (c$,
138 Clazz.superConstructor (this, javax.swing.ProgressMonitor.ProgressOptionPane, [a, 1, -1, null, this.b$["javax.swing.ProgressMonitor"].cancelOption, null]);
140 Clazz.overrideMethod (c$, "getMaxCharactersPerLineCount",
144 Clazz.defineMethod (c$, "createDialog",
146 var $private = Clazz.checkPrivateMethod (arguments);
147 if ($private != null) {
148 return $private.apply (this, arguments);
151 var d = javax.swing.JOptionPane.getWindowForComponent (a);
152 if (Clazz.instanceOf (d, java.awt.Frame)) {
153 c = new javax.swing.JDialog (d, b, false);
155 c = new javax.swing.JDialog (d, b, false);
156 }if (Clazz.instanceOf (d, javax.swing.SwingUtilities.SharedOwnerFrame)) {
157 var e = javax.swing.SwingUtilities.getSharedOwnerFrameShutdownListener ();
158 c.addWindowListener (e);
159 }var e = c.getContentPane ();
160 e.setLayout ( new java.awt.BorderLayout ());
161 e.add (this, "Center");
163 c.setLocationRelativeTo (a);
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)));
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))));
167 }, "java.awt.Component,~S");
168 c$.$ProgressMonitor$ProgressOptionPane$1$ = function () {
170 c$ = Clazz.decorateAsClass (function () {
171 Clazz.prepareCallback (this, arguments);
172 this.gotFocus = false;
173 Clazz.instantialize (this, arguments);
174 }, javax.swing, "ProgressMonitor$ProgressOptionPane$1", java.awt.event.WindowAdapter);
175 Clazz.overrideMethod (c$, "windowClosing",
177 this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"].setValue (this.b$["javax.swing.ProgressMonitor"].cancelOption[0]);
178 }, "java.awt.event.WindowEvent");
179 Clazz.overrideMethod (c$, "windowActivated",
181 if (!this.gotFocus) {
182 this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"].selectInitialValue ();
183 this.gotFocus = true;
184 }}, "java.awt.event.WindowEvent");
187 c$.$ProgressMonitor$ProgressOptionPane$2$ = function () {
189 c$ = Clazz.declareAnonymous (javax.swing, "ProgressMonitor$ProgressOptionPane$2", null, java.beans.PropertyChangeListener);
190 Clazz.overrideMethod (c$, "propertyChange",
192 if (this.f$.c.isVisible () && a.getSource () === this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"] && (a.getPropertyName ().equals ("value") || a.getPropertyName ().equals ("inputValue"))) {
193 this.f$.c.setVisible (false);
194 this.f$.c.dispose ();
195 }}, "java.beans.PropertyChangeEvent");