ilog.cpl.tree
Class IlpDefaultTreeSelectionModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeSelectionModel
      extended by ilog.cpl.tree.IlpDefaultTreeSelectionModel
All Implemented Interfaces:
IlpTreeSelectionModel, IlpObjectSelectionModel, IlpRepresentationObjectSelectionModel, Serializable, Cloneable, TreeSelectionModel

public class IlpDefaultTreeSelectionModel
extends DefaultTreeSelectionModel
implements IlpTreeSelectionModel

Default implementation of IlpTreeSelectionModel. This model maintains the selection of IlpObjects as well as IlpRepresentationObjects.

In addition to the common TreePath and Row interfaces, Object and RepresentationObject interfaces are provided, which allows you to manipulate the selection of IlpObjects and IlpTreeNodes directly. ILOG strongly discourages the use of the Row interface and the CONTIGUOUS_TREE_SELECTION mode with IlpTreeView. In particular, you should be aware that the Row interface ignores the hidden nodes (descendants of collapsed nodes). So a node that is selected but hidden will not be returned by getSelectionRows(). In addition, contiguity is based on the expanded nodes, so you may lose selected hidden nodes when using CONTIGUOUS_TREE_SELECTION.

Since:
JTGO 3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeSelectionModel
changeSupport, leadIndex, leadPath, leadRow, listenerList, listSelectionModel, rowMapper, selection, SELECTION_MODE_PROPERTY, selectionMode
 
Fields inherited from interface javax.swing.tree.TreeSelectionModel
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION
 
Constructor Summary
IlpDefaultTreeSelectionModel()
          Creates a new instance of IlpTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION.
 
Method Summary
 void addSelectionObject(IlpObject object)
          Adds the given IlpObject to the selection.
 void addSelectionRepresentationObject(IlpRepresentationObject object)
          Adds object to the current selection.
 void addSelectionRepresentationObjects(Collection objects)
          Adds objects to the current selection.
 IlpRepresentationObject getLeadSelectionRepresentationObject()
          Returns the last object that was added.
 IlpRepresentationObjectMapper getRepresentationObjectMapper()
          Returns the IlpRepresentationObjectMapper used to find the IlpRepresentationObject associated with an IlpObject.
 IlpObject getSelectedObject()
          Returns the first selected IlpObject from the collection of selected objects.
 Collection getSelectedObjects()
          Returns the set of selected IlpObjects.
 IlpRepresentationObject getSelectedRepresentationObject()
          Returns the first object in the selection.
 Collection getSelectedRepresentationObjects()
          Returns the objects in the selection.
 TreePath getTreePathFor(IlpRepresentationObject object)
          Returns the tree path corresponding to a given representation object.
 TreePath[] getTreePathsFor(Collection objects)
          Returns the tree paths corresponding to a given set of representation objects.
 boolean isObjectSelected(IlpObject object)
          Returns true if the given IlpObject is selected, false otherwise.
 boolean isRepresentationObjectSelected(IlpRepresentationObject object)
          Returns true if object is in the current selection.
 void removeSelectionObject(IlpObject object)
          Removes the given IlpObject from the selection.
 void removeSelectionRepresentationObject(IlpRepresentationObject object)
          Removes object from the selection.
 void removeSelectionRepresentationObjects(Collection objects)
          Removes objects from the selection.
 void setRepresentationObjectMapper(IlpRepresentationObjectMapper representationObjectMapper)
          Sets the IlpRepresentationObjectMapper which will be used to find the IlpRepresentationObject associated with an IlpObject.
 void setSelectedObject(IlpObject object)
          Sets the selected IlpObject.
 void setSelectedObjects(Collection objects)
          Sets the set of selected IlpObjects.
 void setSelectedRepresentationObject(IlpRepresentationObject object)
          Sets the selection to object.
 void setSelectedRepresentationObjects(Collection objects)
          Sets the selection to the representation objects in objects.
 void setSelectionRepresentationObject(IlpRepresentationObject object)
          Deprecated. Please use setSelectedRepresentationObject instead.
 void setSelectionRepresentationObjects(Collection objects)
          Deprecated. Please use setSelectedRepresentationObjects instead.
 
