samples/exceptions/src/org/apidesign/exceptions/trycatchredo/UserQuestionException.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 01 Feb 2009 16:03:37 +0100
changeset 310 fba31e9504a1
parent 309 1687adb2b7f0
permissions -rw-r--r--
QueryException interactive example
jtulach@307
     1
package org.apidesign.exceptions.trycatchredo;
jtulach@307
     2
jtulach@307
     3
import java.io.IOException;
jtulach@309
     4
import javax.swing.JOptionPane;
jtulach@307
     5
jtulach@310
     6
/** Specialized I/O exception to request some kind of user confirmation.
jtulach@310
     7
 * A code that needs to ask user shall not attempt to open a dialog itself,
jtulach@310
     8
 * rather it shall emit this exception and let its callers show the dialog
jtulach@310
     9
 * at appropriate time.
jtulach@307
    10
 *
jtulach@307
    11
 * @author Jaroslav Tulach
jtulach@310
    12
 * @since 2.0
jtulach@307
    13
 */
jtulach@307
    14
public abstract class UserQuestionException extends IOException {
jtulach@310
    15
    /** Description of the dialog to show to the user. Whoever catches
jtulach@310
    16
     * this exception shall use {@link #getQuestionPane()}.{@link JOptionPane#createDialog(java.lang.String)}
jtulach@310
    17
     * to construct and display the dialog.
jtulach@310
    18
     * 
jtulach@310
    19
     * @return the pane to display to user
jtulach@310
    20
     */
jtulach@309
    21
    public abstract JOptionPane getQuestionPane();
jtulach@310
    22
    /** When the user confirms (or rejects) message presented by the
jtulach@310
    23
     * {@link #getQuestionPane()} dialog, the exception shall be notified
jtulach@310
    24
     * by calling this method with {@link JOptionPane#getValue()} option.
jtulach@310
    25
     *
jtulach@310
    26
     * @param option the option selected by the user
jtulach@310
    27
     */
jtulach@309
    28
    public abstract void confirm(Object option);
jtulach@307
    29
}