});
_openFileChooser = new JMenuItem("Add Shape File");
_openFileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new EsriFilter());
int returnVal = fileChooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File shp = fileChooser.getSelectedFile();
String s = shp.getCanonicalPath();
int pos1 = s.lastIndexOf('.');
String name = s.substring(0, pos1);
File shx = new File(s.substring(0, pos1) + ".shx");
File dbf = new File(s.substring(0, pos1) + ".dbf");
EsriLayer layer = new EsriLayer(name, dbf.toURL(), shp.toURL(), shx.toURL());
_layerHandler.addLayer(layer);
} catch (Exception exception) {
System.out.println(exception);
}
}
}
});
_exit = new JMenuItem("Exit");
_exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
_saveFileChooser = new JMenuItem("Save File");
_saveFileChooser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EsriLayer layer = pickEsriLayer();
if (layer != null) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new EsriFilter());
int returnVal = fileChooser.showSaveDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try {
File file = fileChooser.getSelectedFile();
String path = file.getCanonicalPath();
EsriGraphicList list = layer.getEsriGraphicList();
ShpOutputStream pos = new ShpOutputStream(new FileOutputStream(path
+ ".shp"));