Ignore:
Timestamp:
03/15/2017 10:20:21 AM (9 years ago)
Author:
jdalbey
Message:

Merge CAD Client updates for multiple incident view windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/cadclientgui/screens/Login.java

    r3 r59  
    22 
    33import java.awt.Color; 
     4import static java.awt.Component.LEFT_ALIGNMENT; 
    45import java.awt.Dimension; 
    56import java.awt.Font; 
    67import java.awt.event.ActionEvent; 
    78import java.awt.event.ActionListener; 
    8  
    99import javax.swing.Box; 
    1010import javax.swing.BoxLayout; 
     
    1616import javax.swing.SwingConstants; 
    1717 
    18  
    1918/** 
    20  * This class contains the view and controller for the Login screen. The view was not built using a GUI builder plug-in 
    21  * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act.  
    22  *  
     19 * This class contains the view and controller for the Login screen. The view 
     20 * was not built using a GUI builder plug-in (but may want to consider doing so 
     21 * in the future), and the controller uses listeners to control how the view and 
     22 * data act. 
     23 * 
    2324 * @author Vincent 
    2425 */ 
    25  
    26 public class Login extends JFrame { 
    27  
     26public class Login extends JFrame 
     27{ 
    2828    private Box login; 
    2929    private JTextField userNameField; 
    3030    private JTextField passwordField; 
    31  
    32     public Login() { 
     31    public static String kNamePrompt = "Enter your name"; 
     32 
     33    public Login() 
     34    { 
    3335        initView(); 
    3436    } 
    35      
    36     private ActionListener newEnterActionListener(){ 
    37         return new ActionListener() { 
    38             public void actionPerformed(ActionEvent e) { 
     37 
     38    private ActionListener newEnterActionListener() 
     39    { 
     40        return new ActionListener() 
     41        { 
     42            public void actionPerformed(ActionEvent e) 
     43            { 
    3944                setVisible(false); 
    40                 ScreenManager.setUserName(userNameField.getText()); 
     45                // Check if user provided a username JD 
     46                String userEntry = userNameField.getText(); 
     47                if (userEntry.equals(kNamePrompt)) 
     48                { 
     49                    ScreenManager.setUserName("Anonymous Trainee"); 
     50                } 
     51                else 
     52                { 
     53                    ScreenManager.setUserName(userEntry); 
     54                } 
    4155                ScreenManager.openCADMenu(); 
    4256                ScreenManager.openAssignedIncidents(); 
     
    4458                ScreenManager.openPendingIncidents(); 
    4559                ScreenManager.openPowerlineUI(); 
    46                 if (!passwordField.getText().equals("Dispatcher")) { 
     60                if (!passwordField.getText().equals("Dispatcher")) 
     61                { 
    4762                    ScreenManager.setDispatcherAuthority(false); 
    4863                } 
     
    5065        }; 
    5166    } 
    52      
    53     private ActionListener newExitActionListener(){ 
    54         return new ActionListener() { 
    55             public void actionPerformed(ActionEvent e) { 
     67 
     68    private ActionListener newExitActionListener() 
     69    { 
     70        return new ActionListener() 
     71        { 
     72            public void actionPerformed(ActionEvent e) 
     73            { 
    5674                System.exit(0); 
    5775            } 
    5876        }; 
    5977    } 
    60      
    61     private void initView(){ 
     78 
     79    private void initView() 
     80    { 
    6281        login = new Box(BoxLayout.Y_AXIS); 
    6382        login.setAlignmentX(LEFT_ALIGNMENT); 
     
    7897 
    7998        JLabel title = new JLabel(); 
    80         title.setText("Inform CAD 5.3 Patch 5"); 
     99        // Check if we are running from a jar to put message from manifest into title 
     100        Package clientpkg = Login.class.getPackage(); 
     101        String builddate = clientpkg.getImplementationVersion(); 
     102        String version = ""; 
     103        if (builddate != null) 
     104        { 
     105            version = "          (build " + builddate + ")"; 
     106        } 
     107        else // We're running from a dev environment 
     108        { 
     109            version = "           00-00-00 00:00"; 
     110        } 
     111 
     112        title.setText("Inform CAD 5.3 Patch 5 "); 
    81113        title.setHorizontalAlignment(SwingConstants.CENTER); 
    82114        title.setFont(new Font("Arial", Font.PLAIN, 22)); 
     
    87119        blueBackground.add(title); 
    88120 
     121        JLabel builddateLabel = new JLabel(version); 
     122        builddateLabel.setForeground(Color.WHITE); 
     123        builddateLabel.setHorizontalAlignment(SwingConstants.CENTER); 
     124        blueBackground.add(builddateLabel); 
     125 
    89126        Box leftBox = new Box(BoxLayout.Y_AXIS); 
    90127        leftBox.setMaximumSize(new Dimension(350, 50)); 
     
    95132        JLabel userNameLabel = new JLabel("User name "); 
    96133        userNameLabel.setForeground(Color.WHITE); 
    97         userNameField = new JTextField("Enter your name"); 
     134        userNameField = new JTextField(kNamePrompt); 
    98135        Box userNameBox = new Box(BoxLayout.X_AXIS); 
    99136        userNameBox.setAlignmentX(LEFT_ALIGNMENT); 
     
    105142        JLabel passwordLabel = new JLabel("Password  "); 
    106143        passwordLabel.setForeground(Color.WHITE); 
    107         passwordField = new JTextField("Does not matter"); 
     144        passwordField = new JTextField("Not required"); 
    108145        Box passwordBox = new Box(BoxLayout.X_AXIS); 
    109146        passwordBox.setAlignmentX(LEFT_ALIGNMENT); 
Note: See TracChangeset for help on using the changeset viewer.