Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / javax / swing / ProgressMonitor.js
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 () {
4 this.root = null;
5 this.dialog = null;
6 this.pane = null;
7 this.myBar = null;
8 this.noteLabel = null;
9 this.parentComponent = null;
10 this.note = null;
11 this.cancelOption = null;
12 this.message = null;
13 this.T0 = 0;
14 this.millisToDecideToPopup = 500;
15 this.millisToPopup = 2000;
16 this.min = 0;
17 this.max = 0;
18 if (!Clazz.isClassDefined ("javax.swing.ProgressMonitor.ProgressOptionPane")) {
19 javax.swing.ProgressMonitor.$ProgressMonitor$ProgressOptionPane$ ();
20 }
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) {
29 this.min = min;
30 this.max = max;
31 this.parentComponent = parentComponent;
32 this.cancelOption =  new Array (1);
33 this.cancelOption[0] = javax.swing.UIManager.getString ("OptionPane.cancelButtonText");
34 this.message = message;
35 this.note = note;
36 if (group != null) {
37 this.root = (group.root != null) ? group.root : group;
38 this.T0 = this.root.T0;
39 this.dialog = this.root.dialog;
40 } else {
41 this.T0 = System.currentTimeMillis ();
42 }}, "java.awt.Component,~O,~S,~N,~N,javax.swing.ProgressMonitor");
43 Clazz.defineMethod (c$, "setProgress", 
44 function (nv) {
45 if (nv >= this.max) {
46 this.close ();
47 } else {
48 if (this.myBar != null) {
49 this.myBar.setValue (nv);
50 } else {
51 var T = System.currentTimeMillis ();
52 var dT = (T - this.T0);
53 if (dT >= this.millisToDecideToPopup) {
54 var predictedCompletionTime;
55 if (nv > this.min) {
56 predictedCompletionTime = (Clazz.doubleToInt (dT * (this.max - this.min) / (nv - this.min)));
57 } else {
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"));
67 this.dialog.show ();
68 }}}}}, "~N");
69 Clazz.defineMethod (c$, "close", 
70 function () {
71 if (this.dialog != null) {
72 this.dialog.setVisible (false);
73 this.dialog.dispose ();
74 this.dialog = null;
75 this.pane = null;
76 this.myBar = null;
77 }});
78 Clazz.defineMethod (c$, "getMinimum", 
79 function () {
80 return this.min;
81 });
82 Clazz.defineMethod (c$, "setMinimum", 
83 function (m) {
84 if (this.myBar != null) {
85 this.myBar.setMinimum (m);
86 }this.min = m;
87 }, "~N");
88 Clazz.defineMethod (c$, "getMaximum", 
89 function () {
90 return this.max;
91 });
92 Clazz.defineMethod (c$, "setMaximum", 
93 function (m) {
94 if (this.myBar != null) {
95 this.myBar.setMaximum (m);
96 }this.max = m;
97 }, "~N");
98 Clazz.defineMethod (c$, "isCanceled", 
99 function () {
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])));
103 });
104 Clazz.defineMethod (c$, "setMillisToDecideToPopup", 
105 function (millisToDecideToPopup) {
106 this.millisToDecideToPopup = millisToDecideToPopup;
107 }, "~N");
108 Clazz.defineMethod (c$, "getMillisToDecideToPopup", 
109 function () {
110 return this.millisToDecideToPopup;
111 });
112 Clazz.defineMethod (c$, "setMillisToPopup", 
113 function (millisToPopup) {
114 this.millisToPopup = millisToPopup;
115 }, "~N");
116 Clazz.defineMethod (c$, "getMillisToPopup", 
117 function () {
118 return this.millisToPopup;
119 });
120 Clazz.defineMethod (c$, "setNote", 
121 function (note) {
122 this.note = note;
123 if (this.noteLabel != null) {
124 this.noteLabel.setText (note);
125 }}, "~S");
126 Clazz.defineMethod (c$, "getNote", 
127 function () {
128 return this.note;
129 });
130 c$.$ProgressMonitor$ProgressOptionPane$ = function () {
131 Clazz.pu$h(self.c$);
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$, 
137 function (a) {
138 Clazz.superConstructor (this, javax.swing.ProgressMonitor.ProgressOptionPane, [a, 1, -1, null, this.b$["javax.swing.ProgressMonitor"].cancelOption, null]);
139 }, "~O");
140 Clazz.overrideMethod (c$, "getMaxCharactersPerLineCount", 
141 function () {
142 return 60;
143 });
144 Clazz.defineMethod (c$, "createDialog", 
145 function (a, b) {
146 var $private = Clazz.checkPrivateMethod (arguments);
147 if ($private != null) {
148 return $private.apply (this, arguments);
149 }
150 var c;
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);
154 } else {
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");
162 c.pack ();
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))));
166 return c;
167 }, "java.awt.Component,~S");
168 c$.$ProgressMonitor$ProgressOptionPane$1$ = function () {
169 Clazz.pu$h(self.c$);
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", 
176 function (a) {
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", 
180 function (a) {
181 if (!this.gotFocus) {
182 this.b$["javax.swing.ProgressMonitor.ProgressOptionPane"].selectInitialValue ();
183 this.gotFocus = true;
184 }}, "java.awt.event.WindowEvent");
185 c$ = Clazz.p0p ();
186 };
187 c$.$ProgressMonitor$ProgressOptionPane$2$ = function () {
188 Clazz.pu$h(self.c$);
189 c$ = Clazz.declareAnonymous (javax.swing, "ProgressMonitor$ProgressOptionPane$2", null, java.beans.PropertyChangeListener);
190 Clazz.overrideMethod (c$, "propertyChange", 
191 function (a) {
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");
196 c$ = Clazz.p0p ();
197 };
198 c$ = Clazz.p0p ();
199 };
200 });