Changeset 44 in tmcsimulator for trunk/src/tmcsim/cadsimulator/viewer


Ignore:
Timestamp:
06/23/2016 06:30:20 PM (10 years ago)
Author:
jdalbey
Message:

MultiFile? commit: Add CADViewer Interface and change CADSimulator to Observer Pattern.

Location:
trunk/src/tmcsim/cadsimulator/viewer
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/cadsimulator/viewer/CADSimulatorViewer.java

    r36 r44  
    66import java.awt.event.KeyEvent; 
    77import java.awt.event.WindowEvent; 
     8import java.io.IOException; 
     9import java.util.Observable; 
     10import java.util.Properties; 
     11import java.util.logging.Level; 
     12import java.util.logging.Logger; 
    813import javax.swing.JFrame; 
    914import javax.swing.JMenu; 
     
    1318import javax.swing.JTabbedPane; 
    1419import javax.swing.KeyStroke; 
    15 import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 
    16 import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; 
    1720import tmcsim.cadsimulator.viewer.actions.ExitAction; 
    18 import tmcsim.common.CADEnums.PARAMICS_STATUS; 
    19 import tmcsim.common.CADEnums.SCRIPT_STATUS; 
    20 import tmcsim.common.RevisionNumber; 
     21import tmcsim.cadsimulator.viewer.model.CADMediaStatus; 
     22import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 
     23import tmcsim.interfaces.CADViewer; 
    2124 
    2225/** 
     
    3033 */ 
    3134@SuppressWarnings("serial") 
    32 public class CADSimulatorViewer extends JFrame 
     35public class CADSimulatorViewer extends JFrame implements CADViewer 
    3336{ 
    3437 
     
    4548     */ 
    4649    private ConfigStatusPanel configPanel; 
     50 
    4751    /** 
    4852     * Constructor. 
    4953     */ 
    50      
    5154    public CADSimulatorViewer() 
    5255    { 
    53         super("CAD Simulator"); 
     56        super(); 
     57        setTitle("CAD Simulator " + getAppVersion()); 
    5458 
    5559        initComponents(); 
     
    5761 
    5862    /** 
    59      * @see SimulationStatusPanel 
     63     * Read the version number from the application properties. The file 
     64     * 'application.properties' is generated by build.xml. 
     65     * 
     66     * @return a version string obtained from application.properties file, or 
     67     * "Version: unknown" if an IOerror prevents us from reading the file. 
    6068     */ 
    61     public void connectClient() 
     69    private String getAppVersion() 
    6270    { 
    63         simulationPanel.connectClient(); 
    64     } 
    65  
    66     /** 
    67      * @see SimulationStatusPanel 
    68      */ 
    69     public void disconnectClient() 
    70     { 
    71         simulationPanel.disconnectClient(); 
    72     } 
    73  
    74     /** 
    75      * @see SimulationStatusPanel 
    76      */ 
    77     public void setSimManagerStatus(boolean connection) 
    78     { 
    79         simulationPanel.setSimManagerStatus(connection); 
    80     } 
    81  
    82     /** 
    83      * @see SimulationStatusPanel 
    84      */ 
    85     public void setTime(long seconds) 
    86     { 
    87         simulationPanel.setTime(seconds); 
    88     } 
    89  
    90     /** 
    91      * @see SimulationStatusPanel 
    92      */ 
    93     public void setScriptStatus(SCRIPT_STATUS newStatus) 
    94     { 
    95         simulationPanel.setScriptStatus(newStatus); 
    96     } 
    97  
    98     /** 
    99      * @see SimulationStatusPanel 
    100      */ 
    101     public void setParamicsStatus(PARAMICS_STATUS newStatus) 
    102     { 
    103         simulationPanel.setParamicsStatus(newStatus); 
    104     } 
    105  
    106     /** 
    107      * @see SimulationStatusPanel 
    108      */ 
    109     public void setParamicsNetworkLoaded(String networkID) 
    110     { 
    111         simulationPanel.setParamicsNetworkLoaded(networkID); 
    112     } 
    113  
    114     /** 
    115      * @see MediaStatusPanel 
    116      */ 
    117     public void updateDVDStatus(DVDStatusUpdate update) 
    118     { 
    119         mediaPanel.updateDVDStatus(update); 
    120     } 
    121  
    122     /** 
    123      * @see MediaStatusPanel 
    124      */ 
    125     public void updateDVDTitle(DVDTitleUpdate update) 
    126     { 
    127         mediaPanel.updateDVDTitle(update); 
     71        String propfilename = "/tmcsim/application.properties"; 
     72        String propKey = "Application.revision"; 
     73        String version = "unknown"; 
     74        try 
     75        { 
     76            Properties props = new Properties(); 
     77            props.load(this.getClass().getResourceAsStream(propfilename)); 
     78            version = (String) props.get(propKey); 
     79        } catch (IOException ex) 
     80        { 
     81            Logger.getLogger("tmcsim/cadsimulator").log(Level.SEVERE, 
     82                    "CADSimulatorView.getAppVersion()", 
     83                    "IOError reading " + propfilename); 
     84        } 
     85        return "revision: " + version; 
    12886    } 
    12987 
     
    147105        if (evt.getID() == WindowEvent.WINDOW_CLOSING) 
    148106        { 
    149             int option = JOptionPane.showConfirmDialog(null, 
    150                     "Closing the CAD Simulator will stop the current " 
    151                     + "simulation.  Do you wish to continue exiting?", 
    152                     "Confirm Exit", 
    153                     JOptionPane.YES_NO_OPTION); 
    154  
    155             if (option != JOptionPane.NO_OPTION) 
    156             { 
    157                 System.exit(0); 
    158             } 
     107//            int option = JOptionPane.showConfirmDialog(null, 
     108//                    "Closing the CAD Simulator will stop the current " 
     109//                    + "simulation.  Do you wish to continue exiting?", 
     110//                    "Confirm Exit", 
     111//                    JOptionPane.YES_NO_OPTION); 
     112// 
     113//            if (option != JOptionPane.NO_OPTION) 
     114//            { 
     115            System.exit(0); 
     116//            } 
    159117        } 
    160118    } 
     
    196154            public void actionPerformed(java.awt.event.ActionEvent evt) 
    197155            { 
    198                 String ver = RevisionNumber.getString(); 
     156                String ver = "";//RevisionNumber.getString(); 
    199157                JOptionPane.showMessageDialog(rootPane, "Version: " + ver, "About", JOptionPane.INFORMATION_MESSAGE); 
    200158            } 
     
    208166        pack(); 
    209167        setResizable(true); 
     168        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    210169    } 
    211170    private JTabbedPane cadSimTabbedPane; 
     
    213172    private JMenu fileMenu; 
    214173    private JMenuItem exitMenuItem; 
     174 
     175    @Override 
     176    public void update(Observable obs, Object obj) 
     177    { 
     178        if (obs instanceof CADSimulatorStatus) 
     179        { 
     180            simulationPanel.refresh(obs); 
     181        } 
     182        if (obs instanceof CADMediaStatus) 
     183        { 
     184            mediaPanel.refresh(obs); 
     185        } 
     186    } 
    215187} 
  • trunk/src/tmcsim/cadsimulator/viewer/DVDInfoPanel.java

    r2 r44  
    22 
    33import java.awt.Dimension; 
    4  
    54import javax.swing.BorderFactory; 
    65import javax.swing.Box; 
     
    109import javax.swing.JTable; 
    1110import javax.swing.JTextField; 
    12  
    1311import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 
    1412import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; 
     
    1715 
    1816/** 
    19  * DVDInfoPanel is a GUI component used in the CADSimulatorViewer.  The panel 
    20  * displays information regarding the DVD player's connection information. 
    21  * One table on the panel shows all DVD title that have been played or  
    22  * repeated.  A second table shows all DVD status updates that have been 
    23  * received from the controller.  
    24  *  
     17 * DVDInfoPanel is a GUI component used in the CADSimulatorViewer. The panel 
     18 * displays information regarding the DVD player's connection information. One 
     19 * table on the panel shows all DVD title that have been played or repeated. A 
     20 * second table shows all DVD status updates that have been received from the 
     21 * controller. 
     22 * 
    2523 * @author Matthew Cechini 
    26  * @version  
     24 * @version 
    2725 */ 
    2826@SuppressWarnings("serial") 
    29 public class DVDInfoPanel extends JPanel { 
     27public class DVDInfoPanel extends JPanel 
     28{ 
    3029 
    31     /** DVD player connection info. */ 
    32     private String connInfo = null; 
    33      
    34     /** Table model for the title table. */ 
     30    /** 
     31     * DVD player connection info. 
     32     */ 
     33    public final String connInfo; 
     34    /** 
     35     * Table model for the title table. 
     36     */ 
    3537    private DVDTitleTableModel titleTableModel; 
     38    /** 
     39     * Table to display DVD title plays and repeats. 
     40     */ 
     41    private JTable titleTable; 
     42    /** 
     43     * Table model for the Status table. 
     44     */ 
     45    private DVDStatusTableModel statusTableModel; 
     46    /** 
     47     * Table to display DVD status updates. 
     48     */ 
     49    private JTable statusTable; 
    3650 
    37     /** Table to display DVD title plays and repeats. */ 
    38     private JTable titleTable; 
    39      
    40     /** Table model for the Status table. */ 
    41     private DVDStatusTableModel statusTableModel; 
    42      
    43     /** Table to display DVD status updates. */ 
    44     private JTable statusTable; 
    45      
    46      
    4751    /** 
    48      * Constructor.  Initialize the panel GUI components. 
    49      *  
     52     * Constructor. Initialize the panel GUI components. 
     53     * 
    5054     * @param connectionInfo DVD player connection info. 
    5155     */ 
    52     public DVDInfoPanel(String connectionInfo) { 
     56    public DVDInfoPanel(String connectionInfo) 
     57    { 
    5358        connInfo = connectionInfo; 
    54          
     59 
    5560        initComponents(); 
    56     }    
    57      
     61    } 
     62 
    5863    /** 
    5964     * This method updates the DVD status table with the new update object. 
     65     * 
    6066     * @param update Update DVD Status update. 
    6167     */ 
    62     public void updateDVDStatus(DVDStatusUpdate update) { 
     68    public void updateDVDStatus(DVDStatusUpdate update) 
     69    { 
    6370        statusTableModel.addStatusUpdate(update); 
    6471    } 
     
    6673    /** 
    6774     * This method updates the DVD title table with the new update object. 
     75     * 
    6876     * @param update Update DVD Status update. 
    6977     */ 
    70     public void updateDVDTitle(DVDTitleUpdate update) { 
     78    public void updateDVDTitle(DVDTitleUpdate update) 
     79    { 
    7180        titleTableModel.addTitleUpdate(update); 
    7281    } 
    73      
     82 
    7483    /** 
    7584     * Initialize the GUI components. 
    7685     */ 
    77     private void initComponents() { 
     86    private void initComponents() 
     87    { 
    7888 
    7989        connInfoLbl = new JLabel("Connection Info:"); 
    8090        connInfoLbl.setAlignmentX(Box.LEFT_ALIGNMENT); 
    81         connInfoTF  = new JTextField(connInfo); 
     91        connInfoTF = new JTextField(connInfo); 
    8292        connInfoTF.setColumns(30); 
    8393        connInfoTF.setAlignmentX(Box.LEFT_ALIGNMENT); 
    8494        connInfoTF.setEditable(false); 
    85          
     95 
    8696        Box connInfoBox = Box.createVerticalBox(); 
    8797        connInfoBox.add(connInfoLbl); 
    8898        connInfoBox.add(connInfoTF); 
    8999        connInfoBox.setAlignmentX(Box.CENTER_ALIGNMENT); 
    90          
     100 
    91101        titleTableModel = new DVDTitleTableModel(); 
    92         titleTable      = new JTable(titleTableModel); 
    93         titleTable.getTableHeader().setReorderingAllowed(false);   
    94          
    95         for(int c = 0; c < titleTable.getColumnCount(); c++) { 
     102        titleTable = new JTable(titleTableModel); 
     103        titleTable.getTableHeader().setReorderingAllowed(false); 
     104 
     105        for (int c = 0; c < titleTable.getColumnCount(); c++) 
     106        { 
    96107            titleTable.getColumnModel().getColumn(c).setMinWidth( 
    97108                    titleTableModel.getColumnMinWidth(c)); 
     
    102113            titleTable.getColumnModel().getColumn(c).setResizable(true); 
    103114        } 
    104          
    105         titlePane       = new JScrollPane(); 
     115 
     116        titlePane = new JScrollPane(); 
    106117        titlePane.setAlignmentX(Box.CENTER_ALIGNMENT); 
    107118        //titlePane.setMinimumSize(new Dimension(,)); 
    108         titlePane.setPreferredSize(new Dimension(425, 225));         
     119        titlePane.setPreferredSize(new Dimension(425, 225)); 
    109120        titlePane.setViewportView(titleTable); 
    110121        titlePane.setBorder(BorderFactory.createTitledBorder( 
    111                     BorderFactory.createRaisedBevelBorder(), "Title Updates")); 
     122                BorderFactory.createRaisedBevelBorder(), "Title Updates")); 
    112123 
    113124        statusTableModel = new DVDStatusTableModel(); 
    114         statusTable      = new JTable(statusTableModel); 
    115         statusTable.getTableHeader().setReorderingAllowed(false);   
    116          
    117         for(int c = 0; c < statusTable.getColumnCount(); c++) { 
     125        statusTable = new JTable(statusTableModel); 
     126        statusTable.getTableHeader().setReorderingAllowed(false); 
     127 
     128        for (int c = 0; c < statusTable.getColumnCount(); c++) 
     129        { 
    118130            statusTable.getColumnModel().getColumn(c).setMinWidth( 
    119131                    statusTableModel.getColumnMinWidth(c)); 
     
    124136            statusTable.getColumnModel().getColumn(c).setResizable(true); 
    125137        } 
    126          
    127         statusPane       = new JScrollPane(); 
     138 
     139        statusPane = new JScrollPane(); 
    128140        statusPane.setAlignmentX(Box.CENTER_ALIGNMENT); 
    129141        //statusPane.setMinimumSize(new Dimension(,)); 
    130         statusPane.setPreferredSize(new Dimension(425, 150));        
     142        statusPane.setPreferredSize(new Dimension(425, 150)); 
    131143        statusPane.setViewportView(statusTable); 
    132144        statusPane.setBorder(BorderFactory.createTitledBorder( 
    133145                BorderFactory.createRaisedBevelBorder(), "Status Updates")); 
    134          
     146 
    135147        Box panelBox = Box.createVerticalBox(); 
    136148        panelBox.add(connInfoBox); 
     
    139151        panelBox.add(Box.createVerticalStrut(10)); 
    140152        panelBox.add(statusPane); 
    141         panelBox.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
    142          
     153        panelBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 
     154 
    143155        add(panelBox); 
    144156    } 
    145      
    146157    private JScrollPane titlePane; 
    147158    private JScrollPane statusPane; 
    148      
    149159    private JLabel connInfoLbl; 
    150      
    151160    private JTextField connInfoTF; 
    152161} 
  • trunk/src/tmcsim/cadsimulator/viewer/MediaStatusPanel.java

    r2 r44  
    11package tmcsim.cadsimulator.viewer; 
    22 
     3import java.util.Iterator; 
     4import java.util.Observable; 
    35import java.util.TreeMap; 
    4  
    56import javax.swing.JPanel; 
    67import javax.swing.JTabbedPane; 
    7  
    88import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 
    99import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; 
     10import tmcsim.cadsimulator.viewer.model.CADMediaStatus; 
    1011 
    1112/** 
    12  * MediaStatusPanel is a GUI object used for displaying information 
    13  * for DVD connections created by the CAD Simulator.  Tabs for each 
    14  * DVD are created and information is displayed on a DVDInfoPanel. 
    15  * All status and title updates are sent to the corresponding 
    16  * DVDInfoPanel.  The DVDs are referenced by connection info, which 
    17  * is unique to each DVD player. 
    18  *  
    19  * @author Matthew Cechini 
    20  * @version 
     13 * MediaStatusPanel is a GUI object used for displaying information for DVD 
     14 * connections created by the CAD Simulator. Tabs for each DVD are created and 
     15 * information is displayed on a DVDInfoPanel. All status and title updates are 
     16 * sent to the corresponding DVDInfoPanel. The DVDs are referenced by connection 
     17 * info, which is unique to each DVD player. 
     18 * 
     19 * @author jdalbey 
    2120 */ 
    2221@SuppressWarnings("serial") 
    23 public class MediaStatusPanel extends JPanel { 
    24      
    25     /** Map of DVDInfoPanels(values) referenced by a DVD's connection info(key). */ 
     22public class MediaStatusPanel extends JPanel 
     23{ 
     24 
     25    /** 
     26     * Map of DVDInfoPanels(values) referenced by a DVD's connection info(key). 
     27     */ 
    2628    private TreeMap<String, DVDInfoPanel> dvdPanels = null; 
    2729 
    2830    /** 
    29      * Constructor.  Initialize data and GUI components. 
     31     * Constructor. Initialize data and GUI components. 
    3032     */ 
    31     public MediaStatusPanel() { 
     33    public MediaStatusPanel() 
     34    { 
    3235 
    33         dvdPanels   = new TreeMap<String, DVDInfoPanel>(); 
    34          
     36        dvdPanels = new TreeMap<String, DVDInfoPanel>(); 
     37 
    3538        initComponents(); 
    3639    } 
    37      
     40 
     41    public void refresh(Observable obs) 
     42    { 
     43        CADMediaStatus status = (CADMediaStatus) obs; 
     44        Iterator<DVDInfoPanel> iter = status.getDVDlist(); 
     45        // Remove existing tabs before adding them all back 
     46        mediaTabs.removeAll(); 
     47        // add a new tab for each dvd panel 
     48        while (iter.hasNext()) 
     49        { 
     50            DVDInfoPanel item = iter.next(); 
     51            mediaTabs.addTab( 
     52                    "DVD " + (Integer.parseInt(item.connInfo 
     53                    .substring(item.connInfo 
     54                    .indexOf(":") + 1)) % 3000), 
     55                    dvdPanels.get(item.connInfo)); 
     56        } 
     57//            mediaTabs.addTab( 
     58//                    "DVD " + (Integer.parseInt(update.connectionInfo 
     59//                    .substring(update.connectionInfo 
     60//                    .indexOf(":") + 1)) % 3000), 
     61//                    dvdPanels.get(update.connectionInfo)); 
     62 
     63    } 
     64 
    3865    /** 
    39      * Updates the current DVDInfoPanel with the status update. 
    40      * If a panel does not current exist, create one and add 
    41      * a new tab. 
    42      *  
     66     * Updates the current DVDInfoPanel with the status update. If a panel does 
     67     * not current exist, create one and add a new tab. 
     68     * 
    4369     * @param update DVD status update. 
    4470     */ 
    45     public void updateDVDStatus(DVDStatusUpdate update) { 
    46         if(dvdPanels.get(update.connectionInfo) == null) { 
     71    public void updateDVDStatus(DVDStatusUpdate update) 
     72    { 
     73        if (dvdPanels.get(update.connectionInfo) == null) 
     74        { 
    4775            dvdPanels.put(update.connectionInfo, new DVDInfoPanel( 
    4876                    update.connectionInfo)); 
     
    5078            mediaTabs.addTab( 
    5179                    "DVD " + (Integer.parseInt(update.connectionInfo 
    52                                     .substring(update.connectionInfo 
    53                                             .indexOf(":")+1)) % 3000),  
     80                    .substring(update.connectionInfo 
     81                    .indexOf(":") + 1)) % 3000), 
    5482                    dvdPanels.get(update.connectionInfo)); 
    5583        } 
    56          
    57          
     84 
     85 
    5886        dvdPanels.get(update.connectionInfo).updateDVDStatus(update); 
    5987    } 
    60      
     88 
    6189    /** 
    62      * Updates the current DVDInfoPanel with the title update. 
    63      * If a panel does not current exist, create one and add 
    64      * a new tab. 
    65      *  
     90     * Updates the current DVDInfoPanel with the title update. If a panel does 
     91     * not current exist, create one and add a new tab. 
     92     * 
    6693     * @param update DVD title update. 
    6794     */ 
    68     public void updateDVDTitle(DVDTitleUpdate update) { 
    69         if(dvdPanels.get(update.connectionInfo) == null) { 
     95    public void updateDVDTitle(DVDTitleUpdate update) 
     96    { 
     97        if (dvdPanels.get(update.connectionInfo) == null) 
     98        { 
    7099            dvdPanels.put(update.connectionInfo, new DVDInfoPanel(update.connectionInfo)); 
    71              
    72             mediaTabs.addTab("DVD " + dvdPanels.size(),  
     100 
     101            mediaTabs.addTab("DVD " + dvdPanels.size(), 
    73102                    dvdPanels.get(update.connectionInfo)); 
    74103        } 
    75          
     104 
    76105        dvdPanels.get(update.connectionInfo).updateDVDTitle(update); 
    77106    } 
    78      
     107 
    79108    /** 
    80109     * Initialize GUI components. 
    81110     */ 
    82     private void initComponents() { 
     111    private void initComponents() 
     112    { 
    83113        mediaTabs = new JTabbedPane(); 
    84          
     114 
    85115        add(mediaTabs); 
    86116    } 
    87      
    88117    private JTabbedPane mediaTabs; 
    89      
    90118} 
  • trunk/src/tmcsim/cadsimulator/viewer/SimulationStatusPanel.java

    r36 r44  
    55import java.awt.Dimension; 
    66import java.awt.Font; 
    7 import java.util.logging.Handler; 
    8 import java.util.logging.Level; 
    9 import java.util.logging.LogRecord; 
    10 import java.util.logging.Logger; 
     7import java.util.Observable; 
    118import javax.swing.BorderFactory; 
    129import javax.swing.Box; 
     
    1916import javax.swing.border.EtchedBorder; 
    2017import javax.swing.border.TitledBorder; 
     18import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 
    2119import tmcsim.common.CADEnums.PARAMICS_STATUS; 
    2220import tmcsim.common.CADEnums.SCRIPT_STATUS; 
     
    3735 * </ul> 
    3836 * 
    39  * @author Matthew Cechini 
     37 * @author Matthew Cechini, jdalbey 
    4038 * @version 
    4139 */ 
     
    4543 
    4644    /** 
    47      * Logging Handler to listen for Information and Error messages logged for 
    48      * the CAD Simulator. Received LogRecords are displayed in the info or error 
    49      * message Text Area. 
    50      * 
    51      * @author Matthew Cechini 
    52      */ 
    53     private class SimulatorErrorHandler extends Handler 
    54     { 
    55  
    56         public void close() throws SecurityException 
    57         { 
    58         } 
    59  
    60         public void flush() 
    61         { 
    62         } 
    63  
    64         public void publish(LogRecord rec) 
    65         { 
    66             StringBuffer msgBuffer = new StringBuffer(); 
    67  
    68             msgBuffer.append(rec.getSourceClassName() + "." 
    69                     + rec.getSourceMethodName() + " = " 
    70                     + rec.getMessage()); 
    71  
    72             if (rec.getLevel() == Level.INFO) 
    73             { 
    74                 infoMessagesTA.setText(infoMessagesTA.getText() 
    75                         + msgBuffer.toString() + "\n"); 
    76             } else 
    77             { 
    78                 errorMessagesTA.setText(errorMessagesTA.getText() 
    79                         + msgBuffer.toString() + "\n"); 
    80             } 
    81         } 
     45     * Refresh this view 
     46     * 
     47     * @param obs the Observable we are watching 
     48     */ 
     49    public void refresh(Observable obs) 
     50    { 
     51        CADSimulatorStatus status = (CADSimulatorStatus) obs; 
     52        termConnectedTF.setText(String.valueOf(status.getNumClients())); 
     53        String yesno = "No"; 
     54        // Should we show yes or no? 
     55        if (status.isSimManagerConnected()) 
     56        { 
     57            yesno = "Yes"; 
     58        } 
     59        managerConnectedTF.setText(yesno); 
     60        simulationClockLabel.setText(status.getCurrentTime()); 
     61        setScriptStatus(status.getScriptStatus()); 
     62        setParamicsStatus(status.getParamicsStatus()); 
     63 
     64        String netText = status.getParmicsNetworkID(); 
     65        if (netText.length() == 0) 
     66        { 
     67            netText = "None"; 
     68        } 
     69        setParamicsNetworkLoaded(netText); 
     70 
     71        String msgOut = status.getInfoMessages(); 
     72        infoMessagesTA.setText(msgOut); 
     73        errorMessagesTA.setText(status.getErrorMessages()); 
    8274    } 
    8375    /** 
     
    8577     */ 
    8678    private int numClientsConnected = 0; 
    87     /** 
    88      * Logging ErrorHandler. 
    89      */ 
    90     private SimulatorErrorHandler errorHandler; 
    9179 
    9280    /** 
     
    10290        initMessagesPanes(); 
    10391 
    104         errorHandler = new SimulatorErrorHandler(); 
    105         Logger.getLogger("tmcsim.cadsimulator").addHandler(errorHandler); 
    106  
    107         CADSimulatorViewerBox = Box.createVerticalBox(); 
    108         CADSimulatorViewerBox.add(simulationTimeAndStatusBox); 
    109         CADSimulatorViewerBox.add(additionalInfoBox); 
    110         CADSimulatorViewerBox.add(infoMessagesPane); 
    111         CADSimulatorViewerBox.add(errorMessagesPane); 
    112  
    113         add(CADSimulatorViewerBox); 
    114     } 
    115  
    116     /** 
    117      * Method is called when a CAD Client disconnects from the CAD Simulator. 
    118      * The displayed number of connected clients is incremented by one. 
    119      */ 
    120     public void connectClient() 
    121     { 
    122  
    123         numClientsConnected++; 
    124  
    125         termConnectedTF.setText(String.valueOf(numClientsConnected)); 
    126     } 
    127  
    128     /** 
    129      * Method is called when a CAD Client disconnects from the CAD Simulator. 
    130      * The displayed number of connected clients is decremented by one. 
    131      */ 
    132     public void disconnectClient() 
    133     { 
    134  
    135         if (numClientsConnected > 0) 
    136         { 
    137             numClientsConnected--; 
    138         } 
    139  
    140         termConnectedTF.setText(String.valueOf(numClientsConnected)); 
    141     } 
    142  
    143     /** 
    144      * Method is called when Simulation Manager connects or disconnects. 
    145      * 
    146      * @param connection True if simulation manager is connected, false if not. 
    147      */ 
    148     public void setSimManagerStatus(boolean connection) 
    149     { 
    150  
    151         if (connection) 
    152         { 
    153             managerConnectedTF.setText("Yes"); 
    154         } else 
    155         { 
    156             managerConnectedTF.setText("No"); 
    157         } 
    158  
    159     } 
    160  
    161     /** 
    162      * Method called to convert current simulation time (parameter long value) 
    163      * to a string of format H:MM:SS. Time is then updated on GUI. 
    164      * 
    165      * @param seconds Long value of current time 
    166      */ 
    167     public void setTime(long seconds) 
    168     { 
    169         String time = new String(); 
    170         long timeSegment; 
    171  
    172         timeSegment = seconds / 3600; 
    173         time += String.valueOf(timeSegment) + ":"; 
    174  
    175         seconds = seconds % 3600; 
    176  
    177         timeSegment = seconds / 60; 
    178         if (timeSegment < 10) 
    179         { 
    180             time += "0"; 
    181         } 
    182  
    183         time += String.valueOf(timeSegment) + ":"; 
    184         seconds = seconds % 60; 
    185  
    186         timeSegment = seconds; 
    187         if (timeSegment < 10) 
    188         { 
    189             time += "0"; 
    190         } 
    191  
    192         time += String.valueOf(timeSegment); 
    193  
    194         simulationClockLabel.setText(time); 
    195  
     92        //  errorHandler = new SimulatorErrorHandler(); 
     93        //  Logger.getLogger("tmcsim.cadsimulator").addHandler(errorHandler); 
     94 
     95        cadSimulatorViewerBox = Box.createVerticalBox(); 
     96        cadSimulatorViewerBox.add(simulationTimeAndStatusBox); 
     97        cadSimulatorViewerBox.add(additionalInfoBox); 
     98        cadSimulatorViewerBox.add(infoMessagesPane); 
     99        cadSimulatorViewerBox.add(errorMessagesPane); 
     100 
     101        add(cadSimulatorViewerBox); 
    196102    } 
    197103 
     
    206112    protected void displayError(String errorMessage) 
    207113    { 
     114        // Do we clear or append? 
    208115        if (errorMessage == null) 
    209116        { 
    210117            errorMessagesTA.setText(""); 
    211         } else 
     118        } 
     119        else 
    212120        { 
    213121            errorMessagesTA.append(errorMessage + "\n"); 
     
    253161     * </table> 
    254162     */ 
    255     public void setScriptStatus(SCRIPT_STATUS newStatus) 
    256     { 
    257  
     163    private void setScriptStatus(SCRIPT_STATUS newStatus) 
     164    { 
     165        // Display text based on status value 
    258166        switch (newStatus) 
    259167        { 
     
    291199     * or dropped. 
    292200     */ 
    293     public void setParamicsStatus(PARAMICS_STATUS newStatus) 
    294     { 
    295  
     201    private void setParamicsStatus(PARAMICS_STATUS newStatus) 
     202    { 
     203        // Display text based on status value 
    296204        switch (newStatus) 
    297205        { 
     
    310218     * @param networkID Unique ID for Paramics network that has been loaded. 
    311219     */ 
    312     public void setParamicsNetworkLoaded(String networkID) 
     220    private void setParamicsNetworkLoaded(String networkID) 
    313221    { 
    314222        networkLoadedTF.setText(networkID); 
     
    325233        simulationStatus = new JLabel("Simulation Status"); 
    326234        simulationStatusText = new JLabel("No Script"); 
     235        simulationStatusText.setName("simulationStatusText"); 
    327236 
    328237        simulationTime.setLayout(new BorderLayout()); 
     
    470379    private Box paramicsConnectedBox; 
    471380    private Box networkLoadedBox; 
    472     private Box CADSimulatorViewerBox; 
     381    private Box cadSimulatorViewerBox; 
    473382    private Box simulationTimeAndStatusBox; 
    474383    private Box simulationStatusBox; 
Note: See TracChangeset for help on using the changeset viewer.