Changeset 432 in tmcsimulator for trunk/src/tmcsim/client/CADlogDisplay.java


Ignore:
Timestamp:
07/07/2019 11:13:00 AM (7 years ago)
Author:
jdalbey
Message:

CADlogDisplay updated. jar target added for CADlogDisplay. "Log Entries" changed to "CAD Log Entries" in Sim Mgr panel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/client/CADlogDisplay.java

    r425 r432  
    44import java.awt.event.ActionListener; 
    55import java.io.FileInputStream; 
     6import java.io.FileWriter; 
     7import java.io.PrintWriter; 
    68import java.rmi.Naming; 
    79import java.rmi.RemoteException; 
     
    3840    private static Logger cadClientLogger = Logger.getLogger("tmcsim.client"); 
    3941 
    40     @Override 
    41     public void refresh() throws RemoteException 
    42     { 
    43         throw new UnsupportedOperationException("Not supported yet."); 
    44     } 
     42    private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 
     43    private static final String LOG_FILE_NAME = "CADcomments.log"; 
     44    private final static int TEN_SECONDS = 10000; 
    4545 
    4646    /** 
     
    8282     */ 
    8383    private CADClientInterface client = this; 
    84     private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 
    85     private final static int TEN_SECONDS = 10000; 
     84    /* 
     85     * PrintWriter handle for sending log to a file  
     86     */ 
     87    private PrintWriter writer; 
    8688 
    8789    /** 
     
    103105                cadClientProp.getProperty(PROPERTIES.CAD_RMI_PORT.name).trim()); 
    104106 
    105         //theView = new ClockView(); 
    106         //theView.setVisible(true); 
    107  
    108107        // Create a timer that fetches the simulation time every second. 
    109108        Timer timer = new Timer(TEN_SECONDS, new ActionListener() 
    110109        { 
    111             public void actionPerformed(ActionEvent e) 
     110            public void actionPerformed(ActionEvent evt) 
    112111            { 
    113112                try 
    114113                { 
    115114                    Vector<Incident> incList = theCoorInt.getIncidentList();  
    116                     StringBuffer sb = new StringBuffer(); 
     115                    StringBuffer output = new StringBuffer(); 
    117116 
    118117                    for (Incident incident: incList) 
     
    120119                    // DefaultTableModel noteTable = (DefaultTableModel) theCoorInt.getCadDataIncidentTable(INC_TABLE.COMMENTS_NOTES, incident.getLogNum()); 
    121120                     // Output noteTable 
    122                         sb.append("Incident # " + incident.logNum + "\n"); 
    123121                        // Retrieve the table of comments/notes the users created 
    124122                        DefaultTableModel notesTable = incident.getCommentsNotesTable(); 
     
    127125                        { 
    128126                            // Combine the fields into one export entry 
    129                             sb.append(notesTable.getValueAt(row,1) + " "); // time 
    130                             String initials = (String) notesTable.getValueAt(row,2); // initials 
     127                            //sb.append(notesTable.getValueAt(row,1) + " "); // time 
     128                            String initials = (String) notesTable.getValueAt(row,2); // user initials 
    131129                            // If there are user intials, include this item. 
    132                             // Zero length initials mean it's a scripted item 
     130                            // Zero length initials mean it's a scripted item, ignore it. 
    133131                            if (initials.length() > 0) 
    134                             { 
    135                                 sb.append(initials + " "); 
    136                                 sb.append(notesTable.getValueAt(row,4) + "\n"); // notes 
     132                            {//CAD Log Entry, Incident #187, Sharon: REQUEST EXTRA ANCHOVIES 
     133                                output.append("CAD log entry, "); 
     134                                output.append("Incident #" + incident.logNum + ", "); 
     135                                output.append(initials + ": "); 
     136                                output.append(notesTable.getValueAt(row,4) + "\n"); // notes 
    137137                            } 
    138138                        } 
    139139                    } 
    140                     System.out.println(sb); 
     140                    System.out.print(output); 
     141                    // Write output to a file 
     142                    try  
     143                    { 
     144                        writer = new PrintWriter(new FileWriter(LOG_FILE_NAME)); 
     145                        writer.print(output); 
     146                        writer.close(); 
     147                    } catch (Exception exc) { 
     148                        exc.printStackTrace(); 
     149                        }  
     150         
    141151                    //long simtime = theCoorInt.getCurrentSimulationTime(); 
    142152                    //theView.updateTime("" + formatInterval(simtime)); 
     
    256266    } 
    257267 
     268    @Override 
     269    public void refresh() throws RemoteException 
     270    { 
     271        throw new UnsupportedOperationException("Not supported yet."); 
     272    } 
     273 
    258274    /** 
    259275     * Construct the CADClient with the properties file path, either from the 
Note: See TracChangeset for help on using the changeset viewer.