Changeset 91 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/panels


Ignore:
Timestamp:
08/28/2017 03:39:34 PM (9 years ago)
Author:
bmcguffin
Message:

Added functionality for popup menu options: "Events", "Properties", "Delete".

Fixed a bug where closing the properties window without altering the incident number would display an error message.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java

    r90 r91  
    130130            public void actionPerformed(ActionEvent e) 
    131131            { 
    132                 JOptionPane.showMessageDialog(null, e.getActionCommand() + " will be handled here."); 
     132                JFrame topFrame = (JFrame) getTopLevelAncestor(); 
     133                if (topFrame instanceof ScriptBuilderFrame) 
     134                { 
     135                    SimulationScript script = ((ScriptBuilderFrame) topFrame).getScript(); 
     136                    if (e.getActionCommand().equals("Edit Events")) 
     137                    { 
     138                        IncidentEditorFrame editor = new IncidentEditorFrame(incident); 
     139                        script.addObserver(editor); 
     140                        editor.setVisible(true); 
     141                        ((ScriptBuilderFrame) topFrame).update(script, script); 
     142                    } 
     143                    if (e.getActionCommand().equals("Modify Incident Properties")) 
     144                    { 
     145                        ((ScriptBuilderFrame) topFrame).incidentDetailsScreen(incident); 
     146                        ((ScriptBuilderFrame) topFrame).update(script, script); 
     147                    } 
     148                    if (e.getActionCommand().equals("Delete Incident")) 
     149                    { 
     150                        int confirm = JOptionPane.showConfirmDialog(((ScriptBuilderFrame) topFrame), 
     151                                "Are you sure you want to delete " + incident.toString() + "?"); 
     152                        if (confirm == JOptionPane.YES_OPTION) 
     153                        { 
     154                            script.incidents.remove(incident); 
     155                            script.incidents.add(null); 
     156                            ((ScriptBuilderFrame) topFrame).update(script, script); 
     157                        } 
     158                    } 
     159                } 
     160                topFrame.repaint(); 
    133161            } 
    134162        } 
Note: See TracChangeset for help on using the changeset viewer.