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

source: tmcsimulator/trunk/src/tmcsim/simulationmanager/IncidentHistoryPanel.java @ 432

Revision 432, 5.6 KB checked in by jdalbey, 7 years ago (diff)

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

RevLine 
1package tmcsim.simulationmanager;
2
3import java.awt.Dimension;
4
5import javax.swing.BorderFactory;
6import javax.swing.Box;
7import javax.swing.BoxLayout;
8import javax.swing.JLabel;
9import javax.swing.JPanel;
10import javax.swing.JScrollPane;
11import javax.swing.JTable;
12import javax.swing.JTextField;
13import javax.swing.border.EtchedBorder;
14
15import tmcsim.client.cadclientgui.data.IncidentEvent;
16import tmcsim.simulationmanager.model.IncidentHistoryTableModel;
17import tmcsim.simulationmanager.model.IncidentTimeCellRenderer;
18import tmcsim.simulationmanager.model.LogEntryCellRenderer;
19import tmcsim.simulationmanager.model.IncidentHistoryTableModel.EVENT_HIST_COLUMNS;
20
21/**
22 *
23 * @author Matthew Cechini
24 * @version
25 */
26@SuppressWarnings("serial")
27public class IncidentHistoryPanel extends JPanel {
28
29    /**  */
30    private JTable eventHistoryTable = null;
31   
32    /**  */
33    private IncidentHistoryTableModel eventHistoryTableModel;
34   
35   
36    public IncidentHistoryPanel() {
37       
38        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
39        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
40   
41        incTypeLbl = new JLabel("Type:");
42        incTypeLbl.setAlignmentX(Box.LEFT_ALIGNMENT);
43       
44        incTypeTF = new JTextField();
45        incTypeTF.setAlignmentX(Box.LEFT_ALIGNMENT);
46        //incTypeBox.setMinimumSize(new Dimension(50, 20));
47        //incTypeBox.setPreferredSize(new Dimension(100, 20));
48        incTypeTF.setMaximumSize(new Dimension(200, 20));
49        incTypeTF.setEditable(false);
50        incTypeTF.setName("incTypeTF");
51       
52        Box incTypeBox = Box.createVerticalBox();
53        incTypeBox.setAlignmentY(Box.CENTER_ALIGNMENT);
54        incTypeBox.add(incTypeLbl);
55        incTypeBox.add(incTypeTF);
56        incTypeBox.setBorder(BorderFactory.createEmptyBorder(10,0,10,0));
57
58       
59        incLocLbl = new JLabel("Location:");
60        incLocLbl.setAlignmentX(Box.LEFT_ALIGNMENT);
61       
62        incLocTF = new JTextField();
63        incLocTF.setAlignmentX(Box.LEFT_ALIGNMENT);
64        incLocTF.setMaximumSize(new Dimension(800, 20));
65        incLocTF.setEditable(false);
66        incLocTF.setName("incLocTF");
67       
68        Box incLocBox = Box.createVerticalBox();
69        incLocBox.setAlignmentY(Box.CENTER_ALIGNMENT);
70        incLocBox.add(incLocLbl);
71        incLocBox.add(incLocTF);
72               
73        Box incidentInfoBox = Box.createHorizontalBox();
74        incidentInfoBox.setAlignmentX(Box.CENTER_ALIGNMENT);
75        incidentInfoBox.setMaximumSize(new Dimension(1000, 75));
76        incidentInfoBox.add(Box.createHorizontalStrut(10));
77        incidentInfoBox.add(incTypeBox);
78        incidentInfoBox.add(Box.createHorizontalStrut(10));
79        incidentInfoBox.add(incLocBox);
80        incidentInfoBox.add(Box.createHorizontalStrut(10));
81        incidentInfoBox.setBorder(BorderFactory.createTitledBorder(
82                BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
83                "Incident Information"));
84       
85       
86
87        eventHistoryTableModel = new IncidentHistoryTableModel();
88        eventHistoryTable = new JTable(eventHistoryTableModel); 
89        eventHistoryTable.getTableHeader().setReorderingAllowed(false); 
90        eventHistoryTable.setName("LogHistory");
91       
92        for(int c = 0; c < eventHistoryTable.getColumnCount(); c++) {
93            eventHistoryTable.getColumnModel().getColumn(c).setMinWidth(
94                    eventHistoryTableModel.getColumnMinWidth(c));
95            eventHistoryTable.getColumnModel().getColumn(c).setMaxWidth(
96                    eventHistoryTableModel.getColumnMaxWidth(c));
97            eventHistoryTable.getColumnModel().getColumn(c).setPreferredWidth(
98                    eventHistoryTableModel.getColumnPrefWidth(c));
99            eventHistoryTable.getColumnModel().getColumn(c).setResizable(true);
100           
101            if(c == EVENT_HIST_COLUMNS.TIME_COL.colNum)
102                eventHistoryTable.getColumnModel().getColumn(c).setCellRenderer(
103                        new IncidentTimeCellRenderer());
104            else if (c == EVENT_HIST_COLUMNS.EVENT_DESC_COL.colNum)
105                eventHistoryTable.getColumnModel().getColumn(c).setCellRenderer(
106                        new LogEntryCellRenderer());           
107               
108        }       
109       
110        logScrollPane     = new JScrollPane(new JLabel(""), 
111                javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
112                javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
113        logScrollPane.setAlignmentX(Box.CENTER_ALIGNMENT);     
114        logScrollPane.setViewportView(eventHistoryTable);
115        logScrollPane.setBorder(BorderFactory.createTitledBorder(
116                BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "CAD Log Entries"));
117       
118   
119        add(incidentInfoBox);
120        add(Box.createVerticalStrut(10));
121        add(logScrollPane);
122    }
123   
124    public void updateIncidentHistory(IncidentEvent event) {
125       
126        if(event.eventInfo.getHeader().type.trim().length() > 0 &&
127            !incTypeTF.getText().trim().equals(event.eventInfo.getHeader().type.trim())) 
128        {
129            incTypeTF.setText(event.eventInfo.getHeader().type.trim());         
130        }
131
132        if(event.eventInfo.getHeader().fullLocation.trim().length() > 0&&
133            !incLocTF.getText().trim().equals(event.eventInfo.getHeader().fullLocation.trim()))
134        {
135            incLocTF.setText(event.eventInfo.getHeader().fullLocation.trim());
136        }
137
138        eventHistoryTableModel.addEvent(event);
139    }
140       
141    private JLabel incTypeLbl;
142    private JLabel incLocLbl;
143   
144    private JTextField incTypeTF;
145    private JTextField incLocTF;
146   
147    private JScrollPane logScrollPane;
148
149}
Note: See TracBrowser for help on using the repository browser.