Changeset 103 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/gui


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.

Location:
trunk/src/scriptbuilder/gui
Files:
5 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) 
  • trunk/src/scriptbuilder/gui/IncidentPaletteFrame.java

    r82 r103  
    376376        if (script.addIncident(newInc)) 
    377377        { 
    378             new IncidentEditorFrame(newInc).setVisible(true); 
     378            new IncidentEditorFrame(newInc, parent).setVisible(true); 
    379379            this.dispose(); 
    380380        } 
  • trunk/src/scriptbuilder/gui/ScriptBuilderFrame.java

    r100 r103  
    2525import javax.swing.UIManager; 
    2626import javax.swing.UnsupportedLookAndFeelException; 
     27import javax.swing.event.ChangeEvent; 
    2728import scriptbuilder.gui.panels.IncidentTimelinePanel; 
    2829import scriptbuilder.structures.ScriptEvent; 
     
    15371538            script.incidents.get(indx).setOffset((Integer) addIncidentStart.getValue() * 60); 
    15381539            script.numberOfIncidents++; 
    1539             new IncidentEditorFrame(script.incidents.get(indx)).setVisible(true); 
     1540            new IncidentEditorFrame(script.incidents.get(indx), this).setVisible(true); 
    15401541        } 
    15411542        else//editing existing incident 
     
    17261727    }//GEN-LAST:event_incidentDetailsActionPerformed 
    17271728 
     1729    public void returnFocus() 
     1730    { 
     1731        zoomSlider.setValue(zoomSlider.getMinimum()); 
     1732        zoomSliderStateChanged(new ChangeEvent(script)); 
     1733    } 
     1734     
    17281735    public void incidentDetailsScreen(ScriptIncident i) 
    17291736    { 
     
    19942001            if (inc != null) 
    19952002            { 
    1996                 IncidentEditorFrame editor = new IncidentEditorFrame(inc); 
     2003                IncidentEditorFrame editor = new IncidentEditorFrame(inc, this); 
    19972004                script.addObserver(editor); 
    19982005                editor.setVisible(true); 
  • trunk/src/scriptbuilder/gui/application.properties

    r81 r103  
    1 #Fri, 25 Aug 2017 15:31:58 -0700 
     1#Fri, 01 Sep 2017 13:13:39 -0700 
    22 
    33Application.revision=0 
  • trunk/src/scriptbuilder/gui/panels/IncidentTimelinePanel.java

    r101 r103  
    147147                    if (e.getActionCommand().equals("Edit Events")) 
    148148                    { 
    149                         IncidentEditorFrame editor = new IncidentEditorFrame(incident); 
     149                        IncidentEditorFrame editor = new IncidentEditorFrame(incident, (ScriptBuilderFrame)topFrame); 
    150150                        script.addObserver(editor); 
    151151                        editor.setVisible(true); 
Note: See TracChangeset for help on using the changeset viewer.