org.eclipse.nebula.widgets.nattable.selection
Class SelectionModel

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.selection.SelectionModel
All Implemented Interfaces:
ISelectionModel

public class SelectionModel
extends Object
implements ISelectionModel

Tracks the selections made in the table. All selections are tracked in terms of Rectangles. For example if the table has 10 rows and column 2 is selected, the Rectangle tracked is (0, 2, 10, 1) Coordinates are in Selection Layer positions

See Also:
SelectionLayer

Constructor Summary
SelectionModel(SelectionLayer selectionLayer)
           
SelectionModel(SelectionLayer selectionLayer, boolean multipleSelectionAllowed)
           
 
Method Summary
 void addSelection(int columnPosition, int rowPosition)
          Selects a specified cell
 void addSelection(org.eclipse.swt.graphics.Rectangle range)
          Selects the cells of a specified area
 void clearSelection()
          Removes all cell selections
 void clearSelection(int columnPosition, int rowPosition)
          Deselects a specified cell
 void clearSelection(org.eclipse.swt.graphics.Rectangle removedSelection)
          Removes the selection of specified cells
protected  boolean contains(org.eclipse.swt.graphics.Rectangle containerRectangle, org.eclipse.swt.graphics.Rectangle rectangle)
           
 int[] getFullySelectedColumnPositions(int columnHeight)
           
 int[] getFullySelectedRowPositions(int rowWidth)
           
 int[] getSelectedColumnPositions()
          Retrieves the columns that have any selected cells
 int getSelectedRowCount()
          Retrieves the number of rows that have any selected cell
 Set<Range> getSelectedRowPositions()
          Retrieves the rows with a valid row position that have any selected cells
 List<org.eclipse.swt.graphics.Rectangle> getSelections()
          Retrieves the cells that are selected
 boolean isCellPositionSelected(int columnPosition, int rowPosition)
          Determines whether a specified cell is selected
 boolean isColumnPositionFullySelected(int columnPosition, int columnHeight)
          Are all cells in this column selected? Different selection rectangles might aggregate to cover the entire column.
 boolean isColumnPositionSelected(int columnPosition)
          Determines whether a specified column contains any selected cell
 boolean isEmpty()
          Determines whether there are any selected cells
 boolean isMultipleSelectionAllowed()
          Determines whether multiple cells can be selected simultaneously
 boolean isRowPositionFullySelected(int rowPosition, int rowWidth)
           
 boolean isRowPositionSelected(int rowPosition)
          Determines whether a specified row contains any selected cell
 void setMultipleSelectionAllowed(boolean multipleSelectionAllowed)
          Sets whether multiple cells can be selected simultaneously
protected  void sortByX(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInRow)
           
protected  void sortByY(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInColumn)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectionModel

public SelectionModel(SelectionLayer selectionLayer)

SelectionModel

public SelectionModel(SelectionLayer selectionLayer,
                      boolean multipleSelectionAllowed)
Method Detail

isMultipleSelectionAllowed

public boolean isMultipleSelectionAllowed()
Description copied from interface: ISelectionModel
Determines whether multiple cells can be selected simultaneously

Specified by:
isMultipleSelectionAllowed in interface ISelectionModel
Returns:
whether multiple cells can be selected simultaneously

setMultipleSelectionAllowed

public void setMultipleSelectionAllowed(boolean multipleSelectionAllowed)
Description copied from interface: ISelectionModel
Sets whether multiple cells can be selected simultaneously

Specified by:
setMultipleSelectionAllowed in interface ISelectionModel
Parameters:
multipleSelectionAllowed - whether multiple cells can be selected simultaneously

addSelection

public void addSelection(int columnPosition,
                         int rowPosition)
Description copied from interface: ISelectionModel
Selects a specified cell

Specified by:
addSelection in interface ISelectionModel
Parameters:
columnPosition - column position of the cell to select
rowPosition - row position of the cell to select

addSelection

public void addSelection(org.eclipse.swt.graphics.Rectangle range)
Description copied from interface: ISelectionModel
Selects the cells of a specified area

Specified by:
addSelection in interface ISelectionModel
Parameters:
range - the position based area to select

clearSelection

public void clearSelection()
Description copied from interface: ISelectionModel
Removes all cell selections

Specified by:
clearSelection in interface ISelectionModel

clearSelection

