Changeset 130 in tmcsimulator-scriptbuilder for trunk/src/event


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.

Location:
trunk/src/event/editor
Files:
16 edited

Legend:

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

    r92 r130  
    2323    { 
    2424        initComponents(); 
    25  
    2625    } 
    2726 
     
    3231        audioFileText.setText(event.audioPath); 
    3332        audioLengthText.setText(event.audioLength.toString()); 
    34         audioFileText.addKeyListener(new KeyListener() 
    35         { 
    36  
    37             public void keyTyped(KeyEvent e) 
    38             { 
    39             } 
    40  
    41             public void keyPressed(KeyEvent e) 
    42             { 
    43                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    44                 { 
    45                     event.audioPath = audioFileText.getText(); 
    46                 } 
    47             } 
    48  
    49             public void keyReleased(KeyEvent e) 
    50             { 
    51             } 
    52         }); 
    53         audioLengthText.addKeyListener(new KeyListener() 
    54         { 
    55  
    56             public void keyTyped(KeyEvent e) 
    57             { 
    58             } 
    59  
    60             public void keyPressed(KeyEvent e) 
    61             { 
    62                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    63                 { 
    64                     try 
    65                     { 
    66                         event.audioLength = Integer.parseInt(audioLengthText.getText()); 
    67                     } 
    68                     catch (Exception ex) 
    69                     { 
    70  
    71                     } 
    72                 } 
    73             } 
    74  
    75             public void keyReleased(KeyEvent e) 
    76             { 
    77             } 
    78         } 
    79         ); 
    8033    } 
    8134 
     
    8538        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    8639    } 
    87      
     40 
    8841    @Override 
    8942    public boolean removeAssociatedEvent() 
     
    9245        event = null; 
    9346        return true; 
     47    } 
     48 
     49    @Override 
     50    public void uponClose() 
     51    { 
     52        event.audioPath = audioFileText.getText(); 
     53        try 
     54        { 
     55            event.audioLength = Integer.parseInt(audioLengthText.getText()); 
     56        } 
     57        catch (Exception ex) 
     58        { 
     59 
     60        } 
    9461    } 
    9562 
  • trunk/src/event/editor/CADLogPanel.java

    r92 r130  
    3333        event = (CADEvent) sei; 
    3434        CadTextField.setText(event.detail); 
    35         CadTextField.addKeyListener(new KeyListener() 
    36         { 
    37  
    38             public void keyTyped(KeyEvent e) 
    39             { 
    40             } 
    41  
    42             public void keyPressed(KeyEvent e) 
    43             { 
    44                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    45                 { 
    46                     event.detail = CadTextField.getText(); 
    47                 } 
    48             } 
    49  
    50             public void keyReleased(KeyEvent e) 
    51             { 
    52             } 
    53         }); 
    5435    } 
    5536 
     
    6647        event = null; 
    6748        return true; 
     49    } 
     50 
     51    @Override 
     52    public void uponClose() 
     53    { 
     54        event.detail = CadTextField.getText(); 
    6855    } 
    6956 
  • trunk/src/event/editor/CCTVPanel.java

    r92 r130  
    7575        event = null; 
    7676        return true; 
     77    } 
     78 
     79    @Override 
     80    public void uponClose() 
     81    { 
     82        //No change is yet necessary. This panel is not yet implemented. 
    7783    } 
    7884 
  • trunk/src/event/editor/CHPRadioPanel.java

    r92 r130  
    3636        event = (CHPRadioEvent) sei; 
    3737        audioText.setText(event.radioFile); 
    38         audioText.addKeyListener(new KeyListener() 
    39         { 
    40  
    41             public void keyTyped(KeyEvent e) 
    42             { 
    43             } 
    44  
    45             public void keyPressed(KeyEvent e) 
    46             { 
    47                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    48                 { 
    49                     event.radioFile = audioText.getText(); 
    50                 } 
    51             } 
    52  
    53             public void keyReleased(KeyEvent e) 
    54             { 
    55             } 
    56         }); 
     38         
    5739        for (int i = 0; i < event.lines.size(); i++) 
    5840        { 
     
    10890        event = null; 
    10991        return true; 
     92    } 
     93 
     94    @Override 
     95    public void uponClose() 
     96    { 
     97        event.radioFile = audioText.getText(); 
    11098    } 
    11199 
  • trunk/src/event/editor/CMSEvaluationPanel.java

    r92 r130  
    3535        event = (CMSEvaluationEvent) sei; 
    3636        txtID.setText(event.cmsID); 
    37         txtID.addKeyListener(new KeyListener() 
    38         { 
    39  
    40             @Override 
    41             public void keyTyped(KeyEvent e) 
    42             { 
    43             } 
    44  
    45             @Override 
    46             public void keyPressed(KeyEvent e) 
    47             { 
    48                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    49                 { 
    50                     event.cmsID = txtID.getText(); 
    51                 } 
    52             } 
    53  
    54             @Override 
    55             public void keyReleased(KeyEvent e) 
    56             { 
    57             } 
    58         }); 
     37         
    5938        txtLocation.setText(event.location); 
    60         txtLocation.addKeyListener(new KeyListener() 
    61         { 
    62  
    63             @Override 
    64             public void keyTyped(KeyEvent e) 
    65             { 
    66             } 
    67  
    68             @Override 
    69             public void keyPressed(KeyEvent e) 
    70             { 
    71                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    72                 { 
    73                     event.location = txtLocation.getText(); 
    74                 } 
    75             } 
    76  
    77             @Override 
    78             public void keyReleased(KeyEvent e) 
    79             { 
    80             } 
    81         }); 
     39         
    8240        txtMessage.setText(""); 
    8341        for (int i = 0; i < event.message.size(); i++) 
     
    9250            } 
    9351        } 
    94         TypeDropdown.addActionListener(new ActionListener() 
    95         { 
    96  
    97             @Override 
    98             public void actionPerformed(ActionEvent e) 
    99             { 
    100                 event.cmsType = TypeDropdown.getSelectedItem().toString(); 
    101             } 
    102         }); 
     52         
    10353        addButton.addActionListener(new ActionListener() 
    10454        { 
     
    13989        event = null; 
    14090        return true; 
     91    } 
     92 
     93    @Override 
     94    public void uponClose() 
     95    { 
     96        event.cmsID = txtID.getText(); 
     97        event.location = txtLocation.getText(); 
     98        event.cmsType = TypeDropdown.getSelectedItem().toString(); 
    14199    } 
    142100 
  • trunk/src/event/editor/GenericEvaluationPanel.java

    r92 r130  
    8484    } 
    8585 
     86    @Override 
     87    public void uponClose() 
     88    { 
     89        //No change is necessary here; this panel saves its state continually 
     90    } 
     91 
    8692    /** 
    8793     * This method is called from within the constructor to initialize the form. 
  • trunk/src/event/editor/I_ScriptEventEditorPanel.java

    r92 r130  
    2323    void getEventObject(I_ScriptEvent sei); 
    2424     
    25      /** 
     25    /** 
    2626     * Remove the event associated with this panel. 
    2727     *  
     
    2929     */ 
    3030    boolean removeAssociatedEvent(); 
     31     
     32    /** 
     33     * Action to take when the panel closes. 
     34     */ 
     35    void uponClose(); 
    3136} 
  • trunk/src/event/editor/MaintenanceRadioPanel.java

    r92 r130  
    2727        event = (MaintenanceRadioEvent) sei; 
    2828        jTextArea1.setText(event.message); 
    29         jTextArea1.addKeyListener(new KeyListener() 
    30         { 
    31  
    32             public void keyTyped(KeyEvent e) 
    33             { 
    34             } 
    35  
    36             public void keyPressed(KeyEvent e) 
    37             { 
    38                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    39                 { 
    40                     event.message = jTextArea1.getText(); 
    41                 } 
    42             } 
    43  
    44             public void keyReleased(KeyEvent e) 
    45             { 
    46             } 
    47         }); 
    4829    } 
    4930 
     
    5233        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    5334    } 
    54      
     35 
    5536    @Override 
    5637    public boolean removeAssociatedEvent() 
    5738    { 
    58         ((I_ScriptEvent)event).removeThis(); 
     39        ((I_ScriptEvent) event).removeThis(); 
    5940        event = null; 
    6041        return true; 
     42    } 
     43 
     44    @Override 
     45    public void uponClose() 
     46    { 
     47        event.message = jTextArea1.getText(); 
    6148    } 
    6249 
  • trunk/src/event/editor/ParamicsPanel.java

    r92 r130  
    1717    private ActionListener removeListener; 
    1818    private ParamicsEvent event; 
     19    ArrayList<JCheckBox> lanes = new ArrayList<JCheckBox>(); 
    1920 
    2021    /** 
     
    4546            LocationDropdown.setSelectedItem(LocationDropdown.getItemCount() - 1); 
    4647        } 
    47         LocationDropdown.addActionListener(new ActionListener() 
    48         { 
    49  
    50             @Override 
    51             public void actionPerformed(ActionEvent e) 
    52             { 
    53                 event.locationID = LocationDropdown.getSelectedItem().toString(); 
    54             } 
    55         }); 
     48 
    5649        for (int i = 0; i < StatusDropdown.getItemCount(); i++) 
    5750        { 
     
    6154            } 
    6255        } 
    63         StatusDropdown.addActionListener(new ActionListener() 
    64         { 
    65  
    66             @Override 
    67             public void actionPerformed(ActionEvent e) 
    68             { 
    69                 event.status = StatusDropdown.getSelectedItem().toString(); 
    70             } 
    71         }); 
     56 
    7257        for (int i = 0; i < TypeDropdown.getItemCount(); i++) 
    7358        { 
     
    7762            } 
    7863        } 
    79         TypeDropdown.addActionListener(new ActionListener() 
    80         { 
    81  
    82             @Override 
    83             public void actionPerformed(ActionEvent e) 
    84             { 
    85                 event.type = TypeDropdown.getSelectedItem().toString(); 
    86             } 
    87         }); 
    88         ArrayList<JCheckBox> lanes = new ArrayList<JCheckBox>(); 
     64 
    8965        lanes.add(jCheckBox1); 
    9066        lanes.add(jCheckBox2); 
     
    10884        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    10985    } 
    110      
     86 
    11187    @Override 
    11288    public boolean removeAssociatedEvent() 
     
    11591        event = null; 
    11692        return true; 
     93    } 
     94 
     95    @Override 
     96    public void uponClose() 
     97    { 
     98        event.locationID = LocationDropdown.getSelectedItem().toString(); 
     99        event.status = StatusDropdown.getSelectedItem().toString(); 
     100        event.type = TypeDropdown.getSelectedItem().toString(); 
     101        for (JCheckBox lane : lanes) 
     102        { 
     103            lane.getActionListeners()[0].actionPerformed(new ActionEvent(lane, 0, "record")); 
     104        } 
    117105    } 
    118106 
  • trunk/src/event/editor/TMTRadioPanel.java

    r92 r130  
    2727        event = (TMTRadioEvent) sei; 
    2828        jTextArea1.setText(event.message); 
    29         jTextArea1.addKeyListener(new KeyListener() 
    30         { 
    31  
    32             public void keyTyped(KeyEvent e) 
    33             { 
    34             } 
    35  
    36             public void keyPressed(KeyEvent e) 
    37             { 
    38                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    39                 { 
    40                     event.message = jTextArea1.getText(); 
    41                 } 
    42             } 
    43  
    44             public void keyReleased(KeyEvent e) 
    45             { 
    46             } 
    47         }); 
    4829    } 
    4930 
     
    5940        event = null; 
    6041        return true; 
     42    } 
     43 
     44    @Override 
     45    public void uponClose() 
     46    { 
     47        event.message = jTextArea1.getText(); 
    6148    } 
    6249 
  • trunk/src/event/editor/TelephonePanel.java

    r92 r130  
    114114        event = null; 
    115115        return true; 
     116    } 
     117 
     118    @Override 
     119    public void uponClose() 
     120    { 
     121        //No change is necessary here; this panel saves its state continually 
    116122    } 
    117123 
  • trunk/src/event/editor/TowPanel.java

    r92 r130  
    6060        event = (TowEvent) sei; 
    6161        txtCompany.setText(event.towCompany); 
    62         txtCompany.addKeyListener(new KeyListener() 
    63         { 
    64             public void keyTyped(KeyEvent e) 
    65             { 
    66             } 
    67             public void keyPressed(KeyEvent e) 
    68             { 
    69                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    70                 { 
    71                     event.towCompany = txtCompany.getText(); 
    72                 } 
    73             } 
    74             public void keyReleased(KeyEvent e) 
    75             { 
    76             } 
    77         }); 
     62 
    7863        txtBeat.setText(event.towBeat); 
    79         txtBeat.addKeyListener(new KeyListener() 
    80         { 
    81             public void keyTyped(KeyEvent e) 
    82             { 
    83             } 
    84             public void keyPressed(KeyEvent e) 
    85             { 
    86                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    87                 { 
    88                     event.towBeat = txtBeat.getText(); 
    89                 } 
    90             } 
    91             public void keyReleased(KeyEvent e) 
    92             { 
    93             } 
    94         }); 
     64 
    9565        txtConfirmationNumber.setText("" + event.towConfNum); 
    96         txtConfirmationNumber.addKeyListener(new KeyListener() 
    97         { 
    98             public void keyTyped(KeyEvent e) 
    99             { 
    100             } 
    101             public void keyPressed(KeyEvent e) 
    102             { 
    103                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    104                 { 
    105                     event.towConfNum = txtConfirmationNumber.getText(); 
    106                 } 
    107             } 
    108             public void keyReleased(KeyEvent e) 
    109             { 
    110             } 
    111         }); 
     66 
    11267        txtPublicNumber.setText("" + event.towPubNum); 
    113         txtPublicNumber.addKeyListener(new KeyListener() 
    114         { 
    115             public void keyTyped(KeyEvent e) 
    116             { 
    117             } 
    118             public void keyPressed(KeyEvent e) 
    119             { 
    120                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    121                 { 
    122                     event.towPubNum = txtPublicNumber.getText(); 
    123                 } 
    124             } 
    125             public void keyReleased(KeyEvent e) 
    126             { 
    127             } 
    128         }); 
     68 
    12969    } 
    13070 
     
    13474        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    13575    } 
    136      
     76 
    13777    @Override 
    13878    public boolean removeAssociatedEvent() 
     
    14181        event = null; 
    14282        return true; 
     83    } 
     84 
     85    @Override 
     86    public void uponClose() 
     87    { 
     88        event.towCompany = txtCompany.getText(); 
     89        event.towBeat = txtBeat.getText(); 
     90        event.towConfNum = txtConfirmationNumber.getText(); 
     91        event.towPubNum = txtPublicNumber.getText(); 
    14392    } 
    14493 
  • 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 
  • trunk/src/event/editor/WitnessPanel.java

    r92 r130  
    3434            txtFirstName.setText(st.nextToken()); 
    3535        } 
    36         txtFirstName.addKeyListener(new KeyListener() 
    37         { 
    38             public void keyTyped(KeyEvent e) 
    39             { 
    40             } 
    4136 
    42             public void keyPressed(KeyEvent e) 
    43             { 
    44                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    45                 { 
    46                     event.witnessName = txtFirstName.getText() + " " + txtLastName.getText(); 
    47                 } 
    48             } 
    49  
    50             public void keyReleased(KeyEvent e) 
    51             { 
    52             } 
    53         }); 
    5437        txtLastName.setText(""); 
    5538        while (st.hasMoreTokens()) 
     
    5740            txtLastName.setText(txtLastName.getText() + st.nextToken()); 
    5841        } 
    59         txtLastName.addKeyListener(new KeyListener() 
    60         { 
    61             public void keyTyped(KeyEvent e) 
    62             { 
    63             } 
    6442 
    65             public void keyPressed(KeyEvent e) 
    66             { 
    67                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    68                 { 
    69                     event.witnessName = txtFirstName.getText() + " " + txtLastName.getText(); 
    70                 } 
    71             } 
     43        txtPhoneNumber.setText("" + event.witnessNum); 
    7244 
    73             public void keyReleased(KeyEvent e) 
    74             { 
    75             } 
    76         }); 
    77         txtPhoneNumber.setText("" + event.witnessNum); 
    78         txtPhoneNumber.addKeyListener(new KeyListener() 
    79         { 
    80             public void keyTyped(KeyEvent e) 
    81             { 
    82             } 
     45        txtAddress.setText(event.witnessAddress); 
    8346 
    84             public void keyPressed(KeyEvent e) 
    85             { 
    86                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    87                 { 
    88                     event.witnessNum = txtPhoneNumber.getText(); 
    89                 } 
    90             } 
    91  
    92             public void keyReleased(KeyEvent e) 
    93             { 
    94             } 
    95         }); 
    96         txtAddress.setText(event.witnessAddress); 
    97         txtAddress.addKeyListener(new KeyListener() 
    98         { 
    99             public void keyTyped(KeyEvent e) 
    100             { 
    101             } 
    102  
    103             public void keyPressed(KeyEvent e) 
    104             { 
    105                 if (e.getKeyCode() == KeyEvent.VK_ENTER) 
    106                 { 
    107                     event.witnessAddress = txtAddress.getText(); 
    108                 } 
    109             } 
    110  
    111             public void keyReleased(KeyEvent e) 
    112             { 
    113             } 
    114         }); 
    11547    } 
    11648 
     
    12052        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    12153    } 
    122      
     54 
    12355    @Override 
    12456    public boolean removeAssociatedEvent() 
     
    12759        event = null; 
    12860        return true; 
     61    } 
     62 
     63    @Override 
     64    public void uponClose() 
     65    { 
     66        event.witnessName = txtFirstName.getText() + " " + txtLastName.getText(); 
     67        event.witnessNum = txtPhoneNumber.getText(); 
     68        event.witnessAddress = txtAddress.getText(); 
    12969    } 
    13070 
  • trunk/src/event/editor/frame/Editor.java

    r119 r130  
    124124                } 
    125125            } 
     126 
    126127        } 
    127128 
     
    150151            public void keyReleased(KeyEvent e) 
    151152            { 
     153            } 
     154        }); 
     155        this.addWindowListener(new WindowAdapter() 
     156        { 
     157            @Override 
     158            public void windowClosing(WindowEvent e) 
     159            { 
     160                //Add previous offset back in 
     161                //If we didn't adjust the offset, this will just set it to the old value 
     162                //If we deleted the first event(s), this will add the offsets, 
     163                //to ensure that events stay at the correct times 
     164                model.closePanels(); 
    152165            } 
    153166        }); 
  • trunk/src/event/editor/frame/PropertyModel.java

    r101 r130  
    9393        notifyObservers(arg); 
    9494    } 
     95     
     96    /** 
     97     * Propagate the window closure. 
     98     */ 
     99    public void closePanels() 
     100    { 
     101        for(JPanel panel : eventMap.keySet()) 
     102        { 
     103            if(panel instanceof I_ScriptEventEditorPanel) 
     104            { 
     105                ((I_ScriptEventEditorPanel) panel).uponClose(); 
     106            } 
     107        } 
     108    } 
    95109 
    96110    /* 
Note: See TracChangeset for help on using the changeset viewer.