Source code: com/eireneh/config/choices/AbstractChoice.java
1
2 package com.eireneh.config.choices;
3
4 import java.util.*;
5 import java.io.*;
6
7 import com.eireneh.config.*;
8 import com.eireneh.util.UserLevel;
9
10 /**
11 * An AbstractChoice is one that registers itself with
12 * AbstractChoice when it starts up, so that we don't need to pass
13 * parameters around the place the whole time.
14 *
15 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
16 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
17 * Distribution Licence:<br />
18 * Project B is free software; you can redistribute it
19 * and/or modify it under the terms of the GNU General Public License,
20 * version 2 as published by the Free Software Foundation.<br />
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.<br />
25 * The License is available on the internet
26 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
27 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
29 * The copyright to this program is held by it's authors.
30 * </font></td></tr></table>
31 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
32 * @see docs.Licence
33 * @author Joe Walker
34 */
35 public abstract class AbstractChoice implements Choice
36 {
37 /**
38 * Gets a default user level (beginner to advanced)
39 * @return The user level
40 */
41 public int getUserLevel()
42 {
43 return UserLevel.LEVEL_BEGINNER;
44 }
45
46 /**
47 * Get some help on this Field. In this case we are just providing
48 * a default help text, that isn't much use.
49 * @return The default help text
50 */
51 public String getHelpText()
52 {
53 return "";
54 }
55
56 /**
57 * This method is used to configure a good way of editing this
58 * component. It returns a MIME style string, which a config
59 * ui can use to select a suitable ui tool.
60 * @return The editor style to use to edit this Choice
61 */
62 public String getType()
63 {
64 return "text";
65 }
66
67 /**
68 * This method is used to configure a the type selected above.
69 * The object returned will depend on the type of editor selected.
70 * For example an editor of type "options" may need a String array.
71 * @return a configuration parameter for the type
72 */
73 public Object getTypeOptions()
74 {
75 return null;
76 }
77
78 /**
79 * Is this Choice OK to write out to a file, or should we use settings
80 * in this run of the program, but forget them for next time. A
81 * typical use of this is for password configuration.
82 * @return True if it is safe to store the value in a config file.
83 */
84 public boolean isSaveable()
85 {
86 return true;
87 }
88
89 /**
90 * Sometimes we need to ensure that we configure items in a certain
91 * order, the config package moves the changes to the application
92 * starting with the highest priority, moving to the lowest
93 * @return A priority level
94 */
95 public int priority()
96 {
97 return PRIORITY_NORMAL;
98 }
99
100 /**
101 * Do we need to restart the program in order for this change to have
102 * effect?
103 * @return True if a restart is required
104 */
105 public boolean requiresRestart()
106 {
107 return false;
108 }
109 }
110