- Timestamp:
- 2012-05-12T15:39:13+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractMergeAction.java
r4851 r5233 83 83 protected void warnNoTargetLayersForSourceLayer(Layer sourceLayer) { 84 84 JOptionPane.showMessageDialog(Main.parent, 85 tr("<html>There are no layers the source layer<br>''{0}''<br>could be merged to.</html>"), 85 tr("<html>There are no layers the source layer<br>''{0}''<br>could be merged to.</html>", sourceLayer.getName()), 86 86 tr("No target layers"), JOptionPane.WARNING_MESSAGE); 87 87 } -
trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java
r4982 r5233 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 import java.util.Collection; 10 import java.util.Collections; 9 11 import java.util.List; 10 12 … … 12 14 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 13 15 import org.openstreetmap.josm.gui.layer.Layer; 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 import org.openstreetmap.josm.gui.util.GuiHelper; 18 import org.openstreetmap.josm.tools.ImageProvider; 14 19 import org.openstreetmap.josm.tools.Shortcut; 15 20 … … 25 30 } 26 31 27 p ublic void merge(List<Layer> sourceLayers) {28 Layer targetLayer = askTargetLayer( sourceLayers);32 protected void doMerge(List<Layer> targetLayers, final Collection<Layer> sourceLayers) { 33 final Layer targetLayer = askTargetLayer(targetLayers); 29 34 if (targetLayer == null) 30 35 return; 31 for (Layer l: sourceLayers) { 32 if (l != targetLayer) { 33 targetLayer.mergeFrom(l); 34 Main.map.mapView.removeLayer(l); 36 Main.worker.submit(new Runnable() { 37 @Override 38 public void run() { 39 boolean layerMerged = false; 40 for (Layer sourceLayer: sourceLayers) { 41 if (sourceLayer != null && sourceLayer != targetLayer) { 42 if (sourceLayer instanceof OsmDataLayer && targetLayer instanceof OsmDataLayer 43 && ((OsmDataLayer)sourceLayer).isUploadDiscouraged() != ((OsmDataLayer)targetLayer).isUploadDiscouraged()) { 44 if (warnMergingUploadDiscouragedLayers(sourceLayer, targetLayer)) { 45 break; 46 } 47 } 48 targetLayer.mergeFrom(sourceLayer); 49 Main.map.mapView.removeLayer(sourceLayer); 50 layerMerged = true; 51 } 52 } 53 if (layerMerged) { 54 Main.map.mapView.setActiveLayer(targetLayer); 55 } 35 56 } 36 } 37 Main.map.mapView.setActiveLayer(targetLayer); 57 }); 58 } 59 60 public void merge(List<Layer> sourceLayers) { 61 doMerge(sourceLayers, sourceLayers); 38 62 } 39 63 40 public void merge( finalLayer sourceLayer) {64 public void merge(Layer sourceLayer) { 41 65 if (sourceLayer == null) 42 66 return; … … 46 70 return; 47 71 } 48 final Layer targetLayer = askTargetLayer(targetLayers); 49 if (targetLayer == null) 50 return; 51 Main.worker.submit(new Runnable() { 52 @Override 53 public void run() { 54 targetLayer.mergeFrom(sourceLayer); 55 Main.map.mapView.removeLayer(sourceLayer); 56 Main.map.mapView.setActiveLayer(targetLayer); 57 } 58 }); 72 doMerge(targetLayers, Collections.singleton(sourceLayer)); 59 73 } 60 74 … … 74 88 setEnabled(!LayerListDialog.getInstance().getModel().getPossibleMergeTargets(getEditLayer()).isEmpty()); 75 89 } 90 91 /** 92 * returns true if the user wants to cancel, false if they want to continue 93 */ 94 public static final boolean warnMergingUploadDiscouragedLayers(Layer sourceLayer, Layer targetLayer) { 95 return GuiHelper.warnUser(tr("Merging layers with different upload policies"), 96 "<html>" + 97 tr("You are about to merge data between layers ''{0}'' and ''{1}''.<br /><br />"+ 98 "These layers have different upload policies and should not been merged as it.<br />"+ 99 "Merging them will result to enforce the stricter policy (upload discouraged) to ''{1}''.<br /><br />"+ 100 "<b>This is not the recommended way of merging such data</b>.<br />"+ 101 "You should instead check and merge each object, one by one, by using ''<i>Merge selection</i>''.<br /><br />"+ 102 "Are you sure you want to continue?", sourceLayer.getName(), targetLayer.getName(), targetLayer.getName())+ 103 "</html>", 104 ImageProvider.get("dialogs", "mergedown"), tr("Ignore this hint and merge anyway")); 105 } 76 106 } -
trunk/src/org/openstreetmap/josm/actions/MergeSelectionAction.java
r4982 r5233 16 16 import org.openstreetmap.josm.gui.layer.Layer; 17 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.gui.util.GuiHelper; 19 import org.openstreetmap.josm.tools.ImageProvider; 18 20 import org.openstreetmap.josm.tools.Shortcut; 19 21 … … 37 39 if (targetLayer == null) 38 40 return; 41 if (getEditLayer().isUploadDiscouraged() && targetLayer instanceof OsmDataLayer && !((OsmDataLayer)targetLayer).isUploadDiscouraged() 42 && getEditLayer().data.getSelected().size() > 1) { 43 if (warnMergingUploadDiscouragedObjects(targetLayer)) { 44 return; 45 } 46 } 39 47 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(getEditLayer().data); 40 48 ((OsmDataLayer)targetLayer).mergeFrom(builder.build()); … … 60 68 setEnabled(selection != null && !selection.isEmpty()); 61 69 } 70 71 /** 72 * returns true if the user wants to cancel, false if they want to continue 73 */ 74 public static final boolean warnMergingUploadDiscouragedObjects(Layer targetLayer) { 75 return GuiHelper.warnUser(tr("Merging too many objects with different upload policies"), 76 "<html>" + 77 tr("You are about to merge more than 1 object between layers ''{0}'' and ''{1}''.<br /><br />"+ 78 "<b>This is not the recommended way of merging such data</b>.<br />"+ 79 "You should instead check and merge each object, <b>one by one</b>.<br /><br />"+ 80 "Are you sure you want to continue?", getEditLayer().getName(), targetLayer.getName(), targetLayer.getName())+ 81 "</html>", 82 ImageProvider.get("dialogs", "mergedown"), tr("Ignore this hint and merge anyway")); 83 } 62 84 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r5025 r5233 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.awt.Image;8 7 import java.awt.event.ActionEvent; 9 8 import java.awt.event.KeyEvent; 10 9 import java.util.LinkedList; 11 10 12 import javax.swing.Icon;13 import javax.swing.ImageIcon;14 11 import javax.swing.JOptionPane; 15 12 import javax.swing.SwingUtilities; … … 22 19 import org.openstreetmap.josm.data.APIDataSet; 23 20 import org.openstreetmap.josm.data.conflict.ConflictCollection; 24 import org.openstreetmap.josm.gui.ExtendedDialog;25 21 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 26 22 import org.openstreetmap.josm.gui.help.HelpUtil; … … 28 24 import org.openstreetmap.josm.gui.io.UploadPrimitivesTask; 29 25 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 26 import org.openstreetmap.josm.gui.util.GuiHelper; 30 27 import org.openstreetmap.josm.tools.ImageProvider; 31 28 import org.openstreetmap.josm.tools.Shortcut; … … 126 123 */ 127 124 public static final boolean warnUploadDiscouraged(OsmDataLayer layer) { 128 ExtendedDialog dlg = new ExtendedDialog(Main.parent, 129 tr("Upload discouraged"), 130 new String[] {tr("Cancel"), tr("Continue")}); 131 dlg.setContent("<html>" + 125 return GuiHelper.warnUser(tr("Upload discouraged"), 126 "<html>" + 132 127 tr("You are about to upload data from the layer ''{0}''.<br /><br />"+ 133 "Sending data from this layer is <b>strongly discouraged</b>. If you continue,<br />"+ 134 "it may require you subsequently have to revert your changes, or force other contributors to.<br /><br />"+ 135 "Are you sure you want to continue?", layer.getName())+ 136 "</html>"); 137 dlg.setButtonIcons(new Icon[] { 138 ImageProvider.get("cancel"), 139 ImageProvider.overlay( 140 ImageProvider.get("upload"), 141 new ImageIcon(ImageProvider.get("warning-small").getImage().getScaledInstance(10 , 10, Image.SCALE_SMOOTH)), 142 ImageProvider.OverlayPosition.SOUTHEAST)}); 143 dlg.setToolTipTexts(new String[] { 144 tr("Cancel"), 145 tr("Ignore this hint and upload anyway")}); 146 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 147 dlg.setCancelButton(1); 148 return dlg.showDialog().getValue() != 2; 128 "Sending data from this layer is <b>strongly discouraged</b>. If you continue,<br />"+ 129 "it may require you subsequently have to revert your changes, or force other contributors to.<br /><br />"+ 130 "Are you sure you want to continue?", layer.getName())+ 131 "</html>", 132 ImageProvider.get("upload"), tr("Ignore this hint and upload anyway")); 149 133 } 150 134 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayerInfo.java
r4310 r5233 31 31 this.layer = layer; 32 32 this.doSaveToFile = layer.requiresSaveToFile(); 33 this.doUploadToServer = layer.requiresUploadToServer(); 33 this.doUploadToServer = layer.requiresUploadToServer() && !layer.isUploadDiscouraged(); 34 34 this.file = layer.getAssociatedFile(); 35 35 } -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTableColumnModel.java
r5003 r5233 37 37 StringBuilder sb = new StringBuilder(); 38 38 sb.append("<html>"); 39 if (info.getLayer().requiresUploadToServer()) { 39 if (info.getLayer().requiresUploadToServer() && !info.getLayer().isUploadDiscouraged()) { 40 40 add(needsUpload, defaultCellStyle); 41 41 sb.append(tr("Layer ''{0}'' has modifications which should be uploaded to the server.", info.getName())); … … 43 43 } else { 44 44 add(pnlEmpty, defaultCellStyle); 45 sb.append(tr("Layer ''{0}'' has no modifications to be uploaded.", info.getName())); 45 if (info.getLayer().requiresUploadToServer()) { 46 sb.append(tr("Layer ''{0}'' has modifications which are discouraged to be uploaded.", info.getName())); 47 } else { 48 sb.append(tr("Layer ''{0}'' has no modifications to be uploaded.", info.getName())); 49 } 46 50 } 47 51 sb.append("<br/>"); -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r5059 r5233 302 302 final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Merging layers")); 303 303 monitor.setCancelable(false); 304 if (from instanceof OsmDataLayer && ((OsmDataLayer)from).isUploadDiscouraged()) { 305 setUploadDiscouraged(true); 306 } 304 307 mergeFrom(((OsmDataLayer)from).data, monitor); 305 308 monitor.close(); … … 411 414 412 415 @Override public boolean isMergable(final Layer other) { 413 return other instanceof OsmDataLayer && (isUploadDiscouraged() == ((OsmDataLayer)other).isUploadDiscouraged()); 416 // isUploadDiscouraged commented to allow merging between normal layers and discouraged layers with a warning (see #7684) 417 return other instanceof OsmDataLayer;// && (isUploadDiscouraged() == ((OsmDataLayer)other).isUploadDiscouraged()); 414 418 } 415 419 -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r4695 r5233 2 2 package org.openstreetmap.josm.gui.util; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.awt.Component; 5 7 import java.awt.Container; 8 import java.awt.Image; 6 9 10 import javax.swing.Icon; 11 import javax.swing.ImageIcon; 12 import javax.swing.JOptionPane; 7 13 import javax.swing.SwingUtilities; 14 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.gui.ExtendedDialog; 17 import org.openstreetmap.josm.tools.ImageProvider; 8 18 9 19 /** … … 33 43 } 34 44 } 45 46 /** 47 * returns true if the user wants to cancel, false if they 48 * want to continue 49 */ 50 public static final boolean warnUser(String title, String content, ImageIcon baseActionIcon, String continueToolTip) { 51 ExtendedDialog dlg = new ExtendedDialog(Main.parent, 52 title, new String[] {tr("Cancel"), tr("Continue")}); 53 dlg.setContent(content); 54 dlg.setButtonIcons(new Icon[] { 55 ImageProvider.get("cancel"), 56 ImageProvider.overlay( 57 ImageProvider.get("upload"), 58 new ImageIcon(ImageProvider.get("warning-small").getImage().getScaledInstance(10 , 10, Image.SCALE_SMOOTH)), 59 ImageProvider.OverlayPosition.SOUTHEAST)}); 60 dlg.setToolTipTexts(new String[] { 61 tr("Cancel"), 62 continueToolTip}); 63 dlg.setIcon(JOptionPane.WARNING_MESSAGE); 64 dlg.setCancelButton(1); 65 return dlg.showDialog().getValue() != 2; 66 } 35 67 36 68 }
Note:
See TracChangeset
for help on using the changeset viewer.