|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.table.TableView
public class TableView
TableView is a class that allows two-dimensional data to be viewed, edited, and manipulated in tabular form.
TableView tv = new TableView();
tv.initialize();
By default, TableView is 124 pixels wide and 248 pixels tall. You can change these (as with all visual components) with:
setDefaultWidth (int width);
setDefaultHeight (int height);
Since defaultWidth and defaultHeight are class, or static, properties, they affect the size of all object instances. To change the size (and/or position) of a single instance use:
setBounds (int x, int y, int width, int height)
;
TableView requires a model that implements StaticTableInterface.
If available, it will also utilize the following:
It will also take advantage of (but not require) com.sas.collection.ContentsChangedSource.html and com.sas.beans.PropertyChangeSource (if not available will check for addPropertyChangeListener() via reflection) in order to dynamically respond to model changes. Thus models should fire com.sas.collection.ContentsChangedEvent and java.beans.PropertyChangeEvent when they change, and TableView provides several ContentsChangedEvent subclasses to facilitate describing those changes:
To attach a model to TableView:
setModelInterface (your-model);
And to detach the model:
setModelInterface (null);
Besides responding to events from its model, TableView will fire events itself -- java.beans.PropertyChangeEvents and java.awt.event.ItemEvent.html. PropertyChangeEvents are fired (as with other bean components) whenever a bound property is changed. ItemEvents are fired whenever selections are made or removed in the table. To register to receive PropertyChangeEvents:
addPropertyChangeListener (java.beans.PropertyChangeListener listener);
And to receive ItemEvents:
addItemListener (java.awt.event.ItemListener listener);
Here's a sample ItemEvent handler:
public void tableView1ItemStateChangedHandler1 (java.awt.event.ItemEvent event)
{
if (event.getStateChange() == java.awt.event.ItemEvent.SELECTED)
printSelection ((Selection)event.getItem(), "Selected ");
else //if (event.getStateChange() == java.awt.event.ItemEvent.DESELECTED)
{
Object deselections[] = (Object[])event.getItem ();
for (int i = 0; i < deselections.length; i++)
printSelection ((Selection)deselections[i], "Deselected ");
}
}
private void printSelection (Selection selection, String text)
{
Object anchor = selection.getAnchor();
Object end = selection.getEnd();
if (selection instanceof CellSelection)
{
DataCell anchorCell = (DataCell)anchor;
DataCell endCell = (DataCell)end;
text += "cell(" +
anchorCell.getRow().getIndex() + "," +
anchorCell.getColumn().getIndex() + ") thru cell(" +
endCell.getRow().getIndex() + "," +
endCell.getColumn().getIndex() + ")";
}
else
{
if (selection instanceof ColumnSelection)
text += "columns ";
else //if (selection instanceof RowSelection)
text += "rows ";
CellVector anchorCV = (CellVector)anchor;
CellVector endCV = (CellVector)end;
text += anchorCV.getIndex() + " thru " + endCV.getIndex();
}
System.out.println (text);
}
TableView provides several helper classes to surface and allow interaction with the different elements of two-dimensional, or tabular, data:
Columns and rows are identified by their one-based position in the model and can be retrieved via:
Label cells are acquired via their corresponding column or row:
While data cells can be accessed via TableView or their corresponding column or row:
A style is simply a collection of property names with associated values. TableView uses styles to provide control over the formatting and rendering characteristics of cells, columns, and rows; and provides a specific style to use with each:
CellStyle defines properties such as foregroundColor, backgroundColor, and horizontalJustification among many others. ColumnStyle and RowStyle include size and resizable, as well as defaultCellStyle which is the CellStyle to apply to all cells in the affected columns or rows.
TableView provides four default styles which can be accessed, modified, and/or replaced via the customizer or:
getDefaultCellStyle()
and
setDefaultCellStyle()
getDefaultLabelStyle()
and
setDefaultLabelStyle()
getDefaultColumnStyle()
and
setDefaultColumnStyle()
getDefaultRowStyle()
and
setDefaultRowStyle()
These styles serve as the defaults for all cells, columns, and rows in the table. Data cells will defer first to defaultColumnStyle.defaultCellStyle, then to defaultRowStyle.defaultCellStyle, and finally to defaultCellStyle (actually some properties, like foregroundColor, will additionally defer as ambient properties, to for example java.awt.Component.getForeground()). Row label cells will defer first to defaultRowStyle.defaultLabelStyle, to defaultLabelStyle, then to defaultCellStyle. Likewise for column label cells except they start at defaultColumnStyle.defaultLabelStyle. Consider the following examples, though note that the following is also doable without writing code via the customizer:
If you wanted every cell to be red,
getDefaultCellStyle().setForegroundColor (java.awt.Color.red);
If you wanted just the labels to be red,
getDefaultLabelStyle().setForegroundColor (java.awt.Color.red);
Just the row labels,
CellStyle rowLabelStyle = new CellStyle();
rowLabelStyle.setForegroundColor (java.awt.Color.red);
getDefaultRowStyle().setDefaultLabelStyle (rowLabelStyle);
So what did we mean when we said "defer"? That means that if a value is not found for a property at one style level, the property is looked for at the next higher level, and so on. This notion of deferring illustrates the power of styles...each style does not have to (and rarely will) define every property associated with its type. (Actually, styles are extensible so there is no notion of defining every property.) For example, defaultLabelStyle might provide a value for backgroundColor, but not foregroundColor. Instead choosing to defer to defaultCellStyle for foregroundColor. The advantage of this flexibility becomes clearer when styles are associated with individual elements...
By default, individual table elements (cells, columns, and rows) do not have a style of their
own, but one may be assigned via
TableElement.setStyle()
. For example,
to change the foreground color for only the cell at (row-three, column-four):
CellStyle cellStyle = new CellStyle();
cellStyle.setForegroundColor (java.awt.Color.red);
getCell (getRow(3), getColumn(4)).setStyle (cellStyle);
And to change the foreground color of all the data cells in columns five and six:
ColumnStyle colStyle = new ColumnStyle();
CellStyle cellStyle = new CellStyle();
cellStyle.setForegroundColor (Color.red);
colStyle.setDefaultCellStyle (cellStyle);
getColumn(5).setStyle (colStyle);
getColumn(6).setStyle (colStyle);
Notice how the same style can be applied to multiple elements.
[Note: for simplicity and ease in reading this section is written in terms of columns, but the same information and techniques are applicable to rows.]
By default, columns are sized based on their contents. A column's label cell and data cells are individually measured to determine the widest one, and its width is used as the column's width. Since a table may contain a very large number of rows only a sample number of data cells are measured. The number to measure is determined by the effective value of ColumnStyle's cellsToSizeCount property. By default the number is 25, which means that the width of a column will be determined from the width of its label and its first 25 cells. A value of zero will cause only the label to be considered, while a negative value will result in the entire column being measured -- use this when you want to guarantee that no data will be clipped, but only when you're sure that the number of rows will not be too large. Clipped numeric data will be displayed as asterisks (***), while clipped character data will be appended with ellipsis (...).
Columns can be resized interactively by grabbing their label's right border, or programmatically via Column.setSize(). Other programmatic sizing controls include TableView.setColumnsConformed(), ColumnStyle.setSize(), ColumnStyle.setMinimumSize(), and ColumnStyle.setMaximumSize(). The following illustrates the use of some of these:
// Size a three column table such that the first column gets 25%
// of the available space, the second gets 50%, and the third 25%.
import com.sas.measures.Length;
for (int i = 1; i <= 3; i++)
{
Column col = tableView1.getColumn(i);
ColumnStyle style = new ColumnStyle();
Length s = null;
switch (i)
{
// adjust Length magnitudes to get any ratio you want
case 1: s = new Length (1, "px"); break;
case 2: s = new Length (2, "px"); break;
case 3: s = new Length (1, "px"); break;
// extend for other columns as necessary
}
style.setSize (s);
col.setStyle (style);
}
tableView1.setColumnsConformed (true);
As explained above in the Elements section, each cell is represented by a Cell object. However, Cell itself is nothing more than a useful abstraction. The real work of formatting, displaying, and editing cell data is delegated by Cell to a class known as a Cell View -- any class which implements CellViewInterface. This design allows TableView's cells to contain all types of data -- string, numeric, image, etc. -- and allows that data to be displayed and manipulated in a manner that's appropriate for it. For example, TextCell for string data and CheckBoxCell for boolean data.
After you've written your Cell View, you can get TableView to use it via CellStyle's viewClass property. For example, to override the default viewClass (TextCell) for cells in column 3 do the following:
Column col = tableView1.getColumn(3);
ColumnStyle colStyle = new ColumnStyle();
CellStyle cellStyle = new CellStyle();
cellStyle.setViewClass (CheckBoxCell.class);
colStyle.setDefaultCellStyle (cellStyle);
col.setStyle (colStyle);
[Note: all cells are protected from modification by default. To unprotect them, use CellStyle's activationLevel property.]
TableView itself does not get involved in validating data. Validation is left to the Cell Views (see preceding section) and to the model. Cell Views can validate data as it's entered -- i.e. keystroke-by-keystroke -- while models validate data on a cell-by-cell basis. In the latter case, the user has finished modifying a cell and has indicated -- either by a ui-action such as changing the current cell or programmatically via commitModifiedCells() -- to commit the change to the model. When this occurs, TableView calls StaticTableInterface.setCell() with the data. The model is then free to accept or reject the data. If it rejects the data, it should throw a TableException with an appropriate message. TableView will catch this exception and pass its message to any registered error handler, see COMMIT_CELL_ERROR. The cell will also be added to the invalid cells collection, and displayed with the default invalid cell style.
The typical listbox is a single column of selectable, but not editable, items. First, to get the right appearance, you'll want to turn-off row and column labels and size the column to be as wide as the component. This can be accomplished via the customizer or with the following code:
setRowLabelsVisible (false);
setColumnLabelsVisible (false);
setColumnsConformed (true);
The cells are already selectable and uneditable by default, but if this is a single selection list you'll want to disable extended and multiple selection. Again this can be done via the customizer or with the following code:
setExtendedSelectionAllowed (false);
setMultipleSelectionAllowed (false);
If you have a multi-column list, then in addition to leaving column labels visible, you will probably want each selection action to select an entire row instead of one cell at a time. See the "selection element" radiobox in the customizer's selections tab or use:
setSelectionElement (TableView.ROW);
As for your list data itself, com.sas.models.SimpleTable should meet your needs.
Spreadsheets usually have alphabetic column labels (A,B,C,...) and numeric row labels (1,2,3,...) that surround an initially empty but fully editable matrix of data cells. A com.sas.models.SimpleTable can be used as your matrix. For example,
com.sas.models.SimpleTable matrix = new SimpleTable();
matrix.initialize();
matrix.setSize (100, 100);
tableView.setModelInterface (matrix);
TableView will automatically provide row and column labels. Since spreadsheet labels usually
aren't editable, label selections typically are translated into selections of the corresponding
row or column. TableView has properties, rowsSelectedByLabel and
columnsSelectedByLabel
(true
by default), to allow this.
To enable cell editing, there is a "cells are protected" checkbox on the customizer's table tab. Editing is enabled programmatically via CellStyle's activationLevel property:
tableView.getDefaultCellStyle().setActivationLevel (CellActiveStates.ACTIVATED);
The com.sas.sasserver.dataset.DataSetInterface model will allow you to view and edit SAS datasets.
Cell editing can be enabled as described above in the spreadsheet example. If your database is read-only, TableView will recognize this and not allow editing regardless of your customizations.
MultidimensionalTableView
,
Serialized FormField Summary | |
---|---|
static int |
CELL
Cell constant for the selectionElement and transactionElement properties. |
static int |
COLUMN
Column constant for the selectionElement and transactionElement properties. |
static int |
COLUMN_MAJOR
Constant value for the printOrder property which indicates that columns should be given precedence when printing. |
static java.lang.String |
COMMIT_CELL_ERROR
Constant used to identify errors that occur when committing cell changes to the model. |
Scrollbar |
m_vbar
|
static java.lang.String |
RB_KEY
|
static int |
ROW
Row constant for the selectionElement and transactionElement properties. |
static int |
ROW_MAJOR
Constant value for the printOrder property which indicates that rows should be given precedence when printing. |
static int |
USER_DEFINED
User-defined constant for the transactionElement property. |
Fields inherited from interface com.sas.visuals.ScrollbarVisibilityInterface |
---|
SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER |
Fields inherited from interface com.sas.visuals.ScrollingInterface |
---|
SCROLL_BLOCK, SCROLL_COLUMN, SCROLL_ELEMENT, SCROLL_HALF_PAGE, SCROLL_MAXIMUM, SCROLL_PAGE, SCROLL_PIXEL, SCROLL_ROW |
Constructor Summary | |
---|---|
TableView()
Constructor. |
Method Summary | |
---|---|
void |
addItemListener(java.awt.event.ItemListener listener)
Adds a listener to receive java.awt.event.ItemEvent which are generated when items are selected and deselected in the table. |
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
Processes an java.awt.event.AdjustmentEvent sent by the scrollbars. |
void |
attachModel(com.sas.ModelInterface model)
Framework method; call setModelInterface(model) instead. |
java.lang.Object |
clone()
Clones this component. |
protected TableView |
clone(double horizontalScale,
double verticalScale)
Clones this component. |
protected void |
cloneModelDependentState(TableView clone,
double horizontalScale,
double verticalScale)
Clones this component's model dependent state. |
protected void |
cloneModelIndependentState(TableView clone,
double horizontalScale,
double verticalScale)
Clones this component's model independent state. |
boolean |
commitModifiedCells()
Commits any modified cells to the model. |
java.awt.Dimension |
computePreferredSize()
Determines the preferred size of this component. |
void |
contentsChanged(com.sas.collection.ContentsChangedEvent event)
Processes a com.sas.collection.ContentsChangedEvent sent by the model. |
protected DataCell |
createCell(Row row,
Column col)
Factory method for creating cells. |
protected Column |
createColumn(int index)
Factory method for creating columns. |
protected LabelCell |
createColumnLabel(Column col)
Factory method for creating column labels. |
protected LabelCell |
createOriginCell()
Factory method for creating the cell associated with the origin cell. |
protected Row |
createRow(int index)
Factory method for creating rows. |
protected LabelCell |
createRowLabel(Row row)
Factory method for creating row labels. |
void |
detachModel(com.sas.ModelInterface model)
Framework method; call setModelInterface(null) instead. |
void |
disableFullPaint()
Disables full (normal) painting. |
void |
enableFullPaint()
Enables full (normal) painting. |
Cell |
findCell(java.awt.Point point)
Finds the cell that contains a given point. |
Column |
findColumn(int x)
Finds the column that contains a given x-coordinate. |
Row |
findRow(int y)
Finds the row that contains a given y-coordinate. |
protected void |
formatView(java.awt.Graphics g)
Formats the model's data as defined by this view. |
DataCell |
getCell(Row row,
Column col)
Returns the cell at the intersection of a given row and column. |
com.sas.collection.StaticDictionaryInterface |
getCellTypeStyles()
Returns the set of cell types and their associated styles. |
Column |
getColumn(int index)
Returns the column at a given index. |
java.awt.Rectangle |
getColumnLabelBounds()
Returns a rectangle that represents the location and size of the column label area. |
int |
getColumnsConformedThreshold()
Returns the percentage, 0 to 99, of the table's width to the component's width above which columns should be conformed. |
com.sas.util.Command[] |
getContextCommands(java.lang.Object context,
int x,
int y)
Returns a list of commands associated with a given context. |
TableElement |
getCurrentElement()
Returns the value of the current element. |
java.awt.Rectangle |
getDataCellBounds()
Returns a rectangle that represents the location and size of the data cell area. |
CellStyle |
getDefaultCellStyle()
Returns the set of style properties that serve as defaults for all cells. |
protected int |
getDefaultColumnIndex()
Returns the index of the first column that should be displayed following a refresh. |
ColumnStyle |
getDefaultColumnStyle()
Returns the set of style properties that serve as defaults for all columns. |
static int |
getDefaultHeight()
Returns the default height for instances of this class. |
CellStyle |
getDefaultInvalidCellStyle()
Returns the set of style properties that serve as defaults for invalid cells. |
CellStyle |
getDefaultLabelStyle()
Returns the set of style properties that serve as defaults for all labels. |
com.sas.ModelInterface |
getDefaultModel()
Returns the default model. |
protected int |
getDefaultRowIndex()
Returns the index of the first row that should be displayed following a refresh. |
RowStyle |
getDefaultRowStyle()
Returns the set of style properties that serve as defaults for all rows. |
static int |
getDefaultWidth()
Returns the default width for instances of this class. |
com.sas.collection.StaticOrderedCollectionInterface |
getDisplayedColumns()
Returns the set of columns that are currently scrolled into view. |
com.sas.collection.StaticOrderedCollectionInterface |
getDisplayedRows()
Returns the set of rows that are currently scrolled into view. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns metadata describing this class's properties. |
java.awt.Graphics |
getGraphics()
Creates a graphics context for this component. |
java.awt.Color |
getGridColor()
Returns the color of the grid lines. |
com.sas.collection.StaticOrderedCollectionInterface |
getHeldColumns()
Returns the set of held columns. |
com.sas.collection.StaticOrderedCollectionInterface |
getHeldRows()
Returns the set of held rows. |
int |
getHorizontalScrollbarVisibility()
Returns a constant indicating whether the horizontal scrollbar is always visible, never visible, or visible only as needed. |
com.sas.collection.StaticOrderedCollectionInterface |
getInvalidCells()
Returns the set of cells that are invalid. |
protected java.awt.Insets |
getLabelInsets()
Returns the label insets. |
com.sas.collection.StaticOrderedCollectionInterface |
getModifiedCells()
Returns the set of cells that have been modified. |
LabelCell |
getOriginCell()
Returns the cell at the intersection of the row of column labels and the column of row labels. |
java.awt.Rectangle |
getOriginCellBounds()
Returns a rectangle that represents the location and size of the origin cell. |
java.awt.Rectangle |
getPageBounds(java.awt.Graphics g,
int pageNumber,
int pageWidth,
int pageHeight)
Returns the bounds of a given page. |
java.awt.Rectangle |
getPaintableBounds()
Returns a rectangle that represents the location and size of the paintable area. |
java.awt.Panel |
getPrintOptionsPanel()
Returns a gui for specifying a row or column major print order. |
int |
getPrintOrder()
Returns a constant that indicates how the table should be split into multiple pages when printed. |
java.util.Vector |
getRequiredInterfaces()
Returns the interfaces required of a model by this view. |
Row |
getRow(int index)
Returns the row at a given index. |
java.awt.Rectangle |
getRowLabelBounds()
Returns a rectangle that represents the location and size of the row label area. |
int |
getRowsConformedThreshold()
Returns the percentage, 0 to 99, of the table's height to the component's height above which rows should be conformed. |
java.util.Enumeration |
getSelectedCells()
Returns the set of selected cells. |
java.util.Enumeration |
getSelectedColumns()
Returns the set of selected columns. |
java.lang.Object[] |
getSelectedObjects()
Returns the set of selected ranges (if any). |
java.util.Enumeration |
getSelectedRanges()
Returns the set of selected ranges. |
java.util.Enumeration |
getSelectedRows()
Returns the set of selected rows. |
int |
getSelectionElement()
Returns the type of table element that is selected when an interactive selection is made. |
java.awt.Rectangle |
getTableBounds()
Returns a rectangle that represents the location and size of the table within the component's bounds. |
protected java.awt.Rectangle |
getTableBounds(java.awt.Graphics g)
Returns a rectangle that represents the location and size of the table within the component's bounds. |
int |
getTransactionElement()
Returns how often modified cells are committed to the model. |
int |
getVerticalScrollbarVisibility()
Returns a constant indicating whether the vertical scrollbar is always visible, never visible, or visible only as needed. |
void |
hold(CellVector cellVector)
"Holds" a given column or row. |
void |
initialize()
Initialization: register as listener to default styles, and set default model (if appropriate). |
boolean |
isActiveCellHighlighted()
Returns whether the active cell is visually distinguished from the other cells. |
boolean |
isColumnLabelsVisible()
Returns whether column labels should be displayed. |
boolean |
isColumnsConformed()
Returns whether columns are resized to fill the horizontal extent of the component. |
boolean |
isColumnsSelectedByLabel()
Returns whether a column label selection selects the entire column. |
boolean |
isCurrentElementHighlighted()
Returns whether the current element is visually distinguished from the other selected elements. |
boolean |
isDefaultModelAttached()
Returns whether the default model is attached. |
boolean |
isExtendedSelectionAllowed()
Returns whether selections can be extended. |
boolean |
isFocusTraversable()
Returns whether this component can be traversed using tab or shift-tab keyboard focus traversal. |
boolean |
isFullPaintDisabled()
Returns whether full painting is disabled. |
boolean |
isGridVisible()
Returns whether grid lines are drawn over the data cells. |
boolean |
isMultipleSelectionAllowed()
Returns whether a single interactive selection action can span more than one element. |
boolean |
isPartialColumnVisible()
Returns whether the displayed column furthest from the row labels should be shown even if it's only partially displayed (clipped). |
boolean |
isPartialRowVisible()
Returns whether the displayed row furthest from the column labels should be shown even if it's only partially displayed (clipped). |
boolean |
isPopupMenuVisible()
Returns whether a popup menu will be shown when TableView receives the popup event. |
boolean |
isPrintScrollNeeded(int direction)
Get if a scroll is needed in the specified direction to show more data. |
boolean |
isRowLabelsVisible()
Returns whether row labels should be displayed. |
boolean |
isRowsConformed()
Returns whether rows are resized to fill the vertical extent of the component. |
boolean |
isRowsSelectedByLabel()
Returns whether a row label selection selects the entire row. |
boolean |
isSelectionAllowed()
Returns whether interactive selections can be made. |
boolean |
isTableSelectedByOriginCell()
Returns whether a selection of the origin cell selects the entire table. |
protected TableView |
newTableView()
Deprecated. As of AppDevStudio version 1.1. |
int |
nextPrintScrollDirection()
Get the direction needed for the next scroll of the table. |
protected void |
onAllChanged()
Performs a complete refresh of the view's state from its model. |
protected void |
onSizeColumn(Column col,
java.awt.Graphics g)
Sizes a given column. |
protected void |
onSizeRow(Row row,
java.awt.Graphics g)
Sizes a given row. |
boolean |
pageExists(int pageNumber)
Determines if a given page exists. |
void |
paint(java.awt.Graphics g)
Paints this component. |
protected void |
paintTable(java.awt.Graphics g,
java.awt.Rectangle invalidBounds)
Paints the table. |
protected void |
populatePopupMenu(java.awt.PopupMenu popupMenu,
TableElement element)
Populates a popup menu based on a given context (element). |
int |
previousPrintScrollDirection()
Get the direction of the previous scroll. |
void |
print(java.awt.Graphics g)
Prints this component. |
void |
print(java.awt.Graphics g,
int pageNumber,
int pageWidth,
int pageHeight)
Prints the requested page. |
void |
printFinalize()
Notification that printing is complete. |
void |
printInitialize(java.awt.Graphics g)
Notification that printing is about to begin. |
protected void |
processChanges()
Processes any changes that have been reported by the model. |
protected boolean |
processContentsChangedEvent(com.sas.collection.ContentsChangedEvent event)
Processes a contents changed event. |
protected void |
processEvent(java.awt.AWTEvent event)
Processes awt-events occurring on this component. |
protected void |
processFocusEvent(java.awt.event.FocusEvent fe)
Processes focus events occurring on this component. |
protected void |
processKeyEvent(java.awt.event.KeyEvent ke)
Processes key events occurring on this component. |
protected void |
processMouseEvent(java.awt.event.MouseEvent me)
Processes mouse events occurring on this component. |
protected void |
processMouseMotionEvent(java.awt.event.MouseEvent me)
Processes mouse motion events occurring on this component. |
void |
propertyBagChanged(com.sas.collection.PropertyBagChangedEvent e)
Processes a com.sas.collection.PropertyBagChangedEvent sent by a style. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
Processes a java.beans.PropertyChangeEvent sent by the model. |
void |
refresh()
Alias for refresh(getModelInterface()) . |
void |
refresh(com.sas.ModelInterface model)
Notifies the view that a model has changed. |
void |
refreshModifiedCells()
Refreshes any modified cells to their values as maintained by the model. |
void |
release(CellVector cellVector)
"Releases" a given column or row. |
void |
releaseAllColumns()
Releases any held columns. |
void |
releaseAllRows()
Releases any held rows. |
void |
remeasureAllColumns(boolean preserveResizes)
Resets all columns to their preferred width. |
void |
remeasureAllRows(boolean preserveResizes)
Resets all rows to their preferred height. |
void |
removeItemListener(java.awt.event.ItemListener listener)
Removes a listener of java.awt.event.ItemEvent which are generated when items are selected and deselected in the table. |
void |
repaint()
Repaints this component. |
void |
repaint(int x,
int y,
int width,
int height)
Repaints the specified rectangle of this component. |
void |
repaintColumns()
Repaint the whole table except for the row labels. |
void |
repaintRows()
Repaint the whole table except for the column labels. |
void |
scrollHorizontally(int numUnits,
int unit)
Scrolls the table horizontally. |
void |
scrollToCell(Cell cell,
boolean makeFirst)
Ensures that a cell is scrolled fully into view. |
void |
scrollToColumn(Column col,
boolean makeFirst)
Ensures that a column is scrolled fully into view. |
void |
scrollToRow(Row row,
boolean makeFirst)
Ensures that a row is scrolled fully into view. |
void |
scrollVertically(int numUnits,
int unit)
Scrolls the table vertically. |
void |
select(Column start,
Column end,
boolean extend)
Selects a contiguous range of columns. |
void |
select(DataCell start,
DataCell end,
boolean extend)
Selects a rectangular range of cells. |
void |
select(Row start,
Row end,
boolean extend)
Selects a contiguous range of rows. |
void |
select(Selection range,
boolean extend)
Selects a range. |
void |
setActiveCellHighlighted(boolean newValue)
Specifies whether the active cell is visually distinguished from the other cells. |
void |
setBounds(int x,
int y,
int width,
int height)
Moves and resizes this component. |
void |
setColumnLabelsVisible(boolean newValue)
Specifies whether column labels should be displayed. |
void |
setColumnsConformed(boolean newValue)
Specifies whether columns should be resized to fill the horizontal extent of the component. |
void |
setColumnsConformedThreshold(int newValue)
Specifies the percentage, 0 to 99, of the table's width to the component's width above which columns should be conformed. |
void |
setColumnsSelectedByLabel(boolean newValue)
Returns whether a column label selection selects the entire column. |
void |
setCurrentElement(TableElement newValue)
Sets the value of the current element. |
void |
setCurrentElementHighlighted(boolean newValue)
Returns whether the current element is visually distinguished from the other selected elements. |
void |
setCursor(java.awt.Cursor cursor)
Sets the cursor image to a predefined cursor. |
protected void |
setCursor(java.awt.Point point)
Sets the cursor image based on a given mouse pointer location. |
void |
setDefaultCellStyle(CellStyle newValue)
Specifies the set of style properties to use as defaults for all cells. |
void |
setDefaultColumnStyle(ColumnStyle newValue)
Specifies the set of style properties to use as defaults for all columns. |
static void |
setDefaultHeight(int newValue)
Sets the default height for instances of this class. |
void |
setDefaultInvalidCellStyle(CellStyle newValue)
Specifies the set of style properties to use as defaults for invalid cells. |
void |
setDefaultLabelStyle(CellStyle newValue)
Specifies the set of style properties to use as defaults for all labels. |
void |
setDefaultModel(com.sas.ModelInterface newValue)
Sets the default model. |
void |
setDefaultRowStyle(RowStyle newValue)
Specifies the set of style properties to use as defaults for all rows. |
void |
setDefaultValues()
Sets default values for this component's non-transient fields. |
static void |
setDefaultWidth(int newValue)
Returns the default width for instances of this class. |
void |
setExtendedSelectionAllowed(boolean newValue)
Specifies whether selections can be extended. |
void |
setFont(java.awt.Font newValue)
Sets the font of this component. |
void |
setGridColor(java.awt.Color newValue)
Specifies the color of the grid lines. |
void |
setGridVisible(boolean newValue)
Specifies whether grid lines are drawn over the data cells. |
void |
setHorizontalScrollbarVisibility(int newValue)
Specifies when a horizontal scrollbar should be used: always, never, or as needed. |
void |
setModelInterface(com.sas.ModelInterface newValue)
Specifies the model to display in the view. |
void |
setMultipleSelectionAllowed(boolean newValue)
Specifies whether a single interactive selection action can span more than one element. |
void |
setPartialColumnVisible(boolean newValue)
Specifies whether the displayed column furthest from the row labels should be shown even if it's only partially displayed (clipped). |
void |
setPartialRowVisible(boolean newValue)
Specifies whether the displayed row furthest from the column labels should be shown even if it's only partially displayed (clipped). |
void |
setPopupMenuVisible(boolean newValue)
Specifies whether a popup menu should be shown when TableView receives the popup event. |
void |
setPrintOrder(int newValue)
Specifies how the table should be split into multiple pages when printed. |
void |
setRowLabelsVisible(boolean newValue)
Specifies whether row labels should be displayed. |
void |
setRowsConformed(boolean newValue)
Specifies whether rows should be resized to fill the vertical extent of the component. |
void |
setRowsConformedThreshold(int newValue)
Specifies the percentage, 0 to 99, of the table's height to the component's height above which rows should be conformed. |
void |
setRowsSelectedByLabel(boolean newValue)
Specifies whether a row label selection selects the entire row. |
void |
setSelectionAllowed(boolean newValue)
Specifies whether interactive selections can be made. |
void |
setSelectionElement(int newValue)
Specifies the type of table element that is selected when an interactive selection is made. |
void |
setTableSelectedByOriginCell(boolean newValue)
Specifies whether a selection of the origin cell selects the entire table. |
void |
setTransactionElement(int newValue)
Specifies how often modified cells are committed to the model. |
void |
setVerticalScrollbarVisibility(int newValue)
Specifies when a vertical scrollbar should be used: always, never, or as needed. |
void |
unselect()
Unselects all cells, columns, and rows. |
protected void |
updateDisplayedColumns(java.awt.Graphics g)
Updates the set of displayed columns. |
protected void |
updateDisplayedRows(java.awt.Graphics g)
Updates the set of displayed rows. |
protected void |
updateView(java.awt.Graphics g)
Updates this view to reflect the current state of its model. |
Methods inherited from interface com.sas.awt.ContainerInterface |
---|
getComponents, getLayout, invalidate, setLayout, validate |
Field Detail |
---|
public static final java.lang.String RB_KEY
public static final int CELL
getSelectionElement()
,
getTransactionElement()
,
Constant Field Valuespublic static final int COLUMN
getSelectionElement()
,
getTransactionElement()
,
Constant Field Valuespublic static final int ROW
getSelectionElement()
,
getTransactionElement()
,
Constant Field Valuespublic static final int USER_DEFINED
getTransactionElement()
,
Constant Field Valuespublic static final java.lang.String COMMIT_CELL_ERROR
public static final int ROW_MAJOR
COLUMN_MAJOR
,
setPrintOrder(int)
,
Constant Field Valuespublic static final int COLUMN_MAJOR
ROW_MAJOR
,
setPrintOrder(int)
,
Constant Field Valuespublic transient Scrollbar m_vbar
Constructor Detail |
---|
public TableView()
Method Detail |
---|
public static int getDefaultHeight()
public static void setDefaultHeight(int newValue)
newValue
- The new value to assign the defaultHeight property.public static int getDefaultWidth()
public static void setDefaultWidth(int newValue)
newValue
- The new value to assign the defaultWidth property.public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void addItemListener(java.awt.event.ItemListener listener)
When ItemEvent.getStateChange() is SELECTED, ItemEvent.getObject() will return a Selection.
When ItemEvent.getStateChange() is DESELECTED, ItemEvent.getObject() will return an Object array of Selections.
addItemListener
in interface java.awt.ItemSelectable
listener
- An object which handles ItemEvents.removeItemListener(java.awt.event.ItemListener)
,
ItemListener
,
ItemSelectable
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Implemented as return clone(1, 1)
, so subclasses
should override it or one of the clone framework methods it calls, but
should not override this -- it would be declared
final
if it had not been already released as is.
clone
in interface com.sas.PublicClonable
clone
in class ContainerContainerComponent
java.lang.CloneNotSupportedException
- TableView supports cloning, but a subclass may not.clone(double, double)
public boolean commitModifiedCells()
The messages from any exceptions generated by the model are passed to the java.awt.ContainerContainerComponent.setErrorHandler method with a message code of COMMIT_CELL_ERROR.
true
if all cells were accepted by the model, and
false
otherwise.refreshModifiedCells()
,
getModifiedCells()
,
getInvalidCells()
,
setTransactionElement(int)
public java.awt.Dimension computePreferredSize()
computePreferredSize
in interface VisualInterface
computePreferredSize
in class ContainerVisualComponent
getDefaultHeight()
,
getDefaultWidth()
public void disableFullPaint()
paint()
will only paint a
component border and nothing more.
disableFullPaint
in interface FullPaintInterface
enableFullPaint()
,
isFullPaintDisabled()
,
FullPaintInterface
public void enableFullPaint()
enableFullPaint
in interface FullPaintInterface
disableFullPaint()
,
isFullPaintDisabled()
,
FullPaintInterface
public Cell findCell(java.awt.Point point)
null
if no match.findColumn(int)
,
findRow(int)
public Column findColumn(int x)
null
if no match.findCell(java.awt.Point)
,
findRow(int)
public Row findRow(int y)
null
if no match.findColumn(int)
,
findCell(java.awt.Point)
public com.sas.util.Command[] getContextCommands(java.lang.Object context, int x, int y)
TableView does not have any commands, but a subclass might.
getContextCommands
in interface ContextCommandsInterface
context
- The context to return commands for.x
- The horizontal coordinate of the location within the visual
coordinate space of the context for which the caller
would like commands. For example, if this method is being called
in response to a mouse click, then x would be the
x-position of the click. If the caller doesn't have a location
in mind, -1
should be specified.y
- The vertical coordinate of the location within the visual
coordinate space of the context for which the caller
would like commands. For example, if this method is being called
in response to a mouse click, then y would be the
y-position of the click. If the caller doesn't have a location
in mind, -1
should be specified.
ContextCommandsInterface
public void hold(CellVector cellVector)
The order in which columns/rows are held controls the order in which they are displayed.
Does nothing if the column/row is already held.
cellVector
- The column or row to hold.release(com.sas.table.CellVector)
,
getHeldColumns()
,
getHeldRows()
,
CellVector.isHeld()
public DataCell getCell(Row row, Column col)
row
- The desired cell's row.col
- The desired cell's column.
getColumn(int)
,
getRow(int)
public Column getColumn(int index)
index
- The position of the column using one-based indexing.
java.lang.IndexOutOfBoundsException
- If index is not in the range [1, getModelInterface().getColumnCount()].getCell(com.sas.table.Row, com.sas.table.Column)
,
getRow(int)
public Row getRow(int index)
index
- The position of the row using one-based indexing.
java.lang.IndexOutOfBoundsException
- If index is not in the range [1, getModelInterface().getRowCount()].getColumn(int)
,
getCell(com.sas.table.Row, com.sas.table.Column)
public void initialize()
initialize
in interface com.sas.ComponentInterface
initialize
in class ContainerVisualComponent
ComponentInterface.initialize()
public final boolean isDefaultModelAttached()
(getDefaultModel() == getModelInterface() &&
(getDefaultModel() != null)
isDefaultModelAttached
in interface com.sas.ViewDefaultModelInterface
getDefaultModel()
public boolean isFullPaintDisabled()
true
if full painting is disabled, and
false
otherwise.disableFullPaint()
,
enableFullPaint()
public void paint(java.awt.Graphics g)
true
,
or calls updateView() and
paintTable().
paint
in class ContainerVisualComponent
g
- The graphics context to use for painting.VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)
public void print(java.awt.Graphics g)
The default implementation of this method calls the
paint
method.
print
in class java.awt.Container
g
- the graphics context to use for printing.public void print(java.awt.Graphics g, int pageNumber, int pageWidth, int pageHeight) throws com.sas.awt.print.PrintException
print
in interface com.sas.awt.print.PrintableInterface
print
in class ContainerVisualComponent
g
- The graphics context to use for printing.pageNumber
- The one-based index of the page to be printed.pageWidth
- The width of the page (in pixels) being printed to.pageHeight
- The height of the page (in pixels) being printed to.
com.sas.awt.print.PrintException
- Thrown if a failure occurred while printing.
java.lang.IndexOutOfBoundsException
- Thrown if pageExists(pageNumber)
is
false
.PrintableInterface.print(java.awt.Graphics, int, int, int)
public int nextPrintScrollDirection()
nextPrintScrollDirection
in interface com.sas.awt.print.PrintScrollInterface
public int previousPrintScrollDirection()
previousPrintScrollDirection
in interface com.sas.awt.print.PrintScrollInterface
public boolean isPrintScrollNeeded(int direction)
isPrintScrollNeeded
in interface com.sas.awt.print.PrintScrollInterface
public void printInitialize(java.awt.Graphics g) throws com.sas.awt.print.PrintException
printInitialize
in interface com.sas.awt.print.PrintableInterface
printInitialize
in class ContainerVisualComponent
g
- A graphics context for the device being printed to.
com.sas.awt.print.PrintException
- Thrown if a failure occurred while initializing.PrintableInterface.printInitialize(java.awt.Graphics)
public void printFinalize()
printFinalize
in interface com.sas.awt.print.PrintableInterface
printFinalize
in class ContainerVisualComponent
PrintableInterface.printFinalize()
public boolean pageExists(int pageNumber)
pageExists(n)
may be called anytime it's legal to call
print()
with the same page number n.
pageExists
in interface com.sas.awt.print.PrintableInterface
pageExists
in class ContainerVisualComponent
pageNumber
- The one-based index of the page to verify.
true
if the page exists,
and false
otherwise.PrintableInterface.pageExists(int)
public java.awt.Rectangle getPageBounds(java.awt.Graphics g, int pageNumber, int pageWidth, int pageHeight)
getPageBounds(n)
may be called anytime it's legal
to call print()
with the same page number n.
getPageBounds
in interface com.sas.awt.print.PrintableInterface
getPageBounds
in class ContainerVisualComponent
g
- The graphics context to use for printing.pageNumber
- The one-based index of the page to measure.pageWidth
- The width of the page (in pixels) being printed to.pageHeight
- The height of the page (in pixels) being printed to.
print(java.awt.Graphics)
public java.awt.Panel getPrintOptionsPanel()
getPrintOptionsPanel
in interface com.sas.awt.print.PrintableInterface
getPrintOptionsPanel
in class ContainerVisualComponent
setPrintOrder(int)
public int getPrintOrder()
ROW_MAJOR
(the default) or COLUMN_MAJOR
.ROW_MAJOR
,
COLUMN_MAJOR
,
setPrintOrder(int)
public void setPrintOrder(int newValue)
newValue
- ROW_MAJOR
or COLUMN_MAJOR
.ROW_MAJOR
,
COLUMN_MAJOR
,
getPrintOrder()
public final void refresh()
refresh(getModelInterface())
.
public void refresh(com.sas.ModelInterface model)
refresh
in interface com.sas.ViewInterface
refresh
in class ContainerVisualComponent
model
- The changed model.ViewInterface.refresh(com.sas.ModelInterface)
public void refreshModifiedCells()
commitModifiedCells()
,
getModifiedCells()
,
getInvalidCells()
public void release(CellVector cellVector)
Does nothing if the column/row is not held.
cellVector
- The column/row to release.hold(com.sas.table.CellVector)
,
releaseAllColumns()
,
releaseAllRows()
public void releaseAllColumns()
release(com.sas.table.CellVector)
public void releaseAllRows()
release(com.sas.table.CellVector)
public void remeasureAllColumns(boolean preserveResizes)
preserveResizes
- if true
don't remeasure columns that have been
explicitly resized.remeasureAllRows(boolean)
public void remeasureAllRows(boolean preserveResizes)
preserveResizes
- if true
don't remeasure rows that have been
explicitly resized.remeasureAllColumns(boolean)
public void removeItemListener(java.awt.event.ItemListener listener)
removeItemListener
in interface java.awt.ItemSelectable
listener
- An object previously registered with
addItemListener().public void repaint()
repaint
in class java.awt.Component
public void repaint(int x, int y, int width, int height)
repaint
in class java.awt.Component
x
- The x coordinate of the rectangle in pixels
relative to the top-left corner of the component.y
- The y coordinate of the rectangle in pixels
relative to the top-left corner of the component.width
- The width of the rectangle in pixels.height
- The height of the rectangle in pixels.Component.repaint()
public void repaintColumns()
repaintRows()
,
repaint()
,
Column.repaint()
public void repaintRows()
repaintColumns()
,
repaint()
,
Row.repaint()
public void scrollHorizontally(int numUnits, int unit)
scrollHorizontally
in interface ScrollingInterface
numUnits
- Indicates the direction and amount to scroll. A positive number
scrolls forward (right). A negative number scrolls backward (left).unit
- Indicates how to interpret numUnits. Must be one of:
SCROLL_COLUMN, SCROLL_PAGE, SCROLL_MAXIMUM.scrollVertically(int, int)
public void scrollVertically(int numUnits, int unit)
scrollVertically
in interface ScrollingInterface
numUnits
- Indicates the direction and amount to scroll. A positive number
scrolls forward (down). A negative number scrolls backward (up).unit
- Indicates how to interpret numUnits. Must be one of:
SCROLL_ROW, SCROLL_PAGE, SCROLL_MAXIMUM.scrollHorizontally(int, int)
public void scrollToCell(Cell cell, boolean makeFirst)
cell
- The cell to scroll into view.makeFirst
- If true
make cell the first displayed cell;
otherwise scroll the minimum amount necessary.public void scrollToColumn(Column col, boolean makeFirst)
col
- The column to scroll into view.makeFirst
- If true
make col the first column following the
column of row labels; otherwise scroll the minimum amount necessary.public void scrollToRow(Row row, boolean makeFirst)
row
- The row to scroll into view.makeFirst
- If true
make row the first row following the
row of column labels; otherwise scroll the minimum amount necessary.public void select(DataCell start, DataCell end, boolean extend)
start
- Identifies the first cell in the range, i.e. one of the "corners".startCol
- Identifies the last cell in the range, i.e. the other "corner".extend
- If true
the selection extends the current selection set,
otherwise it replaces it.public void select(Column start, Column end, boolean extend)
start
- Identifies the first column in the range.end
- Identifies the last column in the range.extend
- If true
the selection extends the current selection set,
otherwise it replaces it.public void select(Selection range, boolean extend)
range
- The range to select.extend
- If true
the selection extends the current selection set,
otherwise it replaces it.public void select(Row start, Row end, boolean extend)
start
- Identifies the first row in the range.end
- Identifies the last row in the range.extend
- If true
the selection extends the current selection set,
otherwise it replaces it.public void setBounds(int x, int y, int width, int height)
setBounds
in interface VisualInterface
setBounds
in class ContainerVisualComponent
x
- The new x-coordinate of this component.y
- The new y-coordinate of this component.width
- The new width of this component.height
- The new height of this component.VisualInterface.setBounds(int, int, int, int)
public void unselect()
public boolean isActiveCellHighlighted()
true
.
true
if the active cell is highlighted,
and false
otherwise.setActiveCellHighlighted(boolean)
public void setActiveCellHighlighted(boolean newValue)
true
.
newValue
- The new value to assign the activeCellHighlighted property.public com.sas.collection.StaticDictionaryInterface getCellTypeStyles()
The cell types are defined by the model in order to categorize cells. For example, the cells in a column of numeric grades, 0 to 100, might be categorized as "pass" for grades 65 or greater and "fail" for grades less than 65.
The CellStyles, one for each type, are provided by the view and can be individually customized. For example,
StaticDictionaryInterface map = TableView.getCellTypeStyles (); CellStyle style = (CellStyle)map.get ("fail"); style.setForegroundColor (Color.red);
null
.StaticTableTypeStylesInterface
public java.awt.Rectangle getColumnLabelBounds()
getDataCellBounds()
,
getOriginCellBounds()
,
getPaintableBounds()
,
getRowLabelBounds()
,
getTableBounds()
public boolean isColumnLabelsVisible()
true
.
true
if column labels should be displayed,
and false
otherwise.setColumnLabelsVisible(boolean)
,
isRowLabelsVisible()
public void setColumnLabelsVisible(boolean newValue)
true
.
newValue
- The new value to assign the columnLabelsVisible property.isColumnLabelsVisible()
,
setRowLabelsVisible(boolean)
public boolean isColumnsConformed()
true
, all columns are fully in view,
and the percentage ratio of the collective width of the columns to the
component's width is greater than columnsConformedThreshold, then
the width of each column is increased proportionally so that the table
completely fills the horizontal extent of the component.
The default is false
.
true
if columns are conformed,
and false
otherwise.setColumnsConformed(boolean)
,
getColumnsConformedThreshold()
,
isRowsConformed()
public void setColumnsConformed(boolean newValue)
isColumnsConformed()
for more details.
newValue
- The new value to assign the columnsConformed property.isColumnsConformed()
,
setColumnsConformedThreshold(int)
public int getColumnsConformedThreshold()
isColumnsConformed()
returns true
.
The default is 0
.
setColumnsConformedThreshold(int)
,
isColumnsConformed()
public void setColumnsConformedThreshold(int newValue)
isColumnsConformed()
returns true
.
newValue
- The new value to assign the columnsConformedThreshold property.getColumnsConformedThreshold()
,
setColumnsConformed(boolean)
public boolean isColumnsSelectedByLabel()
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is true
.
true
if columns should be selectable via their label,
and false
otherwise.setColumnsSelectedByLabel(boolean)
,
isRowsSelectedByLabel()
,
isTableSelectedByOriginCell()
public void setColumnsSelectedByLabel(boolean newValue)
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is true
.
isColumnsSelectedByLabel()
,
setRowsSelectedByLabel(boolean)
,
setTableSelectedByOriginCell(boolean)
public TableElement getCurrentElement()
null
indicates that no element is current.
See setCurrentElement()
for more details.
setCurrentElement(com.sas.table.TableElement)
public void setCurrentElement(TableElement newValue) throws java.beans.PropertyVetoException
getSelectionElement()
with possible
types being Cell if the selection element is CELL
,
Column if the selection element is COLUMN
, and
Row if the selection element is ROW
.
Specify null
to indicate that no element is current.
newValue
- The new value to assign the currentElement property; its type
must correspond with the selection element as described above.
java.beans.PropertyVetoException
- currentElement is a constrained, or vetoable, property, so a
PropertyVetoException is thrown when the set gets vetoed.getCurrentElement()
public boolean isCurrentElementHighlighted()
true
.
true
if the current element is highlighted,
and false
otherwise.setCurrentElementHighlighted(boolean)
,
isActiveCellHighlighted()
,
getCurrentElement()
public void setCurrentElementHighlighted(boolean newValue)
true
.
newValue
- The new value to assign the currentElementHighlighted property.isCurrentElementHighlighted()
public java.awt.Rectangle getDataCellBounds()
getColumnLabelBounds()
,
getOriginCellBounds()
,
getPaintableBounds()
,
getRowLabelBounds()
,
getTableBounds()
public CellStyle getDefaultCellStyle()
null
.setDefaultCellStyle(com.sas.table.CellStyle)
,
getDefaultLabelStyle()
public void setDefaultCellStyle(CellStyle newValue)
newValue
- The new value to assign the defaultCellStyle property; it must
be non-null.getDefaultCellStyle()
,
setDefaultLabelStyle(com.sas.table.CellStyle)
public ColumnStyle getDefaultColumnStyle()
null
.setDefaultColumnStyle(com.sas.table.ColumnStyle)
,
getDefaultRowStyle()
public void setDefaultColumnStyle(ColumnStyle newValue)
newValue
- The new value to assign the defaultColumnStyle property; it must be
non-null.getDefaultColumnStyle()
,
setDefaultRowStyle(com.sas.table.RowStyle)
public CellStyle getDefaultInvalidCellStyle()
true
from Cell.isDataInvalid()
.
By default the foreground color is set to red.
null
.setDefaultInvalidCellStyle(com.sas.table.CellStyle)
,
getInvalidCells()
,
Cell.isDataInvalid()
public void setDefaultInvalidCellStyle(CellStyle newValue)
getDefaultInvalidCellStyle()
for more details.
newValue
- The new value to assign the defaultInvalidCellStyle property;
it must be non-null.getDefaultInvalidCellStyle()
public CellStyle getDefaultLabelStyle()
null
.setDefaultLabelStyle(com.sas.table.CellStyle)
,
getDefaultCellStyle()
public void setDefaultLabelStyle(CellStyle newValue)
newValue
- The new value to assign the defaultLabelStyle property;
it must be non-null.getDefaultLabelStyle()
,
setDefaultCellStyle(com.sas.table.CellStyle)
public com.sas.ModelInterface getDefaultModel()
null
.
isDefaultModelAttached()
,
setDefaultModel(com.sas.ModelInterface)
public void setDefaultModel(com.sas.ModelInterface newValue)
null
.
newValue
- The new value to assign the defaultModel property.isDefaultModelAttached()
public RowStyle getDefaultRowStyle()
null
.setDefaultRowStyle(com.sas.table.RowStyle)
,
getDefaultColumnStyle()
public void setDefaultRowStyle(RowStyle newValue)
newValue
- The new value to assign the defaultRowStyle property; it must be
non-null.getDefaultRowStyle()
,
setDefaultColumnStyle(com.sas.table.ColumnStyle)
public com.sas.collection.StaticOrderedCollectionInterface getDisplayedColumns()
null
.getDisplayedRows()
public com.sas.collection.StaticOrderedCollectionInterface getDisplayedRows()
null
.getDisplayedColumns()
public boolean isExtendedSelectionAllowed()
true
an existing selection can be extended or
added-to via a non-contiguous selection action such as ctrl-click;
if false an existing selection can not be extended and the
non-contiguous selection action will simply act like a regular selection
and replace the existing selection.
The default is true
.
Note that this property has no effect on selections made programmatically.
- Returns:
true
if selections can be extended,
and false
otherwise.- See Also:
setExtendedSelectionAllowed(boolean)
,
isMultipleSelectionAllowed()
public void setExtendedSelectionAllowed(boolean newValue)
isExtendedSelectionAllowed()
for more details.
newValue
- The new value to assign the extendedSelectionAllowed property.isExtendedSelectionAllowed()
,
setMultipleSelectionAllowed(boolean)
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
true
in order to receive focus from tab and
shift-tab key events in our parent container.public void setFont(java.awt.Font newValue)
setFont
in interface VisualInterface
setFont
in class ContainerVisualComponent
newValue
- The new value to assign the font property.Component.getFont()
public java.awt.Graphics getGraphics()
null
if this component is currently not on
the screen.
getGraphics
in class java.awt.Component
null
if it has none.public java.awt.Color getGridColor()
null
.public void setGridColor(java.awt.Color newValue)
newValue
- The new value to assign the gridColor property; it must be non-null.public boolean isGridVisible()
true
.
true
if grid lines are drawn,
and false
otherwisepublic void setGridVisible(boolean newValue)
true
.
newValue
- The new value to assign the gridVisible property.public com.sas.collection.StaticOrderedCollectionInterface getHeldColumns()
hold(com.sas.table.CellVector)
public com.sas.collection.StaticOrderedCollectionInterface getHeldRows()
hold(com.sas.table.CellVector)
public int getHorizontalScrollbarVisibility()
getHorizontalScrollbarVisibility
in interface ScrollbarVisibilityInterface
ScrollbarVisibilityInterface
,
setHorizontalScrollbarVisibility(int)
,
getVerticalScrollbarVisibility()
public void setHorizontalScrollbarVisibility(int newValue)
setHorizontalScrollbarVisibility
in interface ScrollbarVisibilityInterface
newValue
- The newValue to assign the horizontalScrollbarVisibility property.
Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and
SCROLLBARS_NEVER.ScrollbarVisibilityInterface
,
getHorizontalScrollbarVisibility()
,
setVerticalScrollbarVisibility(int)
public com.sas.collection.StaticOrderedCollectionInterface getInvalidCells()
Invalid cells can be displayed specially, such as with red text, via the defaultInvalidCellStyle.
null
.commitModifiedCells()
,
refreshModifiedCells()
,
getModifiedCells()
,
getDefaultInvalidCellStyle()
public void setModelInterface(com.sas.ModelInterface newValue)
null
to disassociate the view from its model.
setModelInterface
in interface com.sas.ViewInterface
setModelInterface
in class ContainerVisualComponent
newValue
- The new value to assign the modelInterface property.ViewInterface.setModelInterface(com.sas.ModelInterface)
public com.sas.collection.StaticOrderedCollectionInterface getModifiedCells()
null
.commitModifiedCells()
,
refreshModifiedCells()
,
getInvalidCells()
public boolean isMultipleSelectionAllowed()
true
, multiple elements can be interactively selected at
once as with a mouse drag, a shift-click, or a shift-arrow-key;
if false
, they can't.
The default is true
. Note this property has no effect on
selections made programmatically.
true
if multiple selection is allowed,
and false
otherwise.setMultipleSelectionAllowed(boolean)
,
isExtendedSelectionAllowed()
,
isSelectionAllowed()
public void setMultipleSelectionAllowed(boolean newValue)
isMultipleSelectionAllowed()
for more details.
newValue
- The new value to assign the multipleSelectionAllowed property.isMultipleSelectionAllowed()
,
setExtendedSelectionAllowed(boolean)
,
setSelectionAllowed(boolean)
public LabelCell getOriginCell()
null
.public java.awt.Rectangle getOriginCellBounds()
getColumnLabelBounds()
,
getDataCellBounds()
,
getPaintableBounds()
,
getRowLabelBounds()
,
getTableBounds()
public java.awt.Rectangle getPaintableBounds()
getColumnLabelBounds()
,
getDataCellBounds()
,
getOriginCellBounds()
,
getRowLabelBounds()
,
getTableBounds()
public boolean isPartialColumnVisible()
true
partial columns will be displayed;
if false
partial columns will not be displayed.
It's ignored if there's only one displayed column.
The default is true
.
true
if a partial column should be displayed,
and false
otherwise.setPartialColumnVisible(boolean)
,
isPartialRowVisible()
public void setPartialColumnVisible(boolean newValue)
isPartialColumnVisible()
for more details.
newValue
- The new value to assign the partialColumnVisible property.isPartialColumnVisible()
,
setPartialRowVisible(boolean)
public boolean isPartialRowVisible()
true
partial rows will be displayed;
if false
partial rows will not be displayed.
It's ignored if there's only one displayed row.
The default is true
.
true
if a partial row should be displayed,
and false
otherwise.setPartialRowVisible(boolean)
,
isPartialColumnVisible()
public void setPartialRowVisible(boolean newValue)
isPartialRowVisible()
for more details.
newValue
- The new value to assign the partialRowVisible property.isPartialRowVisible()
,
setPartialColumnVisible(boolean)
public boolean isPopupMenuVisible()
true
if the popup menu will be shown,
and false
otherwisesetPopupMenuVisible(boolean)
public void setPopupMenuVisible(boolean newValue)
Note that setting this to true
does not guarantee that
a popup menu will be shown; just that
populatePopupMenu()
will be driven giving subclasses a chance to populate one.
In order to configure a popup menu without subclassing,
create a
PopupMenuAdapter and set popupMenuVisible to
false
, as the adapter has its own popup menu.
Any commands provided by TableView, or its subclasses, can still
be used with the adapter's menu because TableView implements
ContextCommandsInterface, and therefore it can be registered
with the adapter via addContextCommandsProducer()
.
newValue
- true
if the popup menu should be shown,
and false
otherwisepublic java.util.Vector getRequiredInterfaces()
getRequiredInterfaces
in interface com.sas.ViewInterface
getRequiredInterfaces
in class ContainerVisualComponent
ViewInterface.getRequiredInterfaces()
public java.awt.Rectangle getRowLabelBounds()
getColumnLabelBounds()
,
getDataCellBounds()
,
getOriginCellBounds()
,
getPaintableBounds()
,
getTableBounds()
public boolean isRowLabelsVisible()
true
.
true
if row labels should be displayed,
and false
otherwise.setRowLabelsVisible(boolean)
,
isColumnLabelsVisible()
public void setRowLabelsVisible(boolean newValue)
true
.
newValue
- The new value to assign the rowLabelsVisible property.isRowLabelsVisible()
,
setColumnLabelsVisible(boolean)
public boolean isRowsConformed()
false
.
true
if rows are conformed,
and false
otherwise.setRowsConformed(boolean)
,
getRowsConformedThreshold()
,
isColumnsConformed()
public void setRowsConformed(boolean newValue)
isRowsConformed()
for more details.
newValue
- The new value to assign the rowsConformed property.isRowsConformed()
,
setRowsConformedThreshold(int)
public int getRowsConformedThreshold()
isRowsConformed()
returns true
.
The default is 0
.
setRowsConformedThreshold(int)
,
isRowsConformed()
public void setRowsConformedThreshold(int newValue)
isRowsConformed()
returns true
.
The default is 0
.
newValue
- The new value to assign the rowsConformedThreshold property.getRowsConformedThreshold()
,
setRowsConformed(boolean)
public boolean isRowsSelectedByLabel()
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is true
.
true
if rows should be selectable via their label,
and false
otherwise.setRowsSelectedByLabel(boolean)
,
isColumnsSelectedByLabel()
,
isTableSelectedByOriginCell()
public void setRowsSelectedByLabel(boolean newValue)
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is true
.
isRowsSelectedByLabel()
,
setColumnsSelectedByLabel(boolean)
,
setTableSelectedByOriginCell(boolean)
public java.util.Enumeration getSelectedCells()
getSelectedColumns()
,
getSelectedObjects()
,
getSelectedRanges()
,
getSelectedRows()
public java.util.Enumeration getSelectedColumns()
getSelectedCells()
,
getSelectedObjects()
,
getSelectedRanges()
,
getSelectedRows()
public java.lang.Object[] getSelectedObjects()
getSelectedObjects
in interface java.awt.ItemSelectable
null
.getSelectedCells()
,
getSelectedColumns()
,
getSelectedRanges()
,
getSelectedRows()
public java.util.Enumeration getSelectedRanges()
getSelectedCells()
,
getSelectedColumns()
,
getSelectedObjects()
,
getSelectedRows()
public java.util.Enumeration getSelectedRows()
getSelectedCells()
,
getSelectedColumns()
,
getSelectedObjects()
,
getSelectedRanges()
public boolean isSelectionAllowed()
true
selections can be made;
if false
selections can not be made.
The default is true
. Note this property has no effect on
selections made programmatically.
true
if selection is allowed,
and false
otherwise.setSelectionAllowed(boolean)
,
isExtendedSelectionAllowed()
,
isMultipleSelectionAllowed()
public void setSelectionAllowed(boolean newValue)
isSelectionAllowed()
for more details.
newValue
- The new value to assign the selectionAllowed property.isSelectionAllowed()
,
setExtendedSelectionAllowed(boolean)
,
setMultipleSelectionAllowed(boolean)
public int getSelectionElement()
CELL
(the default),
COLUMN
, and ROW
. Note that this property has
no effect on selections made programmatically.
public void setSelectionElement(int newValue)
CELL
(the default),
COLUMN
, and ROW
. Note that this property has
no effect on selections made programmatically.
newValue
- The new value to assign the selectionElement property.public final java.awt.Rectangle getTableBounds()
getColumnLabelBounds()
,
getDataCellBounds()
,
getOriginCellBounds()
,
getPaintableBounds()
,
getRowLabelBounds()
public boolean isTableSelectedByOriginCell()
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is false
.
true
if the table is selectable via the orign cell,
and false
otherwise.setTableSelectedByOriginCell(boolean)
,
isColumnsSelectedByLabel()
,
isRowsSelectedByLabel()
,
getOriginCell()
public void setTableSelectedByOriginCell(boolean newValue)
getSelectionElement()
returns CELL
and
isMultipleSelectionAllowed()
returns true
.
The default is false
.
newValue
- The new value to assign the tableSelectedByOriginCell property.isTableSelectedByOriginCell()
,
setColumnsSelectedByLabel(boolean)
,
setRowsSelectedByLabel(boolean)
public int getTransactionElement()
CELL, COLUMN, ROW,
and USER_DEFINED
.
When transactionElement is CELL
, modified cells are committed
whenever a cell is deactivated.
When transactionElement is COLUMN
, modified cells are committed
whenever the current column is changed.
When transactionElement is ROW
, modified cells are committed
whenever the current row is changed.
When transactionElement is USER_DEFINED
, modified cells are
committed only when commitModifiedCells()
is called.
setTransactionElement(int)
,
commitModifiedCells()
public void setTransactionElement(int newValue)
getTransactionElement()
for more details.
newValue
- The new value to assign the transactionElement property.getTransactionElement()
public int getVerticalScrollbarVisibility()
getVerticalScrollbarVisibility
in interface ScrollbarVisibilityInterface
ScrollbarVisibilityInterface
,
setVerticalScrollbarVisibility(int)
,
getHorizontalScrollbarVisibility()
public void setVerticalScrollbarVisibility(int newValue)
setVerticalScrollbarVisibility
in interface ScrollbarVisibilityInterface
newValue
- The newValue to assign the verticalScrollbarVisibility property.
Possible values are SCROLLBARS_AS_NEEDED, SCROLLBARS_ALWAYS, and
SCROLLBARS_NEVER.ScrollbarVisibilityInterface
,
getVerticalScrollbarVisibility()
,
setHorizontalScrollbarVisibility(int)
public void attachModel(com.sas.ModelInterface model)
Associates a model with this view. This view can only be associated with a single model at a time, therefore detachModel() must be called between two calls to attachModel().
attachModel
in interface com.sas.ViewInterface
attachModel
in class ContainerVisualComponent
model
- The model to attach. It must implement
StaticTableInterface.ViewInterface.attachModel(com.sas.ModelInterface)
public void detachModel(com.sas.ModelInterface model)
Disassociates a model from this view.
detachModel
in interface com.sas.ViewInterface
detachModel
in class ContainerVisualComponent
model
- The model to detach. Must have been previously attached via
attachModel(model) instead.ViewInterface.detachModel(com.sas.ModelInterface)
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
event
- The event to react to.public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
Implementation note: The events are simply queued-up here and processed later, so subclasses will likely want to override processContentsChangedEvent() instead.
contentsChanged
in interface com.sas.collection.ContentsChangedListener
event
- The event to react to.public void propertyBagChanged(com.sas.collection.PropertyBagChangedEvent e)
propertyBagChanged
in interface com.sas.collection.PropertyBagChangedListener
e
- The event to react to.public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange
in interface java.beans.PropertyChangeListener
propertyChange
in class ContainerVisualComponent
e
- The event to react to.PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
public void setDefaultValues()
setDefaultValues
in interface ContainerInterface
setDefaultValues
in interface VisualInterface
setDefaultValues
in interface com.sas.ComponentInterface
setDefaultValues
in class CompositeContainer
java.lang.IllegalStateException
- Thrown if called a second time.ContainerInterface.setDefaultValues()
protected TableView clone(double horizontalScale, double verticalScale) throws java.lang.CloneNotSupportedException
Constructs a clone, then calls cloneModelIndependentState (clone,
horizontalScale, verticalScale)
followed by
cloneModelDependentState (clone, horizontalScale, verticalScale)
.
horizontalScale
- Specifies the scaling factor that should be applied to any x-pixel
values such as column widths. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different horizontal resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.verticalScale
- Specifies the scaling factor that should be applied to any y-pixel
values such as row heights. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different vertical resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.
java.lang.CloneNotSupportedException
- TableView supports cloning, but a subclass may not.cloneModelIndependentState(com.sas.table.TableView, double, double)
,
cloneModelDependentState(com.sas.table.TableView, double, double)
protected void cloneModelDependentState(TableView clone, double horizontalScale, double verticalScale) throws java.lang.CloneNotSupportedException
Called by clone(double, double).
clone
- The instance that is to be this component's clone.horizontalScale
- Specifies the scaling factor that should be applied to any x-pixel
values such as column widths. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different horizontal resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.verticalScale
- Specifies the scaling factor that should be applied to any y-pixel
values such as row heights. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different vertical resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.
java.lang.CloneNotSupportedException
- TableView supports cloning, but a subclass may not.cloneModelIndependentState(com.sas.table.TableView, double, double)
protected void cloneModelIndependentState(TableView clone, double horizontalScale, double verticalScale) throws java.lang.CloneNotSupportedException
Called by clone(double, double).
clone
- The instance that is to be this component's clone.horizontalScale
- Specifies the scaling factor that should be applied to any x-pixel
values such as column widths. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different horizontal resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.verticalScale
- Specifies the scaling factor that should be applied to any y-pixel
values such as row heights. Normally one is specified, but if
the clone is to be parented to a container (device) that has a
different vertical resolution than is in effect for this
component, then the ratio of that resolution to the resolution in
effect should be specified so that pixel values can be
appropriately scaled.
java.lang.CloneNotSupportedException
- TableView supports cloning, but a subclass may not.cloneModelDependentState(com.sas.table.TableView, double, double)
protected DataCell createCell(Row row, Column col)
row
- The row that contains the cell.col
- The column that contains the cell.
protected Column createColumn(int index)
index
- The one-based position of the column in the model.
protected LabelCell createColumnLabel(Column col)
col
- The column that contains the label.
protected LabelCell createOriginCell()
protected Row createRow(int index)
index
- The one-based position of the row in the model.
protected LabelCell createRowLabel(Row row)
row
- The row that contains the label.
protected int getDefaultColumnIndex()
protected int getDefaultRowIndex()
protected java.awt.Insets getLabelInsets()
getInsets()
, but subclasses that want to assume responsibility
for measuring and painting their own row and column labels can override
this without calling super to return larger insets in order to
offset the data cells as TableView will always call this instead of
getInsets()
.
Container.getInsets()
protected java.awt.Rectangle getTableBounds(java.awt.Graphics g)
Called by getTableBounds() with
null
and by
paint(Graphics g) with g
.
Calls updateView().
g
- The graphics context to format with. If null
,
one will be acquired if needed via getGraphics()
.
getColumnLabelBounds()
,
getDataCellBounds()
,
getOriginCellBounds()
,
getPaintableBounds()
,
getRowLabelBounds()
protected TableView newTableView()
protected void paintTable(java.awt.Graphics g, java.awt.Rectangle invalidBounds)
g
- The graphics context to use for painting.invalidBounds
- The area to paint.protected void populatePopupMenu(java.awt.PopupMenu popupMenu, TableElement element)
Called by
processMouseEvent(event) with an empty
popupMenu whenever both event.isPopupTrigger()
and isPopupMenuVisible()
return true
.
popupMenu
- The menu to populate.element
- The table element --
Cell,
Column,
Row,
or null
(the table itself) --
to use as context when populating the menu.isPopupMenuVisible()
protected void processEvent(java.awt.AWTEvent event)
if (isEnabled()) super.processEvent(event);
.
processEvent
in class java.awt.Container
event
- The awt-event to process.protected void processFocusEvent(java.awt.event.FocusEvent fe)
processFocusEvent
in class java.awt.Component
fe
- The focus event.FocusListener
protected void processKeyEvent(java.awt.event.KeyEvent ke)
processKeyEvent
in class java.awt.Component
ke
- The key event.KeyListener
,
InputEvent.consume()
protected void processMouseEvent(java.awt.event.MouseEvent me)
processMouseEvent
in class java.awt.Component
me
- The mouse event.MouseListener
,
InputEvent.consume()
protected void processMouseMotionEvent(java.awt.event.MouseEvent me)
processMouseMotionEvent
in class java.awt.Component
me
- The mouse motion event.MouseMotionListener
,
InputEvent.consume()
protected void updateView(java.awt.Graphics g)
g
- The graphics context to format with. If null
,
one will be acquired if needed via getGraphics()
.processChanges()
,
formatView(java.awt.Graphics)
protected void processChanges()
Calls processContentsChangedEvent() for each com.sas.collection.ContentsChangedEvent that has been queued by contentsChanged() and empties the queue.
Called by updateView().
protected boolean processContentsChangedEvent(com.sas.collection.ContentsChangedEvent event)
Called by processChanges().
When the event indicates that everything has changed,
onAllChanged() is called and true
is returned.
event
- The event to process.
true
if everything changed, i.e. the equivalent of
refresh(), and false
otherwiseprotected void onAllChanged()
Called by processContentsChangedEvent().
This implementation resets some internal data structures and calls repaint().
protected void formatView(java.awt.Graphics g)
Called by updateView(g).
Calls updateDisplayedColumns(g) and updateDisplayedRows(g).
g
- The graphics context to format with. If null
,
one will be acquired if needed via getGraphics()
.protected void updateDisplayedColumns(java.awt.Graphics g)
Called by formatView(g).
Calls onSizeColumn().
g
- The graphics context to format with.updateDisplayedRows(java.awt.Graphics)
,
getDisplayedColumns()
protected void updateDisplayedRows(java.awt.Graphics g)
Called by formatView(g).
Calls onSizeRow().
g
- The graphics context to format with.updateDisplayedColumns(java.awt.Graphics)
,
getDisplayedRows()
protected void onSizeColumn(Column col, java.awt.Graphics g)
Called by
updateDisplayedColumns()
whenever a column has no size (col.getSize()
returns zero).
The default implementation
is col.setPreferredSize (col.computePreferredSize(g));
.
col
- The column to size.g
- The graphics context to format with.onSizeRow(com.sas.table.Row, java.awt.Graphics)
protected void onSizeRow(Row row, java.awt.Graphics g)
Called by
updateDisplayedRows()
whenever a row has no size (row.getSize()
returns zero).
The default implementation
is row.setPreferredSize (row.computePreferredSize(g));
.
row
- The row to size.g
- The graphics context to format with.onSizeColumn(com.sas.table.Column, java.awt.Graphics)
protected void setCursor(java.awt.Point point)
Called by processMouseMotionEvent().
point
- The location of the mouse pointer.setCursor(java.awt.Point)
public void setCursor(java.awt.Cursor cursor)
setCursor
in class java.awt.Component
cursor
- One of the cursor constants defined by the Cursor class.
If this parameter is null
then this component will
inherit the cursor of its parent.
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |