1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.JComponent"], "javax.swing.JOptionPane", ["java.lang.RuntimeException", "java.awt.BorderLayout", "$.Dialog", "$.Frame", "java.awt.event.ComponentAdapter", "$.WindowAdapter", "java.beans.PropertyChangeListener", "javax.swing.JDialog", "$.SwingUtilities", "javax.swing.SwingUtilities.SharedOwnerFrame", "javax.swing.UIManager"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.initialValue = null;
11 this.selectionValues = null;
12 this.inputValue = null;
13 this.initialSelectionValue = null;
14 this.wantsInput = false;
15 Clazz.instantialize (this, arguments);
16 }, javax.swing, "JOptionPane", javax.swing.JComponent);
17 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
19 return javax.swing.JOptionPane.showInputDialog (null, message);
21 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
22 function (message, initialSelectionValue) {
23 return javax.swing.JOptionPane.showInputDialog (null, message, initialSelectionValue);
25 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
26 function (parentComponent, message) {
27 return javax.swing.JOptionPane.showInputDialog (parentComponent, message, javax.swing.UIManager.getString ("OptionPane.inputDialogTitle", parentComponent), 3);
28 }, "java.awt.Component,~O");
29 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
30 function (parentComponent, message, initialSelectionValue) {
31 return javax.swing.JOptionPane.showInputDialog (parentComponent, message, javax.swing.UIManager.getString ("OptionPane.inputDialogTitle", parentComponent), 3, null, null, initialSelectionValue);
32 }, "java.awt.Component,~O,~O");
33 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
34 function (parentComponent, message, title, messageType) {
35 return javax.swing.JOptionPane.showInputDialog (parentComponent, message, title, messageType, null, null, null);
36 }, "java.awt.Component,~O,~S,~N");
37 c$.showInputDialog = Clazz.defineMethod (c$, "showInputDialog",
38 function (parentComponent, message, title, messageType, icon, selectionValues, initialSelectionValue) {
39 var pane = new javax.swing.JOptionPane (message, messageType, 2, icon, null, null);
40 pane.setWantsInput (true);
41 pane.setSelectionValues (selectionValues);
42 pane.setInitialSelectionValue (initialSelectionValue);
43 pane.setComponentOrientation (((parentComponent == null) ? javax.swing.JOptionPane.getRootFrame () : parentComponent).getComponentOrientation ());
44 var style = javax.swing.JOptionPane.styleFromMessageType (messageType);
45 var dialog = pane.createDialog (parentComponent, title, style);
46 pane.selectInitialValue ();
49 var value = pane.getInputValue ();
50 if (value === javax.swing.JOptionPane.UNINITIALIZED_VALUE) {
53 }, "java.awt.Component,~O,~S,~N,javax.swing.Icon,~A,~O");
54 c$.showMessageDialog = Clazz.defineMethod (c$, "showMessageDialog",
55 function (parentComponent, message) {
56 javax.swing.JOptionPane.showMessageDialog (parentComponent, message, javax.swing.UIManager.getString ("OptionPane.messageDialogTitle", parentComponent), 1);
57 }, "java.awt.Component,~O");
58 c$.showMessageDialog = Clazz.defineMethod (c$, "showMessageDialog",
59 function (parentComponent, message, title, messageType) {
60 javax.swing.JOptionPane.showMessageDialog (parentComponent, message, title, messageType, null);
61 }, "java.awt.Component,~O,~S,~N");
62 c$.showMessageDialog = Clazz.defineMethod (c$, "showMessageDialog",
63 function (parentComponent, message, title, messageType, icon) {
64 javax.swing.JOptionPane.showOptionDialog (parentComponent, message, title, -1, messageType, icon, null, null);
65 }, "java.awt.Component,~O,~S,~N,javax.swing.Icon");
66 c$.showConfirmDialog = Clazz.defineMethod (c$, "showConfirmDialog",
67 function (parentComponent, message) {
68 return javax.swing.JOptionPane.showConfirmDialog (parentComponent, message, javax.swing.UIManager.getString ("OptionPane.titleText"), 1);
69 }, "java.awt.Component,~O");
70 c$.showConfirmDialog = Clazz.defineMethod (c$, "showConfirmDialog",
71 function (parentComponent, message, title, optionType) {
72 return javax.swing.JOptionPane.showConfirmDialog (parentComponent, message, title, optionType, 3);
73 }, "java.awt.Component,~O,~S,~N");
74 c$.showConfirmDialog = Clazz.defineMethod (c$, "showConfirmDialog",
75 function (parentComponent, message, title, optionType, messageType) {
76 return javax.swing.JOptionPane.showConfirmDialog (parentComponent, message, title, optionType, messageType, null);
77 }, "java.awt.Component,~O,~S,~N,~N");
78 c$.showConfirmDialog = Clazz.defineMethod (c$, "showConfirmDialog",
79 function (parentComponent, message, title, optionType, messageType, icon) {
80 return javax.swing.JOptionPane.showOptionDialog (parentComponent, message, title, optionType, messageType, icon, null, null);
81 }, "java.awt.Component,~O,~S,~N,~N,javax.swing.Icon");
82 c$.showOptionDialog = Clazz.defineMethod (c$, "showOptionDialog",
83 function (parentComponent, message, title, optionType, messageType, icon, options, initialValue) {
84 var pane = new javax.swing.JOptionPane (message, messageType, optionType, icon, options, initialValue);
85 pane.setInitialValue (initialValue);
86 pane.setComponentOrientation (((parentComponent == null) ? javax.swing.JOptionPane.getRootFrame () : parentComponent).getComponentOrientation ());
87 var style = javax.swing.JOptionPane.styleFromMessageType (messageType);
88 var dialog = pane.createDialog (parentComponent, title, style);
89 pane.selectInitialValue ();
92 var selectedValue = pane.getValue ();
93 if (selectedValue == null) return -1;
94 if (options == null) {
95 if (Clazz.instanceOf (selectedValue, Integer)) return (selectedValue).intValue ();
97 }for (var counter = 0, maxCounter = options.length; counter < maxCounter; counter++) {
98 if (options[counter].equals (selectedValue)) return counter;
101 }, "java.awt.Component,~O,~S,~N,~N,javax.swing.Icon,~A,~O");
102 Clazz.defineMethod (c$, "createDialog",
103 function (parentComponent, title) {
104 var style = javax.swing.JOptionPane.styleFromMessageType (this.getMessageType ());
105 return this.createDialog (parentComponent, title, style);
106 }, "java.awt.Component,~S");
107 Clazz.defineMethod (c$, "createDialog",
109 var style = javax.swing.JOptionPane.styleFromMessageType (this.getMessageType ());
110 var dialog = new javax.swing.JDialog (Clazz.castNullAs ("java.awt.Dialog"), title, true);
111 this.initDialog (dialog, style, null);
114 Clazz.defineMethod (c$, "createDialog",
115 function (parentComponent, title, style) {
117 var window = javax.swing.JOptionPane.getWindowForComponent (parentComponent);
118 if (Clazz.instanceOf (window, java.awt.Frame)) {
119 dialog = new javax.swing.JDialog (window, title, true);
121 dialog = new javax.swing.JDialog (window, title, true);
122 }if (Clazz.instanceOf (window, javax.swing.SwingUtilities.SharedOwnerFrame)) {
123 var ownerShutdownListener = javax.swing.SwingUtilities.getSharedOwnerFrameShutdownListener ();
124 dialog.addWindowListener (ownerShutdownListener);
125 }this.initDialog (dialog, style, parentComponent);
127 }, "java.awt.Component,~S,~N");
128 Clazz.defineMethod (c$, "initDialog",
129 function (dialog, style, parentComponent) {
130 dialog.setComponentOrientation (this.getComponentOrientation ());
131 var contentPane = dialog.getContentPane ();
132 contentPane.setLayout ( new java.awt.BorderLayout ());
133 contentPane.add (this, "Center");
134 dialog.setResizable (false);
135 if (javax.swing.JDialog.isDefaultLookAndFeelDecorated ()) {
136 var supportsWindowDecorations = javax.swing.UIManager.getLookAndFeel ().getSupportsWindowDecorations ();
137 if (supportsWindowDecorations) {
138 dialog.setUndecorated (true);
139 this.getRootPane ().setWindowDecorationStyle (style);
141 dialog.setLocationRelativeTo (parentComponent);
142 var adapter = ((Clazz.isClassDefined ("javax.swing.JOptionPane$1") ? 0 : javax.swing.JOptionPane.$JOptionPane$1$ ()), Clazz.innerTypeInstance (javax.swing.JOptionPane$1, this, null));
143 dialog.addWindowListener (adapter);
144 dialog.addWindowFocusListener (adapter);
145 dialog.addComponentListener (((Clazz.isClassDefined ("javax.swing.JOptionPane$2") ? 0 : javax.swing.JOptionPane.$JOptionPane$2$ ()), Clazz.innerTypeInstance (javax.swing.JOptionPane$2, this, null)));
146 this.addPropertyChangeListener (((Clazz.isClassDefined ("javax.swing.JOptionPane$3") ? 0 : javax.swing.JOptionPane.$JOptionPane$3$ ()), Clazz.innerTypeInstance (javax.swing.JOptionPane$3, this, Clazz.cloneFinals ("dialog", dialog))));
147 }, "javax.swing.JDialog,~N,java.awt.Component");
148 c$.getFrameForComponent = Clazz.defineMethod (c$, "getFrameForComponent",
149 function (parentComponent) {
150 if (parentComponent == null) return javax.swing.JOptionPane.getRootFrame ();
151 if (Clazz.instanceOf (parentComponent, java.awt.Frame)) return parentComponent;
152 return javax.swing.JOptionPane.getFrameForComponent (parentComponent.getParent ());
153 }, "java.awt.Component");
154 c$.getWindowForComponent = Clazz.defineMethod (c$, "getWindowForComponent",
155 function (parentComponent) {
156 if (parentComponent == null) return javax.swing.JOptionPane.getRootFrame ();
157 if (Clazz.instanceOf (parentComponent, java.awt.Frame) || Clazz.instanceOf (parentComponent, java.awt.Dialog)) return parentComponent;
158 return javax.swing.JOptionPane.getWindowForComponent (parentComponent.getParent ());
159 }, "java.awt.Component");
160 c$.setRootFrame = Clazz.defineMethod (c$, "setRootFrame",
161 function (newRootFrame) {
162 if (newRootFrame != null) {
163 javax.swing.SwingUtilities.appContextPut (javax.swing.JOptionPane.sharedFrameKey, newRootFrame);
165 javax.swing.SwingUtilities.appContextRemove (javax.swing.JOptionPane.sharedFrameKey);
166 }}, "java.awt.Frame");
167 c$.getRootFrame = Clazz.defineMethod (c$, "getRootFrame",
169 var sharedFrame = javax.swing.SwingUtilities.appContextGet (javax.swing.JOptionPane.sharedFrameKey);
170 if (sharedFrame == null) {
171 sharedFrame = javax.swing.SwingUtilities.getSharedOwnerFrame ();
172 javax.swing.SwingUtilities.appContextPut (javax.swing.JOptionPane.sharedFrameKey, sharedFrame);
175 Clazz.makeConstructor (c$,
177 this.construct ("JOptionPane message");
179 Clazz.makeConstructor (c$,
181 this.construct (message, -1);
183 Clazz.makeConstructor (c$,
184 function (message, messageType) {
185 this.construct (message, messageType, -1);
187 Clazz.makeConstructor (c$,
188 function (message, messageType, optionType) {
189 this.construct (message, messageType, optionType, null);
191 Clazz.makeConstructor (c$,
192 function (message, messageType, optionType, icon) {
193 this.construct (message, messageType, optionType, icon, null);
194 }, "~O,~N,~N,javax.swing.Icon");
195 Clazz.makeConstructor (c$,
196 function (message, messageType, optionType, icon, options) {
197 this.construct (message, messageType, optionType, icon, options, null);
198 }, "~O,~N,~N,javax.swing.Icon,~A");
199 Clazz.makeConstructor (c$,
200 function (message, messageType, optionType, icon, options, initialValue) {
201 Clazz.superConstructor (this, javax.swing.JOptionPane, []);
202 this.message = message;
203 this.options = options;
204 this.initialValue = initialValue;
206 this.setMessageType (messageType);
207 this.setOptionType (optionType);
208 this.value = javax.swing.JOptionPane.UNINITIALIZED_VALUE;
209 this.inputValue = javax.swing.JOptionPane.UNINITIALIZED_VALUE;
211 }, "~O,~N,~N,javax.swing.Icon,~A,~O");
212 Clazz.defineMethod (c$, "setUI",
214 if (this.ui !== ui) {
215 Clazz.superCall (this, javax.swing.JOptionPane, "setUI", [ui]);
217 }}, "javax.swing.plaf.OptionPaneUI");
218 Clazz.overrideMethod (c$, "getUI",
222 Clazz.overrideMethod (c$, "updateUI",
224 this.setUI (javax.swing.UIManager.getUI (this));
226 Clazz.overrideMethod (c$, "getUIClassID",
228 return "OptionPaneUI";
230 Clazz.defineMethod (c$, "setMessage",
231 function (newMessage) {
232 var oldMessage = this.message;
233 this.message = newMessage;
234 this.firePropertyChangeObject ("message", oldMessage, this.message);
236 Clazz.defineMethod (c$, "getMessage",
240 Clazz.defineMethod (c$, "setIcon",
242 var oldIcon = this.icon;
244 this.firePropertyChangeObject ("icon", oldIcon, this.icon);
245 }, "javax.swing.Icon");
246 Clazz.defineMethod (c$, "getIcon",
250 Clazz.defineMethod (c$, "setValue",
251 function (newValue) {
252 var oldValue = this.value;
253 this.value = newValue;
254 this.firePropertyChangeObject ("value", oldValue, this.value);
256 Clazz.defineMethod (c$, "getValue",
260 Clazz.defineMethod (c$, "setOptions",
261 function (newOptions) {
262 var oldOptions = this.options;
263 this.options = newOptions;
264 this.firePropertyChangeObject ("options", oldOptions, this.options);
266 Clazz.defineMethod (c$, "getOptions",
268 if (this.options != null) {
269 var optionCount = this.options.length;
270 var retOptions = new Array (optionCount);
271 System.arraycopy (this.options, 0, retOptions, 0, optionCount);
273 }return this.options;
275 Clazz.defineMethod (c$, "setInitialValue",
276 function (newInitialValue) {
277 var oldIV = this.initialValue;
278 this.initialValue = newInitialValue;
279 this.firePropertyChangeObject ("initialValue", oldIV, this.initialValue);
281 Clazz.defineMethod (c$, "getInitialValue",
283 return this.initialValue;
285 Clazz.defineMethod (c$, "setMessageType",
287 if (newType != 0 && newType != 1 && newType != 2 && newType != 3 && newType != -1) throw new RuntimeException ("JOptionPane: type must be one of JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE");
288 var oldType = this.messageType;
289 this.messageType = newType;
290 this.firePropertyChangeInt ("messageType", oldType, this.messageType);
292 Clazz.defineMethod (c$, "getMessageType",
294 return this.messageType;
296 Clazz.defineMethod (c$, "setOptionType",
298 if (newType != -1 && newType != 0 && newType != 1 && newType != 2) throw new RuntimeException ("JOptionPane: option type must be one of JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_CANCEL_OPTION or JOptionPane.OK_CANCEL_OPTION");
299 var oldType = this.optionType;
300 this.optionType = newType;
301 this.firePropertyChangeInt ("optionType", oldType, this.optionType);
303 Clazz.defineMethod (c$, "getOptionType",
305 return this.optionType;
307 Clazz.defineMethod (c$, "setSelectionValues",
308 function (newValues) {
309 var oldValues = this.selectionValues;
310 this.selectionValues = newValues;
311 this.firePropertyChangeObject ("selectionValues", oldValues, newValues);
312 if (this.selectionValues != null) this.setWantsInput (true);
314 Clazz.defineMethod (c$, "getSelectionValues",
316 return this.selectionValues;
318 Clazz.defineMethod (c$, "setInitialSelectionValue",
319 function (newValue) {
320 var oldValue = this.initialSelectionValue;
321 this.initialSelectionValue = newValue;
322 this.firePropertyChangeObject ("initialSelectionValue", oldValue, newValue);
324 Clazz.defineMethod (c$, "getInitialSelectionValue",
326 return this.initialSelectionValue;
328 Clazz.defineMethod (c$, "setInputValue",
329 function (newValue) {
330 var oldValue = this.inputValue;
331 this.inputValue = newValue;
332 this.firePropertyChangeObject ("inputValue", oldValue, newValue);
334 Clazz.defineMethod (c$, "getInputValue",
336 return this.inputValue;
338 Clazz.defineMethod (c$, "getMaxCharactersPerLineCount",
342 Clazz.defineMethod (c$, "setWantsInput",
343 function (newValue) {
344 var oldValue = this.wantsInput;
345 this.wantsInput = newValue;
346 this.firePropertyChangeBool ("wantsInput", oldValue, newValue);
348 Clazz.defineMethod (c$, "getWantsInput",
350 return this.wantsInput;
352 Clazz.defineMethod (c$, "selectInitialValue",
354 var ui = this.getUI ();
356 ui.selectInitialValue (this);
358 c$.styleFromMessageType = Clazz.defineMethod (c$, "styleFromMessageType",
359 function (messageType) {
360 switch (messageType) {
374 Clazz.defineMethod (c$, "paramString",
376 var iconString = (this.icon != null ? this.icon.toString () : "");
377 var initialValueString = (this.initialValue != null ? this.initialValue.toString () : "");
378 var messageString = (this.message != null ? this.message.toString () : "");
379 var messageTypeString;
380 if (this.messageType == 0) {
381 messageTypeString = "ERROR_MESSAGE";
382 } else if (this.messageType == 1) {
383 messageTypeString = "INFORMATION_MESSAGE";
384 } else if (this.messageType == 2) {
385 messageTypeString = "WARNING_MESSAGE";
386 } else if (this.messageType == 3) {
387 messageTypeString = "QUESTION_MESSAGE";
388 } else if (this.messageType == -1) {
389 messageTypeString = "PLAIN_MESSAGE";
390 } else messageTypeString = "";
391 var optionTypeString;
392 if (this.optionType == -1) {
393 optionTypeString = "DEFAULT_OPTION";
394 } else if (this.optionType == 0) {
395 optionTypeString = "YES_NO_OPTION";
396 } else if (this.optionType == 1) {
397 optionTypeString = "YES_NO_CANCEL_OPTION";
398 } else if (this.optionType == 2) {
399 optionTypeString = "OK_CANCEL_OPTION";
400 } else optionTypeString = "";
401 var wantsInputString = (this.wantsInput ? "true" : "false");
402 return Clazz.superCall (this, javax.swing.JOptionPane, "paramString", []) + ",icon=" + iconString + ",initialValue=" + initialValueString + ",message=" + messageString + ",messageType=" + messageTypeString + ",optionType=" + optionTypeString + ",wantsInput=" + wantsInputString;
404 c$.$JOptionPane$1$ = function () {
406 c$ = Clazz.decorateAsClass (function () {
407 Clazz.prepareCallback (this, arguments);
408 this.gotFocus = false;
409 Clazz.instantialize (this, arguments);
410 }, javax.swing, "JOptionPane$1", java.awt.event.WindowAdapter);
411 Clazz.overrideMethod (c$, "windowClosing",
413 this.b$["javax.swing.JOptionPane"].setValue (null);
414 }, "java.awt.event.WindowEvent");
415 Clazz.overrideMethod (c$, "windowGainedFocus",
417 if (!this.gotFocus) {
418 this.b$["javax.swing.JOptionPane"].selectInitialValue ();
419 this.gotFocus = true;
420 }}, "java.awt.event.WindowEvent");
423 c$.$JOptionPane$2$ = function () {
425 c$ = Clazz.declareAnonymous (javax.swing, "JOptionPane$2", java.awt.event.ComponentAdapter);
426 Clazz.overrideMethod (c$, "componentShown",
428 this.b$["javax.swing.JOptionPane"].setValue (javax.swing.JOptionPane.UNINITIALIZED_VALUE);
429 }, "java.awt.event.ComponentEvent");
432 c$.$JOptionPane$3$ = function () {
434 c$ = Clazz.declareAnonymous (javax.swing, "JOptionPane$3", null, java.beans.PropertyChangeListener);
435 Clazz.overrideMethod (c$, "propertyChange",
437 if (this.f$.dialog.isVisible () && event.getSource () === this.b$["javax.swing.JOptionPane"] && (event.getPropertyName ().equals ("value") || event.getPropertyName ().equals ("inputValue")) && event.getNewValue () != null && event.getNewValue () !== javax.swing.JOptionPane.UNINITIALIZED_VALUE) {
438 this.f$.dialog.setVisible (false);
439 }}, "java.beans.PropertyChangeEvent");
442 Clazz.defineStatics (c$,
443 "$uiClassID", "OptionPaneUI",
444 "UNINITIALIZED_VALUE", "uninitializedValue",
445 "DEFAULT_OPTION", -1,
447 "YES_NO_CANCEL_OPTION", 1,
448 "OK_CANCEL_OPTION", 2,
455 "INFORMATION_MESSAGE", 1,
456 "WARNING_MESSAGE", 2,
457 "QUESTION_MESSAGE", 3,
459 "ICON_PROPERTY", "icon",
460 "MESSAGE_PROPERTY", "message",
461 "VALUE_PROPERTY", "value",
462 "OPTIONS_PROPERTY", "options",
463 "INITIAL_VALUE_PROPERTY", "initialValue",
464 "MESSAGE_TYPE_PROPERTY", "messageType",
465 "OPTION_TYPE_PROPERTY", "optionType",
466 "SELECTION_VALUES_PROPERTY", "selectionValues",
467 "INITIAL_SELECTION_VALUE_PROPERTY", "initialSelectionValue",
468 "INPUT_VALUE_PROPERTY", "inputValue",
469 "WANTS_INPUT_PROPERTY", "wantsInput");
470 c$.sharedFrameKey = c$.prototype.sharedFrameKey = javax.swing.JOptionPane;