JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table
Class JCSelection

java.lang.Object
  |
  +--com.klg.jclass.table.JCSelection
All Implemented Interfaces:
Moveable, SelectionModel, Serializable
Direct Known Subclasses:
JCListTable.ListSelection

public class JCSelection
extends Object
implements SelectionModel, Serializable

The SelectionModel interface represents the current cell selection state in Table. This implementation supports all selection policies. If the policy is changed, the current selection is cleared.

See Also:
Serialized Form

Field Summary
protected  int last_selected_column
           
protected  int last_selected_row
           
protected  int policy
           
protected  Vector selected_cells
           
protected  com.klg.jclass.table.JCTable table
           
 
Fields inherited from interface com.klg.jclass.table.SelectionModel
ADD, DESELECT, END, EXTEND, SELECT, SELECT_MULTIRANGE, SELECT_NONE, SELECT_RANGE, SELECT_SINGLE
 
Constructor Summary
JCSelection()
           
JCSelection(com.klg.jclass.table.JCTable table)
           
 
Method Summary
 boolean addColumnSelection(int start_column, int end_column)
          Adds a range of columns to the selection.
 boolean addRowSelection(int start_row, int end_row)
          Adds a range of rows to the selection.
 boolean addSelection(int start_row, int start_column, int end_row, int end_column)
          Adds a range of cells to the selection.
 boolean addSelection(com.klg.jclass.table.JCCellRange cr)
          Adds a JCCellRange to the selection.
 void cleanup()
          Ensures that the last range does not duplicate another.
 void clearSelection()
          Clears all selected cells and generates required JCSelectEvents.
 void clearSelection(boolean withAllEvents)
          Clears all selected cells.
protected  void clearWithNoNotification()
          Clears the current selection without notification.
 boolean extendSelection(int row, int column)
          Extends the current selection to the given row and column.
 Collection getSelectedCells()
          Returns a Vector containing all of the selected regions as JCCellRange objects.
 int getSelectionPolicy()
          Returns the policy of selection supported by the model.
 com.klg.jclass.table.JCTable getTable()
          Returns the Table controlled by the SelectionModel.
protected  boolean isLabel(int row, int column)
          Returns true if the given row/column is a label.
 boolean isSelected(int row, int column)
          Returns true if the given row/column is selected.
 void moveColumns(int start_column, int num_columns, int destination)
          Adjusts the selection after moving columns.
 void moveRows(int start_row, int num_rows, int destination)
          Adjusts the selection after moving rows.
 void remapColumns(int[] new_positions)
          Reorders selected columns after the column mapping changes.
 void remapRows(int[] new_positions)
          Reorders selected rows after the row mapping changes.
 boolean select(int state, int row, int column)
          Adds, extends, deselects, or ends a selection based on a row or column.
 boolean selectAll()
          Selects all cells.
 boolean setColumnSelection(int start_column, int end_column)
          Sets a range of columns as the current selection.
 boolean setRowSelection(int start_row, int end_row)
          Sets a range of rows as the current selection.
 boolean setSelection(Collection ranges)
          Sets the selection to a Vector of JCCellRange.
 boolean setSelection(int start_row, int start_column, int end_row, int end_column)
          Sets a range of cells as the current selection.
 boolean setSelection(com.klg.jclass.table.JCCellRange cr)
          Sets the selection to a JCCellRange.
 void setSelectionPolicy(int value)
          Sets the policy of selection supported by the model.
 void setTable(com.klg.jclass.table.JCTable table)
          Sets the Table controlled by the SelectionModel.
 void shiftColumn(int start_column, int num_columns, int direction)
          Adjusts the selection after adding or deleting columns.
 void shiftRow(int start_row, int num_rows, int direction)
          Adjusts the selection after adding or deleting rows.
 void swapColumns(int column1, int column2)
          Adjusts the selection based on two columns swapping position.
 void swapRows(int row1, int row2)
          Adjusts the selection based on two rows swapping position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected com.klg.jclass.table.JCTable table

