~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/common/org/crosswire/common/util/UserLevel.java

  • Committer: joe
  • Date: 2002-10-08 21:36:18 UTC
  • Revision ID: svn-v4:a88caf3b-7e0a-0410-8d0d-cecb45342206:trunk:80
big config and comment update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
package org.crosswire.common.util;
3
3
 
 
4
import org.crosswire.common.config.AbstractChoice;
 
5
import org.crosswire.common.config.MultipleChoice;
 
6
import org.crosswire.common.config.StartupException;
 
7
import org.jdom.Element;
 
8
 
4
9
/**
5
10
 * A UserLevel keeps a track of how advanced the user is.
6
11
 * It may not be a graphical component, but many graphical components
115
120
    /** User level - Advanced */
116
121
    public static final UserLevel ADVANCED = new UserLevel(2, "Advanced");
117
122
 
118
 
    /**
119
 
     * An array containing all the UserLevels
120
 
     */
121
 
    private static final UserLevel[] levels = new UserLevel[]
122
 
    {
123
 
        BEGINNER,
124
 
        INTERMEDIATE,
125
 
        ADVANCED,
126
 
    };
127
 
 
128
123
    /** The level name */
129
124
    private String name;
130
125
    
133
128
 
134
129
    /** The current User level */
135
130
    private static UserLevel global = BEGINNER;
 
131
 
 
132
    /**
 
133
     * A Custom Choice
 
134
     */
 
135
    public static class UserLevelChoice extends AbstractChoice implements MultipleChoice
 
136
    {
 
137
        /**
 
138
         * Simple ctor so there is a default
 
139
         */
 
140
        public void init(Element option) throws StartupException
 
141
        {
 
142
            // Help text
 
143
            Element childele = option.getChild("help");
 
144
            if (childele == null)
 
145
                helptext = "";
 
146
            helptext = childele.getTextTrim();
 
147
        }
 
148
 
 
149
        /**
 
150
         * The available alternative values to be presented as options to the user
 
151
         * where the user interface allows presentation of alternatives.
 
152
         * @return A string array of alternatives.
 
153
         */
 
154
        public String[] getOptions()
 
155
        {
 
156
            return levels;
 
157
        }
 
158
 
 
159
        /**
 
160
         * Accessor for this UserLevels type.
 
161
         */
 
162
        public Class getConvertionClass()
 
163
        {
 
164
            return UserLevel.class;
 
165
        }
 
166
 
 
167
        /**
 
168
         * Read the save setting from UserLevel
 
169
         */
 
170
        public void setString(String value)
 
171
        {
 
172
            UserLevel.setGlobalUserLevel(UserLevel.forName(value));
 
173
        }
 
174
    
 
175
        /**
 
176
         * Save the save setting to UserLevel
 
177
         */
 
178
        public String getString()
 
179
        {
 
180
            return UserLevel.getGlobalUserLevel().getName();
 
181
        }
 
182
 
 
183
        /**
 
184
         * Get some help on this Choice.
 
185
         */
 
186
        public String getHelpText()
 
187
        {
 
188
            return helptext;
 
189
        }
 
190
 
 
191
        private String helptext;
 
192
 
 
193
        /**
 
194
         * An array containing all the UserLevels
 
195
         */
 
196
        private static final String[] levels = new String[]
 
197
        {
 
198
            BEGINNER.getName(),
 
199
            INTERMEDIATE.getName(),
 
200
            ADVANCED.getName(),
 
201
        };
 
202
    }
136
203
}