diff -r 000000000000 -r 0678c9589013 samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java Sun Feb 01 16:29:46 2009 +0100 @@ -0,0 +1,29 @@ +package org.apidesign.exceptions.trycatchredo.api; + +import java.io.IOException; +import javax.swing.JOptionPane; + +/** Specialized I/O exception to request some kind of user confirmation. + * A code that needs to ask user shall not attempt to open a dialog itself, + * rather it shall emit this exception and let its callers show the dialog + * at appropriate time. + * + * @author Jaroslav Tulach + * @since 2.0 + */ +public abstract class UserQuestionException extends IOException { + /** Description of the dialog to show to the user. Whoever catches + * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)} + * to construct and display the dialog. + * + * @return the pane to display to user + */ + public abstract JOptionPane getQuestionPane(); + /** When the user confirms (or rejects) message presented by the + * {@link #getQuestionPane()} dialog, the exception shall be notified + * by calling this method with {@link JOptionPane#getValue()} option. + * + * @param option the option selected by the user + */ + public abstract void confirm(Object option); +}