Changeset 15070 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-05-11T20:24:40+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r14397 r15070 22 22 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 23 23 import org.openstreetmap.josm.gui.MainApplication; 24 import org.openstreetmap.josm.gui.Notification; 24 25 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 25 26 import org.openstreetmap.josm.gui.layer.Layer; … … 37 38 import org.openstreetmap.josm.tools.Logging; 38 39 import org.openstreetmap.josm.tools.Utils; 40 import org.openstreetmap.josm.tools.bugreport.ReportedException; 39 41 40 42 /** … … 138 140 if (canceled) 139 141 return; 140 // NoteImporter directly loads notes into current note layer 141 if (!MainApplication.getLayerManager().containsLayer(l)) { 142 MainApplication.getLayerManager().addLayer(l); 143 } 142 addLayer(l); 144 143 } 145 144 if (active != null) { … … 150 149 } 151 150 } 151 } 152 153 /** 154 * Tries to add a new layer. 155 * @param l layer to add 156 * @return {@code true} if layer has been added, {@code false} if it wasn't needed or if an error occurred 157 */ 158 static boolean addLayer(Layer l) { 159 // NoteImporter directly loads notes into current note layer 160 if (!MainApplication.getLayerManager().containsLayer(l)) { 161 try { 162 MainApplication.getLayerManager().addLayer(l); 163 } catch (ReportedException e) { 164 Logging.error(e); 165 new Notification(tr("Unable to add layer ''{0}'': {1}", l.getName(), e.getMessage())) 166 .setIcon(JOptionPane.ERROR_MESSAGE).setDuration(Notification.TIME_LONG).show(); 167 if (MainApplication.getLayerManager().containsLayer(l)) { 168 MainApplication.getLayerManager().removeLayer(l); 169 } 170 return false; 171 } 172 } 173 return true; 152 174 } 153 175 -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r14741 r15070 565 565 throw new IllegalStateException("Importer " + imp + " returned null for " + support); 566 566 } 567 } catch (IllegalDataException | Illegal StateException | IOException ex) {567 } catch (IllegalDataException | IllegalArgumentException | IllegalStateException | IOException ex) { 568 568 exception = ex; 569 569 } … … 704 704 public void loadSession(File sessionFile, boolean zip, ProgressMonitor progressMonitor) throws IllegalDataException, IOException { 705 705 try (InputStream josIS = createInputStream(sessionFile, zip)) { 706 loadSession(josIS, sessionFile.toURI(), zip, progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE);706 loadSession(josIS, sessionFile.toURI(), zip, progressMonitor); 707 707 } 708 708 } … … 737 737 } 738 738 739 private void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor) 739 /** 740 * Loads session from the given input stream. 741 * @param josIS session stream to load 742 * @param zip {@code true} if it's a zipped session (.joz) 743 * @param sessionFileURI URI of the underlying session file 744 * @param progressMonitor progress monitor 745 * @throws IllegalDataException if invalid data is detected 746 * @throws IOException if any I/O error occurs 747 * @since xxx 748 */ 749 public void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor) 740 750 throws IOException, IllegalDataException { 741 751 … … 744 754 745 755 try { 746 parseJos(XmlUtils.parseSafeDOM(josIS), progressMonitor );756 parseJos(XmlUtils.parseSafeDOM(josIS), progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE); 747 757 } catch (SAXException e) { 748 758 throw new IllegalDataException(e);
Note:
See TracChangeset
for help on using the changeset viewer.