use of org.erlide.engine.model.root.IElementChangedListener in project erlide_eclipse by erlang.
the class ErlModelDeltaManager method fire.
/**
* Fire Model deltas, flushing them after the fact. If the firing mode has
* been turned off, this has no effect.
*/
protected void fire(final IErlElementDelta customDeltas, final int eventType) {
if (fFire) {
IErlElementDelta deltaToNotify;
if (customDeltas == null) {
deltaToNotify = mergeDeltas(erlModelDeltas);
} else {
deltaToNotify = customDeltas;
}
final IElementChangedListener[] listeners;
final int listenerCount;
final int[] listenerMask;
// Notification
synchronized (model.elementChangedListeners) {
listeners = new IElementChangedListener[model.elementChangedListeners.size()];
model.elementChangedListeners.toArray(listeners);
listenerCount = listeners.length;
listenerMask = null;
}
switch(eventType) {
case ErlModelDeltaManager.DEFAULT_CHANGE_EVENT:
// firePreAutoBuildDelta(deltaToNotify, listeners, listenerMask,
// listenerCount);
firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
fireReconcileDelta(listeners, listenerMask, listenerCount);
break;
// break;
case ElementChangedEvent.POST_CHANGE:
firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
fireReconcileDelta(listeners, listenerMask, listenerCount);
break;
case ElementChangedEvent.POST_RECONCILE:
fireReconcileDelta(listeners, listenerMask, listenerCount);
break;
case ElementChangedEvent.POST_SHIFT:
fireShiftEvent(deltaToNotify, listeners, listenerMask, listenerCount);
return;
default:
break;
}
}
}
use of org.erlide.engine.model.root.IElementChangedListener in project erlide_eclipse by erlang.
the class ErlModel method notifyListeners.
public void notifyListeners(final IErlElementDelta deltaToNotify, final int eventType, final IElementChangedListener[] listeners, final int[] listenerMask, final int listenerCount) {
final ElementChangedEvent extraEvent = new ElementChangedEvent(deltaToNotify, eventType);
for (int i = 0; i < listenerCount; i++) {
if (listenerMask == null || (listenerMask[i] & eventType) != 0) {
final IElementChangedListener listener = listeners[i];
long start = -1;
if (ModelConfig.verbose) {
// $NON-NLS-1$//$NON-NLS-2$
ErlLogger.debug("Listener #" + (i + 1) + "=" + listener.toString());
start = System.currentTimeMillis();
}
// wrap callbacks with Safe runnable for subsequent listeners to
// be called
// when some are causing grief
SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(final Throwable exception) {
// CCorePlugin.log(exception, "Exception occurred in
// listener of C
// element change notification"); //$NON-NLS-1$
ErlLogger.error(exception);
}
@Override
public void run() throws Exception {
listener.elementChanged(extraEvent);
}
});
if (ModelConfig.verbose) {
// $NON-NLS-1$ //$NON-NLS-2$
ErlLogger.debug(" -> " + (System.currentTimeMillis() - start) + "ms");
}
}
}
}
Aggregations