samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java
changeset 312 0678c9589013
child 314 03a451fc2256
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/trycatchredo/src/org/apidesign/exceptions/trycatchredo/api/UserQuestionException.java	Sun Feb 01 16:29:46 2009 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +package org.apidesign.exceptions.trycatchredo.api;
     1.5 +
     1.6 +import java.io.IOException;
     1.7 +import javax.swing.JOptionPane;
     1.8 +
     1.9 +/** Specialized I/O exception to request some kind of user confirmation.
    1.10 + * A code that needs to ask user shall not attempt to open a dialog itself,
    1.11 + * rather it shall emit this exception and let its callers show the dialog
    1.12 + * at appropriate time.
    1.13 + *
    1.14 + * @author Jaroslav Tulach
    1.15 + * @since 2.0
    1.16 + */
    1.17 +public abstract class UserQuestionException extends IOException {
    1.18 +    /** Description of the dialog to show to the user. Whoever catches
    1.19 +     * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)}
    1.20 +     * to construct and display the dialog.
    1.21 +     * 
    1.22 +     * @return the pane to display to user
    1.23 +     */
    1.24 +    public abstract JOptionPane getQuestionPane();
    1.25 +    /** When the user confirms (or rejects) message presented by the
    1.26 +     * {@link #getQuestionPane()} dialog, the exception shall be notified
    1.27 +     * by calling this method with {@link JOptionPane#getValue()} option.
    1.28 +     *
    1.29 +     * @param option the option selected by the user
    1.30 +     */
    1.31 +    public abstract void confirm(Object option);
    1.32 +}