X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Futil%2Fdialogrunner%2FDialogRunnerI.java;h=fde80f7843a52154c51915df68f1b41a79e91ed0;hb=3d3cc73c14a48c9af73bf0a33a4897b37a66856b;hp=aaeb30448e52b96ea2bee5fc53d00940e41dc433;hpb=be9359e9a28efb6aade9bdac054d76b4f9452c47;p=jalview.git diff --git a/src/jalview/util/dialogrunner/DialogRunnerI.java b/src/jalview/util/dialogrunner/DialogRunnerI.java index aaeb304..fde80f7 100644 --- a/src/jalview/util/dialogrunner/DialogRunnerI.java +++ b/src/jalview/util/dialogrunner/DialogRunnerI.java @@ -21,21 +21,38 @@ package jalview.util.dialogrunner; /** - * 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 * */ -public interface DialogRunnerI +public interface DialogRunnerI { /** - * define a new response for this dialog. eg. dialog.response(new - * RunResponse(OK_PRessed) { run()...}).response(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 the dialog + * @return */ - T response(RunResponse action); + DialogRunnerI setResponseHandler(Object response, Runnable action); + + /** + * 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 void handleResponse(Object response) + { + } }