root / branches / v2_0_0_prep / libraries / org.gvsig.newlayer / org.gvsig.newlayer.prov / org.gvsig.newlayer.prov.file / src / main / java / org / gvsig / newlayer / prov / file / NewLayerFileProviderPanel.java @ 37804
History | View | Annotate | Download (2.33 KB)
1 |
package org.gvsig.newlayer.prov.file; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Component; |
5 |
import java.io.File; |
6 |
|
7 |
import javax.swing.JOptionPane; |
8 |
|
9 |
import org.gvsig.gui.beans.wizard.panel.SelectFileOptionPanel; |
10 |
import org.gvsig.i18n.Messages; |
11 |
import org.gvsig.newlayer.NewLayerException; |
12 |
import org.gvsig.newlayer.NewLayerProviderPanel; |
13 |
|
14 |
public class NewLayerFileProviderPanel extends NewLayerProviderPanel{ |
15 |
private SelectFileOptionPanel selectFileOptionPanel;
|
16 |
|
17 |
protected NewLayerFileProviderPanel(AbstractNewLayerFileProvider provider) {
|
18 |
super(provider);
|
19 |
this.setLayout(new BorderLayout()); |
20 |
selectFileOptionPanel = |
21 |
new org.gvsig.gui.beans.wizard.panel.SelectFileOptionPanel(null); |
22 |
add(selectFileOptionPanel, BorderLayout.NORTH);
|
23 |
} |
24 |
|
25 |
public AbstractNewLayerFileProvider getProvider() {
|
26 |
return (AbstractNewLayerFileProvider) this.provider; |
27 |
} |
28 |
|
29 |
public File getSelectedFile(){ |
30 |
return selectFileOptionPanel.getSelectedFile();
|
31 |
} |
32 |
|
33 |
@Override
|
34 |
public String getTitle() { |
35 |
return Messages.getText("output_file"); |
36 |
} |
37 |
|
38 |
@Override
|
39 |
public boolean isValidPanel() throws NewLayerException { |
40 |
File file = selectFileOptionPanel.getSelectedFile();
|
41 |
if ((file == null) || (file.equals(""))) { |
42 |
throw new NotEmptyFileException(); |
43 |
} |
44 |
if (file.exists()) {
|
45 |
int resp =
|
46 |
JOptionPane
|
47 |
.showConfirmDialog( |
48 |
(Component) selectFileOptionPanel.getParent(),
|
49 |
Messages.getText("fichero_ya_existe_seguro_desea_guardarlo"),
|
50 |
Messages.getText("guardar"),
|
51 |
JOptionPane.YES_NO_OPTION);
|
52 |
if (resp == JOptionPane.NO_OPTION) { |
53 |
return false; |
54 |
} |
55 |
} |
56 |
return true; |
57 |
} |
58 |
|
59 |
class NotEmptyFileException extends NewLayerException { |
60 |
private static final long serialVersionUID = -3619912245694177044L; |
61 |
private final static String MESSAGE_FORMAT = "The file can not be empty."; |
62 |
private final static String MESSAGE_KEY = "_file_can_not_be_empty_exception"; |
63 |
|
64 |
public NotEmptyFileException() {
|
65 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID);
|
66 |
} |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public void updatePanel() { |
71 |
// TODO Auto-generated method stub
|
72 |
|
73 |
} |
74 |
|
75 |
} |