Package org.jetbrains.mps.openapi.module
Class SRepositoryContentAdapter
- java.lang.Object
-
- org.jetbrains.mps.openapi.module.SModuleListenerBase
-
- org.jetbrains.mps.openapi.module.SRepositoryContentAdapter
-
- All Implemented Interfaces:
SModelListener
,SNodeAccessListener
,SNodeChangeListener
,SModuleListener
,SRepositoryAttachListener
,SRepositoryListener
public class SRepositoryContentAdapter extends SModuleListenerBase implements SModelListener, SModuleListener, SRepositoryListener, SRepositoryAttachListener, SNodeChangeListener, SNodeAccessListener
This class serves as a convenient implementation of all repository listeners at once. In addition it tracks all objects (modules, models and nodes) as they come and leave the repository.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SRepositoryContentAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeModelRemoved(SModule module, SModel model)
void
beforeModuleRemoved(SModule module)
void
commandFinished(SRepository repository)
void
commandStarted(SRepository repository)
Notifications about commands in aModelAccess
associated with the repository.void
conflictDetected(SModel model)
This event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()).protected boolean
isIncluded(SModule module)
void
modelAdded(SModule module, SModel model)
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
modelRemoved(SModule module, SModelReference ref)
Model is removed from a repository.void
modelReplaced(SModel model)
void
modelSaved(SModel model)
void
modelUnloaded(SModel model)
void
moduleAdded(SModule module)
void
moduleChanged(SModule module)
Any change including module dependencies and descriptor reload from diskvoid
moduleRemoved(SModuleReference module)
void
nodeAdded(SNodeAddEvent event)
void
nodeRead(SNodeReadEvent event)
void
nodeRemoved(SNodeRemoveEvent event)
void
problemsDetected(SModel model, Iterable<SModel.Problem> problems)
This method is called each time a new problem, or a set of problems is discovered.void
propertyChanged(SPropertyChangeEvent event)
void
propertyRead(SPropertyReadEvent event)
void
referenceChanged(SReferenceChangeEvent event)
void
referenceRead(SReferenceReadEvent event)
void
repositoryChanged()
Handy notification about change in repository structure, namely added/removed modules and models.protected void
startListening(SModel model)
no-op by default.protected void
startListening(SModule module)
void
startListening(SRepository repository)
protected void
stopListening(SModel model)
no-op by defaultprotected void
stopListening(SModule module)
void
stopListening(SRepository repository)
void
subscribeTo(SRepository repository)
void
unsubscribeFrom(SRepository repository)
-
Methods inherited from class org.jetbrains.mps.openapi.module.SModuleListenerBase
beforeModelRenamed, dependencyAdded, dependencyRemoved, languageAdded, languageRemoved, modelRenamed, moduleRenamed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jetbrains.mps.openapi.module.SModuleListener
beforeModelRenamed, dependencyAdded, dependencyRemoved, languageAdded, languageRemoved, modelRenamed, moduleRenamed
-
Methods inherited from interface org.jetbrains.mps.openapi.module.SRepositoryListener
repositoryCommandFinished, repositoryCommandStarted, updateFinished, updateStarted
-
-
-
-
Method Detail
-
subscribeTo
public void subscribeTo(SRepository repository)
-
unsubscribeFrom
public void unsubscribeFrom(SRepository repository)
-
startListening
public void startListening(@NotNull SRepository repository)
- Specified by:
startListening
in interfaceSRepositoryAttachListener
-
stopListening
public void stopListening(@NotNull SRepository repository)
- Specified by:
stopListening
in interfaceSRepositoryAttachListener
-
startListening
protected void startListening(SModule module)
-
stopListening
protected void stopListening(SModule module)
-
startListening
protected void startListening(@NotNull SModel model)
no-op by default. Subclasses that wish to get model/node change/access events, shall add appropriate listeners here. These listeners are implemented by this class only for convenience, events are not dispatched unless proper listener is explicitly attached.
-
isIncluded
protected boolean isIncluded(SModule module)
- Returns:
- always
true
-
moduleAdded
public void moduleAdded(@NotNull SModule module)
- Specified by:
moduleAdded
in interfaceSRepositoryListener
-
beforeModuleRemoved
public void beforeModuleRemoved(@NotNull SModule module)
- Specified by:
beforeModuleRemoved
in interfaceSRepositoryListener
-
moduleRemoved
public void moduleRemoved(@NotNull SModuleReference module)
- Specified by:
moduleRemoved
in interfaceSRepositoryListener
-
commandStarted
public void commandStarted(SRepository repository)
Description copied from interface:SRepositoryListener
Notifications about commands in aModelAccess
associated with the repository. It's convenient to have command notifications right in SRepositoryListener implementation, like RepositoryChangeTracker (the one where all changes within a command are collected), rather than have distinctCommandListener
. UnlikeCommandListener
, gives context repository to facilitate use of the same listener instance among different repositories.- Specified by:
commandStarted
in interfaceSRepositoryListener
- See Also:
CommandListener.commandStarted()
-
commandFinished
public void commandFinished(SRepository repository)
- Specified by:
commandFinished
in interfaceSRepositoryListener
- See Also:
CommandListener.commandFinished()
-
moduleChanged
public void moduleChanged(SModule module)
Description copied from interface:SModuleListener
Any change including module dependencies and descriptor reload from disk- Specified by:
moduleChanged
in interfaceSModuleListener
- Overrides:
moduleChanged
in classSModuleListenerBase
-
modelAdded
public void modelAdded(SModule module, SModel model)
- Specified by:
modelAdded
in interfaceSModuleListener
- Overrides:
modelAdded
in classSModuleListenerBase
-
beforeModelRemoved
public void beforeModelRemoved(SModule module, SModel model)
- Specified by:
beforeModelRemoved
in interfaceSModuleListener
- Overrides:
beforeModelRemoved
in classSModuleListenerBase
-
modelRemoved
public void modelRemoved(SModule module, SModelReference ref)
Description copied from interface:SModuleListener
Model is removed from a repository. Note, it doesn't necessarily mean model was deleted. Does NOT come for module's models when module is being un-registered from a repository- Specified by:
modelRemoved
in interfaceSModuleListener
- Overrides:
modelRemoved
in classSModuleListenerBase
-
modelLoaded
public void modelLoaded(SModel model, boolean partially)
- Specified by:
modelLoaded
in interfaceSModelListener
-
modelReplaced
public void modelReplaced(SModel model)
- Specified by:
modelReplaced
in interfaceSModelListener
-
modelUnloaded
public void modelUnloaded(SModel model)
- Specified by:
modelUnloaded
in interfaceSModelListener
-
modelSaved
public void modelSaved(SModel model)
- Specified by:
modelSaved
in interfaceSModelListener
-
conflictDetected
public void conflictDetected(SModel model)
Description copied from interface:SModelListener
This event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()).- Specified by:
conflictDetected
in interfaceSModelListener
-
problemsDetected
public void problemsDetected(SModel model, Iterable<SModel.Problem> problems)
Description copied from interface:SModelListener
This method is called each time a new problem, or a set of problems is discovered.- Specified by:
problemsDetected
in interfaceSModelListener
-
modelAttached
public void modelAttached(SModel model, SRepository repository)
Description copied from interface:SModelListener
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.- Specified by:
modelAttached
in interfaceSModelListener
- Parameters:
model
- affected model, nevernull
repository
- repository the model become available at, nevernull
-
modelDetached
public void modelDetached(SModel model, SRepository repository)
Description copied from interface:SModelListener
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 withSModelListener.modelAttached(SModel, SRepository)
in case detached model is brought back (perhaps, in completely different module and repository).- Specified by:
modelDetached
in interfaceSModelListener
- Parameters:
model
- affected model, nevernull
repository
- repository the model become available at, nevernull
-
repositoryChanged
public void repositoryChanged()
Handy notification about change in repository structure, namely added/removed modules and models. For unknown reason also notifies about'unspecified'
module changes no-op by default.
-
nodeRead
public void nodeRead(@NotNull SNodeReadEvent event)
- Specified by:
nodeRead
in interfaceSNodeAccessListener
-
propertyRead
public void propertyRead(@NotNull SPropertyReadEvent event)
- Specified by:
propertyRead
in interfaceSNodeAccessListener
-
referenceRead
public void referenceRead(@NotNull SReferenceReadEvent event)
- Specified by:
referenceRead
in interfaceSNodeAccessListener
-
propertyChanged
public void propertyChanged(@NotNull SPropertyChangeEvent event)
- Specified by:
propertyChanged
in interfaceSNodeChangeListener
-
referenceChanged
public void referenceChanged(@NotNull SReferenceChangeEvent event)
- Specified by:
referenceChanged
in interfaceSNodeChangeListener
-
nodeAdded
public void nodeAdded(@NotNull SNodeAddEvent event)
- Specified by:
nodeAdded
in interfaceSNodeChangeListener
-
nodeRemoved
public void nodeRemoved(@NotNull SNodeRemoveEvent event)
- Specified by:
nodeRemoved
in interfaceSNodeChangeListener
-
-