Changeset 103 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui/IncidentEditorFrame.java


Ignore:
Timestamp:
09/01/2017 12:13:01 PM (9 years ago)
Author:
bmcguffin
Message:

Individual incident editor window now shows the relevant incident as though it started at 00:00:00. When window is closed, the incident is re-inserted into the correct position.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/gui/IncidentEditorFrame.java

    r98 r103  
    11/** 
    22 * Frame for the Individual Incident Editor. 
    3  *  
     3 * 
    44 * @author Bryan McGuffin 
    55 * @version 2017/08/08 
     
    1212import java.awt.event.KeyEvent; 
    1313import java.awt.event.KeyListener; 
     14import java.awt.event.WindowAdapter; 
     15import java.awt.event.WindowEvent; 
    1416import java.io.IOException; 
    1517import java.util.ArrayList; 
     
    4042public class IncidentEditorFrame extends javax.swing.JFrame implements Observer 
    4143{ 
    42      
     44 
    4345    /** 
    4446     * The script incident currently being edited. 
    4547     */ 
    4648    private ScriptIncident theIncident; 
    47      
     49 
     50    private ScriptBuilderFrame parent; 
     51 
     52    private int savedOffset; 
     53 
    4854    /** 
    4955     * The current type of selected event. 
     
    232238     * Constructor. Prep new script model, initialize the GUI, and add listeners 
    233239     * for all buttons. 
    234      *  
    235      * @param theIncident the Script Incident which this window will edit. 
    236      */ 
    237     public IncidentEditorFrame(ScriptIncident theIncident) 
     240     * 
     241     * @param inc the Script Incident which this window will edit. 
     242     */ 
     243    public IncidentEditorFrame(ScriptIncident inc, ScriptBuilderFrame topFrame) 
    238244    { 
    239         this.theIncident = theIncident; 
     245        this.theIncident = inc; 
     246        this.savedOffset = this.theIncident.offset; 
     247        this.theIncident.setOffset(0); 
     248        this.parent = topFrame; 
    240249        initComponents(); 
    241         this.update(null, theIncident); 
     250 
     251        timelineTickPanel.update(theIncident, incidentTimelinePanel1); 
     252        timeStampPanel.update(theIncident, incidentTimelinePanel1); 
     253 
     254        incidentTimelinePanel1.timelinePanelUpdate(theIncident); 
     255 
     256        incidentNumberPanel1.update(theIncident); 
    242257        selectButton.addKeyListener(new TimelineKeyListener()); 
    243258        cadButton.addKeyListener(new TimelineKeyListener()); 
     
    261276//        zoomSlider.setValue(zoomSlider.getValue() - 1); 
    262277//        zoomSlider.setValue(zoomSlider.getValue() + 1); 
    263  
    264278        // Set listener for scroll pane 
    265279        AdjustmentListener listener = new MyAdjustmentListener(); 
     
    287301        eventButtons.add(facilitatorEvalButton); 
    288302        eventButtons.add(radioEvalButton); 
    289          
    290         incidentNumber.setText(""+this.theIncident.number); 
    291         incidentName.setText(""+this.theIncident.name); 
    292         incidentDescription.setText(""+this.theIncident.description); 
     303 
     304        this.addWindowListener(new WindowAdapter() 
     305        { 
     306            @Override 
     307            public void windowClosing(WindowEvent e) 
     308            { 
     309                theIncident.setOffset(savedOffset); 
     310                parent.returnFocus(); 
     311            } 
     312        }); 
     313 
     314        incidentNumber.setText("" + this.theIncident.number); 
     315        incidentName.setText("" + this.theIncident.name); 
     316        incidentDescription.setText("" + this.theIncident.description); 
    293317        zoomSlider.setValue(zoomSlider.getMinimum()); 
     318        this.update(null, this.theIncident); 
    294319    } 
    295320 
     
    310335        { 
    311336            theIncident = (ScriptIncident) arg; 
    312              
     337 
    313338            timelineTickPanel.update(theIncident, incidentTimelinePanel1); 
    314339            timeStampPanel.update(theIncident, incidentTimelinePanel1); 
     
    329354        { 
    330355            TimeSlice slice = ((SliceChangedEvent) arg).slice; 
    331              
     356 
    332357            DefaultListModel model = new DefaultListModel(); 
    333358            for (I_ScriptEvent e : slice.events) 
Note: See TracChangeset for help on using the changeset viewer.