Changeset 5025 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2012-02-26T16:10:39+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r4982 r5025 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.awt.Image; 7 8 import java.awt.event.ActionEvent; 8 9 import java.awt.event.KeyEvent; 9 10 import java.util.LinkedList; 10 11 12 import javax.swing.Icon; 13 import javax.swing.ImageIcon; 11 14 import javax.swing.JOptionPane; 12 15 import javax.swing.SwingUtilities; … … 19 22 import org.openstreetmap.josm.data.APIDataSet; 20 23 import org.openstreetmap.josm.data.conflict.ConflictCollection; 24 import org.openstreetmap.josm.gui.ExtendedDialog; 21 25 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 22 26 import org.openstreetmap.josm.gui.help.HelpUtil; … … 24 28 import org.openstreetmap.josm.gui.io.UploadPrimitivesTask; 25 29 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 30 import org.openstreetmap.josm.tools.ImageProvider; 26 31 import org.openstreetmap.josm.tools.Shortcut; 27 32 … … 104 109 } 105 110 106 protected void alertUnresolvedConflicts(OsmDataLayer layer) {111 protected static void alertUnresolvedConflicts(OsmDataLayer layer) { 107 112 HelpAwareOptionPane.showOptionDialog( 108 113 Main.parent, … … 115 120 ); 116 121 } 122 123 /** 124 * returns true if the user wants to cancel, false if they 125 * want to continue 126 */ 127 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>" + 132 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; 149 } 117 150 118 151 /** 119 152 * Check whether the preconditions are met to upload data in <code>apiData</code>. 120 * Makes sure primitives in <code>apiData</code> don't participate in conflicts and153 * Makes sure upload is allowed, primitives in <code>apiData</code> don't participate in conflicts and 121 154 * runs the installed {@see UploadHook}s. 122 155 * … … 126 159 */ 127 160 public boolean checkPreUploadConditions(OsmDataLayer layer, APIDataSet apiData) { 161 if (layer.isUploadDiscouraged()) { 162 if (warnUploadDiscouraged(layer)) { 163 return false; 164 } 165 } 128 166 ConflictCollection conflicts = layer.getConflicts(); 129 167 if (apiData.participatesInConflict(conflicts)) { -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r4191 r5025 88 88 if (!isEnabled()) 89 89 return; 90 if (getEditLayer().isUploadDiscouraged()) { 91 if (UploadAction.warnUploadDiscouraged(getEditLayer())) { 92 return; 93 } 94 } 90 95 UploadHullBuilder builder = new UploadHullBuilder(); 91 96 UploadSelectionDialog dialog = new UploadSelectionDialog();
Note:
See TracChangeset
for help on using the changeset viewer.