X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2Fdialogrunner%2FDialogRunnerI.java;h=1fc41e7c60cec166e33f913e096b9350b364d942;hb=09be4c7dd6a31d9a39e5317cc8dc9eb21e8e6ebf;hp=cc4a83686866a8fb5cd75f8a746b8dcaa65317c2;hpb=1e28a196997a1e0b8b74d468bfd3df8ec74c1337;p=jalview.git diff --git a/src/jalview/util/dialogrunner/DialogRunnerI.java b/src/jalview/util/dialogrunner/DialogRunnerI.java index cc4a836..1fc41e7 100644 --- a/src/jalview/util/dialogrunner/DialogRunnerI.java +++ b/src/jalview/util/dialogrunner/DialogRunnerI.java @@ -20,10 +20,13 @@ */ package jalview.util.dialogrunner; -import java.util.List; +import java.util.concurrent.Callable; /** - * 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 * @@ -31,17 +34,29 @@ import java.util.List; public interface DialogRunnerI { - DialogRunnerI addResponse(Object response, RunResponse action); + /** + * 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 setResponseHandler(Object response, Callable 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 handleResponse(Object response) + default void handleResponse(Object response) { - return null; } }