Eclipse Platform
Release 3.3

org.eclipse.jface.viewers
Class TreeSelection

java.lang.Object
  extended byorg.eclipse.jface.viewers.StructuredSelection
      extended byorg.eclipse.jface.viewers.TreeSelection
All Implemented Interfaces:
ISelection, IStructuredSelection, ITreeSelection

public class TreeSelection
extends StructuredSelection
implements ITreeSelection

A concrete implementation of the ITreeSelection interface, suitable for instantiating.

This class is not intended to be subclassed.

Since:
3.2

Field Summary
static TreeSelection EMPTY
          The canonical empty selection.
 
Constructor Summary
TreeSelection()
          Creates a new empty selection.
TreeSelection(TreePath treePath)
          Constructs a selection based on the elements identified by the given tree path.
TreeSelection(TreePath[] paths)
          Constructs a selection based on the elements identified by the given tree paths.
TreeSelection(TreePath[] paths, IElementComparer comparer)
          Constructs a selection based on the elements identified by the given tree paths.
TreeSelection(TreePath treePath, IElementComparer comparer)
          Constructs a selection based on the elements identified by the given tree path.
 
Method Summary
 boolean equals(Object obj)
          Returns whether this structured selection is equal to the given object.
 IElementComparer getElementComparer()
          Returns the element comparer passed in when the tree selection has been created or null if no comparer has been provided.
 TreePath[] getPaths()
          Returns the paths in this selection
 TreePath[] getPathsFor(Object element)
          Returns the paths in this selection whose last segment is equal to the given element
 int hashCode()
           
 
Methods inherited from class org.eclipse.jface.viewers.StructuredSelection
getFirstElement, isEmpty, iterator, size, toArray, toList, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.viewers.IStructuredSelection
getFirstElement, iterator, size, toArray, toList
 
Methods inherited from interface org.eclipse.jface.viewers.ISelection
isEmpty
 

Field Detail

EMPTY

public static final TreeSelection EMPTY
The canonical empty selection. This selection should be used instead of null.

Constructor Detail

TreeSelection

public TreeSelection(TreePath[] paths)
Constructs a selection based on the elements identified by the given tree paths.

Parameters:
paths - tree paths

TreeSelection

public TreeSelection(TreePath[] paths,
                     IElementComparer comparer)
Constructs a selection based on the elements identified by the given tree paths.

Parameters:
paths - tree paths
comparer - the comparer, or null if default equals is to be used

TreeSelection

public TreeSelection(TreePath treePath)
Constructs a selection based on the elements identified by the given tree path.

Parameters:
treePath - tree path, or null for an empty selection

TreeSelection

public TreeSelection(TreePath treePath,
                     IElementComparer comparer)
Constructs a selection based on the elements identified by the given tree path.

Parameters:
treePath - tree path, or null for an empty selection
comparer - the comparer, or null if default equals is to be used

TreeSelection

public TreeSelection()
Creates a new empty selection. See also the static field EMPTY which contains an empty selection singleton.

Note that TreeSelection.EMPTY is not equals() to StructuredViewer.EMPTY.

See Also:
EMPTY
Method Detail

getElementComparer

public IElementComparer getElementComparer()
Returns the element comparer passed in when the tree selection has been created or null if no comparer has been provided.

Returns:
the element comparer or null
Since:
3.2

equals

public boolean equals(Object obj)
Description copied from class: StructuredSelection
Returns whether this structured selection is equal to the given object. Two structured selections are equal if they contain the same elements in the same order.

Overrides:
equals in class StructuredSelection
Parameters:
obj - the other object
Returns:
true if they are equal, and false otherwise

hashCode

public int hashCode()

getPaths

public TreePath[] getPaths()
Description copied from interface: ITreeSelection
Returns the paths in this selection

Specified by:
getPaths in interface ITreeSelection
Returns:
the paths in this selection

getPathsFor

public TreePath[] getPathsFor(Object element)
Description copied from interface: ITreeSelection
Returns the paths in this selection whose last segment is equal to the given element

Specified by:
getPathsFor in interface ITreeSelection
Parameters:
element - the element to get the tree paths for
Returns:
the array of tree paths

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.