Changeset 107 in tmcsimulator-scriptbuilder for trunk/src


Ignore:
Timestamp:
09/05/2017 01:18:00 PM (9 years ago)
Author:
bmcguffin
Message:

Fixed a bug where deleting the first timeslice of an incident would not alter the reported start time of the incident.

Location:
trunk/src/scriptbuilder
Files:
4 edited

Legend:

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

    r104 r107  
    307307            public void windowClosing(WindowEvent e) 
    308308            { 
    309                 theIncident.setOffset(savedOffset); 
     309                //Add previous offset back in 
     310                //If we didn't adjust the offset, this will just set it to the old value 
     311                //If we deleted the first event(s), this will add the offsets, 
     312                //to ensure that events stay at the correct times 
     313                theIncident.setOffset(theIncident.offset + savedOffset); 
    310314                parent.returnFocus(); 
    311315            } 
  • trunk/src/scriptbuilder/structures/ScriptEvent.java

    r89 r107  
    196196    { 
    197197        this.slice.events.remove(this); 
     198        this.slice.checkEmpty(); 
    198199    } 
    199200     
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r106 r107  
    375375        return this.number + " - " + this.name; 
    376376    } 
     377     
     378    /** 
     379     * Remove the timeslice at the given position. 
     380     *  
     381     * @param seconds absolute start time of the timeslice to remove. 
     382     */ 
     383    public void removeTimeSlice(int seconds) 
     384    { 
     385        //remove the timeslice 
     386        this.slices.remove(seconds); 
     387         
     388        //offset is equivalent to start time of earliest slice 
     389        if(seconds == offset) 
     390        { 
     391            offset = slices.firstKey(); 
     392        } 
     393        this.updateLength(); 
     394        script.update(); 
     395    } 
    377396} 
  • trunk/src/scriptbuilder/structures/TimeSlice.java

    r89 r107  
    297297                || ev instanceof WitnessEvent || ev instanceof CADEvent; 
    298298    } 
     299     
     300    public void checkEmpty() 
     301    { 
     302        if (this.events.isEmpty()) 
     303        { 
     304            this.thisIncident.removeTimeSlice(this.seconds); 
     305        } 
     306    } 
    299307} 
Note: See TracChangeset for help on using the changeset viewer.