public class UpdateSetStrategy extends Object
Binding
between two observable
sets
. The following behaviors can be customized via the strategy:
Conversion:
When elements are added they can be converted
to the
destination element type.
Automatic processing:
The processing to perform when the source observable changes. This behavior
is configured via policies provided on construction of the strategy (e.g.
POLICY_NEVER
, POLICY_ON_REQUEST
, POLICY_UPDATE
).
Modifier and Type | Field and Description |
---|---|
protected IConverter |
converter |
static int |
POLICY_NEVER
Policy constant denoting that the source observable's state should not be
tracked and that the destination observable's state should never be
updated.
|
static int |
POLICY_ON_REQUEST
Policy constant denoting that the source observable's state should not be
tracked, but that conversion and updating the destination observable's
state should be performed when explicitly requested.
|
static int |
POLICY_UPDATE
Policy constant denoting that the source observable's state should be
tracked, and that conversion and updating the destination observable's
state should be performed automatically on every change of the source
observable state.
|
protected boolean |
provideDefaults |
Constructor and Description |
---|
UpdateSetStrategy()
Creates a new update list strategy for automatically updating the
destination observable list whenever the source observable list changes.
|
UpdateSetStrategy(boolean provideDefaults,
int updatePolicy)
Creates a new update list strategy with a configurable update policy.
|
UpdateSetStrategy(int updatePolicy)
Creates a new update list strategy with a configurable update policy.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkAssignable(Object toType,
Object fromType,
String errorString) |
Object |
convert(Object element)
When an element is added to the destination converts the element from the
source element type to the destination element type.
|
protected IConverter |
createConverter(Object fromType,
Object toType)
Tries to create a converter that can convert from values of type
fromType.
|
protected IStatus |
doAdd(IObservableSet observableSet,
Object element)
Adds the given element at the given index to the given observable list.
|
protected IStatus |
doRemove(IObservableSet observableSet,
Object element)
Removes the element at the given index from the given observable list.
|
protected void |
fillDefaults(IObservableSet source,
IObservableSet destination) |
int |
getUpdatePolicy() |
protected Boolean |
isAssignableFromTo(Object fromType,
Object toType)
Returns
Boolean.TRUE if the from type is assignable to the to
type, or Boolean.FALSE if it not, or null if
unknown. |
UpdateSetStrategy |
setConverter(IConverter converter)
Sets the converter to be invoked when converting added elements from the
source element type to the destination element type.
|
public static final int POLICY_NEVER
public static final int POLICY_ON_REQUEST
public static final int POLICY_UPDATE
protected IConverter converter
protected boolean provideDefaults
public UpdateSetStrategy()
public UpdateSetStrategy(int updatePolicy)
updatePolicy
- one of POLICY_NEVER
, POLICY_ON_REQUEST
, or
POLICY_UPDATE
public UpdateSetStrategy(boolean provideDefaults, int updatePolicy)
provideDefaults
is
true
. The defaults can be changed by calling one of the
setter methods.provideDefaults
- if true
, default validators and a default
converter will be provided based on the observable list's
type.updatePolicy
- one of POLICY_NEVER
, POLICY_ON_REQUEST
, or
POLICY_UPDATE
public Object convert(Object element)
Default implementation will use the converter
if one exists. If no converter exists no conversion occurs.
element
- protected void fillDefaults(IObservableSet source, IObservableSet destination)
source
- destination
- public int getUpdatePolicy()
public UpdateSetStrategy setConverter(IConverter converter)
converter
- protected IStatus doAdd(IObservableSet observableSet, Object element)
observableSet
- element
- protected IStatus doRemove(IObservableSet observableSet, Object element)
observableSet
- element
- protected final void checkAssignable(Object toType, Object fromType, String errorString)
protected IConverter createConverter(Object fromType, Object toType)
null
if no converter could be created.
Either toType or modelDescription can be null
, but not
both.fromType
- toType
- null
if unsuccessfulprotected Boolean isAssignableFromTo(Object fromType, Object toType)
Boolean.TRUE
if the from type is assignable to the to
type, or Boolean.FALSE
if it not, or null
if
unknown.fromType
- toType
- null
if unknown
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.