X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2Fdialogrunner%2FDialogRunnerI.java;h=fde80f7843a52154c51915df68f1b41a79e91ed0;hb=a059dd46fe149a476bd274562cd27b2dc7d390dd;hp=691465625e0ac746d6a0215b6a72d88f8cf276e4;hpb=a4aa14220a6a53391ca8e171bc774cef908057a3;p=jalview.git diff --git a/src/jalview/util/dialogrunner/DialogRunnerI.java b/src/jalview/util/dialogrunner/DialogRunnerI.java index 6914656..fde80f7 100644 --- a/src/jalview/util/dialogrunner/DialogRunnerI.java +++ b/src/jalview/util/dialogrunner/DialogRunnerI.java @@ -20,10 +20,11 @@ */ package jalview.util.dialogrunner; -import java.util.List; - /** - * functional pattern for blocking dialog response handling + * An interface for blocking dialog response handling. This is motivated by + * JalviewJS - when running as Javascript, there is only a single thread, and + * blocking dialogs have to be responsible for performing any actions required + * for user responses. * * @author jprocter * @@ -32,26 +33,26 @@ public interface DialogRunnerI { /** - * Adds a new response for this dialog, and returns the dialog (this), to allow chaining, eg. - *
- * dialog.addResponse(newRunResponse(OK_PRessed) { run()...}) - * .addResponse(new RunResponse(CANCEL_PRESSED); - *+ * Sets the action to be performed when the dialog returns the given response. + * Note this also handles
int
-valued responses, which will be
+ * converted to Integer
when this method is invoked.
*
+ * @param response
* @param action
* @return
*/
- DialogRunnerI addResponse(RunResponse action);
+ DialogRunnerI setResponseHandler(Object response, Runnable action);
/**
- * Runs any registered handlers for the given response, and answers the list
- * of responses run (if any) in order run
+ * Runs the registered handler (if any) for the given response. The default
+ * action is to do nothing. Typically an action will be need on 'OK' or other
+ * positive selection in the dialog. An action might in some cases also be
+ * needed for a 'Cancel' response.
*
* @param response
* @return
*/
- default List