org.eclipse.viatra.addon.viewers.runtime.model

## Class ViewerState

- java.lang.Object
- - org.eclipse.viatra.addon.viewers.runtime.model.ViewerState

- All Implemented Interfaces:
    IViewerLabelListener, IViewerStateListener

      public class ViewerState
      extends java.lang.Object
      implements IViewerStateListener, IViewerLabelListener

  A Viewer state represents a stateful data model for a VIATRA Viewer. The state is capable of either returning lists of its content, and is also capable of sending state change notifications based to `IViewerStateListener` implementations.

  A Viewer can be initialized directly with a set of patterns and model, or a `ViatraViewerDataModel` can be used to prepare and share such data between instances.

  A ViewerState needs to be cleaned up using the `dispose()` method to unregister all listeners.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ViewerState.ViewerStateFeature`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Collection<ViewerState.ViewerStateFeature>` | `features`
    `protected ViewerDataFilter` | `filter`
    `protected boolean` | `hasExternalViewerDataModel` If true, then the viewerstate has an "external" model that should not be disposed internally.
    `protected java.util.Collection<IViewerLabelListener>` | `labelListeners`
    `protected ViewModelManager` | `manager`
    `protected ViewerDataModel` | `model`
    `protected java.util.Collection<IViewerStateListener>` | `stateListeners`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ViewerState(ViewerDataModel model, ViewerDataFilter filter, java.util.Collection<ViewerState.ViewerStateFeature> features)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLabelListener(IViewerLabelListener listener)` Adds a new label Listener to the Viewer State
    `void` | `addStateListener(IViewerStateListener listener)` Adds a new state Listener to the Viewer State
    `void` | `containmentAppeared(Containment containment)`
    `void` | `containmentDisappeared(Containment containment)`
    `void` | `dispose()`
    `void` | `edgeAppeared(Edge edge)`
    `void` | `edgeDisappeared(Edge edge)`
    `java.util.Collection<Item>` | `getChildren(Item parent)`
    `java.util.Collection<Containment>` | `getContainments()`
    `java.util.Collection<Edge>` | `getEdges()`
    `ViatraQueryEngine` | `getEngine()`
    `java.util.Collection<Item>` | `getItems()`
    `java.util.Collection<Item>` | `getItemsFor(java.lang.Object target)` Access the Set of Items mapped to an EObject.
    `ViewModelManager` | `getManager()`
    `NotationModel` | `getNotationModel()`
    `Item` | `getParent(Item child)`
    `Traceability` | `getTraceability()`
    `boolean` | `isDisposed()`
    `void` | `itemAppeared(Item item)`
    `void` | `itemDisappeared(Item item)`
    `void` | `labelUpdated(Edge edge, java.lang.String newLabel)`
    `void` | `labelUpdated(Item item, java.lang.String newLabel)`
    `void` | `removeLabelListener(IViewerLabelListener listener)` Removes a label Listener from the Viewer State
    `void` | `removeStateListener(IViewerStateListener listener)` Removes a state Listener from the Viewer State

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### hasExternalViewerDataModel

          protected boolean hasExternalViewerDataModel

      If true, then the viewerstate has an "external" model that should not be disposed internally.

    - #### model

          protected ViewerDataModel model

    - #### filter

          protected ViewerDataFilter filter

    - #### features

          protected java.util.Collection<ViewerState.ViewerStateFeature> features

    - #### manager

          protected ViewModelManager manager

    - #### stateListeners

          protected java.util.Collection<IViewerStateListener> stateListeners

    - #### labelListeners

          protected java.util.Collection<IViewerLabelListener> labelListeners

  - ### Constructor Detail

    - #### ViewerState

          public ViewerState(ViewerDataModel model,
                             ViewerDataFilter filter,
                             java.util.Collection<ViewerState.ViewerStateFeature> features)

  - ### Method Detail

    - #### getChildren

          public java.util.Collection<Item> getChildren(Item parent)

    - #### getParent

          public Item getParent(Item child)

    - #### itemAppeared

          public final void itemAppeared(Item item)

      Specified by:
        `itemAppeared` in interface `IViewerStateListener`

    - #### itemDisappeared

          public final void itemDisappeared(Item item)

      Specified by:
        `itemDisappeared` in interface `IViewerStateListener`

    - #### containmentAppeared

          public final void containmentAppeared(Containment containment)

      Specified by:
        `containmentAppeared` in interface `IViewerStateListener`

    - #### containmentDisappeared

          public final void containmentDisappeared(Containment containment)

      Specified by:
        `containmentDisappeared` in interface `IViewerStateListener`

    - #### edgeAppeared

          public final void edgeAppeared(Edge edge)

      Specified by:
        `edgeAppeared` in interface `IViewerStateListener`

    - #### edgeDisappeared

          public final void edgeDisappeared(Edge edge)

      Specified by:
        `edgeDisappeared` in interface `IViewerStateListener`

    - #### labelUpdated

          public final void labelUpdated(Item item,
                                         java.lang.String newLabel)

      Specified by:
        `labelUpdated` in interface `IViewerLabelListener`

    - #### labelUpdated

          public final void labelUpdated(Edge edge,
                                         java.lang.String newLabel)

      Specified by:
        `labelUpdated` in interface `IViewerLabelListener`

    - #### addStateListener

          public void addStateListener(IViewerStateListener listener)

      Adds a new state Listener to the Viewer State

    - #### removeStateListener

          public void removeStateListener(IViewerStateListener listener)

      Removes a state Listener from the Viewer State

    - #### addLabelListener

          public void addLabelListener(IViewerLabelListener listener)

      Adds a new label Listener to the Viewer State

    - #### removeLabelListener

          public void removeLabelListener(IViewerLabelListener listener)

      Removes a label Listener from the Viewer State

    - #### getItemsFor

          public java.util.Collection<Item> getItemsFor(java.lang.Object target)

      Access the Set of Items mapped to an EObject.

    - #### getItems

          public java.util.Collection<Item> getItems()

    - #### getEdges

          public java.util.Collection<Edge> getEdges()

    - #### getContainments

          public java.util.Collection<Containment> getContainments()

    - #### getManager

          public ViewModelManager getManager()

    - #### getNotationModel

          public NotationModel getNotationModel()

    - #### getTraceability

          public Traceability getTraceability()

    - #### getEngine

          public ViatraQueryEngine getEngine()

    - #### dispose

          public void dispose()

    - #### isDisposed

          public boolean isDisposed()