- Timestamp:
- 07/25/2017 02:59:09 PM (9 years ago)
- Location:
- trunk/src/scriptbuilder/structures
- Files:
-
- 3 edited
-
ScriptIncident.java (modified) (9 diffs)
-
SimulationScript.java (modified) (3 diffs)
-
TimeSlice.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/ScriptIncident.java
r7 r9 19 19 * @version 2017/06/29 20 20 */ 21 public class ScriptIncident extends Observable21 public class ScriptIncident 22 22 { 23 23 … … 66 66 */ 67 67 private int latestStart = 0; 68 69 SimulationScript script; 68 70 69 71 /** … … 82 84 this.name = name; 83 85 this.description = description; 84 this. addObserver(script);86 this.script = script; 85 87 slices = new TreeMap<Integer, TimeSlice>(); 86 88 } … … 102 104 this.name = name; 103 105 this.description = description; 104 this. addObserver(script);106 this.script = script; 105 107 slices = new TreeMap<Integer, TimeSlice>(); 106 108 } … … 124 126 this.name = name; 125 127 this.description = description; 126 this. addObserver(script);128 this.script = script; 127 129 slices = new TreeMap<Integer, TimeSlice>(); 128 130 this.setOffset(offset); … … 137 139 { 138 140 this.collapsed = collapsed; 139 setChanged(); 140 notifyObservers(); 141 script.update(); 141 142 } 142 143 … … 150 151 { 151 152 this.offset = offset; 152 setChanged(); 153 notifyObservers(); 153 script.update(); 154 154 } 155 155 … … 253 253 if (this.slices.get(i) != null) 254 254 { 255 setChanged(); 256 notifyObservers(new SliceChangedEvent(this.slices.get(i))); 255 script.broadcastEvent(new SliceChangedEvent(this.slices.get(i))); 257 256 } 258 257 } … … 277 276 public void setIncidentActive() 278 277 { 279 setChanged(); 280 notifyObservers(new IncidentFocusedEvent(this)); 278 script.broadcastEvent(new IncidentFocusedEvent(this)); 281 279 } 282 280 -
trunk/src/scriptbuilder/structures/SimulationScript.java
r1 r9 26 26 * @version 2017/06/22 27 27 */ 28 public class SimulationScript extends Observable implements Observer28 public class SimulationScript extends Observable 29 29 { 30 30 … … 155 155 156 156 /** 157 * Pass incident focus events on to observers, if applicable. 158 * 159 * @param o The observable object sending the update 160 * @param arg Argument parameter of update 161 */ 162 @Override 163 public void update(Observable o, Object arg) 164 { 165 if (arg instanceof SliceChangedEvent) 166 { 167 // The slice focus has changed; pass the message 168 setChanged(); 169 notifyObservers(arg); 170 } 171 else if (arg instanceof IncidentFocusedEvent) 172 { 173 // The slice focus has changed; pass the message 174 setChanged(); 175 notifyObservers(arg); 176 } 177 else 178 { 179 // The script has changed, notify observers 180 setChanged(); 181 notifyObservers(this); 182 } 157 * Update the script's observers. 158 * 159 */ 160 public void update() 161 { 162 // The script has changed, notify observers 163 setChanged(); 164 notifyObservers(this); 165 } 166 167 /** 168 * Tell this script's observers that there is a new slice event. 169 * 170 * @param e the slice focus event 171 */ 172 public void broadcastEvent(SliceChangedEvent e) 173 { 174 // The slice focus has changed; pass the message 175 setChanged(); 176 notifyObservers(e); 177 } 178 179 /** 180 * Tell this script's observers that there is a new slice event. 181 * 182 * @param e the incident focus event 183 */ 184 public void broadcastEvent(IncidentFocusedEvent e) 185 { 186 // The slice focus has changed; pass the message 187 setChanged(); 188 notifyObservers(e); 183 189 } 184 190 … … 210 216 ex.printStackTrace(); 211 217 } 212 update(this, this);218 this.update(); 213 219 } 214 220 } -
trunk/src/scriptbuilder/structures/TimeSlice.java
r7 r9 185 185 186 186 } 187 188 /** 189 * Stub method. Converts the contents of this timeslice to a correctly 190 * formatted <ScriptEvent> XML element. 191 * 192 * @return XML conversion of this timeslice. 193 */ 194 public String toXML() 195 { 196 return "STUB"; 197 } 187 198 }
Note: See TracChangeset
for help on using the changeset viewer.
