Changeset 10 in josm for src/org/openstreetmap/josm/actions


Ignore:
Timestamp:
2005-10-04T20:14:54+02:00 (20 years ago)
Author:
imi
Message:

GPX export added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/SaveGpxAction.java

    r1 r10  
    44import java.awt.event.KeyEvent;
    55import java.io.File;
     6import java.io.FileWriter;
     7import java.io.IOException;
    68
    79import javax.swing.AbstractAction;
    810import javax.swing.ImageIcon;
    911import javax.swing.JFileChooser;
     12import javax.swing.JOptionPane;
    1013
    1114import org.openstreetmap.josm.gui.Main;
     15import org.openstreetmap.josm.io.GpxWriter;
    1216
    1317/**
     
    2933       
    3034        @SuppressWarnings("unchecked")
    31         public void actionPerformed(ActionEvent e) {
     35        public void actionPerformed(ActionEvent event) {
     36                if (Main.main.getMapFrame() == null) {
     37                        JOptionPane.showMessageDialog(Main.main, "No document open so nothing to save.");
     38                        return;
     39                }
    3240                JFileChooser fc = new JFileChooser("data");
    3341                fc.showSaveDialog(Main.main);
     
    3543                if (gpxFile == null)
    3644                        return;
     45               
     46                try {
     47                        FileWriter fileWriter = new FileWriter(gpxFile);
     48                        GpxWriter out = new GpxWriter(fileWriter, Main.main.getMapFrame().mapView.dataSet);
     49                        out.output();
     50                        fileWriter.close();
     51                } catch (IOException e) {
     52                        e.printStackTrace();
     53                        JOptionPane.showMessageDialog(Main.main, "An error occoured while saving.\n"+e.getMessage());
     54                }
    3755        }
    3856
Note: See TracChangeset for help on using the changeset viewer.