001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008-2010 Sun Microsystems, Inc. 015 * Portions Copyright 2012-2014 ForgeRock AS. 016 */ 017 018package org.opends.quicksetup; 019import org.forgerock.i18n.LocalizableMessage; 020 021import java.util.List; 022 023/** 024 * This class describes methods for supporting interaction with the user. 025 */ 026public interface UserInteraction { 027 028 /** 029 * Type of message displayed to the user. The type of message 030 * may affect the presentation of the interaction. 031 */ 032 public enum MessageType { 033 034 /** A message with no context. */ 035 PLAIN, 036 037 /** A message displayed as a result of an error. */ 038 ERROR, 039 040 /** A message displayed informing the user of something. */ 041 INFORMATION, 042 043 /** A message displayed to warn the user. */ 044 WARNING, 045 046 /** A message displayed to ask the user a question. */ 047 QUESTION 048 } 049 050 /** 051 * Present a list of choices to the user and wait for them to select one 052 * of them. 053 * @param summary text to present to the user. This is usually just a 054 * string bug For GUI applications can be a component that will appear 055 * inside a dialog 056 * @param detail more details of the message 057 * @param title of the prompt if any 058 * @param type of message 059 * @param options set of options to give the user 060 * @param def the default option from <code>options</code> 061 * @return Object that is the same value as the user selection from the 062 * <code>options</code> parameter. 063 */ 064 Object confirm(LocalizableMessage summary, LocalizableMessage detail, 065 LocalizableMessage title, MessageType type, 066 LocalizableMessage[] options, LocalizableMessage def); 067 068 /** 069 * Present a list of choices to the user and wait for them to select one 070 * of them. 071 * @param summary text to present to the user. This is usually just a 072 * string bug For GUI applications can be a component that will appear 073 * inside a dialog 074 * @param detail more details of the message 075 * @param fineDetails even finer details. This text may be rendered in 076 * such a way that the user needs to take some sort of action to 077 * see this text 078 * @param title of the prompt if any 079 * @param type of message 080 * @param options set of options to give the user 081 * @param def the default option from <code>options</code> 082 * @param viewDetailsOption name of the option to be used for showing the 083 * details. If null a default will be used. 084 * @return Object that is the same value as the user selection from the 085 * <code>options</code> parameter. 086 */ 087 Object confirm(LocalizableMessage summary, LocalizableMessage detail, LocalizableMessage fineDetails, 088 LocalizableMessage title, MessageType type, LocalizableMessage[] options, 089 LocalizableMessage def, LocalizableMessage viewDetailsOption); 090 091 /** 092 * Creates a list appropriate for the presentation implementation. 093 * 094 * @param list to format 095 * @return String representing the list 096 */ 097 String createUnorderedList(List<?> list); 098 099 /** 100 * Tells whether the interaction is command-line based. 101 * @return <CODE>true</CODE> if the user interaction is command-line based and 102 * <CODE>false</CODE> otherwise. 103 */ 104 boolean isCLI(); 105 106 /** 107 * Indicates whether or not the CLI based user has requested to continue when 108 * a non critical error occurs. 109 * 110 * @return boolean where true indicates to continue if there is a non critical 111 * error. 112 */ 113 boolean isForceOnError(); 114 115 /** 116 * Indicates whether or not the CLI user has requested interactive behavior. 117 * 118 * @return <code>true</code> if the CLI user has requested interactive 119 * behavior. 120 */ 121 boolean isInteractive(); 122 123}