1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.gui; |
23 |
|
|
24 |
|
import jalview.util.Platform; |
25 |
|
import jalview.util.dialogrunner.DialogRunnerI; |
26 |
|
|
27 |
|
import java.awt.Component; |
28 |
|
import java.awt.HeadlessException; |
29 |
|
import java.beans.PropertyChangeEvent; |
30 |
|
import java.beans.PropertyChangeListener; |
31 |
|
import java.util.Arrays; |
32 |
|
import java.util.HashMap; |
33 |
|
import java.util.List; |
34 |
|
import java.util.Map; |
35 |
|
|
36 |
|
import javax.swing.Icon; |
37 |
|
import javax.swing.JOptionPane; |
38 |
|
import javax.swing.JPanel; |
39 |
|
|
|
|
| 43.3% |
Uncovered Elements: 136 (240) |
Complexity: 91 |
Complexity Density: 0.71 |
|
40 |
|
public class JvOptionPane extends JOptionPane implements DialogRunnerI, |
41 |
|
PropertyChangeListener |
42 |
|
{ |
43 |
|
private static final long serialVersionUID = -3019167117756785229L; |
44 |
|
|
45 |
|
private static Object mockResponse = JvOptionPane.CANCEL_OPTION; |
46 |
|
|
47 |
|
private static boolean interactiveMode = true; |
48 |
|
|
49 |
|
private Component parentComponent; |
50 |
|
|
51 |
|
private Map<Object, Runnable> callbacks = new HashMap<>(); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
List<Object> ourOptions; |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
59 |
0 |
public JvOptionPane(final Component parent)... |
60 |
|
{ |
61 |
0 |
this.parentComponent = Platform.isJS() ? this : parent; |
62 |
|
} |
63 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
64 |
1 |
public static int showConfirmDialog(Component parentComponent,... |
65 |
|
Object message) throws HeadlessException |
66 |
|
{ |
67 |
|
|
68 |
1 |
return isInteractiveMode() |
69 |
|
? JOptionPane.showConfirmDialog(parentComponent, message) |
70 |
|
: (int) getMockResponse(); |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
@param |
77 |
|
@param |
78 |
|
@param |
79 |
|
@param |
80 |
|
@return |
81 |
|
@throws |
82 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 5 |
Complexity Density: 0.62 |
|
83 |
1 |
public static int showConfirmDialog(Component parentComponent,... |
84 |
|
Object message, String title, int optionType) |
85 |
|
throws HeadlessException |
86 |
|
{ |
87 |
1 |
if (!isInteractiveMode()) |
88 |
|
{ |
89 |
1 |
return (int) getMockResponse(); |
90 |
|
} |
91 |
0 |
switch (optionType) |
92 |
|
{ |
93 |
0 |
case JvOptionPane.YES_NO_CANCEL_OPTION: |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
0 |
default: |
99 |
0 |
case JvOptionPane.YES_NO_OPTION: |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
0 |
case JvOptionPane.OK_CANCEL_OPTION: |
104 |
|
|
105 |
0 |
return JOptionPane.showConfirmDialog(parentComponent, message, title, |
106 |
|
optionType); |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
@param |
114 |
|
@param |
115 |
|
@param |
116 |
|
@param |
117 |
|
@param |
118 |
|
@return |
119 |
|
@throws |
120 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
121 |
1 |
public static int showConfirmDialog(Component parentComponent,... |
122 |
|
Object message, String title, int optionType, int messageType) |
123 |
|
throws HeadlessException |
124 |
|
{ |
125 |
|
|
126 |
|
|
127 |
1 |
return isInteractiveMode() |
128 |
|
? JOptionPane.showConfirmDialog(parentComponent, message, title, |
129 |
|
optionType, messageType) |
130 |
|
: (int) getMockResponse(); |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
@param |
137 |
|
@param |
138 |
|
@param |
139 |
|
@param |
140 |
|
@param |
141 |
|
@param |
142 |
|
@return |
143 |
|
@throws |
144 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
145 |
1 |
public static int showConfirmDialog(Component parentComponent,... |
146 |
|
Object message, String title, int optionType, int messageType, |
147 |
|
Icon icon) throws HeadlessException |
148 |
|
{ |
149 |
|
|
150 |
1 |
return isInteractiveMode() |
151 |
|
? JOptionPane.showConfirmDialog(parentComponent, message, title, |
152 |
|
optionType, messageType, icon) |
153 |
|
: (int) getMockResponse(); |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
@param |
160 |
|
@param |
161 |
|
@return |
162 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
163 |
1 |
public static int showInternalConfirmDialog(Component parentComponent,... |
164 |
|
Object message) |
165 |
|
{ |
166 |
|
|
167 |
1 |
return isInteractiveMode() ? JOptionPane.showInternalConfirmDialog( |
168 |
|
parentComponent, message) : (int) getMockResponse(); |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@param |
175 |
|
@param |
176 |
|
@param |
177 |
|
@param |
178 |
|
@return |
179 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 5 |
Complexity Density: 0.62 |
|
180 |
1 |
public static int showInternalConfirmDialog(Component parentComponent,... |
181 |
|
String message, String title, int optionType) |
182 |
|
{ |
183 |
1 |
if (!isInteractiveMode()) |
184 |
|
{ |
185 |
1 |
return (int) getMockResponse(); |
186 |
|
} |
187 |
0 |
switch (optionType) |
188 |
|
{ |
189 |
0 |
case JvOptionPane.YES_NO_CANCEL_OPTION: |
190 |
|
|
191 |
0 |
case JvOptionPane.YES_NO_OPTION: |
192 |
|
|
193 |
|
|
194 |
0 |
default: |
195 |
0 |
case JvOptionPane.OK_CANCEL_OPTION: |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
0 |
return JOptionPane.showConfirmDialog(parentComponent, message, title, |
202 |
|
optionType); |
203 |
|
} |
204 |
|
} |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
@param |
209 |
|
@param |
210 |
|
@param |
211 |
|
@param |
212 |
|
@param |
213 |
|
@return |
214 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 5 |
Complexity Density: 0.62 |
|
215 |
1 |
public static int showInternalConfirmDialog(Component parentComponent,... |
216 |
|
Object message, String title, int optionType, int messageType) |
217 |
|
{ |
218 |
1 |
if (!isInteractiveMode()) |
219 |
|
{ |
220 |
1 |
return (int) getMockResponse(); |
221 |
|
} |
222 |
0 |
switch (optionType) |
223 |
|
{ |
224 |
0 |
case JvOptionPane.YES_NO_CANCEL_OPTION: |
225 |
0 |
case JvOptionPane.YES_NO_OPTION: |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
0 |
default: |
230 |
0 |
case JvOptionPane.OK_CANCEL_OPTION: |
231 |
|
|
232 |
0 |
return JOptionPane.showConfirmDialog(parentComponent, message, title, |
233 |
|
optionType, messageType); |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
@param |
241 |
|
@param |
242 |
|
@param |
243 |
|
@param |
244 |
|
@param |
245 |
|
@param |
246 |
|
@return |
247 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 5 |
Complexity Density: 0.62 |
|
248 |
1 |
public static int showInternalConfirmDialog(Component parentComponent,... |
249 |
|
Object message, String title, int optionType, int messageType, |
250 |
|
Icon icon) |
251 |
|
{ |
252 |
1 |
if (!isInteractiveMode()) |
253 |
|
{ |
254 |
1 |
return (int) getMockResponse(); |
255 |
|
} |
256 |
0 |
switch (optionType) |
257 |
|
{ |
258 |
0 |
case JvOptionPane.YES_NO_CANCEL_OPTION: |
259 |
0 |
case JvOptionPane.YES_NO_OPTION: |
260 |
|
|
261 |
0 |
default: |
262 |
0 |
case JvOptionPane.OK_CANCEL_OPTION: |
263 |
|
|
264 |
0 |
return JOptionPane.showConfirmDialog(parentComponent, message, title, |
265 |
|
optionType, messageType, icon); |
266 |
|
} |
267 |
|
|
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
@param |
274 |
|
@param |
275 |
|
@param |
276 |
|
@param |
277 |
|
@param |
278 |
|
@param |
279 |
|
@param |
280 |
|
@param |
281 |
|
@return |
282 |
|
@throws |
283 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
284 |
0 |
public static int showOptionDialog(Component parentComponent,... |
285 |
|
String message, String title, int optionType, int messageType, |
286 |
|
Icon icon, Object[] options, Object initialValue) |
287 |
|
throws HeadlessException |
288 |
|
{ |
289 |
0 |
if (!isInteractiveMode()) |
290 |
|
{ |
291 |
0 |
return (int) getMockResponse(); |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
0 |
return JOptionPane.showOptionDialog(parentComponent, message, title, |
308 |
|
optionType, messageType, icon, options, initialValue); |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
@param |
315 |
|
@throws |
316 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
317 |
1 |
public static void showMessageDialog(Component parentComponent,... |
318 |
|
String message) throws HeadlessException |
319 |
|
{ |
320 |
1 |
if (!isInteractiveMode()) |
321 |
|
{ |
322 |
1 |
outputMessage(message); |
323 |
1 |
return; |
324 |
|
} |
325 |
|
|
326 |
|
|
327 |
|
|
328 |
0 |
JOptionPane.showMessageDialog(parentComponent, message); |
329 |
|
} |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
@param |
335 |
|
@param |
336 |
|
@param |
337 |
|
@param |
338 |
|
@throws |
339 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
340 |
2 |
public static void showMessageDialog(Component parentComponent,... |
341 |
|
String message, String title, int messageType) |
342 |
|
throws HeadlessException |
343 |
|
{ |
344 |
|
|
345 |
|
|
346 |
2 |
if (!isInteractiveMode()) |
347 |
|
{ |
348 |
2 |
outputMessage(message); |
349 |
2 |
return; |
350 |
|
} |
351 |
|
|
352 |
0 |
JOptionPane.showMessageDialog(parentComponent, |
353 |
|
getPrefix(messageType) + message, title, messageType); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
@param |
360 |
|
@param |
361 |
|
@param |
362 |
|
@param |
363 |
|
@param |
364 |
|
@throws |
365 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
366 |
1 |
public static void showMessageDialog(Component parentComponent,... |
367 |
|
String message, String title, int messageType, Icon icon) |
368 |
|
throws HeadlessException |
369 |
|
{ |
370 |
|
|
371 |
|
|
372 |
|
|
373 |
1 |
if (!isInteractiveMode()) |
374 |
|
{ |
375 |
1 |
outputMessage(message); |
376 |
1 |
return; |
377 |
|
} |
378 |
|
|
379 |
0 |
JOptionPane.showMessageDialog(parentComponent, message, title, |
380 |
|
messageType, icon); |
381 |
|
} |
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
387 |
1 |
public static void showInternalMessageDialog(Component parentComponent,... |
388 |
|
Object message) |
389 |
|
{ |
390 |
|
|
391 |
|
|
392 |
|
|
393 |
1 |
if (!isInteractiveMode()) |
394 |
|
{ |
395 |
1 |
outputMessage(message); |
396 |
1 |
return; |
397 |
|
} |
398 |
|
|
399 |
0 |
JOptionPane.showMessageDialog(parentComponent, message); |
400 |
|
} |
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
@param |
407 |
|
@param |
408 |
|
@param |
409 |
|
@param |
410 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
411 |
2 |
public static void showInternalMessageDialog(Component parentComponent,... |
412 |
|
String message, String title, int messageType) |
413 |
|
{ |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
2 |
if (!isInteractiveMode()) |
418 |
|
{ |
419 |
1 |
outputMessage(message); |
420 |
1 |
return; |
421 |
|
} |
422 |
|
|
423 |
1 |
JOptionPane.showMessageDialog(parentComponent, |
424 |
|
getPrefix(messageType) + message, title, messageType); |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
@param |
430 |
|
@param |
431 |
|
@param |
432 |
|
@param |
433 |
|
@param |
434 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
435 |
1 |
public static void showInternalMessageDialog(Component parentComponent,... |
436 |
|
Object message, String title, int messageType, Icon icon) |
437 |
|
{ |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
1 |
if (!isInteractiveMode()) |
442 |
|
{ |
443 |
1 |
outputMessage(message); |
444 |
1 |
return; |
445 |
|
} |
446 |
|
|
447 |
0 |
JOptionPane.showMessageDialog(parentComponent, message, title, |
448 |
|
messageType, icon); |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
@param |
454 |
|
@return |
455 |
|
@throws |
456 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
457 |
1 |
public static String showInputDialog(Object message)... |
458 |
|
throws HeadlessException |
459 |
|
{ |
460 |
|
|
461 |
|
|
462 |
1 |
if (!isInteractiveMode()) |
463 |
|
{ |
464 |
1 |
return getMockResponse().toString(); |
465 |
|
} |
466 |
|
|
467 |
0 |
return JOptionPane.showInputDialog(message); |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
@param |
474 |
|
@param |
475 |
|
@return |
476 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
477 |
0 |
public static String showInputDialog(String message,... |
478 |
|
String initialSelectionValue) |
479 |
|
{ |
480 |
0 |
if (!isInteractiveMode()) |
481 |
|
{ |
482 |
0 |
return getMockResponse().toString(); |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
|
487 |
0 |
return JOptionPane.showInputDialog(message, initialSelectionValue); |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
@param |
494 |
|
@param |
495 |
|
@return |
496 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
497 |
1 |
public static String showInputDialog(Object message,... |
498 |
|
Object initialSelectionValue) |
499 |
|
{ |
500 |
1 |
if (!isInteractiveMode()) |
501 |
|
{ |
502 |
1 |
return getMockResponse().toString(); |
503 |
|
} |
504 |
|
|
505 |
|
|
506 |
|
|
507 |
0 |
return JOptionPane.showInputDialog(message, initialSelectionValue); |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
@param |
513 |
|
@param |
514 |
|
@return |
515 |
|
@throws |
516 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
517 |
1 |
public static String showInputDialog(Component parentComponent,... |
518 |
|
String message) throws HeadlessException |
519 |
|
{ |
520 |
|
|
521 |
|
|
522 |
1 |
return isInteractiveMode() |
523 |
|
? JOptionPane.showInputDialog(parentComponent, message) |
524 |
|
: getMockResponse().toString(); |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
@param |
531 |
|
@param |
532 |
|
@param |
533 |
|
@return |
534 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
535 |
0 |
public static String showInputDialog(Component parentComponent,... |
536 |
|
String message, String initialSelectionValue) |
537 |
|
{ |
538 |
|
|
539 |
|
|
540 |
|
|
541 |
0 |
return isInteractiveMode() |
542 |
|
? JOptionPane.showInputDialog(parentComponent, message, |
543 |
|
initialSelectionValue) |
544 |
|
: getMockResponse().toString(); |
545 |
|
} |
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
@param |
552 |
|
@param |
553 |
|
@param |
554 |
|
@return |
555 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
556 |
1 |
public static String showInputDialog(Component parentComponent,... |
557 |
|
Object message, Object initialSelectionValue) |
558 |
|
{ |
559 |
|
|
560 |
|
|
561 |
|
|
562 |
1 |
return isInteractiveMode() |
563 |
|
? JOptionPane.showInputDialog(parentComponent, message, |
564 |
|
initialSelectionValue) |
565 |
|
: getMockResponse().toString(); |
566 |
|
} |
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
@param |
571 |
|
@param |
572 |
|
@param |
573 |
|
@param |
574 |
|
@return |
575 |
|
@throws |
576 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
577 |
1 |
public static String showInputDialog(Component parentComponent,... |
578 |
|
String message, String title, int messageType) |
579 |
|
throws HeadlessException |
580 |
|
{ |
581 |
|
|
582 |
|
|
583 |
|
|
584 |
1 |
return isInteractiveMode() ? JOptionPane |
585 |
|
.showInputDialog(parentComponent, message, title, messageType) |
586 |
|
: getMockResponse().toString(); |
587 |
|
} |
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
@param |
593 |
|
@param |
594 |
|
@param |
595 |
|
@param |
596 |
|
@param |
597 |
|
@param |
598 |
|
@param |
599 |
|
@return |
600 |
|
@throws |
601 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
602 |
1 |
public static Object showInputDialog(Component parentComponent,... |
603 |
|
Object message, String title, int messageType, Icon icon, |
604 |
|
Object[] selectionValues, Object initialSelectionValue) |
605 |
|
throws HeadlessException |
606 |
|
{ |
607 |
|
|
608 |
|
|
609 |
|
|
610 |
1 |
return isInteractiveMode() |
611 |
|
? JOptionPane.showInputDialog(parentComponent, message, title, |
612 |
|
messageType, icon, selectionValues, |
613 |
|
initialSelectionValue) |
614 |
|
: getMockResponse().toString(); |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
@param |
623 |
|
@param |
624 |
|
@return |
625 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
626 |
1 |
public static String showInternalInputDialog(Component parentComponent,... |
627 |
|
String message) |
628 |
|
{ |
629 |
|
|
630 |
|
|
631 |
1 |
return isInteractiveMode() |
632 |
|
? JOptionPane.showInternalInputDialog(parentComponent, message) |
633 |
|
: getMockResponse().toString(); |
634 |
|
} |
635 |
|
|
636 |
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
@param |
641 |
|
@param |
642 |
|
@param |
643 |
|
@param |
644 |
|
@return |
645 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
646 |
1 |
public static String showInternalInputDialog(Component parentComponent,... |
647 |
|
String message, String title, int messageType) |
648 |
|
{ |
649 |
|
|
650 |
|
|
651 |
|
|
652 |
1 |
return isInteractiveMode() |
653 |
|
? JOptionPane.showInternalInputDialog(parentComponent, |
654 |
|
getPrefix(messageType) + message, title, messageType) |
655 |
|
: getMockResponse().toString(); |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
@param |
662 |
|
@param |
663 |
|
@param |
664 |
|
@param |
665 |
|
@param |
666 |
|
@param |
667 |
|
@param |
668 |
|
@return |
669 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
670 |
1 |
public static Object showInternalInputDialog(Component parentComponent,... |
671 |
|
String message, String title, int messageType, Icon icon, |
672 |
|
Object[] selectionValues, Object initialSelectionValue) |
673 |
|
{ |
674 |
|
|
675 |
|
|
676 |
1 |
return isInteractiveMode() |
677 |
|
? JOptionPane.showInternalInputDialog(parentComponent, message, |
678 |
|
title, messageType, icon, selectionValues, |
679 |
|
initialSelectionValue) |
680 |
|
: getMockResponse().toString(); |
681 |
|
} |
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
687 |
7 |
private static void outputMessage(Object message)... |
688 |
|
{ |
689 |
7 |
System.out.println(">>> JOption Message : " + message.toString()); |
690 |
|
} |
691 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
692 |
17 |
public static Object getMockResponse()... |
693 |
|
{ |
694 |
17 |
return mockResponse; |
695 |
|
} |
696 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
697 |
139 |
public static void setMockResponse(Object mockOption)... |
698 |
|
{ |
699 |
139 |
JvOptionPane.mockResponse = mockOption; |
700 |
|
} |
701 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
702 |
0 |
public static void resetMock()... |
703 |
|
{ |
704 |
0 |
setMockResponse(JvOptionPane.CANCEL_OPTION); |
705 |
0 |
setInteractiveMode(true); |
706 |
|
} |
707 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
708 |
25 |
public static boolean isInteractiveMode()... |
709 |
|
{ |
710 |
25 |
return interactiveMode; |
711 |
|
} |
712 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
713 |
139 |
public static void setInteractiveMode(boolean interactive)... |
714 |
|
{ |
715 |
139 |
JvOptionPane.interactiveMode = interactive; |
716 |
|
} |
717 |
|
|
|
|
| 28.6% |
Uncovered Elements: 10 (14) |
Complexity: 4 |
Complexity Density: 0.33 |
|
718 |
1 |
private static String getPrefix(int messageType)... |
719 |
|
{ |
720 |
1 |
String prefix = ""; |
721 |
|
|
722 |
|
|
723 |
1 |
if (Platform.isJS()) |
724 |
|
{ |
725 |
0 |
switch (messageType) |
726 |
|
{ |
727 |
0 |
case JvOptionPane.WARNING_MESSAGE: |
728 |
0 |
prefix = "WARNING! "; |
729 |
0 |
break; |
730 |
0 |
case JvOptionPane.ERROR_MESSAGE: |
731 |
0 |
prefix = "ERROR! "; |
732 |
0 |
break; |
733 |
0 |
default: |
734 |
0 |
prefix = "Note: "; |
735 |
|
} |
736 |
|
} |
737 |
1 |
return prefix; |
738 |
|
} |
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
@param |
745 |
|
@param |
746 |
|
@param |
747 |
|
@param |
748 |
|
@param |
749 |
|
@param |
750 |
|
@param |
751 |
|
@param |
752 |
|
@return |
753 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
754 |
0 |
public static JvOptionPane newOptionDialog(Component parentComponent)... |
755 |
|
{ |
756 |
0 |
return new JvOptionPane(parentComponent); |
757 |
|
} |
758 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
759 |
0 |
public void showDialog(... |
760 |
|
String message, String title, int optionType, int messageType, |
761 |
|
Icon icon, Object[] options, Object initialValue) |
762 |
|
{ |
763 |
|
|
764 |
0 |
if (!isInteractiveMode()) |
765 |
|
{ |
766 |
0 |
handleResponse(getMockResponse()); |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 |
0 |
ourOptions = Arrays.asList(options); |
784 |
|
|
785 |
0 |
int response = JOptionPane.showOptionDialog(parentComponent, message, title, |
786 |
|
optionType, messageType, icon, options, initialValue); |
787 |
|
|
788 |
|
|
789 |
|
|
790 |
|
|
791 |
|
|
792 |
0 |
if (!Platform.isJS()) |
793 |
|
|
794 |
|
|
795 |
|
|
796 |
|
|
797 |
|
|
798 |
|
{ |
799 |
0 |
handleResponse(response); |
800 |
|
} |
801 |
|
} |
802 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
803 |
0 |
public void showInternalDialog(JPanel mainPanel, String title,... |
804 |
|
int yesNoCancelOption, int questionMessage, Icon icon, |
805 |
|
Object[] options, String initresponse) |
806 |
|
{ |
807 |
0 |
if (!isInteractiveMode()) |
808 |
|
{ |
809 |
0 |
handleResponse(getMockResponse()); |
810 |
|
} |
811 |
|
|
812 |
0 |
ourOptions = Arrays.asList(options); |
813 |
0 |
int response; |
814 |
0 |
if (parentComponent != this) |
815 |
|
{ |
816 |
0 |
response = JOptionPane.showInternalOptionDialog(parentComponent, mainPanel, |
817 |
|
title, yesNoCancelOption, questionMessage, icon, options, |
818 |
|
initresponse); |
819 |
|
} |
820 |
|
else |
821 |
|
{ |
822 |
0 |
response = JOptionPane.showOptionDialog(parentComponent, mainPanel, title, |
823 |
|
yesNoCancelOption, questionMessage, icon, options, |
824 |
|
initresponse); |
825 |
|
} |
826 |
0 |
if (!Platform.isJS()) |
827 |
|
|
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
{ |
833 |
0 |
handleResponse(response); |
834 |
|
} |
835 |
|
} |
836 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
837 |
0 |
@Override... |
838 |
|
public JvOptionPane setResponseHandler(Object response, Runnable action) |
839 |
|
{ |
840 |
0 |
callbacks.put(response, action); |
841 |
0 |
return this; |
842 |
|
} |
843 |
|
|
844 |
|
|
845 |
|
|
846 |
|
|
847 |
|
|
848 |
|
|
849 |
|
@param |
850 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
851 |
0 |
@Override... |
852 |
|
public void propertyChange(PropertyChangeEvent evt) |
853 |
|
{ |
854 |
0 |
Object newValue = evt.getNewValue(); |
855 |
0 |
int ourOption = ourOptions.indexOf(newValue); |
856 |
0 |
if (ourOption >= 0) |
857 |
|
{ |
858 |
0 |
handleResponse(ourOption); |
859 |
|
} |
860 |
|
else |
861 |
|
{ |
862 |
|
|
863 |
0 |
handleResponse(newValue); |
864 |
|
} |
865 |
|
} |
866 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
867 |
0 |
@Override... |
868 |
|
public void handleResponse(Object response) |
869 |
|
{ |
870 |
|
|
871 |
|
|
872 |
|
|
873 |
0 |
if (response != null && !response.equals(response)) |
874 |
|
{ |
875 |
0 |
return; |
876 |
|
} |
877 |
0 |
Runnable action = callbacks.get(response); |
878 |
0 |
if (action != null) |
879 |
|
{ |
880 |
0 |
action.run(); |
881 |
|
} |
882 |
|
} |
883 |
|
} |