Changeset 130 in tmcsimulator-scriptbuilder for trunk/src/event/editor/UnitPanel.java


Ignore:
Timestamp:
10/23/2017 08:58:34 AM (9 years ago)
Author:
bmcguffin
Message:

Changed implementation of save function for event editor panels. Instead of updating their model objects whenever the enter key is pressed, panels are now notified when the window is closed and update their information then.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/event/editor/UnitPanel.java

    r92 r130  
    5151            } 
    5252        } 
    53         txtUnitNumber.addKeyListener(new KeyListener() 
    54         { 
    55             public void keyTyped(KeyEvent e) 
    56             { 
    57             } 
    58             public void keyPressed(KeyEvent e) 
    59             { 
    60                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    61                 { 
    62                     event.unitNum = txtUnitNumber.getText(); 
    63                 } 
    64             } 
    65             public void keyReleased(KeyEvent e) 
    66             { 
    67             } 
    68         }); 
    69         ActiveDropdown.addActionListener(new ActionListener() 
    70         { 
    71  
    72             public void actionPerformed(ActionEvent e) 
    73             { 
    74                 event.unitActive = ActiveDropdown.getSelectedItem().toString(); 
    75             } 
    76         }); 
     53 
    7754        for (int i = 0; i < PrimaryDropdown.getItemCount(); i++) 
    7855        { 
     
    8259            } 
    8360        } 
    84         PrimaryDropdown.addActionListener(new ActionListener() 
    85         { 
    86  
    87             public void actionPerformed(ActionEvent e) 
    88             { 
    89                 event.unitPrimary = PrimaryDropdown.getSelectedItem().toString(); 
    90             } 
    91         }); 
     61 
    9262        boolean containsItem = false; 
    9363        for (int i = 0; i < StatusDropdown.getItemCount() && !containsItem; i++) 
     
    10474            StatusDropdown.setSelectedItem(StatusDropdown.getItemCount() - 1); 
    10575        } 
    106         StatusDropdown.addActionListener(new ActionListener() 
    107         { 
    108  
    109             public void actionPerformed(ActionEvent e) 
    110             { 
    111                 event.unitStatus = StatusDropdown.getSelectedItem().toString(); 
    112             } 
    113         }); 
     76 
    11477    } 
    11578 
     
    11982        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    12083    } 
    121      
     84 
    12285    @Override 
    12386    public boolean removeAssociatedEvent() 
     
    12689        event = null; 
    12790        return true; 
     91    } 
     92 
     93    @Override 
     94    public void uponClose() 
     95    { 
     96        event.unitNum = txtUnitNumber.getText(); 
     97        event.unitActive = ActiveDropdown.getSelectedItem().toString(); 
     98        event.unitPrimary = PrimaryDropdown.getSelectedItem().toString(); 
     99        event.unitStatus = StatusDropdown.getSelectedItem().toString(); 
    128100    } 
    129101 
Note: See TracChangeset for help on using the changeset viewer.