Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/cadclientgui/screens/Login.java
r532 r639 53 53 public Login(String studentNamesFile) 54 54 { 55 readNamesFile(studentNamesFile);55 students = readNamesFile(studentNamesFile); 56 56 initView(); 57 57 } … … 62 62 * with the names of participants in that training. 63 63 * @param studentNamesFile the full path to a text file of student names 64 * @author jdalbey ticket #206 64 * @author jdalbey ticket #206, #254 65 65 */ 66 private void readNamesFile(String studentNamesFile) 67 { 66 public static Vector<String> readNamesFile(String studentNamesFile) 67 { 68 // Initialize the student name list 69 Vector<String> lines = new Vector<String>(); 68 70 FileInputStream fis = null; 69 71 try { … … 75 77 // split string into an array 76 78 String[] results = out.split("\\n"); 77 // Initialize the student name list 78 students = new Vector(); 79 // Make sure to truncate names before putting in list 79 // Put the names into a list (so it can be displayed in comboBox) 80 80 for (String name: results) 81 81 { 82 String truncName = name.trim(); 83 // Limit name length so it fits in the combo box 84 if (truncName.length() > 26) 82 // Make sure to reverse name order before putting in list 83 String displayName = name.trim(); 84 // Ignore blank lines 85 if (displayName.length() > 0) 85 86 { 86 truncName = truncName.substring(0,25); 87 // Limit name length so it fits in the combo box 88 if (displayName.length() > 26) 89 { 90 displayName = displayName.substring(0,25); 91 } 92 // Add the validated name to the list of students 93 lines.add(displayName); 87 94 } 88 // Add the validated name to the list of students89 students.add(truncName);90 95 } 91 // Append the default name92 students.add("Anonymous Trainee");93 96 } catch (FileNotFoundException ex) { 94 97 Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); … … 100 103 } 101 104 } 102 } 105 return lines; 106 } 107 108 /** Reverse order of lastname, firstname to firstname lastname 109 * @param formattedname fullname with lastname first, separated by comma 110 * @return fullname with firstname first and no comma 111 * Note, the result is what is desired for the CAD comment log entries. 112 * If formattedname lacks a comma, just return it unchanged. 113 */ 114 public static String reverseLastFirst(String formattedname) 115 { 116 int commapos = formattedname.indexOf(","); 117 // Handle input name without comma - just return it 118 if (commapos < 0) return formattedname; 119 // switch the name order 120 String firstname = formattedname.substring(commapos+1).trim(); 121 String lastname = formattedname.substring(0,commapos).trim(); 122 return firstname + ' ' + lastname; 123 } 124 103 125 private ActionListener newEnterActionListener() 104 126 { … … 110 132 // Extract the selected student name from the combo box 111 133 String userEntry = (String) userNameCombo.getSelectedItem(); 134 userEntry = reverseLastFirst(userEntry); // switch name order 112 135 ScreenManager.setUserName(userEntry); 113 136 ScreenManager.openCADMenu(); … … 216 239 JLabel passwordLabel = new JLabel("Password "); 217 240 passwordLabel.setForeground(Color.WHITE); 218 passwordField = new JTextField(" Not required");219 passwordField.setEnabled( false);241 passwordField = new JTextField(""); 242 passwordField.setEnabled(true); 220 243 Box passwordBox = new Box(BoxLayout.X_AXIS); 221 244 passwordBox.setAlignmentX(LEFT_ALIGNMENT);
Note: See TracChangeset
for help on using the changeset viewer.
