Revision 8127 trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/ESRIpanel.java
ESRIpanel.java | ||
---|---|---|
3 | 3 |
import java.awt.FlowLayout; |
4 | 4 |
import java.awt.GridLayout; |
5 | 5 |
import java.awt.event.ActionEvent; |
6 |
import java.awt.event.ActionListener; |
|
6 | 7 |
import java.io.File; |
7 | 8 |
|
8 | 9 |
import javax.swing.JButton; |
... | ... | |
11 | 12 |
import javax.swing.JLabel; |
12 | 13 |
import javax.swing.JPanel; |
13 | 14 |
import javax.swing.JTextField; |
15 |
import javax.swing.filechooser.FileFilter; |
|
14 | 16 |
|
15 | 17 |
import com.iver.andami.PluginServices; |
16 | 18 |
|
17 |
public class ESRIpanel extends JPanel { |
|
19 |
public class ESRIpanel extends JPanel implements ActionListener {
|
|
18 | 20 |
|
19 | 21 |
/** |
20 | 22 |
* |
... | ... | |
71 | 73 |
jButtonOpen = new JButton(); |
72 | 74 |
jButtonOpen.setText(""); |
73 | 75 |
jButtonOpen.setPreferredSize(new Dimension(20,20)); |
74 |
jButtonOpen.addActionListener(new java.awt.event.ActionListener() { |
|
75 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
76 |
Open_actionPerformed(e); |
|
77 |
} |
|
78 |
}); |
|
76 |
jButtonOpen.addActionListener(this); |
|
79 | 77 |
} |
80 | 78 |
return jButtonOpen; |
81 | 79 |
} |
82 | 80 |
|
83 |
private void Open_actionPerformed(ActionEvent e){ |
|
84 |
add(getOpen(), null); |
|
85 |
openChooser.setCurrentDirectory(f); |
|
86 |
int returnVal = openChooser.showOpenDialog(ESRIpanel.this); |
|
87 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
88 |
File file = openChooser.getSelectedFile(); |
|
89 |
jTextOpen.setText(file.getAbsolutePath()); |
|
90 |
} |
|
91 |
} |
|
81 |
public void actionPerformed(ActionEvent e) { |
|
82 |
// TODO Auto-generated method stub |
|
83 |
if (e.getSource() == this.getButtonOpen()){ |
|
84 |
add(getOpen(), null); |
|
85 |
openChooser.setCurrentDirectory(f); |
|
86 |
int returnVal = openChooser.showOpenDialog(ESRIpanel.this); |
|
87 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
88 |
File file = openChooser.getSelectedFile(); |
|
89 |
jTextOpen.setText(file.getAbsolutePath()); |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
class FiltroESRI extends FileFilter{ |
|
92 | 96 |
|
93 |
|
|
97 |
final static String prj = "prj"; |
|
98 |
|
|
99 |
public boolean accept(File f) { |
|
100 |
if (f.isDirectory()) { |
|
101 |
return true; |
|
102 |
} |
|
94 | 103 |
|
104 |
String s = f.getName(); |
|
105 |
int i = s.lastIndexOf('.'); |
|
106 |
|
|
107 |
if (i > 0 && i < s.length() - 1) { |
|
108 |
String extension = s.substring(i+1).toLowerCase(); |
|
109 |
if (prj.equals(extension)){ |
|
110 |
return true; |
|
111 |
} else { |
|
112 |
return false; |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
public String getDescription() { |
|
120 |
return "Archivos .prj"; |
|
121 |
} |
|
95 | 122 |
} |
123 |
|
Also available in: Unified diff