You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/02/16 12:58:33 UTC
[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3613: Support CompletableFuture in DialogDisplayer
JaroslavTulach commented on a change in pull request #3613:
URL: https://github.com/apache/netbeans/pull/3613#discussion_r807929480
##########
File path: platform/openide.dialogs/src/org/openide/DialogDisplayer.java
##########
@@ -98,6 +101,53 @@ public void run() {
}
});
}
+
+ /**
+ * Notify the user by a message box. The method may be called from any thread; the method
+ * returns immediately and the UI will be shown later, as in {@link #notifyLater}. Unlike
+ * {@link #notifyLater}, this method returns a {@link CompletableFuture} that will be
+ * completed when the UI closes. The value of the returned {@link CompletableFuture} is
+ * the descriptor itself: it's {@link NotifyDescriptor#getValue()} will be set to the
+ * closing option. If a subclass, like {@link NotifyDescriptor.InputLine} is used, the
+ * task can query other values of NotifyDescriptor, such as the text entered.
+ * Any exception thrown by {@link NotifyDescriptor} processing will be reported through {@link CompletableFuture#completeExceptionally}.
+ * <p>
+ * It is possible to call {@link CompletableFuture#cancel(boolean)} on the returned value.
+ * The implementation may (through it is not guaranteed) abort and hide the UI. If cancel() is
+ * called, the returned Future always completes exceptionally, with a {@link CancellationException}.
+ * <p>
+ * The thread that will execute the continuation or exception handler is undefined. Use usual
+ * precautions against EDT blocking and use {@link CompletableFuture#thenAcceptAsync(java.util.function.Consumer, java.util.concurrent.Executor)}
+ * or similar to execute in a specific thread. Prefer usage of {@link RequestProcessor} to the
+ * builtin thread pool.
+ * <div class="nonnormative">
+ * The following snippet is an example of chained dialogs (can be any other processing): {@codesnippet dialogdisplayer-notifyCompletion}
+ * </div>
+ * @param <T> actual subclass of {@link NotifyDescriptor} passed as a parameter.
+ * @param descriptor describes the UI / dialog.
+ * @return the descriptor instance.
+ * @since 7.60
+ */
+ public <T extends NotifyDescriptor> CompletableFuture<T> notifyCompletion(final T descriptor) {
Review comment:
I'd call the method `notifyFuture` - it returns a future, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists