﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
136	Patch for uploading hooks	frsantos@…	imi	"This patch allows plugins to hook to the upload action, vetoing it if needed.


Index: /home/frsantos/Proyectos/JOSM/josm/src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- /home/frsantos/Proyectos/JOSM/josm/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 219)
+++ /home/frsantos/Proyectos/JOSM/josm/src/org/openstreetmap/josm/actions/UploadAction.java	(working copy)
@@ -32,6 +32,27 @@
  * @author imi

  */

 public class UploadAction extends JosmAction {

+	

+	/** Upload Hook */

+	public interface UploadHook {

+		/**

+		 * Checks the upload.

+		 * @param add The added primitives

+		 * @param update The updated primitives

+		 * @param delete The deleted primitives

+		 * @return true, if the upload can continue

+		 */

+		boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, Collection<OsmPrimitive> delete);

+	}

+	

+	/**

+	 * The list of upload hooks. These hooks will be called after showing the

+	 * upload window, so that any plugin can perform actions with the data and

+	 * veto the upload

+	 */

+	public final Collection<UploadHook> uploadHooks = new LinkedList<UploadHook>();

+	

+	

 	public UploadAction() {

 		super(tr(""Upload to OSM""), ""upload"", tr(""Upload all changes to the OSM server.""), KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, true);

 	}

@@ -66,6 +87,10 @@
 		if (!displayUploadScreen(add, update, delete))

 			return;

 

+		for(UploadHook hook : uploadHooks)

+			if( !hook.checkUpload(add, update, delete) )

+				return;

+		

 		final OsmServerWriter server = new OsmServerWriter();

 		final Collection<OsmPrimitive> all = new LinkedList<OsmPrimitive>();

 		all.addAll(add);

"	enhancement	closed	major		Core	latest	fixed		
