1 | /******************************************************************************* | |
2 | * Copyhacked (H) 2012-2020. | |
3 | * This program and the accompanying materials | |
4 | * are made available under no term at all, use it like | |
5 | * you want, but share and discuss about it | |
6 | * every time possible with every body. | |
7 | * | |
8 | * Contributors: | |
9 | * ron190 at ymail dot com - initial implementation | |
10 | ******************************************************************************/ | |
11 | package com.jsql.view.swing.dialog; | |
12 | ||
13 | import com.jsql.util.I18nUtil; | |
14 | ||
15 | import javax.swing.*; | |
16 | ||
17 | /** | |
18 | * File chooser for supporting 'file already exists'. | |
19 | */ | |
20 | public class ReplaceFileChooser extends JFileChooser { | |
21 | | |
22 | /** | |
23 | * Create a file chooser with a replace confirm dialog. | |
24 | * @param s | |
25 | */ | |
26 | public ReplaceFileChooser(String s) { | |
27 | // Unhandled NoSuchMethodError #82561 on constructor: NoSuchMethodError | |
28 | // Unhandled InternalError #93015 on constructor: InvocationTargetException | |
29 | super(s); | |
30 | } | |
31 | | |
32 | @Override | |
33 | public void approveSelection() { | |
34 | | |
35 | var file = this.getSelectedFile(); | |
36 | | |
37 |
1
1. approveSelection : negated conditional → NO_COVERAGE |
if (this.getDialogType() == SAVE_DIALOG) { |
38 |
1
1. approveSelection : negated conditional → NO_COVERAGE |
if (file.exists()) { |
39 | | |
40 | int result = JOptionPane.showConfirmDialog( | |
41 | this, | |
42 | String.format( | |
43 | "%s %s", | |
44 | this.getSelectedFile().getName(), | |
45 | I18nUtil.valueByKey("SAVE_TAB_CONFIRM_LABEL") | |
46 | ), | |
47 | I18nUtil.valueByKey("SAVE_TAB_CONFIRM_TITLE"), | |
48 | JOptionPane.YES_NO_OPTION | |
49 | ); | |
50 | | |
51 | switch (result) { | |
52 | | |
53 | case JOptionPane.YES_OPTION: | |
54 |
1
1. approveSelection : removed call to javax/swing/JFileChooser::approveSelection → NO_COVERAGE |
super.approveSelection(); |
55 | return; | |
56 | | |
57 | case JOptionPane.NO_OPTION: | |
58 | case JOptionPane.CLOSED_OPTION: | |
59 | return; | |
60 | | |
61 | case JOptionPane.CANCEL_OPTION: | |
62 |
1
1. approveSelection : removed call to com/jsql/view/swing/dialog/ReplaceFileChooser::cancelSelection → NO_COVERAGE |
this.cancelSelection(); |
63 | return; | |
64 | | |
65 | default: | |
66 | break; | |
67 | } | |
68 | } else { | |
69 |
1
1. approveSelection : removed call to javax/swing/JFileChooser::approveSelection → NO_COVERAGE |
super.approveSelection(); |
70 | } | |
71 | } | |
72 | } | |
73 | } | |
Mutations | ||
37 |
1.1 |
|
38 |
1.1 |
|
54 |
1.1 |
|
62 |
1.1 |
|
69 |
1.1 |