Warning: Can't use blame annotator:
svn blame failed on trunk/src/tmcsim/client/cadscreens/ON_LoginScreen.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/src/tmcsim/client/cadscreens/ON_LoginScreen.java @ 2

Revision 2, 9.3 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

RevLine 
1package tmcsim.client.cadscreens;
2
3import javax.swing.text.Document;
4
5import tmcsim.client.cadscreens.view.CADMainView;
6
7
8
9/**
10 * The View component to the ON_LoginScreen CAD Screen. There is no model data associated
11 * with this view.  All keyboard input is placed in corresponding input areas on the screen
12 * for user name, personal password, and function password.  Some of the CADScreenStyleSheet
13 * methods are overloaded in this class to provide for this functionality.  The inherited
14 * CADScreenStyleSheet is used to contain the updated view items and create the necessary
15 * objects for display.  <OUT OF DATE>
16 *
17 * @author Matthew Cechini
18 * @version $Revision: 1.4 $ $Date: 2009/04/17 16:27:45 $
19 */
20public class ON_LoginScreen extends CADMainView {
21
22    /**
23     * Count of how many characters have been written to the user identity area.
24     */
25    private int  userIdentityLength     = 0;
26
27    /**
28     * Count of how many characters have been written to the personal password area.
29     */
30    private int  personalPasswordLength = 0;
31
32    /**
33     * Count of how many characters have been written to the function password area.
34     */
35    private int  functionPasswordLength = 0;
36   
37
38    /**
39     * Static final int value to designate the cursor's position on the user identity line.
40     */
41    static final int USER_IDENTITY     = 1;
42
43    /**
44     * Static final int value to designate the cursor's position on the function password line.
45     */
46    static final int FUNCTION_PASSWORD = 2;
47
48    /**
49     * Static final int value to designate the cursor's position on the personal password line.
50     */
51    static final int PERSONAL_PASSWORD = 3;
52
53    /**
54     * Keeps track of which line the cursor is currently on.  Initialize to the user identity line.
55     */
56    private int currentEntryLine = USER_IDENTITY;
57   
58
59    /**
60     * Array of character positions to begin outputting the text strings.
61     */
62    private int documentStartingPosition[] = {0, 125, 140, 165};
63
64    /**
65     * Array of vector positions to offeset the new characters that have been input. 
66     */
67    private int formatVectorStartingPosition[] = {0, 2, 8, 14};
68   
69    public ON_LoginScreen(Document viewDoc) {
70        super(viewDoc);                   
71                   
72    }   
73   
74    /**
75     * Constructor.  Initializes the view with the login screen info.
76     *
77     * @param newCADScreenNumber The ScreenNumber (1-4) for the instance of this view class.
78     * @param newCADScreenType The ScreenType for the instance of this view class.
79     
80    public ON_LoginScreen(int newCADScreenNumber, int newCADScreenType) {
81        String[] initString = {"   SIGN ON\n",
82                               "              USER IDENTITY:     ", "_", "_",
83                               "_", "_", "_" , "_", "\n",
84                               "              PERSONAL PASSWORD: ", "_", "_",
85                               "_", "_", "_" , "_", "\n",
86                               "              FUNCTION PASSWORD: ", "_", "_",
87                               "_", "_", "_" , "_", "\n"};
88
89        String[] initStyles = {"cyan", "cyan", "yellow", "yellow", "yellow",
90                               "yellow", "yellow", "yellow", "yellow",
91                               "cyan", "red", "red", "red", "red", "red", "red",
92                               "red", "cyan", "red", "red", "red", "red", "red",
93                               "red", "red"};
94       
95        currentCADScreenNumber = newCADScreenNumber;
96        CADScreenType = newCADScreenType;
97       
98        addCADScreenStyleItems(initString, initStyles);
99    }   
100   
101   
102    /**
103     * Overloading the CADScreenStyleSheet receiveArrow() method.  Up and down arrows move between input lines.
104     *
105     * @param direction The public static final int value of the arrow's direction. Defined in CADScreenStyleSheet.
106     * @return commandline caret position
107     
108    public int receiveArrow(int direction) {
109        switch(direction) {
110           
111            case LEFT:
112                break;
113                   
114            case UP:
115                break;
116               
117            case RIGHT:
118                break;
119               
120            case DOWN:
121                break;
122           
123        }   
124        return 0;
125    }   
126   
127   /**
128    * Overloading the CADSCerenStyleSheet recieveKeyPress() method.  The input character is added to the current input line.
129    * If the input line is full, the new character replaces the last character in that line
130    *
131    * @param newChar The character pressed by the user.
132    * @return boolean true always returned.
133   
134    public boolean receiveKeyPress(char newChar) {
135       
136        switch (currentEntryLine) {
137       
138           case USER_IDENTITY:
139              if(userIdentityLength < 6) {
140                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[USER_IDENTITY] + userIdentityLength);
141                 textAreaUpdateObject.documentPosition = (documentStartingPosition[USER_IDENTITY] + userIdentityLength);
142                 userIdentityLength++;
143              }
144           
145              break;
146             
147           case PERSONAL_PASSWORD:
148              if(personalPasswordLength < 8) {
149                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[PERSONAL_PASSWORD] + personalPasswordLength);
150                 textAreaUpdateObject.documentPosition = (documentStartingPosition[PERSONAL_PASSWORD] + personalPasswordLength);
151                 personalPasswordLength++;
152              }
153           
154              break;
155             
156           case FUNCTION_PASSWORD:
157              if(functionPasswordLength < 8) {
158                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[FUNCTION_PASSWORD] + functionPasswordLength);
159                 textAreaUpdateObject.documentPosition = (documentStartingPosition[FUNCTION_PASSWORD] + functionPasswordLength);
160                 functionPasswordLength++;
161              }
162           
163              break;   
164           
165        }
166       
167        formatStrings.setElementAt(String.valueOf(newChar), textAreaUpdateObject.formatVectorPosition);
168        formatStyleTypes.setElementAt("yellow", textAreaUpdateObject.formatVectorPosition);     
169       
170        textAreaUpdateObject.formatString = String.valueOf(newChar);
171        textAreaUpdateObject.formatStyleType = "yellow";
172       
173       
174        return true;
175    }
176   
177    /**
178     * Overloading the CADScreenStyleSheet backspace() method.  This method determines if the backspace command
179     * can be executed.  If it can, the last character is removed and true is returned.  If not, the input line
180     * is unchanged and false is returned. 
181     *
182     * @return boolean true if backspace was successful, false if not.
183     
184    public boolean backspace() {
185        boolean retVal = false;
186        switch (currentEntryLine) {
187       
188           case USER_IDENTITY:
189              if(userIdentityLength > 0) {
190                 userIdentityLength--;
191                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[USER_IDENTITY] + userIdentityLength);
192                 textAreaUpdateObject.documentPosition = (documentStartingPosition[USER_IDENTITY] + userIdentityLength);                 
193                 retVal = true;
194              }       
195              break;
196             
197           case PERSONAL_PASSWORD:
198              if(personalPasswordLength > 0) {
199                 personalPasswordLength--;
200                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[PERSONAL_PASSWORD] + personalPasswordLength);
201                 textAreaUpdateObject.documentPosition = (documentStartingPosition[PERSONAL_PASSWORD] + personalPasswordLength);                 
202                 retVal = true;
203              }       
204              break;
205             
206           case FUNCTION_PASSWORD:
207              if(functionPasswordLength > 0) {
208                 functionPasswordLength--;
209                 textAreaUpdateObject.formatVectorPosition = (formatVectorStartingPosition[FUNCTION_PASSWORD] + functionPasswordLength);
210                 textAreaUpdateObject.documentPosition = (documentStartingPosition[FUNCTION_PASSWORD] + functionPasswordLength);                 
211                 retVal = true;
212              }         
213              break;           
214        }
215       
216        if(retVal = true) {
217           formatStrings.setElementAt("_", textAreaUpdateObject.formatVectorPosition);
218           formatStyleTypes.setElementAt("yellow", textAreaUpdateObject.formatVectorPosition);     
219       
220           textAreaUpdateObject.formatString = "_";
221           textAreaUpdateObject.formatStyleType = "yellow";
222        }       
223       
224        return retVal;
225    }   
226   
227    /**
228     * Overloads the CADScreenStyleSheet cycle() method.  If the ON_Login Screen is being displayed, cycling should be
229     * disabled until the user logs in.
230     *
231     * @return boolean always returns false
232     
233    public boolean cycle () {
234       return true;  //should be false 
235    }
236
237    /**
238     * Overloads CADScreenStyleSheet isCommandLineActive() method.  Command line input is not used in the LoginScreen,
239     * so return the command line is not active, return false.
240     *
241     * @return boolean always returns true
242       
243    public boolean isCommandLineActive() {
244       return false;   
245    }   
246   */
247}
Note: See TracBrowser for help on using the repository browser.