1 | /* $Id: SettingsTypes.java 17870 2010-01-12 20:49:32Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 Contributors - see below | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * tfmorris | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 2006-2008 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.uml.reveng; | |
40 | ||
41 | import java.util.List; | |
42 | ||
43 | /** | |
44 | * These are common raw types that a specific import type can use to | |
45 | * build complex settings. If additional types are required then this | |
46 | * interface should be extended. | |
47 | * @author Bogdan Pistol | |
48 | */ | |
49 | public interface SettingsTypes { | |
50 | ||
51 | /** | |
52 | * Base setting class extended by all others | |
53 | */ | |
54 | interface Setting { | |
55 | /** | |
56 | * Returns the string to use as a label for the associated | |
57 | * setting or setting group. The implementor is responsible for | |
58 | * translation into the local language. | |
59 | * | |
60 | * @return the String message | |
61 | */ | |
62 | String getLabel(); | |
63 | ||
64 | } | |
65 | ||
66 | ||
67 | /** | |
68 | * A setting which provides a description as well as a label. | |
69 | */ | |
70 | interface Setting2 extends Setting { | |
71 | ||
72 | /** | |
73 | * Returns a string with an extended description of the setting, | |
74 | * suitable for use as a tooltip or help message. | |
75 | * @return the description | |
76 | */ | |
77 | String getDescription(); | |
78 | } | |
79 | ||
80 | /** | |
81 | * A generic type that has multiple options, from all these options | |
82 | * the user can choose only one option (the selected option). | |
83 | * <p> | |
84 | * There can be a default pre-selected option. | |
85 | */ | |
86 | interface UniqueSelection extends Setting { | |
87 | ||
88 | /** | |
89 | * Selection is undefined. | |
90 | */ | |
91 | public int UNDEFINED_SELECTION = -1; | |
92 | ||
93 | /** | |
94 | * Returns the available options from which the user can pick one. | |
95 | * | |
96 | * @return a list with Strings that identifies the options | |
97 | */ | |
98 | List<String> getOptions(); | |
99 | ||
100 | /** | |
101 | * This is the default selected option, if the user doesn't choose other | |
102 | * option then this will be the selected option. | |
103 | * | |
104 | * @return the 0 based index of the default option as is in the list | |
105 | * returned by | |
106 | * {@link SettingsTypes.UniqueSelection#getOptions()} or | |
107 | * UNDEFINED_SELECTION if there is no default option | |
108 | */ | |
109 | int getDefaultSelection(); | |
110 | ||
111 | /** | |
112 | * This is how the user can choose an option. | |
113 | * | |
114 | * @param selection | |
115 | * the 0 based index of the default option as is in the list | |
116 | * returned by | |
117 | * {@link SettingsTypes.UniqueSelection#getOptions()} | |
118 | * @return true if was successful or false if the selection is out of | |
119 | * bounds | |
120 | */ | |
121 | boolean setSelection(int selection); | |
122 | ||
123 | /** | |
124 | * @return the current selection | |
125 | */ | |
126 | int getSelection(); | |
127 | } | |
128 | ||
129 | /** | |
130 | * A UniqueSelection which includes a description. | |
131 | * @see UniqueSelection | |
132 | */ | |
133 | interface UniqueSelection2 extends UniqueSelection, Setting2 { | |
134 | } | |
135 | ||
136 | /** | |
137 | * Free form string setting to allow user to enter arbitrary string value. | |
138 | */ | |
139 | interface UserString extends Setting { | |
140 | /** | |
141 | * @return the initial string to display, if any. May be null. | |
142 | */ | |
143 | String getDefaultString(); | |
144 | ||
145 | /** | |
146 | * @return the user entered string | |
147 | */ | |
148 | String getUserString(); | |
149 | ||
150 | /** | |
151 | * Set user string to new value. | |
152 | * | |
153 | * @param userString new user string | |
154 | */ | |
155 | void setUserString(String userString); | |
156 | ||
157 | } | |
158 | ||
159 | /** | |
160 | * A UserString which includes a description. | |
161 | * @see UserString | |
162 | */ | |
163 | interface UserString2 extends UserString, Setting2 { | |
164 | ||
165 | } | |
166 | ||
167 | /** | |
168 | * Boolean setting which can take values of true/false (on/off). | |
169 | */ | |
170 | interface BooleanSelection extends Setting { | |
171 | /** | |
172 | * @return the default setting to use when first displayed. | |
173 | */ | |
174 | boolean getDefaultValue(); | |
175 | /** | |
176 | * @return the user selected value | |
177 | */ | |
178 | boolean isSelected(); | |
179 | ||
180 | /** | |
181 | * Set the selection value. | |
182 | * @param selected boolean indicating new state of selection | |
183 | */ | |
184 | void setSelected(boolean selected); | |
185 | } | |
186 | ||
187 | /** | |
188 | * A BooleanSelection which includes a description. | |
189 | * @see BooleanSelection | |
190 | */ | |
191 | interface BooleanSelection2 extends BooleanSelection, Setting2 { | |
192 | ||
193 | } | |
194 | ||
195 | /** | |
196 | * File system path setting. A single path in the file system. | |
197 | */ | |
198 | interface PathSelection extends Setting2 { | |
199 | ||
200 | /** | |
201 | * @return the default path to use when first displayed | |
202 | */ | |
203 | String getDefaultPath(); | |
204 | ||
205 | /** | |
206 | * @return the user selected path | |
207 | */ | |
208 | String getPath(); | |
209 | ||
210 | /** | |
211 | * Set the path to the given value | |
212 | * @param path new value of the path | |
213 | */ | |
214 | void setPath(String path); | |
215 | } | |
216 | ||
217 | /** | |
218 | * Setting containing ordered list of file system paths. Suitable for use | |
219 | * for things like a Java classpath or an preprocessor include path list. | |
220 | */ | |
221 | interface PathListSelection extends Setting2 { | |
222 | ||
223 | /** | |
224 | * @return the default list of paths to use when first displayed | |
225 | */ | |
226 | List<String> getDefaultPathList(); | |
227 | ||
228 | /** | |
229 | * @return the user selected ordered list of file system paths | |
230 | */ | |
231 | List<String> getPathList(); | |
232 | ||
233 | /** | |
234 | * Set the path list to the new values. | |
235 | * | |
236 | * @param pathList new list of paths | |
237 | */ | |
238 | void setPathList(List<String> pathList); | |
239 | } | |
240 | ||
241 | } |