selected_cells

protected Vector selected_cells

policy

protected int policy

last_selected_row

protected int last_selected_row

last_selected_column

protected int last_selected_column
Constructor Detail

JCSelection

public JCSelection()

JCSelection

public JCSelection(com.klg.jclass.table.JCTable table)
Method Detail

getTable

public com.klg.jclass.table.JCTable getTable()
Returns the Table controlled by the SelectionModel.

Specified by:
getTable in interface SelectionModel
Returns:
Table controlled by the SelectionModel

setTable

public void setTable(com.klg.jclass.table.JCTable table)
Sets the Table controlled by the SelectionModel.

Specified by:
setTable in interface SelectionModel
Parameters:
table -

getSelectionPolicy

public int getSelectionPolicy()
Returns the policy of selection supported by the model. Valid values are SELECT_NONE, SELECT_SINGLE, SELECT_RANGE, and SELECT_MULTIRANGE.

Specified by:
getSelectionPolicy in interface SelectionModel
Returns:
policy of selection supported by the model; one of SELECT_NONE, SELECT_SINGLE, SELECT_RANGE, or SELECT_MULTIRANGE
See Also:
setSelectionPolicy(int)

setSelectionPolicy

public void setSelectionPolicy(int value)
Sets the policy of selection supported by the model. Valid policies are SELECT_NONE, SELECT_SINGLE, SELECT_RANGE, and SELECT_MULTIRANGE.

Specified by:
setSelectionPolicy in interface SelectionModel
Parameters:
value -

addColumnSelection

public boolean addColumnSelection(int start_column,
                                  int end_column)
Adds a range of columns to the selection.

Specified by:
addColumnSelection in interface SelectionModel
Parameters:
start_column -
end_column -
Returns:
true if the selection is accepted

addRowSelection

public boolean addRowSelection(int start_row,
                               int end_row)
Adds a range of rows to the selection.

Specified by:
addRowSelection in interface SelectionModel
Parameters:
end_row -
start_row -
Returns:
true if the selection is accepted

addSelection

public boolean addSelection(int start_row,
                            int start_column,
                            int end_row,
                            int end_column)
Adds a range of cells to the selection.

Specified by:
addSelection in interface SelectionModel
Parameters:
end_column -
end_row -
start_column -
start_row -
Returns:
true if the selection is accepted

addSelection

public boolean addSelection(com.klg.jclass.table.JCCellRange cr)
Adds a JCCellRange to the selection.

Specified by:
addSelection in interface SelectionModel
Parameters:
cr -
Returns:
true if the selection is accepted

cleanup

public void cleanup()
Ensures that the last range does not duplicate another.

Specified by:
cleanup in interface SelectionModel

clearSelection

public void clearSelection()
Clears all selected cells and generates required JCSelectEvents.

Specified by:
clearSelection in interface SelectionModel

clearSelection

public void clearSelection(boolean withAllEvents)
Clears all selected cells. If withAllEvents is true, before and after events are generated for the deselected cell ranges.

Parameters:
withAllEvents -

extendSelection

public boolean extendSelection(int row,
                               int column)
Extends the current selection to the given row and column.

Specified by:
extendSelection in interface SelectionModel
Parameters:
row -
column -
Returns:
true if the selection is accepted

getSelectedCells

public Collection getSelectedCells()
Returns a Vector containing all of the selected regions as JCCellRange objects.

Specified by:
getSelectedCells in interface SelectionModel
Returns:
Vector containing all of the selected regions as JCCellRange objects

isSelected

public boolean isSelected(int row,
                          int column)
Returns true if the given row/column is selected.

Specified by:
isSelected in interface SelectionModel
Parameters:
column -
row -
Returns:
true if the selection is accepted

selectAll

public boolean selectAll()
Selects all cells.

Specified by:
selectAll in interface SelectionModel
Returns:
true if the selection is accepted

setColumnSelection

public boolean setColumnSelection(int start_column,
                                  int end_column)
