Lines 126-131
Link Here
|
126 |
* Runs the runnable instance without sending events. |
126 |
* Runs the runnable instance without sending events. |
127 |
*/ |
127 |
*/ |
128 |
public Object runSilent(MRunnable runnable) { |
128 |
public Object runSilent(MRunnable runnable) { |
|
|
129 |
|
129 |
return runWithOptions(runnable, MRunOption.SILENT); |
130 |
return runWithOptions(runnable, MRunOption.SILENT); |
130 |
} |
131 |
} |
131 |
|
132 |
|
Lines 133-138
Link Here
|
133 |
* Runs the runnable instance without semantic procedures. |
134 |
* Runs the runnable instance without semantic procedures. |
134 |
*/ |
135 |
*/ |
135 |
public Object runWithNoSemProcs(MRunnable runnable) { |
136 |
public Object runWithNoSemProcs(MRunnable runnable) { |
|
|
137 |
|
136 |
return runWithOptions(runnable, MRunOption.NO_SEM_PROCS); |
138 |
return runWithOptions(runnable, MRunOption.NO_SEM_PROCS); |
137 |
} |
139 |
} |
138 |
|
140 |
|
Lines 140-145
Link Here
|
140 |
* Runs the runnable instance without validation. |
142 |
* Runs the runnable instance without validation. |
141 |
*/ |
143 |
*/ |
142 |
public Object runUnvalidated(MRunnable runnable) { |
144 |
public Object runUnvalidated(MRunnable runnable) { |
|
|
145 |
|
143 |
return runWithOptions(runnable, MRunOption.UNVALIDATED); |
146 |
return runWithOptions(runnable, MRunOption.UNVALIDATED); |
144 |
} |
147 |
} |
145 |
|
148 |
|
Lines 151-156
Link Here
|
151 |
* @see MRunOption |
154 |
* @see MRunOption |
152 |
*/ |
155 |
*/ |
153 |
public Object runWithOptions(MRunnable runnable, int options) { |
156 |
public Object runWithOptions(MRunnable runnable, int options) { |
|
|
157 |
|
154 |
Object result = null; |
158 |
Object result = null; |
155 |
|
159 |
|
156 |
Object previousNoNotifications = null; |
160 |
Object previousNoNotifications = null; |
Lines 245-250
Link Here
|
245 |
* Adds a new event to the pending list of events. |
249 |
* Adds a new event to the pending list of events. |
246 |
*/ |
250 |
*/ |
247 |
public void addEvent(Notification event) { |
251 |
public void addEvent(Notification event) { |
|
|
252 |
|
248 |
notifyMetaModel(event); |
253 |
notifyMetaModel(event); |
249 |
|
254 |
|
250 |
if (domain.isUndoInProgress()) |
255 |
if (domain.isUndoInProgress()) |
Lines 258-264
Link Here
|
258 |
* Checks if event is undo event. |
263 |
* Checks if event is undo event. |
259 |
*/ |
264 |
*/ |
260 |
public boolean isUndoEvent(Notification event) { |
265 |
public boolean isUndoEvent(Notification event) { |
|
|
266 |
|
261 |
Boolean isUndo = (Boolean) undoRedoEvents.get(event); |
267 |
Boolean isUndo = (Boolean) undoRedoEvents.get(event); |
|
|
268 |
|
262 |
return (isUndo != null) && (isUndo.booleanValue()); |
269 |
return (isUndo != null) && (isUndo.booleanValue()); |
263 |
} |
270 |
} |
264 |
|
271 |
|
Lines 266-272
Link Here
|
266 |
* Checks if event is redo event. |
273 |
* Checks if event is redo event. |
267 |
*/ |
274 |
*/ |
268 |
public boolean isRedoEvent(Notification event) { |
275 |
public boolean isRedoEvent(Notification event) { |
|
|
276 |
|
269 |
Boolean isUndo = (Boolean) undoRedoEvents.get(event); |
277 |
Boolean isUndo = (Boolean) undoRedoEvents.get(event); |
|
|
278 |
|
270 |
return (isUndo != null) && (!isUndo.booleanValue()); |
279 |
return (isUndo != null) && (!isUndo.booleanValue()); |
271 |
} |
280 |
} |
272 |
|
281 |
|
Lines 274-280
Link Here
|
274 |
* Notify the meta-model about the modification. |
283 |
* Notify the meta-model about the modification. |
275 |
*/ |
284 |
*/ |
276 |
public void notifyMetaModel(Notification event) { |
285 |
public void notifyMetaModel(Notification event) { |
|
|
286 |
|
277 |
if (sendEventsToMetaModel) { |
287 |
if (sendEventsToMetaModel) { |
|
|
288 |
|
278 |
Object notifier = event.getNotifier(); |
289 |
Object notifier = event.getNotifier(); |
279 |
|
290 |
|
280 |
if (((domain.isWriteInProgress()) || (domain |
291 |
if (((domain.isWriteInProgress()) || (domain |
Lines 303-308
Link Here
|
303 |
* Fires events. |
314 |
* Fires events. |
304 |
*/ |
315 |
*/ |
305 |
private void fireEvents(List events) { |
316 |
private void fireEvents(List events) { |
|
|
317 |
|
306 |
if (events.isEmpty()) |
318 |
if (events.isEmpty()) |
307 |
return; |
319 |
return; |
308 |
|
320 |
|
Lines 323-329
Link Here
|
323 |
// consuming and save the time of extracting the single Notification from the list. |
335 |
// consuming and save the time of extracting the single Notification from the list. |
324 |
Notification singleEvent = (Notification)events.get(0); |
336 |
Notification singleEvent = (Notification)events.get(0); |
325 |
|
337 |
|
326 |
for (Iterator iter = allListeners.iterator(); iter.hasNext();) { |
338 |
for (Iterator iter = allListeners.iterator(); iter.hasNext();) { |
327 |
MListener listener = (MListener)iter.next(); |
339 |
MListener listener = (MListener)iter.next(); |
328 |
fireSingleEvent(listener, singleEvent, events); |
340 |
fireSingleEvent(listener, singleEvent, events); |
329 |
} |
341 |
} |
Lines 333-345
Link Here
|
333 |
// only have two lists occupying memory that are the same size rather |
345 |
// only have two lists occupying memory that are the same size rather |
334 |
// than allocating lists of different sizes for each listener. |
346 |
// than allocating lists of different sizes for each listener. |
335 |
List listenerEventCache = new ArrayList(events.size()); |
347 |
List listenerEventCache = new ArrayList(events.size()); |
336 |
|
348 |
|
337 |
for (Iterator iter = allListeners.iterator(); iter.hasNext();) { |
349 |
for (Iterator iter = allListeners.iterator(); iter.hasNext();) { |
338 |
MListener listener = (MListener)iter.next(); |
350 |
MListener listener = (MListener)iter.next(); |
339 |
fireEvents(listener, events, listenerEventCache); |
351 |
fireEvents(listener, events, listenerEventCache); |
340 |
} |
|
|
341 |
} |
352 |
} |
342 |
} |
353 |
} |
|
|
354 |
} |
343 |
|
355 |
|
344 |
private boolean shouldSuppressUnbatchedResourceEvent(List events) { |
356 |
private boolean shouldSuppressUnbatchedResourceEvent(List events) { |
345 |
boolean result = false; |
357 |
boolean result = false; |
Lines 349-359
Link Here
|
349 |
|
361 |
|
350 |
if (notification.getNotifier() instanceof Resource) { |
362 |
if (notification.getNotifier() instanceof Resource) { |
351 |
if (notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) { |
363 |
if (notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) { |
352 |
Resource res = (Resource) notification.getNotifier(); |
364 |
result = !notification.getNewBooleanValue() && !(notification instanceof MSLResourceListener.UnloadNotification); |
353 |
|
|
|
354 |
result = notification.getNewBooleanValue()? |
355 |
domain.getResouceListener().loadedWithErrors(res) : |
356 |
!(notification instanceof MSLResourceListener.UnloadNotification); |
357 |
} |
365 |
} |
358 |
} |
366 |
} |
359 |
} |
367 |
} |
Lines 367-372
Link Here
|
367 |
* the returned list is garbage collected. |
375 |
* the returned list is garbage collected. |
368 |
*/ |
376 |
*/ |
369 |
private List getAllListeners() { |
377 |
private List getAllListeners() { |
|
|
378 |
|
370 |
List allListeners = new ArrayList(listeners.size() |
379 |
List allListeners = new ArrayList(listeners.size() |
371 |
+ universalListeners.size() + semProcProviders.size()); |
380 |
+ universalListeners.size() + semProcProviders.size()); |
372 |
|
381 |
|
Lines 397-402
Link Here
|
397 |
Iterator j = events.iterator(); |
406 |
Iterator j = events.iterator(); |
398 |
|
407 |
|
399 |
while (j.hasNext()) { |
408 |
while (j.hasNext()) { |
|
|
409 |
|
400 |
Notification event = (Notification) j.next(); |
410 |
Notification event = (Notification) j.next(); |
401 |
|
411 |
|
402 |
if (filter.matches(event)) |
412 |
if (filter.matches(event)) |
Lines 408-415
Link Here
|
408 |
return; |
418 |
return; |
409 |
|
419 |
|
410 |
try { |
420 |
try { |
|
|
421 |
|
411 |
listener.onEvent(eventsToSend); |
422 |
listener.onEvent(eventsToSend); |
|
|
423 |
|
412 |
} catch (Exception e) { |
424 |
} catch (Exception e) { |
|
|
425 |
|
413 |
// this is a bad listener so remove it so the next |
426 |
// this is a bad listener so remove it so the next |
414 |
// listeners can get their events. |
427 |
// listeners can get their events. |
415 |
// bugzilla110334: Do not remove listener as it will cause |
428 |
// bugzilla110334: Do not remove listener as it will cause |
Lines 437-443
Link Here
|
437 |
if (!filter.matches(event)) { |
450 |
if (!filter.matches(event)) { |
438 |
return; |
451 |
return; |
439 |
} |
452 |
} |
440 |
|
453 |
|
441 |
try { |
454 |
try { |
442 |
listener.onEvent(eventsToSend); |
455 |
listener.onEvent(eventsToSend); |
443 |
} catch (Exception e) { |
456 |
} catch (Exception e) { |