Changeset 12778 in osm for applications/editors/josm/plugins/waypoints/src/WaypointOpenAction.java
- Timestamp:
- 2009-01-01T18:28:53+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/waypoints/src/WaypointOpenAction.java
r12575 r12778 29 29 */ 30 30 public class WaypointOpenAction extends DiskAccessAction { 31 32 /**33 * Create an open action. The name is "Open a file".34 */35 public WaypointOpenAction() {36 super(tr("Open waypoints file"), "open", tr("Open a waypoints file."),37 Shortcut.registerShortcut("tools:waypoints", tr("Menu: {0}",38 tr("Open waypoints file")), KeyEvent.VK_W, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT));39 }31 32 /** 33 * Create an open action. The name is "Open a file". 34 */ 35 public WaypointOpenAction() { 36 super(tr("Open waypoints file"), "open", tr("Open a waypoints file."), 37 Shortcut.registerShortcut("tools:waypoints", tr("Menu: {0}", 38 tr("Open waypoints file")), KeyEvent.VK_W, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT)); 39 } 40 40 41 public void actionPerformed(ActionEvent e) {42 JFileChooser fc = createAndOpenFileChooser(true, true, null);43 if (fc == null)44 return;45 File[] files = fc.getSelectedFiles();46 for (int i = files.length; i > 0; --i)47 openFile(files[i-1]);48 }41 public void actionPerformed(ActionEvent e) { 42 JFileChooser fc = createAndOpenFileChooser(true, true, null); 43 if (fc == null) 44 return; 45 File[] files = fc.getSelectedFiles(); 46 for (int i = files.length; i > 0; --i) 47 openFile(files[i-1]); 48 } 49 49 50 /**51 * Open the given file.52 */53 public void openFile(File file) {54 String fn = file.getName();55 try {56 DataSet dataSet =57 WaypointReader.parse(new FileInputStream(file));58 Main.main.addLayer(new OsmDataLayer(dataSet, file.getName(),59 file));60 } catch (SAXException x) {61 x.printStackTrace();62 JOptionPane.showMessageDialog(Main.parent,63 tr("Error while parsing {0}",fn)+": "+x.getMessage());64 } catch (ParserConfigurationException x) {65 x.printStackTrace(); // broken SAXException chaining66 JOptionPane.showMessageDialog(Main.parent,67 tr("Error while parsing {0}",fn)+": "+x.getMessage());68 } catch (IOException x) {69 x.printStackTrace();70 JOptionPane.showMessageDialog(Main.parent,71 tr("Could not read \"{0}\"",fn)+"\n"+x.getMessage());72 }73 }50 /** 51 * Open the given file. 52 */ 53 public void openFile(File file) { 54 String fn = file.getName(); 55 try { 56 DataSet dataSet = 57 WaypointReader.parse(new FileInputStream(file)); 58 Main.main.addLayer(new OsmDataLayer(dataSet, file.getName(), 59 file)); 60 } catch (SAXException x) { 61 x.printStackTrace(); 62 JOptionPane.showMessageDialog(Main.parent, 63 tr("Error while parsing {0}",fn)+": "+x.getMessage()); 64 } catch (ParserConfigurationException x) { 65 x.printStackTrace(); // broken SAXException chaining 66 JOptionPane.showMessageDialog(Main.parent, 67 tr("Error while parsing {0}",fn)+": "+x.getMessage()); 68 } catch (IOException x) { 69 x.printStackTrace(); 70 JOptionPane.showMessageDialog(Main.parent, 71 tr("Could not read \"{0}\"",fn)+"\n"+x.getMessage()); 72 } 73 } 74 74 }
Note:
See TracChangeset
for help on using the changeset viewer.