public void clearSelection(int columnPosition,
                           int rowPosition)
Description copied from interface: ISelectionModel
Deselects a specified cell

Specified by:
clearSelection in interface ISelectionModel
Parameters:
columnPosition - column position of the cell to deselect
rowPosition - row position of the cell to deselect

clearSelection

public void clearSelection(org.eclipse.swt.graphics.Rectangle removedSelection)
Description copied from interface: ISelectionModel
Removes the selection of specified cells

Specified by:
clearSelection in interface ISelectionModel
Parameters:
removedSelection - the position based area to deselect

isEmpty

public boolean isEmpty()
Description copied from interface: ISelectionModel
Determines whether there are any selected cells

Specified by:
isEmpty in interface ISelectionModel
Returns:
whether there are any selected cells

getSelections

public List<org.eclipse.swt.graphics.Rectangle> getSelections()
Description copied from interface: ISelectionModel
Retrieves the cells that are selected

Specified by:
getSelections in interface ISelectionModel
Returns:
the cells that are selected, expressed in position coordinates

isCellPositionSelected

public boolean isCellPositionSelected(int columnPosition,
                                      int rowPosition)
Description copied from interface: ISelectionModel
Determines whether a specified cell is selected

Specified by:
isCellPositionSelected in interface ISelectionModel
Parameters:
columnPosition - column position of the cell to inspect
rowPosition - row position of the cell to inspect
Returns:
whether the specified cell is selected

getSelectedColumnPositions

public int[] getSelectedColumnPositions()
Description copied from interface: ISelectionModel
Retrieves the columns that have any selected cells

Specified by:
getSelectedColumnPositions in interface ISelectionModel
Returns:
the column positions that have any selected cells

isColumnPositionSelected

public boolean isColumnPositionSelected(int columnPosition)
Description copied from interface: ISelectionModel
Determines whether a specified column contains any selected cell

Specified by:
isColumnPositionSelected in interface ISelectionModel
Parameters:
columnPosition - column position to inspect
Returns:
whether the specified column contains any selected cell

getFullySelectedColumnPositions

public int[] getFullySelectedColumnPositions(int columnHeight)
Specified by:
getFullySelectedColumnPositions in interface ISelectionModel
Parameters:
columnHeight - the number of rows in a fully selected column

isColumnPositionFullySelected

public boolean isColumnPositionFullySelected(int columnPosition,
                                             int columnHeight)
Are all cells in this column selected? Different selection rectangles might aggregate to cover the entire column. We need to take into account any overlapping selections or any selection rectangles contained within each other. See the related tests for a better understanding.

Specified by:
isColumnPositionFullySelected in interface ISelectionModel
columnHeight - the number of rows in a fully selected column

getSelectedRowCount

public int getSelectedRowCount()
Description copied from interface: ISelectionModel
Retrieves the number of rows that have any selected cell

Specified by:
getSelectedRowCount in interface ISelectionModel
Returns:
the number of rows that have any selected cell

getSelectedRowPositions

public Set<Range> getSelectedRowPositions()
Description copied from interface: ISelectionModel
Retrieves the rows with a valid row position that have any selected cells

Specified by:
getSelectedRowPositions in interface ISelectionModel
Returns:
the row positions with a valid row position that have any selected cells

isRowPositionSelected

public boolean isRowPositionSelected(int rowPosition)
Description copied from interface: ISelectionModel
Determines whether a specified row contains any selected cell

Specified by:
isRowPositionSelected in interface ISelectionModel
Parameters:
rowPosition - row position to inspect
Returns:
whether the specified row contains any selected cell

getFullySelectedRowPositions

public int[] getFullySelectedRowPositions(int rowWidth)
Specified by:
getFullySelectedRowPositions in interface ISelectionModel
Parameters:
rowWidth - the number of columns in a fully selected row

isRowPositionFullySelected

public boolean isRowPositionFullySelected(int rowPosition,
                                          int rowWidth)
Specified by:
isRowPositionFullySelected in interface ISelectionModel

contains

protected boolean contains(org.eclipse.swt.graphics.Rectangle containerRectangle,
                           org.eclipse.swt.graphics.Rectangle rectangle)

sortByX

protected void sortByX(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInRow)

sortByY

protected void sortByY(List<org.eclipse.swt.graphics.Rectangle> selectionRectanglesInColumn)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All rights reserved.