Changeset 30738 in osm for applications/editors/josm/plugins/surveyor
- Timestamp:
- 2014-10-19T01:27:04+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveGpsLayerTimerTask.java
r30646 r30738 68 68 // @see LiveGpsLayer 69 69 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(tmpFile))); 70 GpxWriter gpxWriter = new GpxWriter(out) ;71 gpxWriter.write(gpsLayer.data); 72 gpxWriter.close();70 try (GpxWriter gpxWriter = new GpxWriter(out)) { 71 gpxWriter.write(gpsLayer.data); 72 } 73 73 tmpFile.renameTo(file); 74 74 } catch (IOException ioExc) { -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java
r30737 r30738 26 26 27 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.actions.JosmAction; 28 29 import org.openstreetmap.josm.tools.Shortcut; 29 30 import org.openstreetmap.josm.tools.XmlObjectParser; 30 import org.openstreetmap.josm.actions.JosmAction;31 31 import org.xml.sax.SAXException; 32 32 … … 50 50 } 51 51 52 public void actionPerformed(ActionEvent e) { 52 @Override 53 public void actionPerformed(ActionEvent e) { 53 54 if(surveyorFrame == null) { 54 55 surveyorFrame = new JFrame(); … … 64 65 // zoomout: 65 66 actionMap.put("zoomout", new AbstractAction() { 66 public void actionPerformed(ActionEvent e) { 67 @Override 68 public void actionPerformed(ActionEvent e) { 67 69 if(Main.map != null && Main.map.mapView != null) { 68 70 Main.map.mapView.zoomToFactor(2); … … 73 75 // zoomin: 74 76 actionMap.put("zoomin", new AbstractAction() { 75 public void actionPerformed(ActionEvent e) { 77 @Override 78 public void actionPerformed(ActionEvent e) { 76 79 if(Main.map != null && Main.map.mapView != null) { 77 80 Main.map.mapView.zoomToFactor(1/2); … … 82 85 // autocenter: 83 86 actionMap.put("autocenter", new AbstractAction() { 84 public void actionPerformed(ActionEvent e) { 87 @Override 88 public void actionPerformed(ActionEvent e) { 85 89 // toggle autocenter 86 90 gpsPlugin.setAutoCenter(!gpsPlugin.isAutoCenter()); … … 105 109 106 110 public SurveyorComponent createComponent() { 107 InputStream in = null;108 111 String source = Main.pref.get("surveyor.source"); 109 112 if(source == null || source.length() == 0) { … … 114 117 // </FIXXME> 115 118 } 116 SurveyorComponent component= null; 117 try { 118 in = ResourceLoader.getInputStream(source); 119 component = createComponent(in); 120 in.close(); 121 return component; 119 try (InputStream in = ResourceLoader.getInputStream(source)) { 120 return createComponent(in); 122 121 } catch (IOException e) { 123 e.printStackTrace();122 Main.error(e); 124 123 JOptionPane.showMessageDialog(Main.parent, tr("Could not read surveyor definition: {0}",source)); 125 124 } catch (SAXException e) { 126 e.printStackTrace();125 Main.error(e); 127 126 JOptionPane.showMessageDialog(Main.parent, tr("Error parsing {0}: {1}", source, e.getMessage())); 128 127 } 129 return component;128 return null; 130 129 } 131 130 -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/ResourceLoader.java
r30646 r30738 28 28 * @throws IOException if an error occurs on opening the url, or if the file is not found. 29 29 */ 30 public static InputStream getInputStream(String source) throws IOException { 30 @SuppressWarnings("resource") 31 public static InputStream getInputStream(String source) throws IOException { 31 32 InputStream in = null; 32 33 if (source.startsWith("http://") || source.startsWith("https://") || source.startsWith("ftp://") || source.startsWith("file:")) {
Note:
See TracChangeset
for help on using the changeset viewer.