Package org.jetbrains.mps.openapi.model
Interface SModelListener
-
- All Known Implementing Classes:
SModelListenerBase
,SRepositoryContentAdapter
public interface SModelListener
This interface can be implemented to track model state. Generally, we try to send most specific event only, e.g. if a model content is replaced, we likely to send onlymodelReplaced(SModel)
, not a sequence ofmodelUnloaded(SModel)
,modelLoaded(SModel, boolean)
,modelReplaced(SModel)
. However, at the moment we do not ensure this, and chances are you get different sequence for different models. FIXME we lack tests that state aforementioned contract for notifications. FIXME may be useful to provide modelChanged() notification to avoid attaching node change listeners just to figure out if model has been changed. Event makes sense for EditableSModel only, perhaps, could be a separate listener, then?
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
conflictDetected(SModel model)
This event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()).void
modelAttached(SModel model, SRepository repository)
Fired when a model becomes visible in a repository.void
modelDetached(SModel model, SRepository repository)
Fired when a model is no longer part of a repository, e.g.void
modelLoaded(SModel model, boolean partially)
void
modelReplaced(SModel model)
void
modelSaved(SModel model)
void
modelUnloaded(SModel model)
void
problemsDetected(SModel model, Iterable<SModel.Problem> problems)
This method is called each time a new problem, or a set of problems is discovered.
-
-
-
Method Detail
-
modelLoaded
void modelLoaded(SModel model, boolean partially)
-
modelReplaced
void modelReplaced(SModel model)
-
modelUnloaded
void modelUnloaded(SModel model)
-
modelSaved
void modelSaved(SModel model)
-
modelAttached
void modelAttached(SModel model, SRepository repository)
Fired when a model becomes visible in a repository. IMPORTANT: it's unspecified whether the model is part of a module the moment this event is fired or not. Do not expectSModel.getModule()
to give meaningful value. This contract may change (i.e. become stricter) in future. NOTE: This is not an event most clients could make use of, as it's technically tricky to attach a listener to a model not yet visible inside a repository, and thus it's more of internal mechanism (i.e. code that instantiates a model may attach a listener to not yet published model and thus get notified). Besides, detached models do not get their listeners automatically discarded, and the listeners get a chance to react to model detach/re-attach sequence with this event.- Parameters:
model
- affected model, nevernull
repository
- repository the model become available at, nevernull
-
modelDetached
void modelDetached(SModel model, SRepository repository)
Fired when a model is no longer part of a repository, e.g. due to removal from module. This event is intended to clean-up listener caches associated with the model and to gracefully unregister other listeners. IMPORTANT: it's unspecified whether the model is part of a module the moment this event is fired or not. Do not expectSModel.getModule()
to give meaningful value. This contract may change (i.e. become stricter) in future. Primary drive force for this event is desire to add model listener only, without a need to listen to module events to find out when the model is no longer available. Note, listeners not unregistered from the model would get notified withmodelAttached(SModel, SRepository)
in case detached model is brought back (perhaps, in completely different module and repository).- Parameters:
model
- affected model, nevernull
repository
- repository the model become available at, nevernull
-
conflictDetected
void conflictDetected(SModel model)
This event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()). An IDE can listen to it and give user a way to resolve the conflict by invoking either updateTimestamp(), or reloadFromSource().
-
problemsDetected
void problemsDetected(SModel model, Iterable<SModel.Problem> problems)
This method is called each time a new problem, or a set of problems is discovered.
-
-