|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JTable com.jidesoft.grid.JideTable com.jidesoft.grid.ContextSensitiveTable com.jidesoft.grid.NavigableTable com.jidesoft.grid.CellStyleTable com.jidesoft.grid.CellSpanTable com.jidesoft.grid.CategorizedTable com.jidesoft.grid.SortableTable com.jidesoft.grid.TreeTable
public class TreeTable
TreeTable
is a combination of a tree and a table -- a component capable of both expanding and
contracting rows, as well as showing multiple columns of data. Tree and table work on different data structure. The
former is used to display hierarchical data. The latter is used to disable a flat tabular data. So in order to make
the data works in TreeTable, we need to hierarchize the flat tabular data. To make the design simple, we make the
following assumption
If the data can be used in TreeTable, it must be row-oriented, meaning each row in the table can be represented as one data structure. Based on this assumption, we introduce several concepts (they are all Interfaces) to make TreeTable possible.
Node
: represent a node in tree data structure
Expandable
: represent something can be expanded such as tree node with children. Row
:
represent a row in table data structure. ExpandableRow
: represent a row which can have children rows.
TreeTable
is TreeTableModel
. It extends AbstractTableModel. However it's
essentially a list of ExpandableRows or Rows. TreeTableModel
is an abstract class. The only method you
has to implement is TableModel.getColumnCount()
. You might want to override AbstractTableModel.getColumnName(int)
. Otherwise, it will use "A", "B" etc as default names. You also need to make the
columns match with the value you returned in Row.getValueAt(int)
. Once we create a java.util.List of the
Rows, you call
TreeTableModel model = new MyTreeTableModel(list);
TreeTable table = new TreeTable(model);
Now you get a TreeTable instance.
TreeTable
uses a special cell renderer on the first column to paint +/- icon as well as tree line. If
the row is expandable, you will see +/- icon. Clicking on it will expand the row. Clicking again will collapse it.
You can also use keyboard to expand/collapse a row. Right arrow key will expand the selected row and left arrow key
will collapse it. If the selected row doesn't have children or it is collapsed already, it will change the selection
to its parent. If you try it, you will find it is very convenient to navigate in the tree table using arrow keys.
Since the first columns are used to paint +/- icon and tree lines, it'd better you make the first column of the table
not editable. There should be workaround for this limitation, such as using dialog to edit the first cell or
rearranging the table columns to use a non-editable column as the first one.
We used the same +/- icons used in JTree so it will change based on different LookAndFeels. You can also define your
own icons by calling CategorizedTable.setExpandedIcon(javax.swing.Icon)
and CategorizedTable.setCollapsedIcon(javax.swing.Icon)
. The
tree lines can be turn on or off using setShowTreeLines(boolean)
. The line color can be set by setTreeLineColor(java.awt.Color)
. By default, it will use the JTree's tree line color which is
UIManagerLookup.getColor("Tree.hash")
.
There are several keystrokes you can use to expand or collapse rows. If the current cell is the first cell, you can
use right or left arrow keys to expand or collapse the selected row respectively. You can also use "+", "-", "*", "/"
key on Numpad to expand, collapse, expand all, collapse all respectively. So if your tree table has a huge number or
unlimited number of children nodes, you should disable expand all operation because it will never end. This is
important because Numpad "*" will trigger expand all. If you didn't disable expand all, user might press Numpad "*"
key by mistake and freeze the GUI.
Nested Class Summary | |
---|---|
protected class |
TreeTable.DelegateExpandMouseInputListener
|
protected class |
TreeTable.ExpandMouseListener
|
protected static class |
TreeTable.TreeTableAction
|
Nested classes/interfaces inherited from class com.jidesoft.grid.CellSpanTable |
---|
CellSpanTable.DelegateAction |
Nested classes/interfaces inherited from class com.jidesoft.grid.JideTable |
---|
JideTable.NonContiguousTransferHandler |
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
CLIENT_PROPERTY_DO_NOT_PAINT_CELL_CONTENT_BACKGROUND
|
static String |
PROPERTY_DOUBLE_CLICK_ENABLED
|
static String |
PROPERTY_EXPANDABLE_COLUMN
|
static String |
PROPERTY_SELECT_ROW_WHEN_TOGGLING
|
static String |
PROPERTY_SHOW_LEAF_NODE_TREE_LINES
|
static String |
PROPERTY_SHOW_TREE_LINES
|
static String |
PROPERTY_TREE_LINE_COLOR
|
Fields inherited from class com.jidesoft.grid.SortableTable |
---|
MULTICOLUMN_SORTABLE_PROPERTY, PROPERTY_SHOW_SORT_ORDER_NUMBER, SORTABLE_PROPERTY |
Fields inherited from class com.jidesoft.grid.CategorizedTable |
---|
DEFAULT_ASCENDING_ICON, DEFAULT_DESCENDING_ICON, PROPERTY_EXPAND_ICON_VISIBLE |
Fields inherited from class com.jidesoft.grid.CellSpanTable |
---|
AUTO_CELL_MERGE_COLUMNS, AUTO_CELL_MERGE_COLUMNS_LIMITED, AUTO_CELL_MERGE_OFF, AUTO_CELL_MERGE_ROWS, AUTO_CELL_MERGE_ROWS_LIMITED, PROPERTY_AUTO_CONVERT_CELL_SPAN, PROPERTY_PAINT_CELL_SPAN_AS_SELECTED |
Fields inherited from class com.jidesoft.grid.CellStyleTable |
---|
_cellStyleList, PROPERTY_FILLS_SELECTION, PROPERTY_FILLS_VIEWPORT_WITH_STRIPE |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
TreeTable()
|
|
TreeTable(int numRows,
int numColumns)
|
|
TreeTable(Object[][] rowData,
Object[] columnNames)
|
|
TreeTable(TableModel dm)
|
|
TreeTable(TableModel dm,
TableColumnModel cm)
|
|
TreeTable(TableModel dm,
TableColumnModel cm,
ListSelectionModel sm)
|
|
TreeTable(Vector<?> rowData,
Vector<?> columnNames)
|
Method Summary | |
---|---|
void |
addSelectedRow(Row row)
Adds the specified Row . |
void |
addSelectedRows(Row[] rows)
Adds the specified rows . |
void |
addTreeExpansionListener(TreeExpansionListener tel)
Adds a listener for TreeExpansion events. |
void |
addTreeWillExpandListener(TreeWillExpandListener tel)
Adds a listener for TreeWillExpand events. |
boolean |
alwaysCalculateCellRect()
A boolean flag to determine if the rect should always be calculated when painting the grid line and cells. |
void |
collapseAll()
Collapses all so that all non-top level rows are invisible. |
void |
collapseFirstLevel()
Collapses all top level rows only. |
void |
collapseLastLevel()
Collapses all top level rows only. |
protected TableCellRenderer |
createCellRenderer()
Creates the special cell renderer for the first column which paints +/- icon and tree line. |
protected Action |
createDelegateAction(Action action,
KeyStroke keyStroke)
|
protected MouseInputListener |
createExpandMouseInputListener(MouseInputListener listener)
Creates the mouse listener used to handle mouse click on +/- icon. |
protected MouseInputListener |
createExpandMouseListener()
Creates the mouse listener used to handle mouse click on +/- icon. |
protected ISortableTableModel |
createSortableTableModel(TableModel model)
Override the method in SortableTable to create a special sortable table model for TreeTable. |
Row |
expandableRowAtPoint(Point p)
If the point falls into the expand icon (+/- icon), this method will return the Row. |
void |
expandAll()
Expands all so that all rows are visible. |
void |
expandFirstLevel()
Expands all top level rows. |
void |
expandNextLevel()
Expands one more level of rows. |
boolean |
expandRow(int rowIndex,
boolean expanded)
Expands or collapses the row at the specified rowIndex. |
void |
fireTreeCollapsed(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. |
void |
fireTreeExpanded(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. |
void |
fireTreeWillCollapse(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. |
void |
fireTreeWillExpand(TreePath path)
Notifies all listeners that have registered interest for notification on this event type. |
TableCellRenderer |
getActualCellRenderer(int rowIndex,
int columnIndex)
|
String |
getActualUIClassID()
Returns a string that specifies the name of the L&F class that renders this component. |
protected Point |
getCellAt(Point p)
|
protected Rectangle |
getCellRect(Point p)
Gets the cell rect which contains point p. |
TableCellRenderer |
getCellRenderer(int rowIndex,
int columnIndex)
Returns an appropriate renderer for the cell specified by this row and column. |
int |
getDragExpandDelay()
Get the delay time while dragging to expand a row. |
Rectangle |
getEditorCellRect(int rowIndex,
int columnIndex)
In TreeTable and HierarchicalTable case, the cell rect for cell editor should consider the +/- icon size so the cell editor doesn't cover the +/- icon. |
int |
getExpandableColumn()
Gets the expandable column. |
int |
getExpandableColumnViewIndex()
Gets the expandable column view index. |
int |
getHorizontalLegPosition(int cellHeight)
Gets the horizontal leg y position. |
int |
getIndent()
Gets the indent of child level, in pixels. |
protected int |
getIndent(Row row)
Get the indent specificall for this row in the TreeTable. |
int |
getLeftMargin()
Gets the left margin of first level, in pixels. |
Row |
getRowAt(int rowIndex)
Gets the Row from the underlying table model. |
int |
getRowIndex(Row row)
|
boolean |
getShowsRootHandles()
Returns the value of the showsRootHandles property. |
TreeExpansionListener[] |
getTreeExpansionListeners()
Returns an array of all the TreeExpansionListener s added to this TreeTable with
addTreeExpansionListener(). |
Color |
getTreeLineColor()
Gets the line color used to pain the tree line. |
protected TableModel |
getTreeTableModel()
|
TreeWillExpandListener[] |
getTreeWillExpandListeners()
Returns an array of all the TreeWillExpandListener s added to this JTree with
addTreeWillExpandListener(). |
int |
getVerticalLineStartPosition(int cellHeight)
Gets the vertical line start position. |
protected void |
handleMouseEvent(MouseEvent e)
Handles the mouse event. |
boolean |
isCompareCurrentSelection()
Get the flag indicating if comparing with the current selection before loading selection. |
boolean |
isDoubleClickEnabled()
Checks if the double click is enabled. |
boolean |
isExpandable()
Whether allowing the rows to be expanded and collapsed by the users. |
boolean |
isExpandAllAllowed()
Is expand all or collapse all operations are allowed. |
boolean |
isExportCollapsedRowsToExcel()
Get the flag indicating if collapsed rows would be exported to excel while exporting. |
boolean |
isRespectRenderPreferredHeight()
Gets the flag if the renderer's preferred height is respected. |
boolean |
isSelectParentRowWhenCollapsing()
Gets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected. |
boolean |
isSelectRowWhenToggling()
Gets the value of selectRowWhenToggling property. |
boolean |
isShowLeafNodeTreeLines()
Checks if the tree lines are visible. |
boolean |
isShowTreeLines()
Checks if the tree lines are visible. |
protected void |
muteDefaultKeyStroke()
|
void |
removeNotify()
|
void |
removeSelectedRow(Row row)
Removes the selection on the specified Row . |
void |
removeSelectedRows(Row[] rows)
Removes the specified rows . |
void |
removeTreeExpansionListener(TreeExpansionListener tel)
Removes a listener for TreeExpansion events. |
void |
removeTreeWillExpandListener(TreeWillExpandListener tel)
Removes a listener for TreeWillExpand events. |
void |
setCompareCurrentSelection(boolean compareCurrentSelection)
Set the flag indicating if comparing with the current selection before loading selection. |
void |
setDoubleClickEnabled(boolean doubleClickEnabled)
Enables double click on the row to expand/collapse the row. |
void |
setDragExpandDelay(int dragExpandDelay)
Set the delay time while dragging to expand a row. |
void |
setExpandable(boolean expandable)
Sets the flag if the rows are allowed to be expanded and collapsed by the users. |
void |
setExpandableColumn(int expandableColumn)
Sets the expandable column. |
void |
setExpandAllAllowed(boolean expandAllAllowed)
Sets if expand all or collapse all are allowed. |
void |
setExportCollapsedRowsToExcel(boolean exportCollapsedRowsToExcel)
Set the flag indicating if collapsed rows would be exported to excel while exporting. |
void |
setIndent(int indent)
Sets the indent of child level, in pixels. |
void |
setLeftMargin(int leftMargin)
Sets the left margin of first level, in pixels. |
void |
setModel(TableModel tableModel)
Sets the data model for this table to newModel and registers with it for listener notifications from
the new data model. |
void |
setRespectRenderPreferredHeight(boolean respectRenderPreferredHeight)
Sets the flag if the renderer's preferred height is respected. |
void |
setSelectedRow(Row row)
Selects the specified Row . |
void |
setSelectedRows(Row[] rows)
Selects the specified rows . |
void |
setSelectParentRowWhenCollapsing(boolean selectParentRowWhenCollapsing)
Sets the flag indicating if the parent row should be selected when it's collapsed and one of its child row is already selected. |
void |
setSelectRowWhenToggling(boolean selectRowWhenToggling)
Sets the selectRowWhenToggling flag. |
void |
setShowLeafNodeTreeLines(boolean showLeafNodeTreeLines)
Sets the tree lines visible or not. |
void |
setShowsRootHandles(boolean showRootHandles)
Sets the value of the showsRootHandles property, which specifies whether the node handles should be
displayed. |
void |
setShowTreeLines(boolean showTreeLines)
Sets the tree lines visible or not. |
void |
setTreeLineColor(Color treeLineColor)
Sets the tree line color. |
boolean |
shouldDisplayExpandIcon(Row row)
Check if the expand icon should be displayed for a row. |
boolean |
shouldPaintHorizontalLeg(int rowIndex)
Check if TreeTable should paint the horizontal leg for the row. |
void |
tableChanged(TableModelEvent e)
Invoked when this table's TableModel generates a TableModelEvent . |
protected boolean |
toggleRow(Row row)
|
void |
updateUI()
Resets the UI property to a value from the current look and feel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jidesoft.grid.TableAdapter |
---|
getCellSelectionEnabled, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getRowCount, getRowSelectionAllowed, isCellEditable, setCellSelectionEnabled, setValueAt |
Field Detail |
---|
public static final String PROPERTY_SHOW_TREE_LINES
public static final String PROPERTY_SHOW_LEAF_NODE_TREE_LINES
public static final String PROPERTY_TREE_LINE_COLOR
public static final String PROPERTY_DOUBLE_CLICK_ENABLED
public static final String PROPERTY_EXPANDABLE_COLUMN
public static final String PROPERTY_SELECT_ROW_WHEN_TOGGLING
public static final String CLIENT_PROPERTY_DO_NOT_PAINT_CELL_CONTENT_BACKGROUND
Constructor Detail |
---|
public TreeTable()
public TreeTable(int numRows, int numColumns)
public TreeTable(TableModel dm)
public TreeTable(Object[][] rowData, Object[] columnNames)
public TreeTable(Vector<?> rowData, Vector<?> columnNames)
public TreeTable(TableModel dm, TableColumnModel cm)
public TreeTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
Method Detail |
---|
public void updateUI()
updateUI
in class CategorizedTable
JComponent.updateUI()
public String getActualUIClassID()
getActualUIClassID
in class CellSpanTable
UIDefaults.getUI(javax.swing.JComponent)
protected TableCellRenderer createCellRenderer()
protected void muteDefaultKeyStroke()
muteDefaultKeyStroke
in class CellSpanTable
public void setModel(TableModel tableModel)
newModel
and registers with it for listener notifications from
the new data model.
If the table is in editing mode, it will stop cell editing first.
TreeTable
only supports TreeTableModel
. If newModel
is null
or tableModel is not an instance of TreeTableModel
. An empty TreeTableModel
will be
created and used.
setModel
in class SortableTable
tableModel
- the new data source for this table. It must be an instance of TreeTableModelJTable.getModel()
protected void handleMouseEvent(MouseEvent e)
isDoubleClickEnabled()
is true, double click on the row any place other than +/- icon will
expand/collapse the row as well.
Please note, since 1.9.4.10 release, we change the signature of this method to return boolean. If you override
this method before, you will get a compile error. Simply change the overridden method to return boolean will fix
it.
e
- the mouse eventprotected boolean toggleRow(Row row)
public Row getRowAt(int rowIndex)
rowIndex
- the row index
public int getRowIndex(Row row)
public boolean expandRow(int rowIndex, boolean expanded)
rowIndex
- rowIndex to be expanded.expanded
- true to expand and false to collapse.
public boolean isSelectRowWhenToggling()
public void setSelectRowWhenToggling(boolean selectRowWhenToggling)
selectRowWhenToggling
- true or false. If true, the row will be selected when when a row is expanded or
collapsed. If false, the old selection will be kept when a row is expanded or
collapsed.public void setSelectedRow(Row row)
Row
. In TreeTable, a Row
could be at any row index when
expand/collapse state changes. The old way to select a row using selection model won't work. This method will
make it easier to select a row by passing in the Row
which you usually know.
If the Row
is not visible, it will expand its parents to make it visible.
row
- the rowpublic void addSelectedRow(Row row)
Row
. In TreeTable, a Row
could be at any row index when
expand/collapse state changes. The old way to select a row using selection model won't work. This method will
make it easier to select a row by passing in the Row
which you usually know.
If the Row
is not visible, it will expand its parents to make it visible.
row
- the rowpublic void removeSelectedRow(Row row)
Row
. In TreeTable, a Row
could be at any row
index when expand/collapse state changes. The old way to de-select a row using selection model won't work. This
method will make it easier to de-select a row by passing in the Row
which you usually know.
row
- the rowpublic void setSelectedRows(Row[] rows)
rows
. In TreeTable, a Row
could be at any row index when
expand/collapse state changes. The old way to select rows using selection model won't work. This method will make
it easier to select rows by passing in the rows
which you usually know.
If the rows
are not visible, it will expand their parents to make them visible.
rows
- the rowspublic void addSelectedRows(Row[] rows)
rows
. In TreeTable, a Row
could be at any row index when
expand/collapse state changes. The old way to select rows using selection model won't work. This method will make
it easier to select rows by passing in the rows
which you usually know.
If the rows
are not visible, it will expand their parents to make them visible.
rows
- the rowspublic void removeSelectedRows(Row[] rows)
rows
. In TreeTable, a Row
could be at any row index when
expand/collapse state changes. The old way to de-select rows using selection model won't work. This method will
make it easier to de-select rows by passing in the rows
which you usually know.
rows
- the rowspublic void expandAll()
public void expandFirstLevel()
public void expandNextLevel()
public void collapseAll()
public void collapseFirstLevel()
public void collapseLastLevel()
protected Rectangle getCellRect(Point p)
p
- the point
protected Point getCellAt(Point p)
public TableCellRenderer getActualCellRenderer(int rowIndex, int columnIndex)
public void tableChanged(TableModelEvent e)
JideTable
TableModel
generates a TableModelEvent
. The
TableModelEvent
should be constructed in the coordinate system of the model; the appropriate mapping
to the view coordinate system is performed by this JTable
when it receives the event.
Application code will not use these methods explicitly, they are used internally by JTable
.
tableChanged
in interface TableModelListener
tableChanged
in class CellSpanTable
public void removeNotify()
removeNotify
in class JideTable
public TableCellRenderer getCellRenderer(int rowIndex, int columnIndex)
ContextSensitiveTable
ContextSensitiveTable.getDefaultCellRenderer()
method. If null, it will check is ContextSensitiveTable.isCellRendererManagerEnabled()
is true. If true, it will look for the cell renderer that assigned to the
specific column. Only if the renderer is still null, it will use the EditorContext information from
ContextSensitiveTableModel and get the correct CellRedenerer from the CellRendererManager. In any case, if we
can't determine a cell renderer, we will call super.getCellRenderer(row, column) just like regular JTable.
getCellRenderer
in class CellSpanTable
rowIndex
- the row of the cell to render, where 0 is the first rowcolumnIndex
- the column of the cell to render, where 0 is the first column
protected Action createDelegateAction(Action action, KeyStroke keyStroke)
createDelegateAction
in class CellSpanTable
public boolean isCompareCurrentSelection()
setCompareCurrentSelection(boolean)
public void setCompareCurrentSelection(boolean compareCurrentSelection)
compareCurrentSelection
- if current selection will be compared with the selection to load. By default, the
value is false for performance reason. You could turn this flag to true if you
care more about the selection events.public boolean isExportCollapsedRowsToExcel()
public void setExportCollapsedRowsToExcel(boolean exportCollapsedRowsToExcel)
exportCollapsedRowsToExcel
- the flagisExportCollapsedRowsToExcel()
protected int getIndent(Row row)
getIndent()
to
return. If you want to customize the indent behavior for specific rows, please override this method.
row
- the row
public int getDragExpandDelay()
JTable.setDragEnabled(boolean)
,
JTable.setDropMode(javax.swing.DropMode)
,
JComponent.setTransferHandler(javax.swing.TransferHandler)
public void setDragExpandDelay(int dragExpandDelay)
dragExpandDelay
- the delay time in millisecondsgetDragExpandDelay()
public boolean isSelectParentRowWhenCollapsing()
setSelectParentRowWhenCollapsing(boolean)
public void setSelectParentRowWhenCollapsing(boolean selectParentRowWhenCollapsing)
selectParentRowWhenCollapsing
- the flagprotected MouseInputListener createExpandMouseListener()
createExpandMouseInputListener(javax.swing.event.MouseInputListener)
instead.
createExpandMouseInputListener(javax.swing.event.MouseInputListener)
protected MouseInputListener createExpandMouseInputListener(MouseInputListener listener)
createExpandMouseListener()
instead.
listener
- the MouseInputListener
createExpandMouseListener()
public void addTreeExpansionListener(TreeExpansionListener tel)
TreeExpansion
events.
Please note, methods such as expandAll()
, expandFirstLevel()
, expandNextLevel()
,
collapseAll()
, collapseFirstLevel()
and collapseLastLevel()
will not fire this event.
tel
- a TreeExpansionListener that will be notified when a row is expanded or collapsed (a "negative
expansion")public void removeTreeExpansionListener(TreeExpansionListener tel)
TreeExpansion
events.
tel
- the TreeExpansionListener
to removepublic TreeExpansionListener[] getTreeExpansionListeners()
TreeExpansionListener
s added to this TreeTable with
addTreeExpansionListener().
TreeExpansionListener
s added or an empty array if no listeners have been addedpublic void fireTreeExpanded(TreePath path)
path
parameter.
path
- the TreePath
indicating the node that was expandedEventListenerList
public void fireTreeCollapsed(TreePath path)
path
parameter.
path
- the TreePath
indicating the node that was collapsedEventListenerList
public void addTreeWillExpandListener(TreeWillExpandListener tel)
TreeWillExpand
events.
Please note, methods such as expandAll()
, expandFirstLevel()
, expandNextLevel()
,
collapseAll()
, collapseFirstLevel()
and collapseLastLevel()
will not fire this event.
tel
- a TreeWillExpandListener
that will be notified when a tree node will be expanded or
collapsed (a "negative expansion")public void removeTreeWillExpandListener(TreeWillExpandListener tel)
TreeWillExpand
events.
tel
- the TreeWillExpandListener
to removepublic TreeWillExpandListener[] getTreeWillExpandListeners()
TreeWillExpandListener
s added to this JTree with
addTreeWillExpandListener().
TreeWillExpandListener
s added or an empty array if no listeners have been addedpublic void fireTreeWillExpand(TreePath path) throws ExpandVetoException
path
parameter.
path
- the TreePath
indicating the node that was expanded
ExpandVetoException
- if the tree node is not allowed to be expandedEventListenerList
public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException
path
parameter.
path
- the TreePath
indicating the node that was expanded
ExpandVetoException
- if the tree node is not allowed to be collapsedEventListenerList
public boolean isShowTreeLines()
public void setShowTreeLines(boolean showTreeLines)
PROPERTY_SHOW_TREE_LINES
be fired when
value changes.
showTreeLines
- true to show the tree lines. Otherwise false.public boolean isShowLeafNodeTreeLines()
public void setShowLeafNodeTreeLines(boolean showLeafNodeTreeLines)
PROPERTY_SHOW_LEAF_NODE_TREE_LINES
be fired
when value changes.
showLeafNodeTreeLines
- true to show leaf node's tree linespublic boolean isDoubleClickEnabled()
public void setDoubleClickEnabled(boolean doubleClickEnabled)
PROPERTY_DOUBLE_CLICK_ENABLED
be fired when value changes.
doubleClickEnabled
- true to enable double click to expand/collapse a rowpublic Color getTreeLineColor()
public void setTreeLineColor(Color treeLineColor)
PROPERTY_TREE_LINE_COLOR
be fired when value
changes.
treeLineColor
- the new tree line colorprotected TableModel getTreeTableModel()
protected ISortableTableModel createSortableTableModel(TableModel model)
createSortableTableModel
in class SortableTable
model
- the table model.
public int getIndent()
public void setIndent(int indent)
indent
- the new indentpublic int getLeftMargin()
setLeftMargin(int)
public void setLeftMargin(int leftMargin)
leftMargin
- the left marginpublic boolean getShowsRootHandles()
showsRootHandles
property.
showsRootHandles
property_showsRootHandles
public void setShowsRootHandles(boolean showRootHandles)
showsRootHandles
property, which specifies whether the node handles should be
displayed. The default value of this property depends on the constructor used to create the
TreeTable
. Some look and feels might not support handles; they will ignore this property.
showRootHandles
- true
if root handles should be displayed; otherwise, false
description: Whether the node handles are to be displayed._showsRootHandles
,
getShowsRootHandles()
public boolean isExpandAllAllowed()
public void setExpandAllAllowed(boolean expandAllAllowed)
expandAllAllowed
- true to enable expand allpublic boolean isExpandable()
public void setExpandable(boolean expandable)
expandable
- true to allow the rows to be expanded and collapsed by the users.public int getExpandableColumnViewIndex()
getExpandableColumn()
, this one will convert the
index from model index to index. There is no setter for this method, you have to set it through setExpandableColumn(int)
. If you never called setExpandableColumn, this method will always return 0 meaning the
first visible column will be used to display the +/- icon.
public boolean shouldPaintHorizontalLeg(int rowIndex)
Row row = getRowAt(rowIndex);
if (row == null) {
return false;
}
Expandable parent = row.getParent();
if (row instanceof Expandable && !((Expandable) row).hasChildren() && !isShowLeafNodeTreeLines() && parent
instanceof Row) {
int lastChildIndex = getRowIndex((Row) parent) + TableModelWrapperUtils.getVisibleChildrenCount(getModel(),
(Row) parent);
if (rowIndex != lastChildIndex) {
return false;
}
}
return true;
rowIndex
- the index of the row
isShowLeafNodeTreeLines()
public int getExpandableColumn()
public void setExpandableColumn(int expandableColumn)
expandableColumn
- new expandable column.getExpandableColumn()
public int getHorizontalLegPosition(int cellHeight)
cellHeight
- the new cell height
public int getVerticalLineStartPosition(int cellHeight)
cellHeight
- the cell height
public Row expandableRowAtPoint(Point p)
p
- the point
public Rectangle getEditorCellRect(int rowIndex, int columnIndex)
JideTable
getEditorCellRect
in class JideTable
rowIndex
- the row index.columnIndex
- the column index
public boolean alwaysCalculateCellRect()
alwaysCalculateCellRect
in class JideTable
public boolean isRespectRenderPreferredHeight()
public void setRespectRenderPreferredHeight(boolean respectRenderPreferredHeight)
respectRenderPreferredHeight
- true or false.public boolean shouldDisplayExpandIcon(Row row)
row
- the row to check
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |