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


Ignore:
Timestamp:
08/28/2017 01:38:15 PM (9 years ago)
Author:
bmcguffin
Message:

Added dropdown menu item to ScriptBuilderFrame?: "Delete Incident". When clicked, user may select an existing incident to delete. Program will prompt user to confirm the deletion, then remove the incident from the script and refresh the display.

Added button to individual event editor window: "Remove this event". When clicked, the currently displayed event will be removed from the timeslice it is in. The display will be refreshed accordingly. NOTE: This still has some bugs, namely that the last remaining event in a timeslice fails to be deleted.

Restructured Interface ScriptEventEditorPanel? to include a removeAssociatedEvent method, which calls a new method in I_ScriptEvent called removeThis, which causes the event to be removed from its timeslice.

Editor.Java previously contained several classes and enums, none of which were set to private scope. Moved these extra classes to their own files to decrease clutter in Editor.java and increase readability of all files.

Location:
trunk/src/event/editor
Files:
7 added
17 edited

Legend:

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

    r76 r89  
    2828    /** 
    2929     * Load the script event associated with this editor panel. 
    30      *  
     30     * 
    3131     * @param sei The script event in question 
    3232     */ 
     
    9393    { 
    9494        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     95    } 
     96     
     97    @Override 
     98    public boolean removeAssociatedEvent() 
     99    { 
     100        event.removeThis(); 
     101        event = null; 
     102        return true; 
    95103    } 
    96104 
  • trunk/src/event/editor/CADLogPanel.java

    r76 r89  
    6363    { 
    6464        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     65    } 
     66 
     67    @Override 
     68    public boolean removeAssociatedEvent() 
     69    { 
     70        event.removeThis(); 
     71        event = null; 
     72        return true; 
    6573    } 
    6674 
  • trunk/src/event/editor/CCTVPanel.java

    r76 r89  
    7474    { 
    7575        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     76    } 
     77     
     78    @Override 
     79    public boolean removeAssociatedEvent() 
     80    { 
     81        event.removeThis(); 
     82        event = null; 
     83        return true; 
    7684    } 
    7785 
  • trunk/src/event/editor/CHPRadioPanel.java

    r76 r89  
    101101        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    102102    } 
     103     
     104    @Override 
     105    public boolean removeAssociatedEvent() 
     106    { 
     107        ((I_ScriptEvent)event).removeThis(); 
     108        event = null; 
     109        return true; 
     110    } 
    103111 
    104112    /** 
     
    109117    @SuppressWarnings("unchecked") 
    110118    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 
    111     private void initComponents() { 
     119    private void initComponents() 
     120    { 
    112121 
    113122        jLabel4 = new javax.swing.JLabel(); 
     
    125134        jButton2.setText("Browse"); 
    126135        jButton2.setToolTipText("Browse for the radio audio file"); 
    127         jButton2.addMouseListener(new java.awt.event.MouseAdapter() { 
    128             public void mouseClicked(java.awt.event.MouseEvent evt) { 
     136        jButton2.addMouseListener(new java.awt.event.MouseAdapter() 
     137        { 
     138            public void mouseClicked(java.awt.event.MouseEvent evt) 
     139            { 
    129140                browse(evt); 
    130141            } 
     
    139150        addFieldButton.setText("Add Field"); 
    140151        addFieldButton.setToolTipText("Adds a row for dialog by the field operator in the table"); 
    141         addFieldButton.addActionListener(new java.awt.event.ActionListener() { 
    142             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     152        addFieldButton.addActionListener(new java.awt.event.ActionListener() 
     153        { 
     154            public void actionPerformed(java.awt.event.ActionEvent evt) 
     155            { 
    143156                addFieldButtonActionPerformed(evt); 
    144157            } 
     
    158171                        .add(addFieldButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 
    159172                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) 
    160                         .add(deleteSelectedButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 131, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 
    161                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)) 
     173                        .add(deleteSelectedButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 131, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 
    162174                    .add(layout.createSequentialGroup() 
    163175                        .add(jLabel4) 
  • trunk/src/event/editor/CMSEvaluationPanel.java

    r76 r89  
    136136    { 
    137137        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     138    } 
     139     
     140    @Override 
     141    public boolean removeAssociatedEvent() 
     142    { 
     143        event.removeThis(); 
     144        event = null; 
     145        return true; 
    138146    } 
    139147 
  • trunk/src/event/editor/Editor.form

    r1 r89  
    33<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> 
    44  <NonVisualComponents> 
     5    <Container class="javax.swing.JPanel" name="jPanel1"> 
     6 
     7      <Layout> 
     8        <DimensionLayout dim="0"> 
     9          <Group type="103" groupAlignment="0" attributes="0"> 
     10              <EmptySpace min="0" pref="100" max="32767" attributes="0"/> 
     11          </Group> 
     12        </DimensionLayout> 
     13        <DimensionLayout dim="1"> 
     14          <Group type="103" groupAlignment="0" attributes="0"> 
     15              <EmptySpace min="0" pref="100" max="32767" attributes="0"/> 
     16          </Group> 
     17        </DimensionLayout> 
     18      </Layout> 
     19    </Container> 
    520    <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> 
    621      <SubComponents> 
     
    271286    <DimensionLayout dim="0"> 
    272287      <Group type="103" groupAlignment="0" attributes="0"> 
    273           <Group type="102" alignment="0" attributes="0"> 
    274               <EmptySpace max="-2" attributes="0"/> 
    275               <Component id="jTabbedPane1" pref="921" max="32767" attributes="0"/> 
    276               <EmptySpace max="-2" attributes="0"/> 
    277           </Group> 
     288          <Component id="jTabbedPane1" alignment="1" max="32767" attributes="0"/> 
     289          <Component id="jPanel2" alignment="0" max="32767" attributes="0"/> 
    278290      </Group> 
    279291    </DimensionLayout> 
     
    282294          <Group type="102" alignment="0" attributes="0"> 
    283295              <EmptySpace max="-2" attributes="0"/> 
    284               <Component id="jTabbedPane1" pref="580" max="32767" attributes="0"/> 
     296              <Component id="jTabbedPane1" pref="539" max="32767" attributes="0"/> 
    285297              <EmptySpace max="-2" attributes="0"/> 
     298              <Component id="jPanel2" min="-2" max="-2" attributes="0"/> 
    286299          </Group> 
    287300      </Group> 
     
    293306      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> 
    294307    </Container> 
     308    <Container class="javax.swing.JPanel" name="jPanel2"> 
     309 
     310      <Layout> 
     311        <DimensionLayout dim="0"> 
     312          <Group type="103" groupAlignment="0" attributes="0"> 
     313              <Group type="102" alignment="1" attributes="0"> 
     314                  <EmptySpace pref="701" max="32767" attributes="0"/> 
     315                  <Component id="btnRemoveCurrentEvent" min="-2" pref="226" max="-2" attributes="0"/> 
     316                  <EmptySpace max="-2" attributes="0"/> 
     317              </Group> 
     318          </Group> 
     319        </DimensionLayout> 
     320        <DimensionLayout dim="1"> 
     321          <Group type="103" groupAlignment="0" attributes="0"> 
     322              <Component id="btnRemoveCurrentEvent" min="-2" max="-2" attributes="0"/> 
     323          </Group> 
     324        </DimensionLayout> 
     325      </Layout> 
     326      <SubComponents> 
     327        <Component class="javax.swing.JButton" name="btnRemoveCurrentEvent"> 
     328          <Properties> 
     329            <Property name="text" type="java.lang.String" value="Remove This Event"/> 
     330          </Properties> 
     331          <Events> 
     332            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnRemoveCurrentEventActionPerformed"/> 
     333          </Events> 
     334        </Component> 
     335      </SubComponents> 
     336    </Container> 
    295337  </SubComponents> 
    296338</Form> 
  • trunk/src/event/editor/Editor.java

    r76 r89  
    77import java.util.*; 
    88import java.awt.event.*; 
     9import scriptbuilder.gui.IncidentEditorFrame; 
     10import scriptbuilder.structures.ScriptIncident; 
    911import scriptbuilder.structures.events.*; 
    10  
    11 enum UpdateType 
    12 { 
    13  
    14     Add, Remove, TitleChange 
    15 } 
    16  
    17 class PropertyUpdate 
    18 { 
    19  
    20     private UpdateType type; 
    21     private PropertyPanel panel; 
    22     private int position = -1; 
    23  
    24     public PropertyUpdate(UpdateType theType, PropertyPanel thePanel) 
    25     { 
    26         type = theType; 
    27         panel = thePanel; 
    28     } 
    29  
    30     public PropertyUpdate(UpdateType theType, PropertyPanel thePanel, int thePosition) 
    31     { 
    32         this(theType, thePanel); 
    33         position = thePosition; 
    34     } 
    35  
    36     public int getPosition() 
    37     { 
    38         if (position == -1) 
    39         { 
    40             throw new RuntimeException("position unknown"); 
    41         } 
    42  
    43         return position; 
    44     } 
    45  
    46     public UpdateType getType() 
    47     { 
    48         return type; 
    49     } 
    50  
    51     public PropertyPanel getPanel() 
    52     { 
    53         return panel; 
    54     } 
    55 } 
    56  
    57 enum PropertyTypes 
    58 { 
    59  
    60     Optional, Multiple; 
    61 } 
    62  
    63 class PropertyPanel 
    64 { 
    65  
    66     private final JPanel panel; 
    67     private final Properties property; 
    68  
    69     public PropertyPanel(JPanel thePanel, 
    70             Properties theProperty) 
    71     { 
    72         panel = thePanel; 
    73         property = theProperty; 
    74     } 
    75  
    76     public JPanel getPanel() 
    77     { 
    78         return panel; 
    79     } 
    80  
    81     public Properties getProperty() 
    82     { 
    83         return property; 
    84     } 
    85  
    86     public String title() 
    87     { 
    88         return property.getTitle(); 
    89     } 
    90 } 
    91  
    92 class MultPropertyPanel extends PropertyPanel 
    93 { 
    94  
    95     private int index; 
    96  
    97     public MultPropertyPanel(JPanel thePanel, 
    98             Properties theProperty, 
    99             int theIndex) 
    100     { 
    101         super(thePanel, theProperty); 
    102         index = theIndex; 
    103     } 
    104  
    105     public int getIndex() 
    106     { 
    107         return index; 
    108     } 
    109  
    110     public void setIndex(int newIndex) 
    111     { 
    112         index = newIndex; 
    113     } 
    114  
    115     @Override 
    116     public String title() 
    117     { 
    118         return super.title() + " " + index; 
    119     } 
    120 } 
    121  
    122 class PropertyPanels extends Observable 
    123 { 
    124  
    125     private Vector<PropertyPanel> properties = new Vector<PropertyPanel>(); 
    126  
    127     private EnumMap<Properties, Integer> propertyCounter 
    128             = new EnumMap<Properties, Integer>(Properties.class); 
    129  
    130     public PropertyPanels() 
    131     { 
    132         for (Properties property : Properties.values()) 
    133         { 
    134             propertyCounter.put(property, 0); 
    135         } 
    136     } 
    137  
    138     private int nextIndex(Properties property) 
    139     { 
    140         propertyCounter.put(property, propertyCounter.get(property) + 1); 
    141  
    142         return propertyCounter.get(property); 
    143     } 
    144  
    145     /** 
    146      * public Vector<PropertyPanel> getProperties() { return 
    147      * (Vector<PropertyPanel>) properties.clone(); } 
    148      */ 
    149     private int add(PropertyPanel panel) 
    150     { 
    151         int position = 0; 
    152  
    153         for (int i = 0; i < properties.size(); i++) 
    154         { 
    155             if (properties.get(i).title().compareTo(panel.title()) < 0) 
    156             { 
    157                 position = i + 1; 
    158             } 
    159         } 
    160  
    161         properties.add(position, panel); 
    162  
    163         return position; 
    164     } 
    165  
    166     public PropertyPanel addPropertyPanel(Properties property, JPanel panel) 
    167     { 
    168         PropertyPanel propertyPanel = null; 
    169  
    170         if (property.getType() == PropertyTypes.Multiple) 
    171         { 
    172             propertyPanel = new MultPropertyPanel(panel, property, nextIndex(property)); 
    173             //propertyPanel.addObserver(this); 
    174             int position = add(propertyPanel); 
    175             setChanged(); 
    176             notifyObservers(new PropertyUpdate(UpdateType.Add, propertyPanel, position)); 
    177  
    178         } 
    179         else if (property.getType() == PropertyTypes.Optional) 
    180         { 
    181             if (containsProperty(property)) 
    182             { 
    183                 throw new RuntimeException("Property \"" + property + "\" is already added"); 
    184             } 
    185             else 
    186             { 
    187                 propertyPanel = new PropertyPanel(panel, property); 
    188                 int position = add(propertyPanel); 
    189                 //propertyPanel.addObserver(this); 
    190                 setChanged(); 
    191                 notifyObservers(new PropertyUpdate(UpdateType.Add, propertyPanel, position)); 
    192             } 
    193         } 
    194         else 
    195         { 
    196             throw new RuntimeException("Property \"" + property + "\" not accounted for"); 
    197         } 
    198  
    199         return propertyPanel; 
    200     } 
    201  
    202     private boolean remove(PropertyPanel panel) 
    203     { 
    204         boolean result = false; 
    205  
    206         if ((result = properties.remove(panel))) 
    207         { 
    208             setChanged(); 
    209             notifyObservers(new PropertyUpdate(UpdateType.Remove, panel)); 
    210         } 
    211         else 
    212         { 
    213             throw new RuntimeException("Attempted to remove panel that did not exist"); 
    214         } 
    215  
    216         if (panel.getProperty().getType() == PropertyTypes.Multiple) 
    217         { 
    218             Vector<MultPropertyPanel> panelsOfSameType = new Vector<MultPropertyPanel>(); 
    219             Vector<MultPropertyPanel> panelsOfGreaterIndex = new Vector<MultPropertyPanel>(); 
    220  
    221             propertyCounter.put(panel.getProperty(), propertyCounter.get(panel.getProperty()) - 1); 
    222  
    223             // extract panels of the same property type 
    224             for (PropertyPanel pan : properties) 
    225             { 
    226                 if (pan.getProperty() == panel.getProperty()) 
    227                 { 
    228                     panelsOfSameType.add((MultPropertyPanel) pan); 
    229                 } 
    230             } 
    231  
    232             // extract panels whose index is greater than the index of the panel 
    233             // being removed 
    234             for (MultPropertyPanel pan : panelsOfSameType) 
    235             { 
    236                 if (pan.getIndex() > ((MultPropertyPanel) panel).getIndex()) 
    237                 { 
    238                     panelsOfGreaterIndex.add(pan); 
    239                 } 
    240             } 
    241  
    242             // decrement the index of each of the remaining panels by one 
    243             for (MultPropertyPanel pan : panelsOfGreaterIndex) 
    244             { 
    245                 pan.setIndex(pan.getIndex() - 1); 
    246                 setChanged(); 
    247                 notifyObservers(new PropertyUpdate(UpdateType.TitleChange, pan)); 
    248             } 
    249         } 
    250         else if (panel.getProperty().getType() == PropertyTypes.Optional) 
    251         { 
    252             // do nothing 
    253         } 
    254         else 
    255         { 
    256             throw new RuntimeException("PropertyTypes not accounted for"); 
    257         } 
    258  
    259         return result; 
    260     } 
    261  
    262     public PropertyPanel removeProperty(Properties property) 
    263     { 
    264         if (property.getType() == PropertyTypes.Multiple) 
    265         { 
    266             throw new RuntimeException("Attemping to remove a property of multiple type"); 
    267         } 
    268  
    269         PropertyPanel removed = null; 
    270  
    271         for (PropertyPanel panel : properties) 
    272         { 
    273             if (panel.getProperty() == property) 
    274             { 
    275                 removed = panel; 
    276             } 
    277         } 
    278  
    279         if (removed == null) 
    280         { 
    281             throw new RuntimeException("Could not find panel with property \"" + property + "\""); 
    282         } 
    283  
    284         remove(removed); 
    285  
    286         return removed; 
    287     } 
    288  
    289     public PropertyPanel removeProperty(JPanel jPanel) 
    290     { 
    291         PropertyPanel removed = null; 
    292  
    293         for (PropertyPanel panel : properties) 
    294         { 
    295             if (panel.getPanel() == jPanel) 
    296             { 
    297                 removed = panel; 
    298             } 
    299         } 
    300  
    301         if (removed == null) 
    302         { 
    303             throw new RuntimeException("Could not find jPanel"); 
    304         } 
    305  
    306         remove(removed); 
    307  
    308         return removed; 
    309     } 
    310  
    311     public PropertyPanel removeProperty(String title) 
    312     { 
    313         PropertyPanel removed = null; 
    314  
    315         for (PropertyPanel panel : properties) 
    316         { 
    317             if (panel.title().equals(title)) 
    318             { 
    319                 if (removed == null) 
    320                 { 
    321                     removed = panel; 
    322                 } 
    323                 else 
    324                 { 
    325                     throw new RuntimeException("Attempted to remove a property by title but the title was not unique"); 
    326                 } 
    327             } 
    328         } 
    329  
    330         if (removed == null) 
    331         { 
    332             throw new RuntimeException("Did not find titel \"" + title + "\""); 
    333         } 
    334  
    335         remove(removed); 
    336  
    337         return removed; 
    338     } 
    339  
    340     public boolean removeProperty(PropertyPanel panel) 
    341     { 
    342         return remove(panel); 
    343     } 
    344  
    345     public boolean containsProperty(Properties property) 
    346     { 
    347         boolean contains = false; 
    348  
    349         for (PropertyPanel panel : properties) 
    350         { 
    351             if (panel.getProperty() == property) 
    352             { 
    353                 contains = true; 
    354             } 
    355         } 
    356  
    357         return contains; 
    358     } 
    359 } 
    360  
    361 class PropertyModel extends Observable implements Observer 
    362 { 
    363  
    364     PropertyPanels properties = new PropertyPanels(); 
    365  
    366     private EnumMap<Properties, Class> classMap 
    367             = new EnumMap<Properties, Class>(Properties.class); 
    368  
    369     public PropertyModel() 
    370     { 
    371         classMap.put(Properties.ATMS, GenericEvaluationPanel.class); 
    372         classMap.put(Properties.ActivityLog, GenericEvaluationPanel.class); 
    373         classMap.put(Properties.CAD, GenericEvaluationPanel.class); 
    374         classMap.put(Properties.Facilitator, GenericEvaluationPanel.class); 
    375         classMap.put(Properties.Radio, GenericEvaluationPanel.class); 
    376  
    377         classMap.put(Properties.MaintenanceRadio, MaintenanceRadioPanel.class); 
    378         classMap.put(Properties.TMTRadio, TMTRadioPanel.class); 
    379         classMap.put(Properties.CHPRadio, CHPRadioPanel.class); 
    380         classMap.put(Properties.Telephone, TelephonePanel.class); 
    381  
    382         classMap.put(Properties.Audio, AudioPanel.class); 
    383         classMap.put(Properties.CADLog, CADLogPanel.class); 
    384         classMap.put(Properties.CCTV, CCTVPanel.class); 
    385         classMap.put(Properties.CMS, CMSEvaluationPanel.class); 
    386         classMap.put(Properties.Paramics, ParamicsPanel.class); 
    387         classMap.put(Properties.Tow, TowPanel.class); 
    388         classMap.put(Properties.Unit, UnitPanel.class); 
    389         classMap.put(Properties.Witness, WitnessPanel.class); 
    390  
    391         properties.addObserver(this); 
    392     } 
    393  
    394     public void addProperty(Properties property, I_ScriptEvent se) 
    395     { 
    396         try 
    397         { 
    398             JPanel panel = (JPanel) classMap.get(property).newInstance(); 
    399  
    400             final PropertyPanel propertyPanel = properties.addPropertyPanel(property, panel); 
    401             if (panel instanceof ScriptEventEditorPanel) 
    402             { 
    403                 ((ScriptEventEditorPanel) panel).getEventObject(se); 
    404             } 
    405             if (property.getType() == PropertyTypes.Multiple) 
    406             { 
    407  
    408                 if (panel instanceof RemoveablePanel) 
    409                 { 
    410                     ((RemoveablePanel) panel).setRemoveListener(new ActionListener() 
    411                     { 
    412                         public void actionPerformed(ActionEvent evt) 
    413                         { 
    414                             properties.removeProperty(propertyPanel); 
    415                         } 
    416                     }); 
    417                 } 
    418                 else 
    419                 { 
    420                     throw new RuntimeException("Property was multiple but panel was not removeable"); 
    421                 } 
    422             } 
    423         } 
    424         catch (Exception e) 
    425         { 
    426             System.err.println("Could not create panel of type \"" + property + "\""); 
    427         } 
    428     } 
    429  
    430     public void removeProperty(Properties property) 
    431     { 
    432         properties.removeProperty(property); 
    433     } 
    434  
    435     public void update(Observable o, Object arg) 
    436     { 
    437         setChanged(); 
    438         notifyObservers(arg); 
    439     } 
    440  
    441     /* 
    442      public Vector<PropertyPanel> getPropertyPanels() 
    443      { 
    444      return properties.getProperties(); 
    445      } 
    446      */ 
    447 } 
    44812 
    44913public class Editor extends javax.swing.JFrame implements Observer 
    45014{ 
     15 
     16    IncidentEditorFrame topFrame = null; 
    45117 
    45218    private PropertyModel model = new PropertyModel(); 
     
    45622//        return model; 
    45723//    } 
    458  
    45924    public void addProperty(Properties property, I_ScriptEvent se) 
    46025    { 
     
    49257     * Blank constructor for a new editor. 
    49358     */ 
    494     public Editor() 
    495     { 
     59    public Editor(IncidentEditorFrame frame) 
     60    { 
     61        topFrame = frame; 
    49662        initComponents(); 
    49763 
     
    53399    @SuppressWarnings("unchecked") 
    534100    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 
    535     private void initComponents() { 
    536  
     101    private void initComponents() 
     102    { 
     103 
     104        jPanel1 = new javax.swing.JPanel(); 
    537105        jTabbedPane1 = new javax.swing.JTabbedPane(); 
     106        jPanel2 = new javax.swing.JPanel(); 
     107        btnRemoveCurrentEvent = new javax.swing.JButton(); 
    538108        jMenuBar1 = new javax.swing.JMenuBar(); 
    539109        jMenu1 = new javax.swing.JMenu(); 
     
    558128        Witness = new javax.swing.JMenuItem(); 
    559129 
     130        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); 
     131        jPanel1.setLayout(jPanel1Layout); 
     132        jPanel1Layout.setHorizontalGroup( 
     133            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 
     134            .add(0, 100, Short.MAX_VALUE) 
     135        ); 
     136        jPanel1Layout.setVerticalGroup( 
     137            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 
     138            .add(0, 100, Short.MAX_VALUE) 
     139        ); 
     140 
    560141        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 
    561142        setTitle("Event Editor"); 
     143 
     144        btnRemoveCurrentEvent.setText("Remove This Event"); 
     145        btnRemoveCurrentEvent.addActionListener(new java.awt.event.ActionListener() 
     146        { 
     147            public void actionPerformed(java.awt.event.ActionEvent evt) 
     148            { 
     149                btnRemoveCurrentEventActionPerformed(evt); 
     150            } 
     151        }); 
     152 
     153        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); 
     154        jPanel2.setLayout(jPanel2Layout); 
     155        jPanel2Layout.setHorizontalGroup( 
     156            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 
     157            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup() 
     158                .addContainerGap(701, Short.MAX_VALUE) 
     159                .add(btnRemoveCurrentEvent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 
     160                .addContainerGap()) 
     161        ); 
     162        jPanel2Layout.setVerticalGroup( 
     163            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 
     164            .add(btnRemoveCurrentEvent) 
     165        ); 
    562166 
    563167        jMenu1.setText("Evaluations"); 
     
    566170        ATMS.setText("ATMS"); 
    567171        ATMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ATMSEval.png"))); // NOI18N 
    568         ATMS.addActionListener(new java.awt.event.ActionListener() { 
    569             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     172        ATMS.addActionListener(new java.awt.event.ActionListener() 
     173        { 
     174            public void actionPerformed(java.awt.event.ActionEvent evt) 
     175            { 
    570176                multipleChange(evt); 
    571177            } 
     
    576182        ActivityLog.setText("Activity Log"); 
    577183        ActivityLog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/ActivityLogEval.png"))); // NOI18N 
    578         ActivityLog.addActionListener(new java.awt.event.ActionListener() { 
    579             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     184        ActivityLog.addActionListener(new java.awt.event.ActionListener() 
     185        { 
     186            public void actionPerformed(java.awt.event.ActionEvent evt) 
     187            { 
    580188                multipleChange(evt); 
    581189            } 
     
    586194        CAD.setText("CAD"); 
    587195        CAD.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CADEval.png"))); // NOI18N 
    588         CAD.addActionListener(new java.awt.event.ActionListener() { 
    589             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     196        CAD.addActionListener(new java.awt.event.ActionListener() 
     197        { 
     198            public void actionPerformed(java.awt.event.ActionEvent evt) 
     199            { 
    590200                multipleChange(evt); 
    591201            } 
     
    596206        CMS.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CMSEval.png"))); // NOI18N 
    597207        CMS.setText("CMS"); 
    598         CMS.addMouseListener(new java.awt.event.MouseAdapter() { 
    599             public void mouseClicked(java.awt.event.MouseEvent evt) { 
     208        CMS.addMouseListener(new java.awt.event.MouseAdapter() 
     209        { 
     210            public void mouseClicked(java.awt.event.MouseEvent evt) 
     211            { 
    600212                multipleChangeListener(evt); 
    601213            } 
    602214        }); 
    603         CMS.addActionListener(new java.awt.event.ActionListener() { 
    604             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     215        CMS.addActionListener(new java.awt.event.ActionListener() 
     216        { 
     217            public void actionPerformed(java.awt.event.ActionEvent evt) 
     218            { 
    605219                multipleChange(evt); 
    606220            } 
     
    611225        Facilitator.setText("Facilitator"); 
    612226        Facilitator.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/FacilitatorEval.png"))); // NOI18N 
    613         Facilitator.addActionListener(new java.awt.event.ActionListener() { 
    614             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     227        Facilitator.addActionListener(new java.awt.event.ActionListener() 
     228        { 
     229            public void actionPerformed(java.awt.event.ActionEvent evt) 
     230            { 
    615231                optionalChange(evt); 
    616232            } 
     
    621237        Radio.setText("Radio"); 
    622238        Radio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/RadioEval.png"))); // NOI18N 
    623         Radio.addActionListener(new java.awt.event.ActionListener() { 
    624             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     239        Radio.addActionListener(new java.awt.event.ActionListener() 
     240        { 
     241            public void actionPerformed(java.awt.event.ActionEvent evt) 
     242            { 
    625243                optionalChange(evt); 
    626244            } 
     
    635253        MaintenanceRadio.setText("Maintenance Radio"); 
    636254        MaintenanceRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/MaintenanceRadio.png"))); // NOI18N 
    637         MaintenanceRadio.addActionListener(new java.awt.event.ActionListener() { 
    638             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     255        MaintenanceRadio.addActionListener(new java.awt.event.ActionListener() 
     256        { 
     257            public void actionPerformed(java.awt.event.ActionEvent evt) 
     258            { 
    639259                optionalChange(evt); 
    640260            } 
     
    645265        TMTRadio.setText("TMT Radio"); 
    646266        TMTRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/TMTRadio.png"))); // NOI18N 
    647         TMTRadio.addActionListener(new java.awt.event.ActionListener() { 
    648             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     267        TMTRadio.addActionListener(new java.awt.event.ActionListener() 
     268        { 
     269            public void actionPerformed(java.awt.event.ActionEvent evt) 
     270            { 
    649271                optionalChange(evt); 
    650272            } 
     
    655277        Telephone.setText("Telephone"); 
    656278        Telephone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Telephone.png"))); // NOI18N 
    657         Telephone.addActionListener(new java.awt.event.ActionListener() { 
    658             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     279        Telephone.addActionListener(new java.awt.event.ActionListener() 
     280        { 
     281            public void actionPerformed(java.awt.event.ActionEvent evt) 
     282            { 
    659283                optionalChange(evt); 
    660284            } 
     
    684308        CHPRadio.setText("CHP Radio"); 
    685309        CHPRadio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/CHPRadio.png"))); // NOI18N 
    686         CHPRadio.addActionListener(new java.awt.event.ActionListener() { 
    687             public void actionPerformed(java.awt.event.ActionEvent evt) { 
     310        CHPRadio.addActionListener(new java.awt.event.ActionListener() 
     311        { 
     312            public void actionPerformed(java.awt.event.ActionEvent evt) 
     313            { 
    688314                optionalChange(evt); 
    689315            } 
     
    719345        layout.setHorizontalGroup( 
    720346            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 
    721             .add(layout.createSequentialGroup() 
    722                 .addContainerGap() 
    723                 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 921, Short.MAX_VALUE) 
    724                 .addContainerGap()) 
     347            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1) 
     348            .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 
    725349        ); 
    726350        layout.setVerticalGroup( 
     
    728352            .add(layout.createSequentialGroup() 
    729353                .addContainerGap() 
    730                 .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) 
    731                 .addContainerGap()) 
     354                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE) 
     355                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 
     356                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 
    732357        ); 
    733358 
     
    746371 
    747372    }//GEN-LAST:event_optionalChange 
     373 
     374    private void btnRemoveCurrentEventActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRemoveCurrentEventActionPerformed 
     375    {//GEN-HEADEREND:event_btnRemoveCurrentEventActionPerformed 
     376 
     377        int index = jTabbedPane1.getSelectedIndex(); 
     378 
     379        if (index > 0 && jTabbedPane1.getTabComponentAt(index) != null) 
     380        { 
     381            JPanel removable = (JPanel) jTabbedPane1 
     382                    .getSelectedComponent(); 
     383            this.model.properties.removeProperty(removable); 
     384        } 
     385 
     386    }//GEN-LAST:event_btnRemoveCurrentEventActionPerformed 
    748387 
    749388    /** 
     
    756395            public void run() 
    757396            { 
    758                 new Editor().setVisible(true); 
     397                new Editor(new IncidentEditorFrame(new ScriptIncident(100, null, null, null))).setVisible(true); 
    759398            } 
    760399        }); 
     
    780419    private javax.swing.JMenuItem Unit; 
    781420    private javax.swing.JMenuItem Witness; 
     421    private javax.swing.JButton btnRemoveCurrentEvent; 
    782422    private javax.swing.JMenu jMenu1; 
    783423    private javax.swing.JMenu jMenu3; 
    784424    private javax.swing.JMenuBar jMenuBar1; 
     425    private javax.swing.JPanel jPanel1; 
     426    private javax.swing.JPanel jPanel2; 
    785427    private javax.swing.JTabbedPane jTabbedPane1; 
    786428    // End of variables declaration//GEN-END:variables 
    787429 
     430    @Override 
    788431    public void update(Observable o, Object arg) 
    789432    { 
     
    808451            jTabbedPane1.setTabComponentAt(update.getPosition(), title); 
    809452            jTabbedPane1.setSelectedIndex(update.getPosition()); 
     453            topFrame.repaint(); 
    810454        } 
    811455        else if (update.getType() == UpdateType.Remove) 
    812456        { 
    813457            jTabbedPane1.remove(update.getPanel().getPanel()); 
     458            if (update.getPanel().getPanel() instanceof ScriptEventEditorPanel) 
     459            { 
     460                ((ScriptEventEditorPanel) update.getPanel().getPanel()).removeAssociatedEvent(); 
     461            } 
     462            topFrame.repaint(); 
    814463        } 
    815464        else if (update.getType() == UpdateType.TitleChange) 
  • trunk/src/event/editor/GenericEvaluationPanel.java

    r7 r89  
    7878    { 
    7979        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     80    } 
     81     
     82    @Override 
     83    public boolean removeAssociatedEvent() 
     84    { 
     85        ((I_ScriptEvent)event).removeThis(); 
     86        event = null; 
     87        return true; 
    8088    } 
    8189 
  • trunk/src/event/editor/MaintenanceRadioPanel.java

    r7 r89  
    5252        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    5353    } 
     54     
     55    @Override 
     56    public boolean removeAssociatedEvent() 
     57    { 
     58        ((I_ScriptEvent)event).removeThis(); 
     59        event = null; 
     60        return true; 
     61    } 
    5462 
    5563    /** 
  • trunk/src/event/editor/ParamicsPanel.java

    r50 r89  
    110110    { 
    111111        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     112    } 
     113     
     114    @Override 
     115    public boolean removeAssociatedEvent() 
     116    { 
     117        event.removeThis(); 
     118        event = null; 
     119        return true; 
    112120    } 
    113121 
  • trunk/src/event/editor/RemoveablePanel.java

    r76 r89  
    22 
    33import java.awt.event.*; 
    4 import scriptbuilder.structures.events.I_ScriptEvent; 
    54 
    65public interface RemoveablePanel 
  • trunk/src/event/editor/ScriptEventEditorPanel.java

    r76 r89  
    2222     */ 
    2323    void getEventObject(I_ScriptEvent sei); 
     24     
     25     /** 
     26     * Remove the event associated with this panel. 
     27     *  
     28     * @return true if the event was successfully deleted. 
     29     */ 
     30    boolean removeAssociatedEvent(); 
    2431} 
  • trunk/src/event/editor/TMTRadioPanel.java

    r7 r89  
    5252        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    5353    } 
     54     
     55    @Override 
     56    public boolean removeAssociatedEvent() 
     57    { 
     58        ((I_ScriptEvent)event).removeThis(); 
     59        event = null; 
     60        return true; 
     61    } 
    5462 
    5563    /** 
  • trunk/src/event/editor/TelephonePanel.java

    r7 r89  
    106106    { 
    107107        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     108    } 
     109     
     110    @Override 
     111    public boolean removeAssociatedEvent() 
     112    { 
     113        ((I_ScriptEvent)event).removeThis(); 
     114        event = null; 
     115        return true; 
    108116    } 
    109117 
  • trunk/src/event/editor/TowPanel.java

    r7 r89  
    136136    { 
    137137        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     138    } 
     139     
     140    @Override 
     141    public boolean removeAssociatedEvent() 
     142    { 
     143        event.removeThis(); 
     144        event = null; 
     145        return true; 
    138146    } 
    139147 
  • trunk/src/event/editor/UnitPanel.java

    r7 r89  
    121121    { 
    122122        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     123    } 
     124     
     125    @Override 
     126    public boolean removeAssociatedEvent() 
     127    { 
     128        event.removeThis(); 
     129        event = null; 
     130        return true; 
    123131    } 
    124132 
  • trunk/src/event/editor/WitnessPanel.java

    r50 r89  
    122122    { 
    123123        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     124    } 
     125     
     126    @Override 
     127    public boolean removeAssociatedEvent() 
     128    { 
     129        event.removeThis(); 
     130        event = null; 
     131        return true; 
    124132    } 
    125133 
Note: See TracChangeset for help on using the changeset viewer.