Sets a range of columns as the current selection.

Specified by:
setColumnSelection in interface SelectionModel
Parameters:
end_column -
start_column -
Returns:
true if the selection is accepted

setRowSelection

public boolean setRowSelection(int start_row,
                               int end_row)
Sets a range of rows as the current selection.

Specified by:
setRowSelection in interface SelectionModel
Parameters:
end_row -
start_row -
Returns:
true if the selection is accepted

setSelection

public boolean setSelection(int start_row,
                            int start_column,
                            int end_row,
                            int end_column)
Sets a range of cells as the current selection.

Specified by:
setSelection in interface SelectionModel
Parameters:
end_column -
end_row -
start_column -
start_row -
Returns:
true if the selection is accepted

setSelection

public boolean setSelection(Collection ranges)
Sets the selection to a Vector of JCCellRange.

Specified by:
setSelection in interface SelectionModel
Parameters:
ranges -
Returns:
true if the selection is accepted

setSelection

public boolean setSelection(com.klg.jclass.table.JCCellRange cr)
Sets the selection to a JCCellRange.

Specified by:
setSelection in interface SelectionModel
Parameters:
cr -
Returns:
true if the selection is accepted

select

public boolean select(int state,
                      int row,
                      int column)
Adds, extends, deselects, or ends a selection based on a row or column. This method is called by the mouse and key process handler and should not be used for programmatic manipulation of selected regions.

Specified by:
select in interface SelectionModel
Parameters:
column -
row -
state -
Returns:
true if the model supports the selection

clearWithNoNotification

protected void clearWithNoNotification()
Clears the current selection without notification. This is used when processing a series of selections that must all succeed. If one fails, rollback won't generate deselect events for changes already processed.


isLabel

protected boolean isLabel(int row,
                          int column)
Returns true if the given row/column is a label.

Parameters:
column -
row -
Returns:
true if the given row/column is a label

moveColumns

public void moveColumns(int start_column,
                        int num_columns,
                        int destination)
Adjusts the selection after moving columns.

Specified by:
moveColumns in interface Moveable
Parameters:
start_column - the starting position
num_columns - the number of columns
destination - the column before which the source columns are moved (use JCTableEnum.MAXINT to move the columns to the end)

moveRows

public void moveRows(int start_row,
                     int num_rows,
                     int destination)
Adjusts the selection after moving rows.

Specified by:
moveRows in interface Moveable
Parameters:
start_row - the starting position
num_rows - the number of rows
destination - the row before which the source rows are moved (use JCTableEnum.MAXINT to move the rows to the end)

remapColumns

public void remapColumns(int[] new_positions)
Reorders selected columns after the column mapping changes.

Specified by:
remapColumns in interface Moveable
Parameters:
new_positions -

remapRows

public void remapRows(int[] new_positions)
Reorders selected rows after the row mapping changes.

Specified by:
remapRows in interface Moveable
Parameters:
new_positions -

shiftColumn

public void shiftColumn(int start_column,
                        int num_columns,
                        int direction)
Adjusts the selection after adding or deleting columns.

Specified by:
shiftColumn in interface Moveable
Parameters:
start_column - the start position
num_columns - the number of columns
direction - use +1 for insert and -1 for delete

shiftRow

public void shiftRow(int start_row,
                     int num_rows,
                     int direction)
Adjusts the selection after adding or deleting rows.

Specified by:
shiftRow in interface Moveable
Parameters:
start_row - the start position
num_rows - the number of rows
direction - use +1 for insert and -1 for delete

swapColumns

public void swapColumns(int column1,
                        int column2)
Adjusts the selection based on two columns swapping position.

Specified by:
swapColumns in interface Moveable
Parameters:
column1 -
column2 -

swapRows

public void swapRows(int row1,
                     int row2)
Adjusts the selection based on two rows swapping position.

Specified by:
swapRows in interface Moveable
Parameters:
row1 -
row2 -

Copyright © 2004 Quest Software Inc..
All rights reserved.