package org.zaproxy.zap.extension.script;

import java.awt.event.MouseAdapter;
import java.io.Writer;
import java.util.List;

import javax.swing.TransferHandler;
import javax.swing.tree.TreeCellRenderer;

public interface ScriptUI {

	/**
	 * Called after an engine is added.
	 * <p>
	 * The UI should display the contents of the selected script if it's targeting the added engine.
	 * 
	 * @param scriptEngineWrapper the engine that was removed
	 * @since 2.4.0
	 */
	void engineAdded(ScriptEngineWrapper scriptEngineWrapper);

	/**
	 * Called after an engine is removed.
	 * <p>
	 * The UI should clear the contents of the selected script if it's targeting the removed engine.
	 * 
	 * @param scriptEngineWrapper the engine that was removed
	 * @since 2.4.0
	 */
	void engineRemoved(ScriptEngineWrapper scriptEngineWrapper);

	ScriptNode getSelectedNode();
	
	List<ScriptNode> getSelectedNodes();
	
	void addMouseListener(MouseAdapter adapter); 

	/**
	 * Removes the given mouse listener.
	 *
	 * @param mouseListener the mouse listener that will be removed.
	 * @since 2.4.0
	 */
	void removeMouseListener(MouseAdapter mouseListener); 
	
	void addRenderer(Class<?> c, TreeCellRenderer renderer);

	/**
	 * Removes the renderer added for the given class.
	 *
	 * @param klass the class whose target renderer should be removed
	 * @since 2.4.0
	 */
	void removeRenderer(Class<?> klass);

	/**
	 * Adds a transfer handler for the given class.
	 *
	 * @param klass the class in which the given transfer handler will be used
	 * @param th the transfer handler
	 * @since 2.4.0
	 */
	void addScriptTreeTransferHandler(Class<?> klass, TransferHandler th);

	/**
	 * Removes the transfer handler that was being used for the given class.
	 *
	 * @param klass the class whose targeting transfer handler will be removed
	 * @since 2.4.0
	 */
	void removeScriptTreeTransferHandler(Class<?> klass);
	
	void displayScript (ScriptWrapper script);

	boolean isScriptDisplayed(ScriptWrapper script);

	void selectNode(ScriptNode node, boolean expand);

	void disableScriptDialog(Class<?> klass);

	/**
	 * Removes a disabled script dialogue of the given class.
	 *
	 * @param klass the class that has the script dialogue disabled
	 * @since 2.4.0
	 */
	void removeDisableScriptDialog(Class<?> klass);
	
	String getTreeName();
	
	Writer getOutputWriter();
}

@@ -151,24 +151,72 @@
 ferHandler;%0A
+import javax.swing.event.TreeSelectionListener;%0A
 import javax
@@ -874,77 +874,1104 @@
 ;%0A%0A%09
-ScriptNode getSelectedNode();%0A%09%0A%09List%3CScriptNode%3E getSelectedNodes();
+/**%0A%09 * Gets the currently selected script node.%0A%09 *%0A%09 * @return the selected node, or %7B@code null%7D if none.%0A%09 * @see #getSelectedNodes()%0A%09 * @see #addSelectionListener(TreeSelectionListener)%0A%09 */%0A%09ScriptNode getSelectedNode();%0A%09%0A%09/**%0A%09 * Gets the currently selected script nodes.%0A%09 *%0A%09 * @return the selected nodes, or empty list if none.%0A%09 * @see #getSelectedNode()%0A%09 * @see #addSelectionListener(TreeSelectionListener)%0A%09 */%0A%09List%3CScriptNode%3E getSelectedNodes();%0A%0A%09/**%0A%09 * Adds the given tree selection listener.%0A%09 *%0A%09 * @param tsl the tree selection listener to be added.%0A%09 * @since TODO add version%0A%09 * @see #removeSelectionListener(TreeSelectionListener)%0A%09 * @see #getSelectedNode()%0A%09 * @see #getSelectedNodes()%0A%09 */%0A%09default void addSelectionListener(TreeSelectionListener tsl) %7B%0A%09%09// Nothing to do.%0A%09%7D%0A%0A%09/**%0A%09 * Removes the given tree selection listener.%0A%09 *%0A%09 * @param tsl the tree selection listener to remove.%0A%09 * @since TODO add version%0A%09 * @see #addSelectionListener(TreeSelectionListener)%0A%09 */%0A%09default void removeSelectionListener(TreeSelectionListener tsl) %7B%0A%09%09// Nothing to do.%0A%09%7D
 %0A%09%0A%09

Allow to react to selection change in Scripts tree