Methods inherited from class javax.swing.tree.DefaultTreeSelectionModel
addPropertyChangeListener, addSelectionPath, addSelectionPaths, addTreeSelectionListener, arePathsContiguous, canPathsBeAdded, canPathsBeRemoved, clearSelection, clone, fireValueChanged, getLeadSelectionPath, getLeadSelectionRow, getListeners, getMaxSelectionRow, getMinSelectionRow, getPropertyChangeListeners, getRowMapper, getSelectionCount, getSelectionMode, getSelectionPath, getSelectionPaths, getSelectionRows, getTreeSelectionListeners, insureRowContinuity, insureUniqueness, isPathSelected, isRowSelected, isSelectionEmpty, notifyPathChange, removePropertyChangeListener, removeSelectionPath, removeSelectionPaths, removeTreeSelectionListener, resetRowSelection, setRowMapper, setSelectionMode, setSelectionPath, setSelectionPaths, toString, updateLeadIndex
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeSelectionModel
addPropertyChangeListener, addSelectionPath, addSelectionPaths, addTreeSelectionListener, clearSelection, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getRowMapper, getSelectionCount, getSelectionMode, getSelectionPath, getSelectionPaths, getSelectionRows, isPathSelected, isRowSelected, isSelectionEmpty, removePropertyChangeListener, removeSelectionPath, removeSelectionPaths, removeTreeSelectionListener, resetRowSelection, setRowMapper, setSelectionMode, setSelectionPath, setSelectionPaths
 
Methods inherited from interface ilog.cpl.util.selection.IlpRepresentationObjectSelectionModel
clearSelection
 
Methods inherited from interface ilog.cpl.util.selection.IlpObjectSelectionModel
clearSelection
 

Constructor Detail

IlpDefaultTreeSelectionModel

public IlpDefaultTreeSelectionModel()
Creates a new instance of IlpTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION.

Method Detail

addSelectionRepresentationObject

public void addSelectionRepresentationObject(IlpRepresentationObject object)
Adds object to the current selection. If object is not currently in the selection the TreeSelectionListeners are notified. This has no effect if object is null.

Specified by:
addSelectionRepresentationObject in interface IlpRepresentationObjectSelectionModel
Parameters:
object - The new object to add to the current selection.

addSelectionRepresentationObjects

public void addSelectionRepresentationObjects(Collection objects)
Adds objects to the current selection. If any of the representation objects in objects are not currently in the selection the TreeSelectionListeners are notified. This has no effect if objects is null.

The lead path is set to the last element in objects.

If the selection mode is CONTIGUOUS_TREE_SELECTION and adding the new objects would make the selection discontiguous, one of two situations may occur: if the IlpRepresentationObjects in objects are contiguous, these IlpRepresentationObjects will become the selection; otherwise, the IlpRepresentationObjects are not contiguous and the first IlpRepresentationObject in objects becomes the selection.

Specified by:
addSelectionRepresentationObjects in interface IlpTreeSelectionModel
Parameters:
objects - The new objects to add to the current selection.

removeSelectionRepresentationObject

public void removeSelectionRepresentationObject(IlpRepresentationObject object)
Removes object from the selection. If object is in the selection, the TreeSelectionListeners are notified. This has no effect if object is null.

Specified by:
removeSelectionRepresentationObject in interface IlpRepresentationObjectSelectionModel
Parameters:
object - The object to remove from the selection.

removeSelectionRepresentationObjects

public void removeSelectionRepresentationObjects(Collection objects)
Removes objects from the selection. If any of the objects in objects are in the selection the TreeSelectionListeners are notified. This has no effect if objects is null.

Specified by:
removeSelectionRepresentationObjects in interface IlpTreeSelectionModel
Specified by:
removeSelectionRepresentationObjects in interface IlpRepresentationObjectSelectionModel
Parameters:
objects - The objects to remove from the selection.

setSelectionRepresentationObject

public void setSelectionRepresentationObject(IlpRepresentationObject object)
Deprecated. Please use setSelectedRepresentationObject instead.

Sets the selection to object. If this represents a change, then the TreeSelectionListeners are notified. If object is null, this has the same effect as invoking clearSelection.

Specified by:
setSelectionRepresentationObject in interface IlpTreeSelectionModel
Parameters:
object - New object to select.
Deprecated Since:
JTGO 4.0

setSelectedRepresentationObject

public void setSelectedRepresentationObject(IlpRepresentationObject object)
Sets the selection to object. If this represents a change, then the TreeSelectionListeners are notified. If object is null, this has the same effect as invoking clearSelection.

Specified by:
setSelectedRepresentationObject in interface IlpTreeSelectionModel
Specified by:
setSelectedRepresentationObject in interface IlpRepresentationObjectSelectionModel
Parameters:
object - New object to select.
Since:
JTGO 4.0

getSelectedRepresentationObjects

public Collection getSelectedRepresentationObjects()
Returns the objects in the selection. This will return an empty collection if nothing is currently selected.

Specified by:
getSelectedRepresentationObjects in interface IlpRepresentationObjectSelectionModel
Returns:
an unmodifiable Collection of IlpRepresentationObjects

getSelectedRepresentationObject

public IlpRepresentationObject getSelectedRepresentationObject()
Returns the first object in the selection. This is useful if there if only one item currently selected.

Specified by:
getSelectedRepresentationObject in interface IlpRepresentationObjectSelectionModel
Returns:
the first selected representation object, or null if the selection is empty.

setSelectionRepresentationObjects

