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/PendingIncidents.java

    r3 r59  
    44import java.awt.Component; 
    55import java.awt.Dimension; 
     6import java.awt.Point; 
    67import java.awt.Toolkit; 
    78import java.awt.datatransfer.DataFlavor; 
     
    1415import java.rmi.RemoteException; 
    1516import java.util.List; 
    16  
    1717import javax.swing.Box; 
    1818import javax.swing.BoxLayout; 
     
    2323import javax.swing.JTable; 
    2424import javax.swing.ListSelectionModel; 
     25import javax.swing.RowSorter.SortKey; 
    2526import javax.swing.SwingUtilities; 
    2627import javax.swing.TransferHandler; 
    27 import javax.swing.RowSorter.SortKey; 
    2828import javax.swing.table.DefaultTableModel; 
    2929import javax.swing.table.TableCellRenderer; 
    30  
    3130import tmcsim.client.cadclientgui.enums.CADDataEnums; 
     31import tmcsim.client.cadclientgui.enums.CADDataEnums.INC_VAL; 
     32import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; 
    3233import tmcsim.client.cadclientgui.enums.IncidentEnums; 
    3334import tmcsim.client.cadclientgui.enums.TableHeaders; 
    3435import tmcsim.client.cadclientgui.enums.UnitStatusEnums; 
    35 import tmcsim.client.cadclientgui.enums.CADDataEnums.INC_VAL; 
    36 import tmcsim.client.cadclientgui.enums.CADScriptTags.UNIT_TAGS; 
    3736 
    3837/** 
    39  * This class contains the view and controller for the PendingIncidents screen. The view was not built using a GUI builder plug-in 
    40  * (but may want to consider doing so in the future), and the controller uses listeners to control how the view and data act.  
    41  *  
     38 * This class contains the view and controller for the PendingIncidents screen. 
     39 * The view was not built using a GUI builder plug-in (but may want to consider 
     40 * doing so in the future), and the controller uses listeners to control how the 
     41 * view and data act. 
     42 * 
    4243 * @author Vincent 
    4344 */ 
    44  
    45 public class PendingIncidents extends JFrame { 
    46      
     45public class PendingIncidents extends JFrame 
     46{ 
    4747    private final String SCREEN_TITLE = "(Shift + F2) Pending Incidents"; 
    48      
    49     private final Dimension SCREEN_DIMENSIONS = new Dimension(1400,250); 
    50      
    51     private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension(170,20); 
    52      
    53     private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170,180); 
    54      
     48    private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); 
     49    private final Dimension DROP_DOWN_MENU_LABEL_DIMENSIONS = new Dimension(170, 20); 
     50    private final Dimension DROP_DOWN_MENU_DIMENSIONS = new Dimension(170, 180); 
    5551    private final int COLUMN_WIDTH = 120; 
    56      
    57     private final String[] LABELS = {"Recommend...", "Add Resources...", "Open", "Recall Incident", 
    58             "Cancel", "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", "Mail...", "Fax..."}; 
    59      
     52    private final String[] LABELS = 
     53    { 
     54        "Recommend...", "Add Resources...", "Open", "Recall Incident", 
     55        "Cancel", "Link/Append", "Map", "Recall Linked Incidents", "Read Notes", "Mail...", "Fax..." 
     56    }; 
    6057    private final String LABEL_SPACING = "     "; 
    61      
    6258    private JTable pendingIncidentsTable; 
    6359    private JFrame pendingIncidentsMenu; 
    64      
    6560    //labels for the drop down menu 
    6661    private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 
    67      
    6862    private long lastLeftClick;//used for double clicking feature 
    69      
    70     public PendingIncidents(){ 
     63 
     64    public PendingIncidents() 
     65    { 
    7166        initComponents(); 
    7267    } 
    73          
    74     private void initComponents() { 
     68 
     69    private void initComponents() 
     70    { 
    7571        initializeTable(); 
    7672        initControllers(); 
    7773        initializeDropDownMenu(); 
    78          
    79         JScrollPane scrollpane = new JScrollPane(pendingIncidentsTable ); 
     74 
     75        JScrollPane scrollpane = new JScrollPane(pendingIncidentsTable); 
    8076        scrollpane.getViewport().setBackground(Color.WHITE); 
    81          
     77 
    8278        setTitle(SCREEN_TITLE); 
    8379        setPreferredSize(SCREEN_DIMENSIONS); 
     
    8682        pack(); 
    8783        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); 
    88         setLocation(0, (int) (dim.getHeight()*3/4)); 
     84        setLocation(0, (int) (dim.getHeight() * 3 / 4)); 
    8985        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 
    90         setVisible(false);       
    91     } 
    92      
     86        setVisible(false); 
     87    } 
     88 
    9389    /* 
    9490     * Initializes the table and prepares the cell renderer for color management. It initializes the default settings 
    9591     * and handles the drag and drop feature. 
    9692     */ 
    97     private void initializeTable(){ 
    98         pendingIncidentsTable = new JTable(){ 
     93    private void initializeTable() 
     94    { 
     95        pendingIncidentsTable = new JTable() 
     96        { 
    9997            /* 
    10098             * Custom renderer to set different background/foreground colors 
    10199             * @see javax.swing.JTable#prepareRenderer(javax.swing.table.TableCellRenderer, int, int) 
    102100             */ 
    103             public Component prepareRenderer(TableCellRenderer renderer, int row, int column){ 
     101            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) 
     102            { 
    104103                Component comp = super.prepareRenderer(renderer, row, column); 
    105                  
     104 
    106105                comp.setForeground(Color.BLACK); 
    107106                comp.setBackground(Color.CYAN); 
    108                  
    109                 if (getSelectedRow() == row){ 
     107 
     108                if (getSelectedRow() == row) 
     109                { 
    110110                    comp.setForeground(Color.WHITE); 
    111111                    comp.setBackground(Color.BLUE); 
    112112                } 
    113                  
     113 
    114114                return comp; 
    115115            } 
    116              
    117             public Class getColumnClass(int c) { 
     116 
     117            public Class getColumnClass(int c) 
     118            { 
    118119                return getValueAt(0, c).getClass(); 
    119120            } 
    120121        }; 
    121          
     122 
    122123        pendingIncidentsTable.setOpaque(true); 
    123124        pendingIncidentsTable.setIntercellSpacing(new Dimension(1, 0)); 
     
    127128        pendingIncidentsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 
    128129        pendingIncidentsTable.setAutoCreateRowSorter(true); 
    129          
     130 
    130131        pendingIncidentsTable.setModel(new DefaultTableModel()); 
    131132        ((DefaultTableModel) pendingIncidentsTable.getModel()).setColumnIdentifiers(TableHeaders.PENDING_INCIDENTS_HEADERS); 
    132          
    133         pendingIncidentsTable.setTransferHandler(new TransferHandler(){ 
    134              
    135             public boolean canImport(TransferHandler.TransferSupport info) { 
     133 
     134        pendingIncidentsTable.setTransferHandler(new TransferHandler() 
     135        { 
     136            public boolean canImport(TransferHandler.TransferSupport info) 
     137            { 
    136138                // Check for String flavor 
    137                 if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { 
     139                if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) 
     140                { 
    138141                    return false; 
    139142                } 
    140143                return true; 
    141            } 
    142              
    143             public boolean importData(TransferHandler.TransferSupport info) { 
    144                 if (!info.isDrop()) { 
     144            } 
     145 
     146            public boolean importData(TransferHandler.TransferSupport info) 
     147            { 
     148                if (!info.isDrop()) 
     149                { 
    145150                    return false; 
    146151                } 
    147           
    148                 DefaultTableModel tableModel = (DefaultTableModel)pendingIncidentsTable.getModel(); 
    149                 JTable.DropLocation dl = (JTable.DropLocation)info.getDropLocation(); 
     152 
     153                DefaultTableModel tableModel = (DefaultTableModel) pendingIncidentsTable.getModel(); 
     154                JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation(); 
    150155                int index = dl.getRow(); 
    151           
     156 
    152157                // Get the string that is being dropped. 
    153158                Transferable t = info.getTransferable(); 
    154159                String data; 
    155                 try { 
    156                     data = (String)t.getTransferData(DataFlavor.stringFlavor); 
    157                 } 
    158                 catch (Exception e) { return false; } 
    159                                           
     160                try 
     161                { 
     162                    data = (String) t.getTransferData(DataFlavor.stringFlavor); 
     163                } catch (Exception e) 
     164                { 
     165                    return false; 
     166                } 
     167 
    160168                // Perform the actual import 
    161169                // TODO 
    162                 int incidentId = (Integer)pendingIncidentsTable.getValueAt(dl.getRow(), 0); 
    163                 try { 
    164                 String masterInc = (String) ScreenManager.theCoordinator. 
    165                         getCadDataIncVal(INC_VAL.MASTER_INC, incidentId); 
    166                 ScreenManager.theCoordinator.setCadDataUnitValue(data, 
    167                           UNIT_TAGS.MASTER_INC_NUM, masterInc); 
    168                  
    169                         ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 
    170                         ScreenManager.theCoordinator.setCadDataUnitValue(data, 
    171                       UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 
    172                      ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 
    173                      ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 
    174                      } catch (RemoteException e) { 
    175                         e.printStackTrace(); 
    176                      } 
     170                int incidentId = (Integer) pendingIncidentsTable.getValueAt(dl.getRow(), 0); 
     171                try 
     172                { 
     173                    String masterInc = (String) ScreenManager.theCoordinator. 
     174                            getCadDataIncVal(INC_VAL.MASTER_INC, incidentId); 
     175                    ScreenManager.theCoordinator.setCadDataUnitValue(data, 
     176                            UNIT_TAGS.MASTER_INC_NUM, masterInc); 
     177 
     178                    ScreenManager.theCoordinator.setCadDataUnitAssignedId(data, incidentId); 
     179                    ScreenManager.theCoordinator.setCadDataUnitValue(data, 
     180                            UNIT_TAGS.UNIT_STATUS, UnitStatusEnums.Arrived); 
     181                    ScreenManager.theCoordinator.addCadDataIncidentAssignedUnitNum(incidentId, data); 
     182                    ScreenManager.theCoordinator.setCadDataIncidentStatus(incidentId, IncidentEnums.Assigned); 
     183                } catch (RemoteException e) 
     184                { 
     185                    e.printStackTrace(); 
     186                } 
    177187                return true; 
    178188            } 
    179189        }); 
    180         for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 
     190        for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 
     191        { 
    181192            pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(120); 
    182193        } 
    183194    } 
    184      
    185     /*  
     195 
     196    /* 
    186197     * Adds the key and mouse listeners for the table and component listener for screen. 
    187198     */ 
    188     private void initControllers(){ 
    189         pendingIncidentsTable.addMouseListener(new MouseListener(){ 
    190             public void mouseClicked(MouseEvent e) { 
    191                 if(SwingUtilities.isLeftMouseButton(e)){ 
    192                     if(System.currentTimeMillis() - lastLeftClick < 1000){ 
     199    private void initControllers() 
     200    { 
     201        pendingIncidentsTable.addMouseListener(new MouseListener() 
     202        { 
     203            public void mouseClicked(MouseEvent e) 
     204            { 
     205                if (SwingUtilities.isLeftMouseButton(e)) 
     206                { 
     207                    if (System.currentTimeMillis() - lastLeftClick < 1000) 
     208                    { 
    193209                        int idColumn = 0; 
    194                         ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt(pendingIncidentsTable.getSelectedRow(),idColumn)); 
    195                     }else{ 
     210                        ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt(pendingIncidentsTable.getSelectedRow(), idColumn)); 
     211                    } 
     212                    else 
     213                    { 
    196214                        lastLeftClick = System.currentTimeMillis(); 
    197215                    } 
    198216                } 
    199                 if(SwingUtilities.isRightMouseButton(e)){ 
     217                if (SwingUtilities.isRightMouseButton(e)) 
     218                { 
     219                    // Fixed to force right click to cause the row to be selected. JD 
     220                    // get the coordinates of the mouse click 
     221                    Point p = e.getPoint(); 
     222                    // get the row index that contains that coordinate 
     223                    int rowNumber = pendingIncidentsTable.rowAtPoint(p); 
     224                    // Get the ListSelectionModel of the JTable 
     225                    ListSelectionModel model = pendingIncidentsTable.getSelectionModel(); 
     226                    // set the selected interval of rows. Using the "rowNumber" 
     227                    // variable for the beginning and end selects only that one row. 
     228                    model.setSelectionInterval(rowNumber, rowNumber); 
     229                    // go open the drop down menu 
    200230                    openDropDownMenu(e); 
    201                 }else{ 
     231                } 
     232                else 
     233                { 
    202234                    closeDropDownMenu(); 
    203235                } 
    204236            } 
    205             public void mouseEntered(MouseEvent e) {} 
    206             public void mouseExited(MouseEvent e) {} 
    207             public void mousePressed(MouseEvent e) {} 
    208             public void mouseReleased(MouseEvent e) {} 
     237 
     238            public void mouseEntered(MouseEvent e) 
     239            { 
     240            } 
     241 
     242            public void mouseExited(MouseEvent e) 
     243            { 
     244            } 
     245 
     246            public void mousePressed(MouseEvent e) 
     247            { 
     248            } 
     249 
     250            public void mouseReleased(MouseEvent e) 
     251            { 
     252            } 
    209253        }); 
    210          
    211         addComponentListener( new ComponentListener(){ 
    212             public void componentHidden(ComponentEvent e) {} 
    213             public void componentMoved(ComponentEvent e) { 
     254 
     255        addComponentListener(new ComponentListener() 
     256        { 
     257            public void componentHidden(ComponentEvent e) 
     258            { 
     259            } 
     260 
     261            public void componentMoved(ComponentEvent e) 
     262            { 
    214263                closeDropDownMenu(); 
    215264            } 
    216             public void componentResized(ComponentEvent e) {} 
    217             public void componentShown(ComponentEvent e) {} 
     265 
     266            public void componentResized(ComponentEvent e) 
     267            { 
     268            } 
     269 
     270            public void componentShown(ComponentEvent e) 
     271            { 
     272            } 
    218273        }); 
    219274    } 
    220      
     275 
    221276    /* 
    222277     * Creates the drop down menu that appears when a right click is performed on the table. 
    223278     */ 
    224     private void initializeDropDownMenu(){ 
     279    private void initializeDropDownMenu() 
     280    { 
    225281        Box menu = new Box(BoxLayout.Y_AXIS); 
    226282        initializeDropDownLabels(); 
    227283        addLabelsToBox(menu); 
    228      
     284 
    229285        //Sets the highlighted background color, note that it does not become "Highlighted" until opaque(true) is called 
    230286        setMenuHighlightedBackground(Color.BLUE); 
    231          
     287 
    232288        pendingIncidentsMenu = new JFrame(); 
    233289        pendingIncidentsMenu.getContentPane().add(menu); 
     
    237293        pendingIncidentsMenu.setVisible(false); 
    238294    } 
    239      
     295 
    240296    /* 
    241297     * Sets the text and size and adds a listener to each label. 
    242298     */ 
    243     private void initializeDropDownLabels(){  
    244         for(int i = 0; i < dropDownLabels.length; i++){ 
     299    private void initializeDropDownLabels() 
     300    { 
     301        for (int i = 0; i < dropDownLabels.length; i++) 
     302        { 
    245303            dropDownLabels[i] = new JLabel(LABEL_SPACING + LABELS[i]); 
    246304            dropDownLabels[i].setMaximumSize(DROP_DOWN_MENU_LABEL_DIMENSIONS); 
     
    252310        addMouseListenersToLabel(dropDownLabels[8]); 
    253311    } 
    254      
    255     /* 
    256      * Add the labels to the box in order with separators and spacings in between.  
    257      */ 
    258     private void addLabelsToBox(Box menu){ 
     312 
     313    /* 
     314     * Add the labels to the box in order with separators and spacings in between. 
     315     */ 
     316    private void addLabelsToBox(Box menu) 
     317    { 
    259318        menu.add(dropDownLabels[0]); 
    260319        menu.add(dropDownLabels[1]); 
    261          
     320 
    262321        menu.add(Box.createVerticalStrut(5)); 
    263322        menu.add(new JSeparator()); 
    264323        menu.add(Box.createVerticalStrut(5)); 
    265          
     324 
    266325        menu.add(dropDownLabels[2]); 
    267326        menu.add(dropDownLabels[3]); 
    268327        menu.add(dropDownLabels[4]); 
    269328        menu.add(dropDownLabels[5]); 
    270          
     329 
    271330        menu.add(Box.createVerticalStrut(5)); 
    272331        menu.add(new JSeparator()); 
    273332        menu.add(Box.createVerticalStrut(5)); 
    274          
     333 
    275334        menu.add(dropDownLabels[6]); 
    276335        menu.add(dropDownLabels[7]); 
    277336        menu.add(dropDownLabels[8]); 
    278          
     337 
    279338        menu.add(Box.createVerticalStrut(5)); 
    280339        menu.add(new JSeparator()); 
    281340        menu.add(Box.createVerticalStrut(5)); 
    282          
     341 
    283342        menu.add(dropDownLabels[9]); 
    284343        menu.add(dropDownLabels[10]); 
    285          
    286         menu.add(Box.createVerticalStrut(5)); 
    287     } 
    288      
     344 
     345        menu.add(Box.createVerticalStrut(5)); 
     346    } 
     347 
    289348    /* 
    290349     * Sets the highlighted color(when the mouse is over it) of the JLabels. 
     
    292351     * @param color the highlighted color 
    293352     */ 
    294     public void setMenuHighlightedBackground(Color color){ 
    295         for(int i = 0; i < dropDownLabels.length; i++){ 
     353    public void setMenuHighlightedBackground(Color color) 
     354    { 
     355        for (int i = 0; i < dropDownLabels.length; i++) 
     356        { 
    296357            dropDownLabels[i].setBackground(color); 
    297358        } 
    298359    } 
    299      
     360 
    300361    /* 
    301362     * Sets all JLabels to not display a highlighted background 
    302363     */ 
    303     public void unSelectAllLabels(){ 
    304         for(int i = 0; i < dropDownLabels.length; i++){ 
     364    public void unSelectAllLabels() 
     365    { 
     366        for (int i = 0; i < dropDownLabels.length; i++) 
     367        { 
    305368            dropDownLabels[i].setOpaque(false); 
    306369        } 
     
    311374     * @param label the label that is selected/highlighted 
    312375     */ 
    313     public void selectLabel(Object label){ 
    314         ((JLabel)label).setOpaque(true); 
    315     } 
    316      
     376    public void selectLabel(Object label) 
     377    { 
     378        ((JLabel) label).setOpaque(true); 
     379    } 
     380 
    317381    /* 
    318382     * Performs the label action depending on which label was clicked. 
    319383     */ 
    320     public void performLabelAction(Object label){ 
    321         if(label.equals(dropDownLabels[0])){//Recommend 
    322              
    323         }else if(label.equals(dropDownLabels[1])){//Add Resources 
    324              
    325         }else if(label.equals(dropDownLabels[2])){//Open 
    326           int idColumn = 0; 
     384    public void performLabelAction(Object label) 
     385    { 
     386        if (label.equals(dropDownLabels[0])) 
     387        {//Recommend 
     388        } 
     389        else if (label.equals(dropDownLabels[1])) 
     390        {//Add Resources 
     391        } 
     392        else if (label.equals(dropDownLabels[2])) 
     393        {//Open 
     394            int idColumn = 0; 
    327395            ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt( 
    328                 pendingIncidentsTable.getSelectedRow(),idColumn)); 
    329         }else if(label.equals(dropDownLabels[3])){//Recall Incident 
    330              
    331         }else if(label.equals(dropDownLabels[4])){//Cancel 
    332         }else if(label.equals(dropDownLabels[5])){//Link Append 
    333              
    334         }else if(label.equals(dropDownLabels[6])){//Map 
    335              
    336         }else if(label.equals(dropDownLabels[7])){//Recall Linked Incidents 
    337            
    338         }else if(label.equals(dropDownLabels[8])){//Read Notes 
    339           int idColumn = 0; 
     396                    pendingIncidentsTable.getSelectedRow(), idColumn)); 
     397        } 
     398        else if (label.equals(dropDownLabels[3])) 
     399        {//Recall Incident 
     400        } 
     401        else if (label.equals(dropDownLabels[4])) 
     402        {//Cancel 
     403        } 
     404        else if (label.equals(dropDownLabels[5])) 
     405        {//Link Append 
     406        } 
     407        else if (label.equals(dropDownLabels[6])) 
     408        {//Map 
     409        } 
     410        else if (label.equals(dropDownLabels[7])) 
     411        {//Recall Linked Incidents 
     412        } 
     413        else if (label.equals(dropDownLabels[8])) 
     414        {//Read Notes 
     415            int idColumn = 0; 
    340416            ScreenManager.openIncidentViewer((Integer) pendingIncidentsTable.getValueAt( 
    341             pendingIncidentsTable.getSelectedRow(),idColumn)); 
    342         }else if(label.equals(dropDownLabels[9])){//Mail 
    343              
    344         }else if(label.equals(dropDownLabels[10])){//Fax 
    345              
    346         } 
    347     } 
    348      
    349     /* 
    350      * Factory method. Adds a mouse listeners to the label. The MouseMotionListener detects  
     417                    pendingIncidentsTable.getSelectedRow(), idColumn)); 
     418        } 
     419        else if (label.equals(dropDownLabels[9])) 
     420        {//Mail 
     421        } 
     422        else if (label.equals(dropDownLabels[10])) 
     423        {//Fax 
     424        } 
     425    } 
     426 
     427    /* 
     428     * Factory method. Adds a mouse listeners to the label. The MouseMotionListener detects 
    351429     * the mouse's location to highlight the label. The MouseListener detects 
    352430     * for clicks and performs the action of the label designates. 
    353431     */ 
    354     public void addMouseListenersToLabel(JLabel label){ 
    355         label.addMouseMotionListener(new MouseMotionListener(){ 
    356             public void mouseDragged(MouseEvent e) {} 
    357             public void mouseMoved(MouseEvent e) { 
     432    public void addMouseListenersToLabel(JLabel label) 
     433    { 
     434        label.addMouseMotionListener(new MouseMotionListener() 
     435        { 
     436            public void mouseDragged(MouseEvent e) 
     437            { 
     438            } 
     439 
     440            public void mouseMoved(MouseEvent e) 
     441            { 
    358442                unSelectAllLabels(); 
    359443                selectLabel(e.getSource()); 
     
    362446            } 
    363447        }); 
    364         label.addMouseListener(new MouseListener() { 
    365             public void mouseClicked(MouseEvent e) { 
     448        label.addMouseListener(new MouseListener() 
     449        { 
     450            public void mouseClicked(MouseEvent e) 
     451            { 
    366452                performLabelAction(e.getSource()); 
    367453                unSelectAllLabels(); 
     
    370456                pendingIncidentsMenu.setVisible(false); 
    371457            } 
    372             public void mouseEntered(MouseEvent e) {}            
    373             public void mouseExited(MouseEvent e) {}             
    374             public void mousePressed(MouseEvent e) {}            
    375             public void mouseReleased(MouseEvent e)  {}          
     458 
     459            public void mouseEntered(MouseEvent e) 
     460            { 
     461            } 
     462 
     463            public void mouseExited(MouseEvent e) 
     464            { 
     465            } 
     466 
     467            public void mousePressed(MouseEvent e) 
     468            { 
     469            } 
     470 
     471            public void mouseReleased(MouseEvent e) 
     472            { 
     473            } 
    376474        }); 
    377475    } 
    378      
     476 
    379477    /* 
    380478     * Displays the menu where the right click occurred. 
    381479     */ 
    382     public void openDropDownMenu(MouseEvent e){ 
     480    public void openDropDownMenu(MouseEvent e) 
     481    { 
    383482        pendingIncidentsMenu.setLocation(e.getX() + this.getX(), e.getY() + this.getY()); 
    384483        pendingIncidentsMenu.setVisible(true); 
    385484    } 
    386      
     485 
    387486    /* 
    388487     * Hides the menu. 
    389488     */ 
    390     public void closeDropDownMenu(){ 
     489    public void closeDropDownMenu() 
     490    { 
    391491        unSelectAllLabels(); 
    392492        pendingIncidentsMenu.revalidate(); 
     
    394494        pendingIncidentsMenu.setVisible(false); 
    395495    } 
    396      
     496 
    397497    /* 
    398498     * Refreshes the data in the table by updating all data and repainting the 
    399      * screen. It saves user preferences(like column sizes, selected row, sorted preferences)  
     499     * screen. It saves user preferences(like column sizes, selected row, sorted preferences) 
    400500     * and applies them to the updated model it receives from the server. 
    401501     */ 
    402     public void refreshTable(){ 
    403      
    404       if(pendingIncidentsTable.getTableHeader().getResizingColumn() == null){//only update info if resize not in progress 
    405           try { 
    406             int index = pendingIncidentsTable.getSelectedRow(); 
    407             int[] columnWidths = new int[20]; 
    408             List<? extends SortKey> keys = pendingIncidentsTable.getRowSorter().getSortKeys(); 
    409             for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 
    410                 columnWidths[i] = pendingIncidentsTable.getColumnModel().getColumn(i).getWidth(); 
    411             } 
    412              
    413             pendingIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.PENDING_INCIDENTS)); 
    414              
    415             for(int i = 0; i < pendingIncidentsTable.getColumnCount(); i++){ 
    416                 pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
    417             } 
    418             pendingIncidentsTable.getRowSorter().setSortKeys(keys); 
    419             pendingIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 
    420             } catch (RemoteException e) { 
     502    public void refreshTable() 
     503    { 
     504 
     505        if (pendingIncidentsTable.getTableHeader().getResizingColumn() == null) 
     506        {//only update info if resize not in progress 
     507            try 
     508            { 
     509                int index = pendingIncidentsTable.getSelectedRow(); 
     510                int[] columnWidths = new int[20]; 
     511                List<? extends SortKey> keys = pendingIncidentsTable.getRowSorter().getSortKeys(); 
     512                for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 
     513                { 
     514                    columnWidths[i] = pendingIncidentsTable.getColumnModel().getColumn(i).getWidth(); 
     515                } 
     516 
     517                pendingIncidentsTable.setModel(ScreenManager.theCoordinator.getCadDataTable(CADDataEnums.TABLE.PENDING_INCIDENTS)); 
     518 
     519                for (int i = 0; i < pendingIncidentsTable.getColumnCount(); i++) 
     520                { 
     521                    pendingIncidentsTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]); 
     522                } 
     523                pendingIncidentsTable.getRowSorter().setSortKeys(keys); 
     524                pendingIncidentsTable.getSelectionModel().setSelectionInterval(index, index); 
     525            } catch (RemoteException e) 
     526            { 
    421527                e.printStackTrace(); 
    422528            } 
    423529            revalidate(); 
    424530            repaint(); 
    425       } 
    426     } 
    427      
    428     /*  
     531        } 
     532    } 
     533 
     534    /* 
    429535     * Makes screen visible. 
    430536     */ 
    431     public void open(){ 
     537    public void open() 
     538    { 
    432539        setVisible(true); 
    433540    } 
    434      
     541 
    435542    /* 
    436543     * Hides screen. 
    437544     */ 
    438     public void close(){ 
     545    public void close() 
     546    { 
    439547        setVisible(false); 
    440548    } 
    441          
    442549} 
Note: See TracChangeset for help on using the changeset viewer.