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