Changeset 9 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/ScriptIncident.java


Ignore:
Timestamp:
07/25/2017 02:59:09 PM (9 years ago)
Author:
bmcguffin
Message:

Decoupled ScriptIncident? from the observer-observable pattern. SimulationScript? no longer implements Observer; instead, ScriptIncident? calls methods in SimulationScript? which notify the script's observers of a change.

Also: TimeSlice? now contains a stub method, toXML(), which returns the contents of the timeslice in XML text format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/structures/ScriptIncident.java

    r7 r9  
    1919 * @version 2017/06/29 
    2020 */ 
    21 public class ScriptIncident extends Observable 
     21public class ScriptIncident 
    2222{ 
    2323 
     
    6666     */ 
    6767    private int latestStart = 0; 
     68 
     69    SimulationScript script; 
    6870 
    6971    /** 
     
    8284        this.name = name; 
    8385        this.description = description; 
    84         this.addObserver(script); 
     86        this.script = script; 
    8587        slices = new TreeMap<Integer, TimeSlice>(); 
    8688    } 
     
    102104        this.name = name; 
    103105        this.description = description; 
    104         this.addObserver(script); 
     106        this.script = script; 
    105107        slices = new TreeMap<Integer, TimeSlice>(); 
    106108    } 
     
    124126        this.name = name; 
    125127        this.description = description; 
    126         this.addObserver(script); 
     128        this.script = script; 
    127129        slices = new TreeMap<Integer, TimeSlice>(); 
    128130        this.setOffset(offset); 
     
    137139    { 
    138140        this.collapsed = collapsed; 
    139         setChanged(); 
    140         notifyObservers(); 
     141        script.update(); 
    141142    } 
    142143 
     
    150151    { 
    151152        this.offset = offset; 
    152         setChanged(); 
    153         notifyObservers(); 
     153        script.update(); 
    154154    } 
    155155 
     
    253253        if (this.slices.get(i) != null) 
    254254        { 
    255             setChanged(); 
    256             notifyObservers(new SliceChangedEvent(this.slices.get(i))); 
     255            script.broadcastEvent(new SliceChangedEvent(this.slices.get(i))); 
    257256        } 
    258257    } 
     
    277276    public void setIncidentActive() 
    278277    { 
    279         setChanged(); 
    280         notifyObservers(new IncidentFocusedEvent(this)); 
     278        script.broadcastEvent(new IncidentFocusedEvent(this)); 
    281279    } 
    282280 
Note: See TracChangeset for help on using the changeset viewer.