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
-
Constructor Summary
ConstructorDescriptionAbstractJsonAdapter
(T model, IUiSession uiSession, String id, IJsonAdapter<?> parent) -
Method Summary
Modifier and TypeMethodDescriptionprotected final JsonEvent
addActionEvent
(String eventName) protected final JsonEvent
addActionEvent
(String eventName, IJsonAdapter<?> referenceAdapter, JSONObject eventData) protected final JsonEvent
addActionEvent
(String eventName, JSONObject eventData) protected JsonEvent
addPropertyChangeEvent
(String propertyName, Object newValue) final <A extends IJsonAdapter<M>,
M>
AattachAdapter
(M model) final <A extends IJsonAdapter<M>,
M>
AattachAdapter
(M model, Predicate<M> filter) final <M> List<IJsonAdapter<?>>
attachAdapters
(Collection<M> models) final <M> List<IJsonAdapter<?>>
attachAdapters
(Collection<M> models, Predicate<M> filter) protected void
Attach child adapters of this adapter instance here by calling theattachAdapter[s](model[s])
methods.protected final <A extends IJsonAdapter<M>,
M>
AattachGlobalAdapter
(M model) A global adapter is registered under the root json adapter and may be used by other adapters.protected final <A extends IJsonAdapter<M>,
M>
AattachGlobalAdapter
(M model, Predicate<M> filter) protected final <M> List<IJsonAdapter<?>>
attachGlobalAdapters
(Collection<M> models) protected final <M> List<IJsonAdapter<?>>
attachGlobalAdapters
(Collection<M> models, Predicate<M> filter) protected void
Override this method in order to attach listeners on the Scout model object.void
An adapter may clean up it's event filters when this method is called after an UI event has been processed.protected void
final void
dispose()
protected void
final <A extends IJsonAdapter<M>,
M>
AgetAdapter
(M model) Returns an existing adapter for the given model.<A extends IJsonAdapter<M>,
M>
AgetAdapter
(M model, Predicate<M> filter) final Collection<IJsonAdapter<?>>
getAdapters
(Collection<?> models) <M> Collection<IJsonAdapter<?>>
getAdapters
(Collection<M> models, Predicate<M> filter) final <A extends IJsonAdapter<M>,
M>
AgetGlobalAdapter
(M model) final <A extends IJsonAdapter<M>,
M>
AgetGlobalAdapter
(M model, Predicate<M> filter) final String
getId()
getModel()
Returns the Scout model object.protected String
Returns a string used to identify the object-type in the JSON output (JSON attribute 'objectType').IJsonAdapter<?>
void
handleUiEvent
(JsonEvent event) protected void
handleUiPropertyChange
(String propertyName, JSONObject data) Override this method to handle property changes from the UI.protected void
handleUiPropertyChange
(JsonEvent event) boolean
hasAncestor
(IJsonAdapter<?> ancestor) void
init()
Init method which is called by the factory after the constructor has been executed.boolean
boolean
void
Consumes all buffered model events, if there are any.protected final <M> JSONObject
putAdapterIdProperty
(JSONObject json, String key, M model) protected final <M> JSONObject
putAdapterIdProperty
(JSONObject json, String key, M model, Predicate<M> filter) protected final <M> JSONObject
putAdapterIdsProperty
(JSONObject json, String key, Collection<M> models) protected final <M> JSONObject
putAdapterIdsProperty
(JSONObject json, String key, Collection<M> models, Predicate<M> filter) protected final JSONObject
putProperty
(JSONObject json, String key, Object value) protected final void
protected final JsonEvent
replaceActionEvent
(String eventName, JSONObject eventData) LikeaddActionEvent(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.toJson()
toString()
protected final void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.scout.rt.ui.html.json.IJsonAdapter
getObjectType
-
Constructor Details
-
AbstractJsonAdapter
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceIJsonAdapter<T>
-
getUiSession
- Specified by:
getUiSession
in interfaceIJsonAdapter<T>
-
getParent
- Specified by:
getParent
in interfaceIJsonAdapter<T>
-
hasAncestor
- Specified by:
hasAncestor
in interfaceIJsonAdapter<T>
-
getModel
Description copied from interface:IJsonAdapter
Returns the Scout model object.- Specified by:
getModel
in interfaceIJsonAdapter<T>
-
attachChildAdapters
protected void attachChildAdapters()Attach child adapters of this adapter instance here by calling theattachAdapter[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 callsattachModel()
andattachChildAdapters()
.- Specified by:
init
in interfaceIJsonAdapter<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 interfaceIJsonAdapter<T>
-
detachModel
protected void detachModel() -
isDisposed
public boolean isDisposed()- Specified by:
isDisposed
in interfaceIJsonAdapter<T>
-
isInitialized
public boolean isInitialized()- Specified by:
isInitialized
in interfaceIJsonAdapter<T>
-
toJson
- Specified by:
toJson
in interfaceIJsonAdapter<T>
- Specified by:
toJson
in interfaceIJsonObject
-
getObjectTypeVariant
Returns a string used to identify the object-type in the JSON output (JSON attribute 'objectType'). UnlikeIJsonAdapter.getObjectType()
, this method returns the object type including the model variant (if set). The resulting string looks like this:"<ObjectType>.<ModelVariant>"
.- See Also:
-
handleUiEvent
- Specified by:
handleUiEvent
in interfaceIJsonAdapter<T>
-
handleUiPropertyChange
-
handleUiPropertyChange
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
-
attachAdapter
- Specified by:
attachAdapter
in interfaceIJsonAdapter<T>
-
attachAdapters
- Specified by:
attachAdapters
in interfaceIJsonAdapter<T>
-
attachAdapters
- Specified by:
attachAdapters
in interfaceIJsonAdapter<T>
-
getAdapter
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 forgetUiSession().getJsonAdapter(model)
.- Specified by:
getAdapter
in interfaceIJsonAdapter<T>
-
getAdapter
- Specified by:
getAdapter
in interfaceIJsonAdapter<T>
-
getAdapters
- Specified by:
getAdapters
in interfaceIJsonAdapter<T>
-
getAdapters
- Specified by:
getAdapters
in interfaceIJsonAdapter<T>
-
getGlobalAdapter
-
getGlobalAdapter
-
attachGlobalAdapters
-
attachGlobalAdapters
protected final <M> List<IJsonAdapter<?>> attachGlobalAdapters(Collection<M> models, Predicate<M> filter) -
attachGlobalAdapter
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
-
putAdapterIdProperty
-
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
-
addActionEvent
-
addActionEvent
-
addActionEvent
protected final JsonEvent addActionEvent(String eventName, IJsonAdapter<?> referenceAdapter, JSONObject eventData) -
registerAsBufferedEventsAdapter
protected final void registerAsBufferedEventsAdapter() -
unregisterAsBufferedEventsAdapter
protected final void unregisterAsBufferedEventsAdapter() -
replaceActionEvent
LikeaddActionEvent(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
-
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 interfaceIJsonAdapter<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 interfaceIJsonAdapter<T>
-
toString
-