KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > util > AbstractUIHandler


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2003 Tino Schwarze
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.izforge.izpack.util;
23
24 /**
25  * This interface describes basic functionality neccessary for user interaction.
26  *
27  * All methods or functions which perform work and need to notify or ask the user use a listener for
28  * such purposes. This way, we can separate UI from function.
29  *
30  */

31
32 public interface AbstractUIHandler
33 {
34
35     /**
36      * Notify the user about something.
37      *
38      * The difference between notification and warning is that a notification should not need user
39      * interaction and can savely be ignored.
40      *
41      * @param message The notification.
42      */

43     public void emitNotification(String JavaDoc message);
44
45     /**
46      * Warn the user about something.
47      *
48      * @param title The message title (used for dialog name, might not be displayed)
49      * @param message The warning message.
50      * @return true if the user decided not to continue
51      */

52     public boolean emitWarning(String JavaDoc title, String JavaDoc message);
53
54     /**
55      * Notify the user of some error.
56      *
57      * @param title The message title (used for dialog name, might not be displayed)
58      * @param message The error message.
59      */

60     public void emitError(String JavaDoc title, String JavaDoc message);
61
62     // constants for asking questions
63
// must all be >= 0!
64
public static final int ANSWER_CANCEL = 45;
65
66     public static final int ANSWER_YES = 47;
67
68     public static final int ANSWER_NO = 49;
69
70     // values for choices to present to the user
71
public static final int CHOICES_YES_NO = 37;
72
73     public static final int CHOICES_YES_NO_CANCEL = 38;
74
75     /**
76      * Ask the user a question.
77      *
78      * @param title The title of the question (useful for dialogs). Might be null.
79      * @param question The question.
80      * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL
81      *
82      * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO)
83      */

84     public int askQuestion(String JavaDoc title, String JavaDoc question, int choices);
85
86     /**
87      * Ask the user a question.
88      *
89      * @param title The title of the question (useful for dialogs). Might be null.
90      * @param question The question.
91      * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL
92      * @param default_choice The default choice. One of ANSWER_CANCEL, ANSWER_YES or ANSWER_NO.
93      *
94      * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO)
95      */

96     public int askQuestion(String JavaDoc title, String JavaDoc question, int choices, int default_choice);
97
98 }
99
Popular Tags