01: /*
02: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
03: *
04: * http://izpack.org/
05: * http://izpack.codehaus.org/
06: *
07: * Copyright 2003 Tino Schwarze
08: *
09: * 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: * Notify the user about something.
36: *
37: * The difference between notification and warning is that a notification should not need user
38: * interaction and can savely be ignored.
39: *
40: * @param message The notification.
41: */
42: public void emitNotification(String message);
43:
44: /**
45: * Warn the user about something.
46: *
47: * @param title The message title (used for dialog name, might not be displayed)
48: * @param message The warning message.
49: * @return true if the user decided not to continue
50: */
51: public boolean emitWarning(String title, String message);
52:
53: /**
54: * Notify the user of some error.
55: *
56: * @param title The message title (used for dialog name, might not be displayed)
57: * @param message The error message.
58: */
59: public void emitError(String title, String message);
60:
61: // constants for asking questions
62: // must all be >= 0!
63: public static final int ANSWER_CANCEL = 45;
64:
65: public static final int ANSWER_YES = 47;
66:
67: public static final int ANSWER_NO = 49;
68:
69: // values for choices to present to the user
70: public static final int CHOICES_YES_NO = 37;
71:
72: public static final int CHOICES_YES_NO_CANCEL = 38;
73:
74: /**
75: * Ask the user a question.
76: *
77: * @param title The title of the question (useful for dialogs). Might be null.
78: * @param question The question.
79: * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL
80: *
81: * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO)
82: */
83: public int askQuestion(String title, String question, int choices);
84:
85: /**
86: * Ask the user a question.
87: *
88: * @param title The title of the question (useful for dialogs). Might be null.
89: * @param question The question.
90: * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL
91: * @param default_choice The default choice. One of ANSWER_CANCEL, ANSWER_YES or ANSWER_NO.
92: *
93: * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO)
94: */
95: public int askQuestion(String title, String question, int choices,
96: int default_choice);
97:
98: }
|