Class AbstractJsonAdapter<T>

java.lang.Object
org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter<T>
All Implemented Interfaces:
IJsonAdapter<T>, IJsonObject
Direct Known Subclasses:
AbstractJsonPropertyObserver, JsonCalendarComponent, JsonFileChooser, JsonUuidPool

public abstract class AbstractJsonAdapter<T> extends Object implements IJsonAdapter<T>
  • Constructor Details

  • Method Details

    • getId

      public final String getId()
      Specified by:
      getId in interface IJsonAdapter<T>
    • getUiSession

      public IUiSession getUiSession()
      Specified by:
      getUiSession in interface IJsonAdapter<T>
    • getParent

      public IJsonAdapter<?> getParent()
      Specified by:
      getParent in interface IJsonAdapter<T>
    • hasAncestor

      public boolean hasAncestor(IJsonAdapter<?> ancestor)
      Specified by:
      hasAncestor in interface IJsonAdapter<T>
    • getModel

      public T getModel()
      Description copied from interface: IJsonAdapter
      Returns the Scout model object.
      Specified by:
      getModel in interface IJsonAdapter<T>
    • attachChildAdapters

      protected void attachChildAdapters()
      Attach child adapters of this adapter instance here by calling the attachAdapter[s](model[s]) methods. This will also create a new JSON adapter instance when the adapter does not yet exist for the given model.
    • disposeChildAdapters

      protected void disposeChildAdapters()
    • init

      public void init()
      Description copied from interface: IJsonAdapter
      Init method which is called by the factory after the constructor has been executed. The default implementation calls attachModel() and attachChildAdapters().
      Specified by:
      init in interface IJsonAdapter<T>
    • attachModel

      protected void attachModel()
      Override this method in order to attach listeners on the Scout model object. At this point a JsonAdapter instance has been already created for the model object. The default implementation does nothing.
    • dispose

      public final void dispose()
      Specified by:
      dispose in interface IJsonAdapter<T>
    • detachModel

      protected void detachModel()
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface IJsonAdapter<T>
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface IJsonAdapter<T>
    • toJson

      public JSONObject toJson()
      Specified by:
      toJson in interface IJsonAdapter<T>
      Specified by:
      toJson in interface IJsonObject
    • getObjectTypeVariant

      protected String getObjectTypeVariant()
      Returns a string used to identify the object-type in the JSON output (JSON attribute 'objectType'). Unlike IJsonAdapter.getObjectType(), this method returns the object type including the model variant (if set). The resulting string looks like this: "<ObjectType>.<ModelVariant>".
      See Also:
    • handleUiEvent

      public void handleUiEvent(JsonEvent event)
      Specified by:
      handleUiEvent in interface IJsonAdapter<T>
    • handleUiPropertyChange

      protected void handleUiPropertyChange(JsonEvent event)
    • handleUiPropertyChange

      protected void handleUiPropertyChange(String propertyName, JSONObject data)
      Override this method to handle property changes from the UI. You should use the get[Type] methods of the data JSONObject to retrieve the value. The default impl. does nothing.
    • attachAdapter

      public final <A extends IJsonAdapter<M>, M> A attachAdapter(M model)
    • attachAdapter

      public final <A extends IJsonAdapter<M>, M> A attachAdapter(M model, Predicate<M> filter)
      Specified by:
      attachAdapter in interface IJsonAdapter<T>
    • attachAdapters

      public final <M> List<IJsonAdapter<?>> attachAdapters(Collection<M> models)
      Specified by:
      attachAdapters in interface IJsonAdapter<T>
    • attachAdapters

      public final <M> List<IJsonAdapter<?>> attachAdapters(Collection<M> models, Predicate<M> filter)
      Specified by:
      attachAdapters in interface IJsonAdapter<T>
    • getAdapter

      public final <A extends IJsonAdapter<M>, M> A getAdapter(M model)
      Returns an existing adapter for the given model. When no adapter is registered for the given model this method will return null. This method is a shortcut for getUiSession().getJsonAdapter(model).
      Specified by:
      getAdapter in interface IJsonAdapter<T>
    • getAdapter

      public <A extends IJsonAdapter<M>, M> A getAdapter(M model, Predicate<M> filter)
      Specified by:
      getAdapter in interface IJsonAdapter<T>
    • getAdapters

      public final Collection<IJsonAdapter<?>> getAdapters(Collection<?> models)
      Specified by:
      getAdapters in interface IJsonAdapter<T>
    • getAdapters

      public <M> Collection<IJsonAdapter<?>> getAdapters(Collection<M> models, Predicate<M> filter)
      Specified by:
      getAdapters in interface IJsonAdapter<T>
    • getGlobalAdapter

      public final <A extends IJsonAdapter<M>, M> A getGlobalAdapter(M model)
    • getGlobalAdapter

      public final <A extends IJsonAdapter<M>, M> A getGlobalAdapter(M model, Predicate<M> filter)
    • attachGlobalAdapters

      protected final <M> List<IJsonAdapter<?>> attachGlobalAdapters(Collection<M> models)
    • attachGlobalAdapters

      protected final <M> List<IJsonAdapter<?>> attachGlobalAdapters(Collection<M> models, Predicate<M> filter)
    • attachGlobalAdapter

      protected final <A extends IJsonAdapter<M>, M> A attachGlobalAdapter(M model)
      A global adapter is registered under the root json adapter and may be used by other adapters.

      Rule: Always create a global adapter if the model is able to dispose itself (Form, MessageBox, etc). In every other case you have to be very careful. If you dispose a global adapter it may influence others which are using it.

      Global adapters (like every other) get disposed on session disposal.

    • attachGlobalAdapter

      protected final <A extends IJsonAdapter<M>, M> A attachGlobalAdapter(M model, Predicate<M> filter)
    • putAdapterIdProperty

      protected final <M> JSONObject putAdapterIdProperty(JSONObject json, String key, M model)
    • putAdapterIdProperty

      protected final <M> JSONObject putAdapterIdProperty(JSONObject json, String key, M model, Predicate<M> filter)
    • putAdapterIdsProperty

      protected final <M> JSONObject putAdapterIdsProperty(JSONObject json, String key, Collection<M> models)
    • putAdapterIdsProperty

      protected final <M> JSONObject putAdapterIdsProperty(JSONObject json, String key, Collection<M> models, Predicate<M> filter)
    • putProperty

      protected final JSONObject putProperty(JSONObject json, String key, Object value)
    • addActionEvent

      protected final JsonEvent addActionEvent(String eventName)
    • addActionEvent

      protected final JsonEvent addActionEvent(String eventName, JSONObject eventData)
    • addActionEvent

      protected final JsonEvent addActionEvent(String eventName, IJsonAdapter<?> referenceAdapter, JSONObject eventData)
    • registerAsBufferedEventsAdapter

      protected final void registerAsBufferedEventsAdapter()
    • unregisterAsBufferedEventsAdapter

      protected final void unregisterAsBufferedEventsAdapter()
    • replaceActionEvent

      protected final JsonEvent replaceActionEvent(String eventName, JSONObject eventData)
      Like addActionEvent(String, JSONObject) but if there are already action events for the same event in the current response, all existing events are removed before adding the new event.
    • addPropertyChangeEvent

      protected JsonEvent addPropertyChangeEvent(String propertyName, Object newValue)
    • cleanUpEventFilters

      public void cleanUpEventFilters()
      Description copied from interface: IJsonAdapter
      An adapter may clean up it's event filters when this method is called after an UI event has been processed. By default this method does nothing.
      Specified by:
      cleanUpEventFilters in interface IJsonAdapter<T>
    • processBufferedEvents

      public void processBufferedEvents()
      Description copied from interface: IJsonAdapter
      Consumes all buffered model events, if there are any. The buffer will be empty afterwards.
      Specified by:
      processBufferedEvents in interface IJsonAdapter<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object