001/* 002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved. 003 * 004 * http://www.izforge.com/izpack/ 005 * http://developer.berlios.de/projects/izpack/ 006 * 007 * Copyright 2003 Tino Schwarze 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package com.izforge.izpack.util; 023 024/** 025 * This interface describes basic functionality neccessary for user interaction. 026 * 027 * All methods or functions which perform work and need to notify or ask the user use a listener for 028 * such purposes. This way, we can separate UI from function. 029 * 030 */ 031 032public interface AbstractUIHandler 033{ 034 035 /** 036 * Notify the user about something. 037 * 038 * The difference between notification and warning is that a notification should not need user 039 * interaction and can savely be ignored. 040 * 041 * @param message The notification. 042 */ 043 public void emitNotification(String message); 044 045 /** 046 * Warn the user about something. 047 * 048 * @param title The message title (used for dialog name, might not be displayed) 049 * @param message The warning message. 050 * @return true if the user decided not to continue 051 */ 052 public boolean emitWarning(String title, String message); 053 054 /** 055 * Notify the user of some error. 056 * 057 * @param title The message title (used for dialog name, might not be displayed) 058 * @param message The error message. 059 */ 060 public void emitError(String title, String message); 061 062 // constants for asking questions 063 // must all be >= 0! 064 public static final int ANSWER_CANCEL = 45; 065 066 public static final int ANSWER_YES = 47; 067 068 public static final int ANSWER_NO = 49; 069 070 // values for choices to present to the user 071 public static final int CHOICES_YES_NO = 37; 072 073 public static final int CHOICES_YES_NO_CANCEL = 38; 074 075 /** 076 * Ask the user a question. 077 * 078 * @param title The title of the question (useful for dialogs). Might be null. 079 * @param question The question. 080 * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL 081 * 082 * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO) 083 */ 084 public int askQuestion(String title, String question, int choices); 085 086 /** 087 * Ask the user a question. 088 * 089 * @param title The title of the question (useful for dialogs). Might be null. 090 * @param question The question. 091 * @param choices The set of choices to present. Either CHOICES_YES_NO or CHOICES_YES_NO_CANCEL 092 * @param default_choice The default choice. One of ANSWER_CANCEL, ANSWER_YES or ANSWER_NO. 093 * 094 * @return The user's choice. (ANSWER_CANCEL, ANSWER_YES or ANSWER_NO) 095 */ 096 public int askQuestion(String title, String question, int choices, int default_choice); 097 098}