source: josm/trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java@ 4126

Last change on this file since 4126 was 4126, checked in by bastiK, 13 years ago

memory optimizations for Node & WayPoint (Patch by Gubaer, modified)

The field 'proj' in CachedLatLon is a waste of memory. For the 2 classes where this has the greatest impact, the cache for the projected coordinates is replaced by 2 simple double fields (east & north). On projection change, they have to be invalidated explicitly. This is handled by the DataSet & the GpxLayer.

  • Property svn:eol-style set to native
File size: 24.3 KB
Line 
1// License: GPL. See LICENSE file for details.
2
3package org.openstreetmap.josm.gui.layer;
4
5import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
6import static org.openstreetmap.josm.tools.I18n.marktr;
7import static org.openstreetmap.josm.tools.I18n.tr;
8import static org.openstreetmap.josm.tools.I18n.trn;
9
10import java.awt.AlphaComposite;
11import java.awt.Color;
12import java.awt.Composite;
13import java.awt.Graphics2D;
14import java.awt.GridBagLayout;
15import java.awt.Point;
16import java.awt.Rectangle;
17import java.awt.TexturePaint;
18import java.awt.event.ActionEvent;
19import java.awt.geom.Area;
20import java.awt.image.BufferedImage;
21import java.io.File;
22import java.util.ArrayList;
23import java.util.Collection;
24import java.util.HashMap;
25import java.util.HashSet;
26import java.util.List;
27import java.util.Map;
28
29import javax.swing.AbstractAction;
30import javax.swing.Action;
31import javax.swing.Icon;
32import javax.swing.JLabel;
33import javax.swing.JOptionPane;
34import javax.swing.JPanel;
35import javax.swing.JScrollPane;
36import javax.swing.JTextArea;
37
38import org.openstreetmap.josm.Main;
39import org.openstreetmap.josm.actions.RenameLayerAction;
40import org.openstreetmap.josm.data.Bounds;
41import org.openstreetmap.josm.data.SelectionChangedListener;
42import org.openstreetmap.josm.data.conflict.Conflict;
43import org.openstreetmap.josm.data.conflict.ConflictCollection;
44import org.openstreetmap.josm.data.coor.LatLon;
45import org.openstreetmap.josm.data.gpx.GpxData;
46import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack;
47import org.openstreetmap.josm.data.gpx.WayPoint;
48import org.openstreetmap.josm.data.osm.DataIntegrityProblemException;
49import org.openstreetmap.josm.data.osm.DataSet;
50import org.openstreetmap.josm.data.osm.DataSetMerger;
51import org.openstreetmap.josm.data.osm.DataSource;
52import org.openstreetmap.josm.data.osm.DatasetConsistencyTest;
53import org.openstreetmap.josm.data.osm.Node;
54import org.openstreetmap.josm.data.osm.OsmPrimitive;
55import org.openstreetmap.josm.data.osm.Relation;
56import org.openstreetmap.josm.data.osm.Way;
57import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
58import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
59import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
60import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
61import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
62import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory;
63import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
64import org.openstreetmap.josm.data.projection.Projection;
65import org.openstreetmap.josm.data.validation.TestError;
66import org.openstreetmap.josm.gui.HelpAwareOptionPane;
67import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
68import org.openstreetmap.josm.gui.MapView;
69import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
70import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
71import org.openstreetmap.josm.tools.DateUtils;
72import org.openstreetmap.josm.tools.FilteredCollection;
73import org.openstreetmap.josm.tools.GBC;
74import org.openstreetmap.josm.tools.ImageProvider;
75
76/**
77 * A layer holding data from a specific dataset.
78 * The data can be fully edited.
79 *
80 * @author imi
81 */
82public class OsmDataLayer extends Layer implements Listener, SelectionChangedListener {
83 // static private final Logger logger = Logger.getLogger(OsmDataLayer.class.getName());
84
85 static public final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk";
86 static public final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer";
87
88 private boolean requiresSaveToFile = false;
89 private boolean requiresUploadToServer = false;
90 private boolean isChanged = true;
91 private int highlightUpdateCount;
92
93 public List<TestError> validationErrors = new ArrayList<TestError>();
94
95 protected void setRequiresSaveToFile(boolean newValue) {
96 boolean oldValue = requiresSaveToFile;
97 requiresSaveToFile = newValue;
98 if (oldValue != newValue) {
99 propertyChangeSupport.firePropertyChange(REQUIRES_SAVE_TO_DISK_PROP, oldValue, newValue);
100 }
101 }
102
103 protected void setRequiresUploadToServer(boolean newValue) {
104 boolean oldValue = requiresUploadToServer;
105 requiresUploadToServer = newValue;
106 if (oldValue != newValue) {
107 propertyChangeSupport.firePropertyChange(REQUIRES_UPLOAD_TO_SERVER_PROP, oldValue, newValue);
108 }
109 }
110
111 /** the global counter for created data layers */
112 static private int dataLayerCounter = 0;
113
114 /**
115 * Replies a new unique name for a data layer
116 *
117 * @return a new unique name for a data layer
118 */
119 static public String createNewName() {
120 dataLayerCounter++;
121 return tr("Data Layer {0}", dataLayerCounter);
122 }
123
124 public final static class DataCountVisitor extends AbstractVisitor {
125 public int nodes;
126 public int ways;
127 public int relations;
128 public int deletedNodes;
129 public int deletedWays;
130 public int deletedRelations;
131
132 public void visit(final Node n) {
133 nodes++;
134 if (n.isDeleted()) {
135 deletedNodes++;
136 }
137 }
138
139 public void visit(final Way w) {
140 ways++;
141 if (w.isDeleted()) {
142 deletedWays++;
143 }
144 }
145
146 public void visit(final Relation r) {
147 relations++;
148 if (r.isDeleted()) {
149 deletedRelations++;
150 }
151 }
152 }
153
154 public interface CommandQueueListener {
155 void commandChanged(int queueSize, int redoSize);
156 }
157
158 /**
159 * The data behind this layer.
160 */
161 public final DataSet data;
162
163 /**
164 * the collection of conflicts detected in this layer
165 */
166 private ConflictCollection conflicts;
167
168 /**
169 * a paint texture for non-downloaded area
170 */
171 private static TexturePaint hatched;
172
173 static {
174 createHatchTexture();
175 }
176
177 public static Color getBackgroundColor() {
178 return Main.pref.getColor(marktr("background"), Color.BLACK);
179 }
180
181 public static Color getOutsideColor() {
182 return Main.pref.getColor(marktr("outside downloaded area"), Color.YELLOW);
183 }
184
185 /**
186 * Initialize the hatch pattern used to paint the non-downloaded area
187 */
188 public static void createHatchTexture() {
189 BufferedImage bi = new BufferedImage(15, 15, BufferedImage.TYPE_INT_ARGB);
190 Graphics2D big = bi.createGraphics();
191 big.setColor(getBackgroundColor());
192 Composite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
193 big.setComposite(comp);
194 big.fillRect(0,0,15,15);
195 big.setColor(getOutsideColor());
196 big.drawLine(0,15,15,0);
197 Rectangle r = new Rectangle(0, 0, 15,15);
198 hatched = new TexturePaint(bi, r);
199 }
200
201 /**
202 * Construct a OsmDataLayer.
203 */
204 public OsmDataLayer(final DataSet data, final String name, final File associatedFile) {
205 super(name);
206 this.data = data;
207 this.setAssociatedFile(associatedFile);
208 conflicts = new ConflictCollection();
209 data.addDataSetListener(new DataSetListenerAdapter(this));
210 DataSet.addSelectionListener(this);
211 }
212
213 /**
214 * TODO: @return Return a dynamic drawn icon of the map data. The icon is
215 * updated by a background thread to not disturb the running programm.
216 */
217 @Override public Icon getIcon() {
218 return ImageProvider.get("layer", "osmdata_small");
219 }
220
221 /**
222 * Draw all primitives in this layer but do not draw modified ones (they
223 * are drawn by the edit layer).
224 * Draw nodes last to overlap the ways they belong to.
225 */
226 @Override public void paint(final Graphics2D g, final MapView mv, Bounds box) {
227 isChanged = false;
228 highlightUpdateCount = data.getHighlightUpdateCount();
229
230 boolean active = mv.getActiveLayer() == this;
231 boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true);
232 boolean virtual = !inactive && mv.isVirtualNodesEnabled();
233
234 // draw the hatched area for non-downloaded region. only draw if we're the active
235 // and bounds are defined; don't draw for inactive layers or loaded GPX files etc
236 if (active && Main.pref.getBoolean("draw.data.downloaded_area", true) && !data.dataSources.isEmpty()) {
237 // initialize area with current viewport
238 Rectangle b = mv.getBounds();
239 // on some platforms viewport bounds seem to be offset from the left,
240 // over-grow it just to be sure
241 b.grow(100, 100);
242 Area a = new Area(b);
243
244 // now successively subtract downloaded areas
245 for (Bounds bounds : data.getDataSourceBounds()) {
246 if (bounds.isCollapsed()) {
247 continue;
248 }
249 Point p1 = mv.getPoint(bounds.getMin());
250 Point p2 = mv.getPoint(bounds.getMax());
251 Rectangle r = new Rectangle(Math.min(p1.x, p2.x),Math.min(p1.y, p2.y),Math.abs(p2.x-p1.x),Math.abs(p2.y-p1.y));
252 a.subtract(new Area(r));
253 }
254
255 // paint remainder
256 g.setPaint(hatched);
257 g.fill(a);
258 }
259
260 Rendering painter = MapRendererFactory.getInstance().createActiveRenderer(g, mv, inactive);
261 painter.render(data, virtual, box);
262 Main.map.conflictDialog.paintConflicts(g, mv);
263 }
264
265 @Override public String getToolTipText() {
266 int nodes = new FilteredCollection<Node>(data.getNodes(), OsmPrimitive.nonDeletedPredicate).size();
267 int ways = new FilteredCollection<Way>(data.getWays(), OsmPrimitive.nonDeletedPredicate).size();
268
269 String tool = trn("{0} node", "{0} nodes", nodes, nodes)+", ";
270 tool += trn("{0} way", "{0} ways", ways, ways);
271
272 if (data.getVersion() != null) {
273 tool += ", " + tr("version {0}", data.getVersion());
274 }
275 File f = getAssociatedFile();
276 if (f != null) {
277 tool = "<html>"+tool+"<br>"+f.getPath()+"</html>";
278 }
279 return tool;
280 }
281
282 @Override public void mergeFrom(final Layer from) {
283 mergeFrom(((OsmDataLayer)from).data);
284 }
285
286 /**
287 * merges the primitives in dataset <code>from</code> into the dataset of
288 * this layer
289 *
290 * @param from the source data set
291 */
292 public void mergeFrom(final DataSet from) {
293 final DataSetMerger visitor = new DataSetMerger(data,from);
294 try {
295 visitor.merge();
296 } catch (DataIntegrityProblemException e) {
297 JOptionPane.showMessageDialog(
298 Main.parent,
299 e.getMessage(),
300 tr("Error"),
301 JOptionPane.ERROR_MESSAGE
302 );
303 return;
304
305 }
306
307 Area a = data.getDataSourceArea();
308
309 // copy the merged layer's data source info;
310 // only add source rectangles if they are not contained in the
311 // layer already.
312 for (DataSource src : from.dataSources) {
313 if (a == null || !a.contains(src.bounds.asRect())) {
314 data.dataSources.add(src);
315 }
316 }
317
318 // copy the merged layer's API version, downgrade if required
319 if (data.getVersion() == null) {
320 data.setVersion(from.getVersion());
321 } else if ("0.5".equals(data.getVersion()) ^ "0.5".equals(from.getVersion())) {
322 System.err.println(tr("Warning: mixing 0.6 and 0.5 data results in version 0.5"));
323 data.setVersion("0.5");
324 }
325
326 int numNewConflicts = 0;
327 for (Conflict<?> c : visitor.getConflicts()) {
328 if (!conflicts.hasConflict(c)) {
329 numNewConflicts++;
330 conflicts.add(c);
331 }
332 }
333 // repaint to make sure new data is displayed properly.
334 Main.map.mapView.repaint();
335 warnNumNewConflicts(numNewConflicts);
336 }
337
338 /**
339 * Warns the user about the number of detected conflicts
340 *
341 * @param numNewConflicts the number of detected conflicts
342 */
343 protected void warnNumNewConflicts(int numNewConflicts) {
344 if (numNewConflicts == 0) return;
345
346 String msg1 = trn(
347 "There was {0} conflict detected.",
348 "There were {0} conflicts detected.",
349 numNewConflicts,
350 numNewConflicts
351 );
352
353 StringBuffer sb = new StringBuffer();
354 sb.append("<html>").append(msg1).append("</html>");
355 if (numNewConflicts > 0) {
356 ButtonSpec[] options = new ButtonSpec[] {
357 new ButtonSpec(
358 tr("OK"),
359 ImageProvider.get("ok"),
360 tr("Click to close this dialog and continue editing"),
361 null /* no specific help */
362 )
363 };
364 HelpAwareOptionPane.showOptionDialog(
365 Main.parent,
366 sb.toString(),
367 tr("Conflicts detected"),
368 JOptionPane.WARNING_MESSAGE,
369 null, /* no icon */
370 options,
371 options[0],
372 ht("/Concepts/Conflict#WarningAboutDetectedConflicts")
373 );
374 Main.map.conflictDialog.unfurlDialog();
375 Main.map.repaint();
376 }
377 }
378
379
380 @Override public boolean isMergable(final Layer other) {
381 return other instanceof OsmDataLayer;
382 }
383
384 @Override public void visitBoundingBox(final BoundingXYVisitor v) {
385 for (final Node n: data.getNodes()) {
386 if (n.isUsable()) {
387 v.visit(n);
388 }
389 }
390 }
391
392 /**
393 * Clean out the data behind the layer. This means clearing the redo/undo lists,
394 * really deleting all deleted objects and reset the modified flags. This should
395 * be done after an upload, even after a partial upload.
396 *
397 * @param processed A list of all objects that were actually uploaded.
398 * May be <code>null</code>, which means nothing has been uploaded
399 */
400 public void cleanupAfterUpload(final Collection<OsmPrimitive> processed) {
401 // return immediately if an upload attempt failed
402 if (processed == null || processed.isEmpty())
403 return;
404
405 Main.main.undoRedo.clean(this);
406
407 // if uploaded, clean the modified flags as well
408 data.cleanupDeletedPrimitives();
409 for (OsmPrimitive p: data.allPrimitives()) {
410 if (processed.contains(p)) {
411 p.setModified(false);
412 }
413 }
414 }
415
416
417 @Override public Object getInfoComponent() {
418 final DataCountVisitor counter = new DataCountVisitor();
419 for (final OsmPrimitive osm : data.allPrimitives()) {
420 osm.visit(counter);
421 }
422 final JPanel p = new JPanel(new GridBagLayout());
423
424 String nodeText = trn("{0} node", "{0} nodes", counter.nodes, counter.nodes);
425 if (counter.deletedNodes > 0) {
426 nodeText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedNodes, counter.deletedNodes)+")";
427 }
428
429 String wayText = trn("{0} way", "{0} ways", counter.ways, counter.ways);
430 if (counter.deletedWays > 0) {
431 wayText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedWays, counter.deletedWays)+")";
432 }
433
434 String relationText = trn("{0} relation", "{0} relations", counter.relations, counter.relations);
435 if (counter.deletedRelations > 0) {
436 relationText += " ("+trn("{0} deleted", "{0} deleted", counter.deletedRelations, counter.deletedRelations)+")";
437 }
438
439 p.add(new JLabel(tr("{0} consists of:", getName())), GBC.eol());
440 p.add(new JLabel(nodeText, ImageProvider.get("data", "node"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0));
441 p.add(new JLabel(wayText, ImageProvider.get("data", "way"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0));
442 p.add(new JLabel(relationText, ImageProvider.get("data", "relation"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0));
443 p.add(new JLabel(tr("API version: {0}", (data.getVersion() != null) ? data.getVersion() : tr("unset"))));
444
445 return p;
446 }
447
448 @Override public Action[] getMenuEntries() {
449 if (Main.applet)
450 return new Action[]{
451 LayerListDialog.getInstance().createActivateLayerAction(this),
452 LayerListDialog.getInstance().createShowHideLayerAction(),
453 LayerListDialog.getInstance().createDeleteLayerAction(),
454 SeparatorLayerAction.INSTANCE,
455 LayerListDialog.getInstance().createMergeLayerAction(this),
456 SeparatorLayerAction.INSTANCE,
457 new RenameLayerAction(getAssociatedFile(), this),
458 new ConsistencyTestAction(),
459 SeparatorLayerAction.INSTANCE,
460 new LayerListPopup.InfoAction(this)};
461 return new Action[]{
462 LayerListDialog.getInstance().createActivateLayerAction(this),
463 LayerListDialog.getInstance().createShowHideLayerAction(),
464 LayerListDialog.getInstance().createDeleteLayerAction(),
465 SeparatorLayerAction.INSTANCE,
466 LayerListDialog.getInstance().createMergeLayerAction(this),
467 new LayerSaveAction(this),
468 new LayerSaveAsAction(this),
469 new LayerGpxExportAction(this),
470 new ConvertToGpxLayerAction(),
471 SeparatorLayerAction.INSTANCE,
472 new RenameLayerAction(getAssociatedFile(), this),
473 new ConsistencyTestAction(),
474 SeparatorLayerAction.INSTANCE,
475 new LayerListPopup.InfoAction(this)};
476 }
477
478 public static GpxData toGpxData(DataSet data, File file) {
479 GpxData gpxData = new GpxData();
480 gpxData.storageFile = file;
481 HashSet<Node> doneNodes = new HashSet<Node>();
482 for (Way w : data.getWays()) {
483 if (!w.isUsable()) {
484 continue;
485 }
486 Collection<Collection<WayPoint>> trk = new ArrayList<Collection<WayPoint>>();
487 Map<String, Object> trkAttr = new HashMap<String, Object>();
488
489 if (w.get("name") != null) {
490 trkAttr.put("name", w.get("name"));
491 }
492
493 List<WayPoint> trkseg = null;
494 for (Node n : w.getNodes()) {
495 if (!n.isUsable()) {
496 trkseg = null;
497 continue;
498 }
499 if (trkseg == null) {
500 trkseg = new ArrayList<WayPoint>();
501 trk.add(trkseg);
502 }
503 if (!n.isTagged()) {
504 doneNodes.add(n);
505 }
506 WayPoint wpt = new WayPoint(n.getCoor());
507 if (!n.isTimestampEmpty()) {
508 wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
509 wpt.setTime();
510 }
511 trkseg.add(wpt);
512 }
513
514 gpxData.tracks.add(new ImmutableGpxTrack(trk, trkAttr));
515 }
516
517 for (Node n : data.getNodes()) {
518 if (n.isIncomplete() || n.isDeleted() || doneNodes.contains(n)) {
519 continue;
520 }
521 String name = n.get("name");
522 if (name == null) {
523 continue;
524 }
525 WayPoint wpt = new WayPoint(n.getCoor());
526 wpt.attr.put("name", name);
527 if (!n.isTimestampEmpty()) {
528 wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
529 wpt.setTime();
530 }
531 String desc = n.get("description");
532 if (desc != null) {
533 wpt.attr.put("desc", desc);
534 }
535
536 gpxData.waypoints.add(wpt);
537 }
538 return gpxData;
539 }
540
541 public GpxData toGpxData() {
542 return toGpxData(data, getAssociatedFile());
543 }
544
545 public class ConvertToGpxLayerAction extends AbstractAction {
546 public ConvertToGpxLayerAction() {
547 super(tr("Convert to GPX layer"), ImageProvider.get("converttogpx"));
548 }
549 public void actionPerformed(ActionEvent e) {
550 Main.main.addLayer(new GpxLayer(toGpxData(), tr("Converted from: {0}", getName())));
551 Main.main.removeLayer(OsmDataLayer.this);
552 }
553 }
554
555 public boolean containsPoint(LatLon coor) {
556 // we'll assume that if this has no data sources
557 // that it also has no borders
558 if (this.data.dataSources.isEmpty())
559 return true;
560
561 boolean layer_bounds_point = false;
562 for (DataSource src : this.data.dataSources) {
563 if (src.bounds.contains(coor)) {
564 layer_bounds_point = true;
565 break;
566 }
567 }
568 return layer_bounds_point;
569 }
570
571 /**
572 * replies the set of conflicts currently managed in this layer
573 *
574 * @return the set of conflicts currently managed in this layer
575 */
576 public ConflictCollection getConflicts() {
577 return conflicts;
578 }
579
580 /**
581 * Replies true if the data managed by this layer needs to be uploaded to
582 * the server because it contains at least one modified primitive.
583 *
584 * @return true if the data managed by this layer needs to be uploaded to
585 * the server because it contains at least one modified primitive; false,
586 * otherwise
587 */
588 public boolean requiresUploadToServer() {
589 return requiresUploadToServer;
590 }
591
592 /**
593 * Replies true if the data managed by this layer needs to be saved to
594 * a file. Only replies true if a file is assigned to this layer and
595 * if the data managed by this layer has been modified since the last
596 * save operation to the file.
597 *
598 * @return true if the data managed by this layer needs to be saved to
599 * a file
600 */
601 public boolean requiresSaveToFile() {
602 return getAssociatedFile() != null && requiresSaveToFile;
603 }
604
605 /**
606 * Initializes the layer after a successful load of OSM data from a file
607 *
608 */
609 public void onPostLoadFromFile() {
610 setRequiresSaveToFile(false);
611 setRequiresUploadToServer(data.isModified());
612 }
613
614 public void onPostDownloadFromServer() {
615 setRequiresSaveToFile(true);
616 setRequiresUploadToServer(data.isModified());
617 }
618
619 @Override
620 public boolean isChanged() {
621 return isChanged || highlightUpdateCount != data.getHighlightUpdateCount();
622 }
623
624 /**
625 * Initializes the layer after a successful save of OSM data to a file
626 *
627 */
628 public void onPostSaveToFile() {
629 setRequiresSaveToFile(false);
630 setRequiresUploadToServer(data.isModified());
631 }
632
633 /**
634 * Initializes the layer after a successful upload to the server
635 *
636 */
637 public void onPostUploadToServer() {
638 setRequiresUploadToServer(data.isModified());
639 // keep requiresSaveToDisk unchanged
640 }
641
642 private class ConsistencyTestAction extends AbstractAction {
643
644 public ConsistencyTestAction() {
645 super(tr("Dataset consistency test"));
646 }
647
648 public void actionPerformed(ActionEvent e) {
649 String result = DatasetConsistencyTest.runTests(data);
650 if (result.length() == 0) {
651 JOptionPane.showMessageDialog(Main.parent, tr("No problems found"));
652 } else {
653 JPanel p = new JPanel(new GridBagLayout());
654 p.add(new JLabel(tr("Following problems found:")), GBC.eol());
655 JTextArea info = new JTextArea(result, 20, 60);
656 info.setCaretPosition(0);
657 info.setEditable(false);
658 p.add(new JScrollPane(info), GBC.eop());
659
660 JOptionPane.showMessageDialog(Main.parent, p, tr("Warning"), JOptionPane.WARNING_MESSAGE);
661 }
662 }
663 }
664
665 @Override
666 public void destroy() {
667 DataSet.removeSelectionListener(this);
668 }
669
670 public void processDatasetEvent(AbstractDatasetChangedEvent event) {
671 isChanged = true;
672 setRequiresSaveToFile(true);
673 setRequiresUploadToServer(true);
674 }
675
676 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
677 isChanged = true;
678 }
679
680 @Override
681 public void projectionChanged(Projection oldValue, Projection newValue) {
682 /*
683 * No reprojection required. The dataset itself is registered as projection
684 * change listener and already got notified.
685 */
686 }
687}
Note: See TracBrowser for help on using the repository browser.