Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.core.databinding
Class UpdateListStrategy


java.lang.Object
  extended by 
org.eclipse.core.databinding.UpdateListStrategy

public class UpdateListStrategy
extends Object

Customizes a Binding between two observable lists. The following behaviors can be customized via the strategy:

  • Conversion
  • Automatic processing

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).

Since:
1.0
See Also:
DataBindingContext.bindList(IObservableList, IObservableList, UpdateListStrategy, UpdateListStrategy), IConverter

Nested Class Summary
protected static class UpdateStrategy.DefaultConverter
           
 
Field Summary
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 Summary
UpdateListStrategy ()
          Creates a new update list strategy for automatically updating the destination observable list whenever the source observable list changes.
UpdateListStrategy (boolean provideDefaults, int updatePolicy)
          Creates a new update list strategy with a configurable update policy.
UpdateListStrategy (int updatePolicy)
          Creates a new update list strategy with a configurable update policy.
 
Method Summary
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 ( IObservableList observableList, Object element, int index)
          Adds the given element at the given index to the given observable list.
protected   IStatus doMove ( IObservableList observableList, int oldIndex, int newIndex)
          Moves the element in the observable list located at the given old index to the given new index.
protected   IStatus doRemove ( IObservableList observableList, int index)
          Removes the element at the given index from the given observable list.
protected   IStatus doReplace ( IObservableList observableList, int index, Object element)
          Replaces the element in the observable list located at the given index to with the given element.
protected  void fillDefaults ( IObservableList source, IObservableList 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.
  UpdateListStrategy setConverter ( IConverter converter)
          Sets the converter to be invoked when converting added elements from the source element type to the destination element type.
protected  boolean useMoveAndReplace ()
          Returns whether ListBinding should call doMove(IObservableList, int, int) and doReplace(IObservableList, int, Object) instead of paired calls to doRemove(IObservableList, int) and doAdd(IObservableList, Object, int).
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLICY_NEVER

public 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.


POLICY_ON_REQUEST

public 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.


POLICY_UPDATE

public 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.


converter

protected 
IConverter converter

provideDefaults

protected boolean provideDefaults
Constructor Detail

UpdateListStrategy

public UpdateListStrategy()
Creates a new update list strategy for automatically updating the destination observable list whenever the source observable list changes. A default converter will be provided. The defaults can be changed by calling one of the setter methods.


UpdateListStrategy

public UpdateListStrategy(int updatePolicy)
Creates a new update list strategy with a configurable update policy. A default converter will be provided. The defaults can be changed by calling one of the setter methods.

Parameters:
updatePolicy - one of POLICY_NEVER, POLICY_ON_REQUEST, or POLICY_UPDATE

UpdateListStrategy

public UpdateListStrategy(boolean provideDefaults,
                          int updatePolicy)
Creates a new update list strategy with a configurable update policy. A default converter will be provided if provideDefaults is true. The defaults can be changed by calling one of the setter methods.

Parameters:
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
Method Detail

convert

public 
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.

Default implementation will use the converter if one exists. If no converter exists no conversion occurs.

Parameters:
element -
Returns:
the converted element

fillDefaults

protected void fillDefaults(
IObservableList source,
                            
IObservableList destination)
Parameters:
source -
destination -

getUpdatePolicy

public int getUpdatePolicy()
Returns:
the update policy

setConverter

public 
UpdateListStrategy setConverter(
IConverter converter)
Sets the converter to be invoked when converting added elements from the source element type to the destination element type.

Parameters:
converter -
Returns:
the receiver, to enable method call chaining

doAdd

protected 
IStatus doAdd(
IObservableList observableList,
                        
Object element,
                        int index)
Adds the given element at the given index to the given observable list. Clients may extend but must call the super implementation.

Parameters:
observableList -
element -
index -
Returns:
a status

doRemove

protected 
IStatus doRemove(
IObservableList observableList,
                           int index)
Removes the element at the given index from the given observable list. Clients may extend but must call the super implementation.

Parameters:
observableList -
index -
Returns:
a status

useMoveAndReplace

protected boolean useMoveAndReplace()
Returns whether ListBinding should call doMove(IObservableList, int, int) and doReplace(IObservableList, int, Object) instead of paired calls to doRemove(IObservableList, int) and doAdd(IObservableList, Object, int). The default implementation returns true for this class and false for subclasses.

This method is provided for the benefit of subclasses which extend the doAdd(IObservableList, Object, int) and doRemove(IObservableList, int) methods. The doMove(IObservableList, int, int) and doReplace(IObservableList, int, Object) methods were added in version 1.2 so that logically related remove() and add() operations could be combined into a single method call. However to ensure that custom behavior is not lost in existing code, ListBinding is advised by this method whether these new methods may be used.

To enable use of these methods in subclasses, override this method to return true.

Returns:
whether ListBinding should call doMove() and doReplace() instead of paired calls of doRemove() and doAdd()
Since:
1.2
Restriction:
This method is not intended to be referenced by clients.

doMove

protected 
IStatus doMove(
IObservableList observableList,
                         int oldIndex,
                         int newIndex)
Moves the element in the observable list located at the given old index to the given new index.

Parameters:
observableList -
oldIndex -
newIndex -
Returns:
a status
Since:
1.2

doReplace

protected 
IStatus doReplace(
IObservableList observableList,
                            int index,
                            
Object element)
Replaces the element in the observable list located at the given index to with the given element.

Parameters:
observableList -
index -
element -
Returns:
a status
Since:
1.2

checkAssignable

protected final void checkAssignable(
Object toType,
                                     
Object fromType,
                                     
String errorString)

createConverter

protected 
IConverter createConverter(
Object fromType,
                                     
Object toType)
Tries to create a converter that can convert from values of type fromType. Returns null if no converter could be created. Either toType or modelDescription can be null, but not both.

Parameters:
fromType -
toType -
Returns:
an IConverter, or null if unsuccessful

isAssignableFromTo

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.

Parameters:
fromType -
toType -
Returns:
whether fromType is assignable to toType, or null if unknown

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire