Changeset 6271 in josm
- Timestamp:
- 2013-09-30T02:51:34+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r6245 r6271 67 67 private final boolean zip; 68 68 private List<Layer> layers; 69 private Layer active; 69 70 private List<Runnable> postLoadTasks; 70 71 private ViewportData viewport; … … 122 123 if (canceled) return; 123 124 Main.main.addLayer(l); 125 } 126 if (active != null) { 127 Main.map.mapView.setActiveLayer(active); 124 128 } 125 129 if (noMap) { … … 158 162 reader.loadSession(file, zip, monitor); 159 163 layers = reader.getLayers(); 164 active = reader.getActive(); 160 165 postLoadTasks = reader.getPostLoadTasks(); 161 166 viewport = reader.getViewport(); -
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r6267 r6271 123 123 layersOut.add(layer); 124 124 } 125 126 SessionWriter sw = new SessionWriter(layersOut, exporters, dependencies, zip); 125 126 int active = -1; 127 Layer activeLayer = Main.map.mapView.getActiveLayer(); 128 if (activeLayer != null) { 129 active = layersOut.indexOf(activeLayer); 130 } 131 132 SessionWriter sw = new SessionWriter(layersOut, active, exporters, dependencies, zip); 127 133 try { 128 134 sw.write(file); … … 157 163 } 158 164 165 /** 166 * Initializes action. 167 */ 159 168 public void initialize() { 160 169 layers = new ArrayList<Layer>(Main.map.mapView.getAllLayersAsList()); … … 196 205 } 197 206 198 p ublicComponent build() {207 protected Component build() { 199 208 JPanel p = new JPanel(new GridBagLayout()); 200 209 JPanel ip = new JPanel(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r6245 r6271 89 89 private ZipFile zipFile; 90 90 private List<Layer> layers = new ArrayList<Layer>(); 91 private int active = -1; 91 92 private List<Runnable> postLoadTasks = new ArrayList<Runnable>(); 92 93 private ViewportData viewport; … … 97 98 public List<Layer> getLayers() { 98 99 return layers; 100 } 101 102 /** 103 * @return active layer, or {@code null} if not set 104 * @since 6271 105 */ 106 public Layer getActive() { 107 // layers is in reverse order because of the way TreeMap is built 108 return (active >= 0 && active < layers.size()) ? layers.get(layers.size()-1-active) : null; 99 109 } 100 110 … … 327 337 if (layersEl == null) return; 328 338 339 String activeAtt = layersEl.getAttribute("active"); 340 try { 341 active = (activeAtt != null && !activeAtt.isEmpty()) ? Integer.parseInt(activeAtt)-1 : -1; 342 } catch (NumberFormatException e) { 343 Main.warn("Unsupported value for 'active' layer attribute. Ignoring it. Error was: "+e.getMessage()); 344 active = -1; 345 } 346 329 347 MultiMap<Integer, Integer> deps = new MultiMap<Integer, Integer>(); 330 348 Map<Integer, Element> elems = new HashMap<Integer, Element>(); -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r6142 r6271 80 80 } 81 81 82 private List<Layer> layers; 83 private Map<Layer, SessionLayerExporter> exporters; 84 private MultiMap<Layer, Layer> dependencies; 85 private boolean zip; 82 private final List<Layer> layers; 83 private final int active; 84 private final Map<Layer, SessionLayerExporter> exporters; 85 private final MultiMap<Layer, Layer> dependencies; 86 private final boolean zip; 86 87 87 88 private ZipOutputStream zipOut; 88 89 89 public SessionWriter(List<Layer> layers, Map<Layer, SessionLayerExporter> exporters, 90 /** 91 * Constructs a new {@code SessionWriter}. 92 * @param layers The ordered list of layers to save 93 * @param active The index of active layer in {@code layers} (starts to 0). Ignored if set to -1 94 * @param exporters The exprters to use to save layers 95 * @param zip {@code true} if a joz archive has to be created, {@code false otherwise} 96 * @since 6271 97 */ 98 public SessionWriter(List<Layer> layers, int active, Map<Layer, SessionLayerExporter> exporters, 90 99 MultiMap<Layer, Layer> dependencies, boolean zip) { 91 100 this.layers = layers; 101 this.active = active; 92 102 this.exporters = exporters; 93 103 this.dependencies = dependencies; … … 182 192 183 193 Element layersEl = doc.createElement("layers"); 194 if (active >= 0) { 195 layersEl.setAttribute("active", Integer.toString(active+1)); 196 } 184 197 root.appendChild(layersEl); 185 198
Note:
See TracChangeset
for help on using the changeset viewer.