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

Last change on this file since 4684 was 4684, checked in by Don-vip, 12 years ago

see #7159 - Layer merging performance

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