// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.actions.upload; import static org.openstreetmap.josm.tools.I18n.tr; import java.awt.Dimension; import java.awt.GridBagLayout; import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.swing.JPanel; import javax.swing.JScrollPane; import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.APIDataSet; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; import org.openstreetmap.josm.data.validation.OsmValidator; import org.openstreetmap.josm.data.validation.Severity; import org.openstreetmap.josm.data.validation.Test; import org.openstreetmap.josm.data.validation.TestError; import org.openstreetmap.josm.data.validation.util.AggregatePrimitivesVisitor; import org.openstreetmap.josm.gui.ExtendedDialog; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.MapFrame; import org.openstreetmap.josm.gui.dialogs.validator.ValidatorTreePanel; import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.gui.layer.ValidatorLayer; import org.openstreetmap.josm.gui.widgets.HtmlPanel; import org.openstreetmap.josm.tools.GBC; /** * The action that does the validate thing. *
* This action iterates through all active tests and give them the data, so that
* each one can test it.
*
* @author frsantos
* @since 3669
*/
public class ValidateUploadHook implements UploadHook {
/**
* Validate the modified data before uploading
*/
@Override
public boolean checkUpload(APIDataSet apiDataSet) {
OsmValidator.initializeTests();
Collectiontrue
, if the upload should continue. false
* if the user requested cancel.
*/
private static boolean displayErrorScreen(List
When you"
+ " cancel this dialog, you can find the entries in the validator"
+ " side panel to inspect them.")
+ ""
+ "
"
);
pnlMessage.setPreferredSize(new Dimension(500, 150));
p.add(pnlMessage, GBC.eol().fill(GBC.HORIZONTAL));
p.add(new JScrollPane(errorPanel), GBC.eol().fill(GBC.BOTH));
ExtendedDialog ed = new ExtendedDialog(Main.parent,
tr("Suspicious data found. Upload anyway?"),
tr("Continue upload"), tr("Cancel"))
.setButtonIcons("ok", "cancel")
.setContent(p);
if (ed.showDialog().getValue() != 1) {
OsmValidator.initializeTests();
OsmValidator.initializeErrorLayer();
MainApplication.getMap().validatorDialog.unfurlDialog();
MainApplication.getLayerManager().getLayersOfType(ValidatorLayer.class).forEach(ValidatorLayer::invalidate);
return false;
}
return true;
}
}
"
+ ""+tr("Errors")
+ " "
+ tr("Usually this should be fixed.")+" "
+ ""+tr("Warnings")
+ " "
+ tr("Fix these when possible.")+" "
+ ""+tr("Other")
+ " "
+ tr("Informational warnings, expect many false entries.")+"