public void setSelectionRepresentationObjects(Collection objects)
Deprecated. Please use setSelectedRepresentationObjects instead.

Sets the selection to the representation objects in objects. If this represents a change the TreeSelectionListeners are notified.

If objects is null, this has the same effect as invoking clearSelection.

The lead path is set to the last object in objects.

If the selection mode is CONTIGUOUS_TREE_SELECTION and adding the new objects would make the selection discontiguous, the selection will be reset to the first IlpRepresentationObject in objects.

Specified by:
setSelectionRepresentationObjects in interface IlpTreeSelectionModel
Parameters:
objects - New selection.
Deprecated Since:
JTGO 4.0

setSelectedRepresentationObjects

public void setSelectedRepresentationObjects(Collection objects)
Sets the selection to the representation objects in objects. If this represents a change the TreeSelectionListeners are notified.

If objects is null, this has the same effect as invoking clearSelection.

The lead path is set to the last object in objects.

If the selection mode is CONTIGUOUS_TREE_SELECTION and adding the new objects would make the selection discontiguous, the selection will be reset to the first IlpRepresentationObject in objects.

Specified by:
setSelectedRepresentationObjects in interface IlpRepresentationObjectSelectionModel
Parameters:
objects - New selection.

isRepresentationObjectSelected

public boolean isRepresentationObjectSelected(IlpRepresentationObject object)
Returns true if object is in the current selection.

Specified by:
isRepresentationObjectSelected in interface IlpRepresentationObjectSelectionModel
Parameters:
object - The representation object that may be selected.

getLeadSelectionRepresentationObject

public IlpRepresentationObject getLeadSelectionRepresentationObject()
Returns the last object that was added.

Specified by:
getLeadSelectionRepresentationObject in interface IlpTreeSelectionModel

getTreePathFor

public TreePath getTreePathFor(IlpRepresentationObject object)
Returns the tree path corresponding to a given representation object.

Parameters:
object - The representation object whose tree path is required.

getTreePathsFor

public TreePath[] getTreePathsFor(Collection objects)
Returns the tree paths corresponding to a given set of representation objects.

Parameters:
objects - The representation objects whose tree paths are required.

getSelectedObject

public IlpObject getSelectedObject()
Returns the first selected IlpObject from the collection of selected objects. Returns null if there is no selected object.

Specified by:
getSelectedObject in interface IlpObjectSelectionModel

getSelectedObjects

public Collection getSelectedObjects()
Returns the set of selected IlpObjects. The set should be ordered if the component implementing this interface supports an ordered selection. Returns an empty set if there is no selected object.

Specified by:
getSelectedObjects in interface IlpObjectSelectionModel
Returns:
An unmodifiable Collection of IlpObjects.

setSelectedObject

public void setSelectedObject(IlpObject object)
Sets the selected IlpObject. This has no effect if the given object is already selected.

Specified by:
setSelectedObject in interface IlpObjectSelectionModel
Parameters:
object - The object that will become the selection.
Since:
JTGO 4.0

setSelectedObjects

public void setSelectedObjects(Collection objects)
Sets the set of selected IlpObjects.

Specified by:
setSelectedObjects in interface IlpObjectSelectionModel
Parameters:
objects - The collection of objects that will become the selection.
Since:
JTGO 4.0

isObjectSelected

public boolean isObjectSelected(IlpObject object)
Returns true if the given IlpObject is selected, false otherwise.

Specified by:
isObjectSelected in interface IlpObjectSelectionModel
Parameters:
object - The object which may be selected.

addSelectionObject

public void addSelectionObject(IlpObject object)
Adds the given IlpObject to the selection. This has no effect if the given object is null.

Specified by:
addSelectionObject in interface IlpObjectSelectionModel
Parameters:
object - The object that will be added to the selection.

removeSelectionObject

public void removeSelectionObject(IlpObject object)
Removes the given IlpObject from the selection. This has no effect if the given object is null.

Specified by:
removeSelectionObject in interface IlpObjectSelectionModel
Parameters:
object - The object that will be removed from the selection.

setRepresentationObjectMapper

public void setRepresentationObjectMapper(IlpRepresentationObjectMapper representationObjectMapper)
Sets the IlpRepresentationObjectMapper which will be used to find the IlpRepresentationObject associated with an IlpObject.

Specified by:
setRepresentationObjectMapper in interface IlpTreeSelectionModel
Parameters:
representationObjectMapper - The representation object mapper to be used. If this parameter is null, the IlpObject selection API has no effect.

getRepresentationObjectMapper

public IlpRepresentationObjectMapper getRepresentationObjectMapper()
Returns the IlpRepresentationObjectMapper used to find the IlpRepresentationObject associated with an IlpObject.

Specified by:
getRepresentationObjectMapper in interface IlpTreeSelectionModel
Returns:
The representation object mapper used; can be null.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.