]> git.mxchange.org Git - addressbook-swing.git/blob - src/org/mxchange/addressbook/client/AddressbookClient.java
c2c2b6b2d20306ef5458f3ff290c871f1cc64e17
[addressbook-swing.git] / src / org / mxchange / addressbook / client / AddressbookClient.java
1 /*
2  * Copyright (C) 2016 - 2022 Free Software Foundation
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.addressbook.client;
18
19 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
20 import org.mxchange.jcontacts.model.contact.Contact;
21 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
22 import org.mxchange.jcore.client.Client;
23 import org.mxchange.jcore.exceptions.MenuInitializationException;
24 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
25
26 /**
27  * A special client interface for addressbook applications.
28  * <p>
29  * @author Roland Häder<roland@mxchange.org>
30  */
31 public interface AddressbookClient extends Client {
32
33         /**
34          * Displays a "box" for the address
35          * <p>
36          * @param contact Contact to show address from
37          */
38         void displayAddressBox (final Contact contact);
39
40         /**
41          * Displays a "box" for the name
42          * <p>
43          * @param contact Contact to show name from
44          */
45         void displayNameBox (final Contact contact);
46
47         /**
48          * Displays a "box" for other data
49          * <p>
50          * @param contact Contact to show other data from
51          */
52         void displayOtherDataBox (final Contact contact);
53
54         /**
55          * Shows given contact instamce
56          * <p>
57          * @param contact Contact instance
58          */
59         void show (final Contact contact);
60
61         /**
62          * The user changes own address data
63          * <p>
64          * @param contact Contact instance to change
65          */
66         void doChangeOwnAddressData (final Contact contact);
67
68         /**
69          * The user changes own name data
70          * <p>
71          * @param contact
72          */
73         void doChangeOwnNameData (final Contact contact);
74
75         /**
76          * The user changes own other data
77          * <p>
78          * @param contact Constact instance to change
79          */
80         void doChangeOwnOtherData (final Contact contact);
81
82         /**
83          * Allows the user to enter own data
84          * <p>
85          * @return Finished Contact instance
86          */
87         Contact doEnterOwnData ();
88
89         /**
90          * Asks the user for a choice and proceeds accordingly
91          * <p>
92          * @throws UnhandledUserChoiceException If choice is not supported
93          * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the
94          * menu cannot be initialized
95          */
96         void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
97
98         /**
99          * Asks the the user to enter a single character which must match validChars
100          * <p>
101          * @param       validChars Valid chars that are accepted
102          * @param       message    Message to user
103          * <p>
104          * @return      Allowed character
105          */
106         char enterChar (final char[] validChars, final String message);
107
108         /**
109          * Asks the user to enter his/her personal title (M=Male, F=Female,
110          * C=Company)
111          * <p>
112          * @param message Message to output
113          * <p>
114          * @return PersonalTitle enum
115          */
116         PersonalTitle enterPersonalTitle (final String message);
117
118         /**
119          * Reads an integer (int) from the user
120          * <p>
121          * @param minimum Minimum allowed number
122          * @param maximum Maximum allowed number
123          * @param message       Message to user
124          * <p>
125          * @return Entered string by user or null if empty string is allowed
126          */
127         int enterInt (final int minimum, final int maximum, final String message);
128
129         /**
130          * Reads a string of minimum and maximum length from the user. An empty
131          * string should be generally not allowed, but might be okay for e.g.
132          * company name.
133          * <p>
134          * @param minLength      Minimum length of the string to read
135          * @param maxLength      Maximum length of the string to read
136          * @param message          Message to user
137          * @param allowEmpty Whether empty strings are allowed
138          * <p>
139          * @return Entered string by user or null if empty string is allowed
140          */
141         String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
142
143         /**
144          * Setter for current menu choice
145          * <p>
146          * @param currentMenu Current menu choice
147          */
148         void setCurrentMenu (final String currentMenu);
149
150         /**
151          * Some "Getter" for menu item
152          * <p>
153          * @param accessKey Key to press to access this menu
154          * @param text      Text to show to user
155          * <p>
156          * @return
157          */
158         SelectableMenuItem getMenuItem (final char accessKey, final String text);
159
160         /**
161          * Shows current menu selection to the user
162          */
163         void showCurrentMenu ();
164
165         /**
166          * Shows given menu entry in client
167          * <p>
168          * @param item Menu item to show
169          */
170         void showEntry (final SelectableMenuItem item);
171
172         /**
173          * Let the user choose what to change on the address: [n]ame, [a]ddress,
174          * [o]ther
175          * <p>
176          * @param contact Contact instance to let the user change data
177          * <p>
178          * @throws UnhandledUserChoiceException If choice is not supported
179          */
180         void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
181 }