| 1 | /* |
|---|
| 2 | * To change this template, choose Tools | Templates |
|---|
| 3 | * and open the template in the editor. |
|---|
| 4 | */ |
|---|
| 5 | package tmcsim.client.cadclientgui.screens; |
|---|
| 6 | |
|---|
| 7 | import java.awt.Color; |
|---|
| 8 | import java.awt.Component; |
|---|
| 9 | import java.awt.Dimension; |
|---|
| 10 | import java.awt.event.ActionEvent; |
|---|
| 11 | import java.awt.event.ActionListener; |
|---|
| 12 | import java.awt.event.MouseEvent; |
|---|
| 13 | import java.awt.event.MouseListener; |
|---|
| 14 | import java.rmi.RemoteException; |
|---|
| 15 | import java.text.DateFormat; |
|---|
| 16 | import java.text.SimpleDateFormat; |
|---|
| 17 | import java.util.Calendar; |
|---|
| 18 | import java.util.Date; |
|---|
| 19 | |
|---|
| 20 | import javax.swing.BorderFactory; |
|---|
| 21 | import javax.swing.DefaultListModel; |
|---|
| 22 | import javax.swing.JLabel; |
|---|
| 23 | import javax.swing.JPanel; |
|---|
| 24 | import javax.swing.JScrollBar; |
|---|
| 25 | import javax.swing.JTable; |
|---|
| 26 | import javax.swing.ListSelectionModel; |
|---|
| 27 | import javax.swing.SwingConstants; |
|---|
| 28 | import javax.swing.border.LineBorder; |
|---|
| 29 | import javax.swing.table.DefaultTableCellRenderer; |
|---|
| 30 | import javax.swing.table.DefaultTableModel; |
|---|
| 31 | import javax.swing.table.TableCellRenderer; |
|---|
| 32 | |
|---|
| 33 | import tmcsim.client.cadclientgui.enums.TableHeaders; |
|---|
| 34 | import tmcsim.client.cadclientgui.enums.CADDataEnums.TABLE; |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * This class contains the view and controller for the IncidentEditor screen. The view is built using a GUI builder plug-in, and the controller |
|---|
| 38 | * uses listeners to control how the view and data act. |
|---|
| 39 | * @author Stuart |
|---|
| 40 | */ |
|---|
| 41 | public class IncidentEditor extends javax.swing.JFrame { |
|---|
| 42 | |
|---|
| 43 | private final String[] monthNames = { "January", "February", |
|---|
| 44 | "March", "April", "May", "June", "July", "August", "September", |
|---|
| 45 | "October", "November", "December"}; |
|---|
| 46 | |
|---|
| 47 | private final String[] dayNames = { "Sun", "Mon", "Tue", "Wed", |
|---|
| 48 | "Thu", "Fri", "Sat"}; |
|---|
| 49 | |
|---|
| 50 | private DefaultTableModel blankTable; |
|---|
| 51 | |
|---|
| 52 | private JTable calendarTable; |
|---|
| 53 | private int todayRow; |
|---|
| 54 | private int todayCol; |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Creates new form IncidentEditor |
|---|
| 58 | */ |
|---|
| 59 | public IncidentEditor() { |
|---|
| 60 | declareComponents(); |
|---|
| 61 | initControllers(); |
|---|
| 62 | initLayout(); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /** |
|---|
| 66 | * This method is called from within the constructor to initialize the form. |
|---|
| 67 | * WARNING: Do NOT modify this code. The content of this method is always |
|---|
| 68 | * regenerated by the Form Editor. |
|---|
| 69 | */ |
|---|
| 70 | @SuppressWarnings("unchecked") |
|---|
| 71 | // <editor-fold defaultstate="collapsed" |
|---|
| 72 | // desc="Generated Code">//GEN-BEGIN:initComponents |
|---|
| 73 | private void declareComponents() { |
|---|
| 74 | |
|---|
| 75 | incidentLogScroll = new javax.swing.JScrollPane(); |
|---|
| 76 | incidentLogTable = new javax.swing.JTable(); |
|---|
| 77 | agencyTypeLabel = new javax.swing.JLabel(); |
|---|
| 78 | jScrollPane1 = new javax.swing.JScrollPane(); |
|---|
| 79 | agencyTypeList = new javax.swing.JList(); |
|---|
| 80 | currentDatabaseLabel = new javax.swing.JLabel(); |
|---|
| 81 | currentDatabaseCombo = new javax.swing.JComboBox(); |
|---|
| 82 | searchLimitLabel = new javax.swing.JLabel(); |
|---|
| 83 | reopenButton = new javax.swing.JButton(); |
|---|
| 84 | duplicateCellButton = new javax.swing.JButton(); |
|---|
| 85 | searchButton = new javax.swing.JButton(); |
|---|
| 86 | printButton = new javax.swing.JButton(); |
|---|
| 87 | viewButton = new javax.swing.JButton(); |
|---|
| 88 | refreshButton = new javax.swing.JButton(); |
|---|
| 89 | exitButton = new javax.swing.JButton(); |
|---|
| 90 | fromLabel = new javax.swing.JLabel(); |
|---|
| 91 | toLabel = new javax.swing.JLabel(); |
|---|
| 92 | fromCalendar = new javax.swing.JPanel(); |
|---|
| 93 | toCalendar = new javax.swing.JPanel(); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | public MouseListener newMouseListener(){ |
|---|
| 97 | return new MouseListener() { |
|---|
| 98 | public void mouseClicked(MouseEvent e) { |
|---|
| 99 | viewButton.setEnabled(true); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | public void mouseEntered(MouseEvent e) { |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | public void mouseExited(MouseEvent e) { |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | public void mousePressed(MouseEvent e) { |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | public void mouseReleased(MouseEvent e) { |
|---|
| 112 | } |
|---|
| 113 | }; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | public ActionListener newSearchActionListener(){ |
|---|
| 117 | return new ActionListener() { |
|---|
| 118 | public void actionPerformed(ActionEvent e) { |
|---|
| 119 | ScreenManager.openSearch(); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | }; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | public ActionListener newViewActionListener(){ |
|---|
| 126 | return new ActionListener() { |
|---|
| 127 | public void actionPerformed(ActionEvent e) { |
|---|
| 128 | String masterInc = (String) incidentLogTable.getValueAt( |
|---|
| 129 | incidentLogTable.getSelectedRow(), 5); |
|---|
| 130 | int incidentId = 0; |
|---|
| 131 | try { |
|---|
| 132 | incidentId = ScreenManager.theCoordinator |
|---|
| 133 | .getIncidentId(masterInc); |
|---|
| 134 | } catch (RemoteException e1) { |
|---|
| 135 | e1.printStackTrace(); |
|---|
| 136 | } |
|---|
| 137 | ScreenManager.openIncidentViewer(incidentId); |
|---|
| 138 | } |
|---|
| 139 | }; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | public ActionListener newRefreshActionListener(){ |
|---|
| 143 | return new ActionListener() { |
|---|
| 144 | public void actionPerformed(ActionEvent e) { |
|---|
| 145 | refreshInformation(); |
|---|
| 146 | } |
|---|
| 147 | }; |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | public ActionListener newExitActionListener(){ |
|---|
| 151 | return new ActionListener() { |
|---|
| 152 | public void actionPerformed(ActionEvent arg0) { |
|---|
| 153 | close(); |
|---|
| 154 | } |
|---|
| 155 | }; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | private void initControllers() { |
|---|
| 159 | |
|---|
| 160 | incidentLogTable.addMouseListener(newMouseListener()); |
|---|
| 161 | |
|---|
| 162 | searchButton.addActionListener(newSearchActionListener()); |
|---|
| 163 | viewButton.addActionListener(newViewActionListener()); |
|---|
| 164 | refreshButton.addActionListener(newRefreshActionListener()); |
|---|
| 165 | exitButton.addActionListener(newExitActionListener()); |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | private void initLayout() { |
|---|
| 169 | blankTable = new DefaultTableModel(); |
|---|
| 170 | blankTable.setColumnIdentifiers(TableHeaders.INCIDENT_EDITOR_HEADERS); |
|---|
| 171 | |
|---|
| 172 | setTitle("Incident Editor"); |
|---|
| 173 | setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); |
|---|
| 174 | setPreferredSize(new java.awt.Dimension(800, 600)); |
|---|
| 175 | |
|---|
| 176 | incidentLogTable.setOpaque(true); |
|---|
| 177 | incidentLogTable.setIntercellSpacing(new Dimension(1, 0)); |
|---|
| 178 | incidentLogTable.setGridColor(Color.WHITE); |
|---|
| 179 | incidentLogTable.getTableHeader().setReorderingAllowed(false); |
|---|
| 180 | incidentLogTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|---|
| 181 | incidentLogTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|---|
| 182 | incidentLogTable.setAutoCreateRowSorter(true); |
|---|
| 183 | incidentLogScroll.setViewportView(incidentLogTable); |
|---|
| 184 | |
|---|
| 185 | agencyTypeLabel.setText("Agency Type:"); |
|---|
| 186 | |
|---|
| 187 | DefaultListModel<String> dlm = new DefaultListModel(); |
|---|
| 188 | dlm.addElement("CHP"); |
|---|
| 189 | agencyTypeList.setModel(dlm); |
|---|
| 190 | agencyTypeList.setEnabled(false); |
|---|
| 191 | |
|---|
| 192 | jScrollPane1.setViewportView(agencyTypeList); |
|---|
| 193 | |
|---|
| 194 | currentDatabaseLabel.setText("Current Database:"); |
|---|
| 195 | |
|---|
| 196 | currentDatabaseCombo.setModel(new javax.swing.DefaultComboBoxModel( |
|---|
| 197 | new String[] { "System" })); |
|---|
| 198 | currentDatabaseCombo.setEnabled(false); |
|---|
| 199 | |
|---|
| 200 | searchLimitLabel.setText("Search Limit On Live System: 30 Days"); |
|---|
| 201 | |
|---|
| 202 | fromCalendar = createCalendar(); |
|---|
| 203 | toCalendar = createCalendar(); |
|---|
| 204 | |
|---|
| 205 | reopenButton.setText("ReOpen"); |
|---|
| 206 | reopenButton.setEnabled(false); |
|---|
| 207 | |
|---|
| 208 | duplicateCellButton.setText("Duplicate Cell"); |
|---|
| 209 | duplicateCellButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
|---|
| 210 | duplicateCellButton.setEnabled(false); |
|---|
| 211 | |
|---|
| 212 | searchButton.setText("Search"); |
|---|
| 213 | |
|---|
| 214 | printButton.setText("Print"); |
|---|
| 215 | printButton.setEnabled(false); |
|---|
| 216 | |
|---|
| 217 | viewButton.setText("View"); |
|---|
| 218 | viewButton.setEnabled(false); |
|---|
| 219 | |
|---|
| 220 | refreshButton.setText("Refresh"); |
|---|
| 221 | exitButton.setText("Exit"); |
|---|
| 222 | |
|---|
| 223 | fromLabel.setText("From..."); |
|---|
| 224 | |
|---|
| 225 | toLabel.setText("To..."); |
|---|
| 226 | |
|---|
| 227 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); |
|---|
| 228 | getContentPane().setLayout(layout); |
|---|
| 229 | layout.setHorizontalGroup( |
|---|
| 230 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 231 | .addComponent(incidentLogScroll) |
|---|
| 232 | .addGroup(layout.createSequentialGroup() |
|---|
| 233 | .addContainerGap() |
|---|
| 234 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 235 | .addComponent(agencyTypeLabel) |
|---|
| 236 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) |
|---|
| 237 | .addGroup(layout.createSequentialGroup() |
|---|
| 238 | .addGap(10, 10, 10) |
|---|
| 239 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 240 | .addComponent(currentDatabaseLabel) |
|---|
| 241 | .addComponent(currentDatabaseCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))) |
|---|
| 242 | .addComponent(searchLimitLabel)) |
|---|
| 243 | .addGap(32, 32, 32) |
|---|
| 244 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 245 | .addComponent(fromLabel) |
|---|
| 246 | .addComponent(fromCalendar, 200, 200, 200)) |
|---|
| 247 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE) |
|---|
| 248 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 249 | .addComponent(toLabel) |
|---|
| 250 | .addComponent(toCalendar, 200, 200, 200)) |
|---|
| 251 | .addGap(25, 25, 25) |
|---|
| 252 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
|---|
| 253 | .addComponent(reopenButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 254 | .addComponent(duplicateCellButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 255 | .addComponent(searchButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 256 | .addComponent(printButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 257 | .addComponent(viewButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 258 | .addComponent(refreshButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|---|
| 259 | .addComponent(exitButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) |
|---|
| 260 | ); |
|---|
| 261 | layout.setVerticalGroup( |
|---|
| 262 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 263 | .addGroup(layout.createSequentialGroup() |
|---|
| 264 | .addComponent(incidentLogScroll, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) |
|---|
| 265 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|---|
| 266 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
|---|
| 267 | .addComponent(agencyTypeLabel) |
|---|
| 268 | .addComponent(reopenButton) |
|---|
| 269 | .addComponent(fromLabel) |
|---|
| 270 | .addComponent(toLabel)) |
|---|
| 271 | .addGap(2, 2, 2) |
|---|
| 272 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|---|
| 273 | .addGroup(layout.createSequentialGroup() |
|---|
| 274 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) |
|---|
| 275 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|---|
| 276 | .addComponent(currentDatabaseLabel) |
|---|
| 277 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|---|
| 278 | .addComponent(currentDatabaseCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
|---|
| 279 | .addGap(18, 18, 18) |
|---|
| 280 | .addComponent(searchLimitLabel)) |
|---|
| 281 | .addGroup(layout.createSequentialGroup() |
|---|
| 282 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
|---|
| 283 | .addComponent(fromCalendar, 150, 150, 150) |
|---|
| 284 | .addComponent(toCalendar, 150, 150, 150))) |
|---|
| 285 | .addGroup(layout.createSequentialGroup() |
|---|
| 286 | .addComponent(duplicateCellButton) |
|---|
| 287 | .addGap(2, 2, 2) |
|---|
| 288 | .addComponent(searchButton) |
|---|
| 289 | .addGap(2, 2, 2) |
|---|
| 290 | .addComponent(printButton) |
|---|
| 291 | .addGap(2, 2, 2) |
|---|
| 292 | .addComponent(viewButton) |
|---|
| 293 | .addGap(2, 2, 2) |
|---|
| 294 | .addComponent(refreshButton) |
|---|
| 295 | .addGap(2, 2, 2) |
|---|
| 296 | .addComponent(exitButton))) |
|---|
| 297 | .addGap(0, 41, Short.MAX_VALUE)) |
|---|
| 298 | ); |
|---|
| 299 | |
|---|
| 300 | pack(); |
|---|
| 301 | }// </editor-fold>//GEN-END:initComponents |
|---|
| 302 | |
|---|
| 303 | public JPanel createCalendar(){ |
|---|
| 304 | |
|---|
| 305 | JPanel calendarPanel = new JPanel(); |
|---|
| 306 | Calendar now = Calendar.getInstance(); |
|---|
| 307 | calendarPanel.setBorder(new LineBorder(new Color(0, 0, 0))); |
|---|
| 308 | calendarPanel.setLayout(null); |
|---|
| 309 | |
|---|
| 310 | JLabel monthLabel = new JLabel("New label"); |
|---|
| 311 | monthLabel.setBounds(0, 0, 140, 20); |
|---|
| 312 | monthLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|---|
| 313 | monthLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|---|
| 314 | monthLabel.setText(monthNames[now.get(Calendar.MONTH)]); |
|---|
| 315 | calendarPanel.add(monthLabel); |
|---|
| 316 | |
|---|
| 317 | JLabel yearLabel = new JLabel("New label"); |
|---|
| 318 | yearLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|---|
| 319 | yearLabel.setBounds(140, 0, 60, 20); |
|---|
| 320 | yearLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|---|
| 321 | yearLabel.setText(Integer.toString(now.get(Calendar.YEAR))); |
|---|
| 322 | calendarPanel.add(yearLabel); |
|---|
| 323 | |
|---|
| 324 | Date date = new Date(); |
|---|
| 325 | DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); |
|---|
| 326 | String dateString = dateFormat.format(date); |
|---|
| 327 | |
|---|
| 328 | JLabel dateLabel1 = new JLabel("New label"); |
|---|
| 329 | dateLabel1.setBounds(0, 130, 60, 20); |
|---|
| 330 | dateLabel1.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|---|
| 331 | dateLabel1.setText(dateString); |
|---|
| 332 | dateLabel1.setHorizontalAlignment(JLabel.CENTER); |
|---|
| 333 | calendarPanel.add(dateLabel1); |
|---|
| 334 | |
|---|
| 335 | JLabel dateLabel2 = new JLabel("New label"); |
|---|
| 336 | dateLabel2.setBounds(140, 130, 60, 20); |
|---|
| 337 | dateLabel2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|---|
| 338 | dateLabel2.setText(dateString); |
|---|
| 339 | dateLabel2.setHorizontalAlignment(JLabel.CENTER); |
|---|
| 340 | calendarPanel.add(dateLabel2); |
|---|
| 341 | |
|---|
| 342 | JScrollBar scrollBar = new JScrollBar(); |
|---|
| 343 | scrollBar.setOrientation(JScrollBar.HORIZONTAL); |
|---|
| 344 | scrollBar.setBounds(60, 130, 80, 20); |
|---|
| 345 | scrollBar.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
|---|
| 346 | scrollBar.setEnabled(false); |
|---|
| 347 | calendarPanel.add(scrollBar); |
|---|
| 348 | |
|---|
| 349 | calendarTable = new JTable(){ |
|---|
| 350 | /* |
|---|
| 351 | * Custom renderer to set different background/foreground colors |
|---|
| 352 | * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, int, int) |
|---|
| 353 | */ |
|---|
| 354 | public Component prepareRenderer(TableCellRenderer renderer, int row, int column){ |
|---|
| 355 | Component comp = super.prepareRenderer(renderer, row, column); |
|---|
| 356 | if(todayRow == row && todayCol == column){ |
|---|
| 357 | comp.setBackground(Color.BLUE); |
|---|
| 358 | comp.setForeground(Color.WHITE); |
|---|
| 359 | } |
|---|
| 360 | else{ |
|---|
| 361 | comp.setBackground(new Color(235, 235, 235)); |
|---|
| 362 | comp.setForeground(Color.BLACK); |
|---|
| 363 | } |
|---|
| 364 | return comp; |
|---|
| 365 | } |
|---|
| 366 | }; |
|---|
| 367 | calendarTable.setModel(createDaysModel()); |
|---|
| 368 | DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer(); |
|---|
| 369 | centerRenderer.setHorizontalAlignment(JLabel.CENTER); |
|---|
| 370 | for(int i = 0; i < dayNames.length; i++){ |
|---|
| 371 | calendarTable.getColumnModel().getColumn(i).setCellRenderer(centerRenderer); |
|---|
| 372 | } |
|---|
| 373 | calendarTable.setEnabled(false); |
|---|
| 374 | calendarTable.setBounds(0, 20, 200, 110); |
|---|
| 375 | calendarPanel.add(calendarTable); |
|---|
| 376 | |
|---|
| 377 | return calendarPanel; |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | protected DefaultTableModel createDaysModel() { |
|---|
| 381 | |
|---|
| 382 | String[][] emptyModel = {{"", "", "", "", "", "", ""}, |
|---|
| 383 | {"", "", "", "", "", "", ""}, |
|---|
| 384 | {"", "", "", "", "", "", ""}, |
|---|
| 385 | {"", "", "", "", "", "", ""}, |
|---|
| 386 | {"", "", "", "", "", "", ""}, |
|---|
| 387 | {"", "", "", "", "", "", ""}, |
|---|
| 388 | {"", "", "", "", "", "", ""}, |
|---|
| 389 | {"", "", "", "", "", "", ""}}; |
|---|
| 390 | |
|---|
| 391 | String[] emptyHeader = {"", "", "", "", "", "", ""}; |
|---|
| 392 | DefaultTableModel calendarModel = new DefaultTableModel(emptyModel, emptyHeader); |
|---|
| 393 | int row = 0; |
|---|
| 394 | int col = 0; |
|---|
| 395 | |
|---|
| 396 | Calendar today = Calendar.getInstance(); |
|---|
| 397 | int tMonth = today.get(Calendar.MONTH); |
|---|
| 398 | int tYear = today.get(Calendar.YEAR); |
|---|
| 399 | int tDay = today.get(Calendar.DAY_OF_MONTH); |
|---|
| 400 | |
|---|
| 401 | Calendar calendar = Calendar.getInstance(); |
|---|
| 402 | calendar.set(Calendar.MONTH, tMonth); |
|---|
| 403 | calendar.set(Calendar.YEAR, tYear); |
|---|
| 404 | calendar.set(Calendar.DAY_OF_MONTH, 1); |
|---|
| 405 | |
|---|
| 406 | Calendar iterator = (Calendar) calendar.clone(); |
|---|
| 407 | iterator.add(Calendar.DAY_OF_MONTH, |
|---|
| 408 | -(iterator.get(Calendar.DAY_OF_WEEK) - 1)); |
|---|
| 409 | |
|---|
| 410 | Calendar maximum = (Calendar) calendar.clone(); |
|---|
| 411 | maximum.add(Calendar.MONTH, +1); |
|---|
| 412 | |
|---|
| 413 | for (int i = 0; i < dayNames.length; i++) { |
|---|
| 414 | calendarModel.setValueAt(dayNames[i], row, col); |
|---|
| 415 | col++; |
|---|
| 416 | } |
|---|
| 417 | col = 0; |
|---|
| 418 | row = 1; |
|---|
| 419 | |
|---|
| 420 | while (iterator.getTimeInMillis() < maximum.getTimeInMillis()) { |
|---|
| 421 | int lMonth = iterator.get(Calendar.MONTH); |
|---|
| 422 | int lYear = iterator.get(Calendar.YEAR); |
|---|
| 423 | |
|---|
| 424 | if ((lMonth == tMonth) && (lYear == tYear)) { |
|---|
| 425 | int lDay = iterator.get(Calendar.DAY_OF_MONTH); |
|---|
| 426 | calendarModel.setValueAt(Integer.toString(lDay), row, col); |
|---|
| 427 | if ((tMonth == lMonth) && (tYear == lYear) && (tDay == lDay)) { |
|---|
| 428 | todayRow = row; |
|---|
| 429 | todayCol = col; |
|---|
| 430 | } |
|---|
| 431 | } |
|---|
| 432 | iterator.add(Calendar.DAY_OF_YEAR, +1); |
|---|
| 433 | |
|---|
| 434 | col++; |
|---|
| 435 | if(col >= calendarModel.getColumnCount()){ |
|---|
| 436 | row++; |
|---|
| 437 | col = 0; |
|---|
| 438 | } |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | return calendarModel; |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | public void refreshInformation() { |
|---|
| 446 | try { |
|---|
| 447 | incidentLogTable.setModel(ScreenManager.theCoordinator |
|---|
| 448 | .getCadDataTable(TABLE.INCIDENT_EDITOR)); |
|---|
| 449 | } catch (RemoteException e) { |
|---|
| 450 | e.printStackTrace(); |
|---|
| 451 | } |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | /* |
|---|
| 455 | * Makes screen visible. |
|---|
| 456 | */ |
|---|
| 457 | public void open() { |
|---|
| 458 | incidentLogTable.setModel(blankTable); |
|---|
| 459 | viewButton.setEnabled(false); |
|---|
| 460 | setVisible(true); |
|---|
| 461 | } |
|---|
| 462 | |
|---|
| 463 | /* |
|---|
| 464 | * Hides screen. |
|---|
| 465 | */ |
|---|
| 466 | public void close() { |
|---|
| 467 | setVisible(false); |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | // Variables declaration - do not modify//GEN-BEGIN:variables |
|---|
| 471 | private javax.swing.JLabel agencyTypeLabel; |
|---|
| 472 | private javax.swing.JList agencyTypeList; |
|---|
| 473 | private javax.swing.JComboBox currentDatabaseCombo; |
|---|
| 474 | private javax.swing.JLabel currentDatabaseLabel; |
|---|
| 475 | private javax.swing.JButton duplicateCellButton; |
|---|
| 476 | private javax.swing.JButton exitButton; |
|---|
| 477 | private javax.swing.JPanel fromCalendar; |
|---|
| 478 | private javax.swing.JLabel fromLabel; |
|---|
| 479 | private javax.swing.JScrollPane incidentLogScroll; |
|---|
| 480 | private javax.swing.JTable incidentLogTable; |
|---|
| 481 | private javax.swing.JPanel toCalendar; |
|---|
| 482 | private javax.swing.JScrollPane jScrollPane1; |
|---|
| 483 | private javax.swing.JButton printButton; |
|---|
| 484 | private javax.swing.JButton refreshButton; |
|---|
| 485 | private javax.swing.JButton reopenButton; |
|---|
| 486 | private javax.swing.JButton searchButton; |
|---|
| 487 | private javax.swing.JLabel searchLimitLabel; |
|---|
| 488 | private javax.swing.JLabel toLabel; |
|---|
| 489 | private javax.swing.JButton viewButton; |
|---|
| 490 | // End of variables declaration//GEN-END:variables |
|---|
| 491 | } |
|---|