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
8 this.noteLabel = null;
\r
9 this.parentComponent = null;
\r
11 this.cancelOption = null;
\r
12 this.message = null;
\r
14 this.millisToDecideToPopup = 500;
\r
15 this.millisToPopup = 2000;
\r
18 if (!Clazz.isClassDefined ("javax.swing.ProgressMonitor.ProgressOptionPane")) {
\r
19 javax.swing.ProgressMonitor.$ProgressMonitor$ProgressOptionPane$ ();
\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
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
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
41 this.T0 = System.currentTimeMillis ();
\r
42 }}, "java.awt.Component,~O,~S,~N,~N,javax.swing.ProgressMonitor");
\r
43 Clazz.defineMethod (c$, "setProgress",
\r
45 if (nv >= this.max) {
\r
48 if (this.myBar != null) {
\r
49 this.myBar.setValue (nv);
\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
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
69 Clazz.defineMethod (c$, "close",
\r
71 if (this.dialog != null) {
\r
72 this.dialog.setVisible (false);
\r
73 this.dialog.dispose ();
\r
78 Clazz.defineMethod (c$, "getMinimum",
\r
82 Clazz.defineMethod (c$, "setMinimum",
\r
84 if (this.myBar != null) {
\r
85 this.myBar.setMinimum (m);
\r
88 Clazz.defineMethod (c$, "getMaximum",
\r
92 Clazz.defineMethod (c$, "setMaximum",
\r
94 if (this.myBar != null) {
\r
95 this.myBar.setMaximum (m);
\r
98 Clazz.defineMethod (c$, "isCanceled",
\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
104 Clazz.defineMethod (c$, "setMillisToDecideToPopup",
\r
105 function (millisToDecideToPopup) {
\r
106 this.millisToDecideToPopup = millisToDecideToPopup;
\r
108 Clazz.defineMethod (c$, "getMillisToDecideToPopup",
\r
110 return this.millisToDecideToPopup;
\r
112 Clazz.defineMethod (c$, "setMillisToPopup",
\r
113 function (millisToPopup) {
\r
114 this.millisToPopup = millisToPopup;
\r
116 Clazz.defineMethod (c$, "getMillisToPopup",
\r
118 return this.millisToPopup;
\r
120 Clazz.defineMethod (c$, "setNote",
\r
123 if (this.noteLabel != null) {
\r
124 this.noteLabel.setText (note);
\r
126 Clazz.defineMethod (c$, "getNote",
\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
138 Clazz.superConstructor (this, javax.swing.ProgressMonitor.ProgressOptionPane, [a, 1, -1, null, this.b$["javax.swing.ProgressMonitor"].cancelOption, null]);
\r
140 Clazz.overrideMethod (c$, "getMaxCharactersPerLineCount",
\r
144 Clazz.defineMethod (c$, "createDialog",
\r
146 var $private = Clazz.checkPrivateMethod (arguments);
\r
147 if ($private != null) {
\r
148 return $private.apply (this, arguments);
\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
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
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
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
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
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
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
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