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 only modelReplaced(SModel), not a sequence of modelUnloaded(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 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 expect SModel.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, never null
        repository - repository the model become available at, never null
      • 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 expect SModel.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 with modelAttached(SModel, SRepository) in case detached model is brought back (perhaps, in completely different module and repository).

        Parameters:
        model - affected model, never null
        repository - repository the model become available at, never null
      • 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.