All Packages Class Hierarchy This Package Previous Next Index
Class jclass.bwt.JCOutliner
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----jclass.bwt.JCContainer
|
+----jclass.bwt.JCScrolledWindow
|
+----jclass.bwt.JCMultiColumnWindow
|
+----jclass.bwt.JCOutliner
- public class JCOutliner
- extends JCMultiColumnWindow
- implements JCOutlinerInterface
JCOutliner provides an easy way to display hierarchically-organized data.
The data items can be organized into columns for easier display.
The data is assumed to be in the form of a tree. Each item is either a
folder (a tree branch)
or an item (a tree leaf).
Each folder or item is displayed with an icon to its left. The appearance
of each node is specified by a style
. Column labels can also be optionally added.
The user can control
whether the data contained in a folder is to be displayed. The user can
collapse or uncollapse a folder by either double-clicking on the folder,
hitting the space key,
or clicking on the optional shortcut button displayed to the left of the folder. Typing a character will cause the first item which starts with the
character to be made visible and selected. If no item can be found, no action
is taken.
The shortcut button contains a character that indicates whether a folder is
collapsed by displaying either a "+" (collapsed), or "-" (uncollapsed).
Properties
Events
Class | Listener | Description |
JCActionEvent | addActionListener | Posted when an item is double-clicked, or the ENTER key is hit |
JCOutlinerEvent | addItemListener | Posted when an item is clicked or the space key is hit |
-
DRAGDROP_ALL
-
-
DRAGDROP_NONE
-
-
DRAGDROP_SOURCE
-
-
DRAGDROP_TARGET
-
-
FOLDER_CLOSED
-
-
FOLDER_OPEN_ALL
-
-
FOLDER_OPEN_FOLDERS
-
-
FOLDER_OPEN_ITEMS
-
-
FOLDER_OPEN_NONE
-
-
JCOutliner()
- Creates an empty outliner.
-
JCOutliner(int, boolean)
- Creates an outliner with the specified number of visible lines.
-
JCOutliner(JCOutlinerNode)
- Creates an outliner with the specified root node.
-
JCOutliner(JCOutlinerNode, Applet, String)
- Creates a outliner which reads parameters from the applet's HTML file.
-
addActionListener(JCActionListener)
- Adds the specified action listener to receive action events.
-
addItemListener(JCItemListener)
- Adds the specified item listener to receive item events.
-
calculateNodeHeight(JCOutlinerNode)
- Calculates the height of a node (by looking at the node's style).
-
eventInShortcut(Event, JCOutlinerNode)
- Returns true if the node is a folder and the event is within the
folder's shortcut button.
-
eventToNode(Event)
- Gets the node in which the event occurred.
-
folderChanged(JCOutlinerNode)
- Notifies the outliner that the number of a folder's children has changed.
-
getAllowMultipleSelections()
- Returns true if this outliner allows multiple selections.
-
getAutoSelect()
- Gets the AutoSelect value.
-
getBatched()
- Gets the Batched value.
-
getBounds(JCOutlinerNode, Rectangle)
- Gets the physical bounding rectangle of a node (icon and label)
(ie adjusted for scrolling and insets).
-
getDefaultNodeStyle()
- Gets the default node style.
-
getDragAndDropPolicy()
- Gets the DragAndDropPolicy value.
-
getFocusNode()
- Returns the node which currently has focus, or null.
-
getNextNode(JCOutlinerNode)
- Returns the next visible node, or null if none was found.
-
getNodeHeight()
- Gets the NodeHeight value.
-
getNodeIndent()
- Gets the NodeIndent value.
-
getNumNodes()
- Gets the current number of non-collapsed nodes (ie the number of
open folders and their children).
-
getOutliner()
- Gets the internal outliner component.
-
getPreviousNode(JCOutlinerNode)
- Returns the previous visible node, or null if none was found.
-
getRootNode()
- Gets the root node.
-
getRootVisible()
- Gets the RootVisible value.
-
getSelectedIndex()
- Gets the row of the first selected node,
or BWTEnum.NOTFOUND if no node is selected.
-
getSelectedIndexes()
- Returns an array containing the rows of the selected nodes,
or null if no nodes are selected.
-
getSelectedNode()
- Returns the currently selected node, or null.
-
getSelectedObjects()
- Returns the an array containing the
labels of the selected nodes, or null if no node is selected.
-
getSpacing()
- Gets the spacing between items.
-
getStateList()
- Gets the current StateList.
-
getStyleList()
- Gets the current StyleList.
-
getTree()
- Gets the current node hierarchy as a String list.
-
getViewportHeight()
- Sets the work area height to be the outliner's virtual height.
-
getVisibleNodes()
- Gets a list of the nodes which are currently displayed.
-
getVisibleRows()
- Returns the number of visible lines.
-
makeNodeVisible(JCOutlinerNode)
- Scrolls the display if necessary to make the node visible.
-
removeActionListener(JCActionListener)
- Removes the specified action listener so it no longer receives
action events.
-
removeItemListener(JCItemListener)
- Removes the specified item listener so it no longer receives
item events.
-
scrollVertical(JCScrollableInterface, JCAdjustmentEvent, int)
- Scrolls the list vertically.
-
selectNode(JCOutlinerNode, Event)
- Selects a node, and posts a JCOutlinerEvent.
-
setAllowMultipleSelections(boolean)
- Sets whether the outliner allows multiple selections.
-
setAutoSelect(boolean)
- If true (default), the node which currently has focus is also selected.
HTML param name/value: "AutoSelect"/boolean
-
setBatched(boolean)
- If false (default), the component is repainted every time an item
is changed.
-
setDragAndDropPolicy(int)
- Sets whether the outliner can be used as a drag and/or drop site.
-
setFocusNode(JCOutlinerNode, Event)
- Sets a node to have the keyboard focus.
-
setHorizScrollbarValues()
- This method may be overriden by a subclass to change the default values
of the horizontal scrollbar.
-
setNodeHeight(int)
- Sets the height of each node (pixels).
-
setNodeIndent(int)
- Sets the indentation of each node relative to its parent (pixels).
HTML param name/value: "NodeIndent"/int
-
setNodeState(JCOutlinerNode, int, boolean)
- Sets the state of a folder.
-
setOutliner(JCOutlinerComponent)
- Replaces the current outliner.
-
setRootNode(JCOutlinerNode)
- Sets the root node.
-
setRootVisible(boolean)
- If true (default), the root node is drawn.
HTML param name/value: "RootVisible"/boolean
-
setSpacing(int)
- Sets the spacing between items (default: 0).
-
setStateList(int[])
- Sets a list of values used for double-clicking on a folder or clicking
its shortcut button.
-
setStyleList(JCOutlinerNodeStyle[])
- Sets the list of node styles.
-
setTree(String[])
- Sets the node hierarchy by parsing the string list.
-
setVertScrollbarValues()
- This method may be overriden by a subclass to change the default values
of the vertical scrollbar.
-
setVisibleRows(int)
- Sets the number of visible rows.
-
sortByColumn(int, JCSortInterface)
- Sorts the nodes in the list in ascending order based on a specified column,
using the String equivalents of each value.
-
sortByColumn(int, JCSortInterface, int)
- Sorts the nodes in the list based on a specified column,
using the String equivalents of each value.
FOLDER_CLOSED
public static final int FOLDER_CLOSED
FOLDER_OPEN_NONE
public static final int FOLDER_OPEN_NONE
FOLDER_OPEN_FOLDERS
public static final int FOLDER_OPEN_FOLDERS
FOLDER_OPEN_ITEMS
public static final int FOLDER_OPEN_ITEMS
FOLDER_OPEN_ALL
public static final int FOLDER_OPEN_ALL
DRAGDROP_NONE
public static final int DRAGDROP_NONE
DRAGDROP_TARGET
public static final int DRAGDROP_TARGET
DRAGDROP_SOURCE
public static final int DRAGDROP_SOURCE
DRAGDROP_ALL
public static final int DRAGDROP_ALL
JCOutliner
public JCOutliner()
- Creates an empty outliner. No parameters are read from an HTML file
JCOutliner
public JCOutliner(JCOutlinerNode root)
- Creates an outliner with the specified root node.
No parameters are read from an HTML file
- See Also:
- setRootNode
JCOutliner
public JCOutliner(int rows,
boolean multipleSelections)
- Creates an outliner with the specified number of visible lines.
- Parameters:
- rows - the number of items to show.
If set to 0, the outliner will attempt to show all its items.
- multipleSelections - if true then multiple selections are allowed.
JCOutliner
public JCOutliner(JCOutlinerNode root,
Applet applet,
String name)
- Creates a outliner which reads parameters from the applet's HTML file.
- Parameters:
- items - the initial items
This may be a String, JCString or any object (in which case the object's
toString() method is called to obtain a string).
- applet - the applet whose PARAM tags are to be read
- name - if this is not null, only parameters preceded by this name are read
- See Also:
- getParameter, JCString
getOutliner
public JCOutlinerComponent getOutliner()
- Gets the internal outliner component.
setOutliner
public void setOutliner(JCOutlinerComponent outliner)
- Replaces the current outliner.
setVertScrollbarValues
protected void setVertScrollbarValues()
- This method may be overriden by a subclass to change the default values
of the vertical scrollbar.
- Overrides:
- setVertScrollbarValues in class JCScrolledWindow
setHorizScrollbarValues
protected void setHorizScrollbarValues()
- This method may be overriden by a subclass to change the default values
of the horizontal scrollbar.
- Overrides:
- setHorizScrollbarValues in class JCScrolledWindow
getViewportHeight
protected int getViewportHeight()
- Sets the work area height to be the outliner's virtual height.
- Overrides:
- getViewportHeight in class JCScrolledWindow
scrollVertical
protected void scrollVertical(JCScrollableInterface scrollable,
JCAdjustmentEvent ev,
int value)
- Scrolls the list vertically.
- Overrides:
- scrollVertical in class JCScrolledWindow
addItemListener
public void addItemListener(JCItemListener l)
- Adds the specified item listener to receive item events.
If the listener implements JCOutlinerListener (an JCItemListener subclass),
it will be passed JCOutlinerEvents.
- See Also:
- JCItemEvent, JCOutlinerEvent, JCOutlinerListener
removeItemListener
public void removeItemListener(JCItemListener l)
- Removes the specified item listener so it no longer receives
item events.
addActionListener
public void addActionListener(JCActionListener l)
- Adds the specified action listener to receive action events.
Action events occur when a node is double-clicked.
- See Also:
- JCActionEvent
removeActionListener
public void removeActionListener(JCActionListener l)
- Removes the specified action listener so it no longer receives
action events.
- See Also:
- addActionListener
folderChanged
public void folderChanged(JCOutlinerNode node)
- Notifies the outliner that the number of a folder's children has changed.
getBatched
public boolean getBatched()
- Gets the Batched value.
- See Also:
- setBatched
setBatched
public void setBatched(boolean v)
- If false (default), the component is repainted every time an item
is changed. If set to true, the component is only repainted (if necessary)
when the value is again set to false.
getRootNode
public JCOutlinerNode getRootNode()
- Gets the root node.
- See Also:
- setRootNode
setRootNode
public void setRootNode(JCOutlinerNode node)
- Sets the root node.
getTree
public String[] getTree()
- Gets the current node hierarchy as a String list.
- See Also:
- setTree
setTree
public void setTree(String s[])
- Sets the node hierarchy by parsing the string list.
Each line in the list represents a node's label.
Spaces or tabs at the start of each
line supply the tree hierarchy. Lines with the same indentation level are
children. Nodes without children are assumed to be items. To create a folder
without children, append the string "(FOLDER)" to the line.
HTML param name/value: "Tree"/comma-separated lines
getRootVisible
public boolean getRootVisible()
- Gets the RootVisible value.
- See Also:
- setRootVisible
setRootVisible
public void setRootVisible(boolean v)
- If true (default), the root node is drawn.
HTML param name/value: "RootVisible"/boolean
getNumNodes
public int getNumNodes()
- Gets the current number of non-collapsed nodes (ie the number of
open folders and their children).
calculateNodeHeight
public int calculateNodeHeight(JCOutlinerNode node)
- Calculates the height of a node (by looking at the node's style).
getNodeHeight
public int getNodeHeight()
- Gets the NodeHeight value.
- See Also:
- setNodeHeight
setNodeHeight
public void setNodeHeight(int v)
- Sets the height of each node (pixels).
If 0 (default), the height is determined using the largest font and
image height in the list of node styles.
HTML param name/value: "NodeHeight"/int
getAllowMultipleSelections
public boolean getAllowMultipleSelections()
- Returns true if this outliner allows multiple selections.
- See Also:
- setAllowMultipleSelections
setAllowMultipleSelections
public void setAllowMultipleSelections(boolean v)
- Sets whether the outliner allows multiple selections.
HTML param name/value: "AllowMultipleSelections"/boolean
- See Also:
- getAllowMultipleSelections
getAutoSelect
public boolean getAutoSelect()
- Gets the AutoSelect value.
- See Also:
- setAutoSelect
setAutoSelect
public void setAutoSelect(boolean v)
- If true (default), the node which currently has focus is also selected.
HTML param name/value: "AutoSelect"/boolean
- See Also:
- setFocusNode, selectNode
getNodeIndent
public int getNodeIndent()
- Gets the NodeIndent value.
- See Also:
- setNodeIndent
setNodeIndent
public void setNodeIndent(int v)
- Sets the indentation of each node relative to its parent (pixels).
HTML param name/value: "NodeIndent"/int
getStateList
public int[] getStateList()
- Gets the current StateList.
- See Also:
- setStateList
setStateList
public void setStateList(int list[])
- Sets a list of values used for double-clicking on a folder or clicking
its shortcut button.
The folder's state is cycled through the list. Valid values:
FOLDER_CLOSED Folder closed; no children visible
FOLDER_OPEN_NONE Folder open; no children visible
FOLDER_OPEN_FOLDERS Folder open; only folder children visible
FOLDER_OPEN_ITEMS Folder open; only non-folder children visible
FOLDER_OPEN_ALL Folder open; all children visible
HTML param name/value: "StateList"/comma-separated list of enums
getStyleList
public JCOutlinerNodeStyle[] getStyleList()
- Gets the current StyleList.
- See Also:
- setStyleList
setStyleList
public void setStyleList(JCOutlinerNodeStyle list[])
- Sets the list of node styles. The list is only used for determining
the node height if it has not been set.
- See Also:
- setNodeHeight
getDefaultNodeStyle
public JCOutlinerNodeStyle getDefaultNodeStyle()
- Gets the default node style.
getSpacing
public int getSpacing()
- Gets the spacing between items.
- See Also:
- setSpacing
setSpacing
public void setSpacing(int v)
- Sets the spacing between items (default: 0).
This value increases the HighlightThickness value.
HTML param name/value: "Spacing"/int
- See Also:
- setHighlightThickness
getVisibleRows
public int getVisibleRows()
- Returns the number of visible lines.
- See Also:
- setVisibleRows
setVisibleRows
public void setVisibleRows(int v)
- Sets the number of visible rows. If set to 0 (default), the list
will attempt to resize itself so that all its items are visible.
HTML param name/value: "VisibleRows"/int
getSelectedIndex
public int getSelectedIndex()
- Gets the row of the first selected node,
or BWTEnum.NOTFOUND if no node is selected.
- See Also:
- selectNode
getSelectedIndexes
public int[] getSelectedIndexes()
- Returns an array containing the rows of the selected nodes,
or null if no nodes are selected.
getSelectedObjects
public Object[] getSelectedObjects()
- Returns the an array containing the
labels of the selected nodes, or null if no node is selected.
getSelectedNode
public JCOutlinerNode getSelectedNode()
- Returns the currently selected node, or null.
selectNode
public void selectNode(JCOutlinerNode node,
Event ev)
- Selects a node, and posts a JCOutlinerEvent.
- Parameters:
- node - if null, the currently selected nodes are deselected
- ev - event which caused the selection (passed to listener)
- See Also:
- addItemListener
getFocusNode
public JCOutlinerNode getFocusNode()
- Returns the node which currently has focus, or null.
setFocusNode
public void setFocusNode(JCOutlinerNode node,
Event ev)
- Sets a node to have the keyboard focus.
- Parameters:
- node - if null, no the current focus node is unchanged
- ev - event which caused the focus change
getVisibleNodes
public JCVector getVisibleNodes()
- Gets a list of the nodes which are currently displayed.
setNodeState
public boolean setNodeState(JCOutlinerNode node,
int state,
boolean notify)
- Sets the state of a folder.
- Parameters:
- node - if not a folder, no action is taken
- state - one of:
FOLDER_CLOSED Folder closed; no children visible
FOLDER_OPEN_NONE Folder open; no children visible
FOLDER_OPEN_FOLDERS Folder open; only folder children visible
FOLDER_OPEN_ITEMS Folder open; only non-folder children visible
FOLDER_OPEN_ALL Folder open; all children visible
- notify - if true, a JCOutlinerEvent and JCActionEvent is posted for the node
- Returns:
- false if the app disallowed the state change
- Throws: IllegalArgumentException
- If the value is invalid
- See Also:
- addActionListener, addItemListener
makeNodeVisible
public boolean makeNodeVisible(JCOutlinerNode node)
- Scrolls the display if necessary to make the node visible.
- Returns:
- false if the node could not be made visible due to its parent's state
getNextNode
public JCOutlinerNode getNextNode(JCOutlinerNode node)
- Returns the next visible node, or null if none was found.
getPreviousNode
public JCOutlinerNode getPreviousNode(JCOutlinerNode node)
- Returns the previous visible node, or null if none was found.
getBounds
public Rectangle getBounds(JCOutlinerNode node,
Rectangle rect)
- Gets the physical bounding rectangle of a node (icon and label)
(ie adjusted for scrolling and insets).
- Parameters:
- rect - if not null, its members are set
- Returns:
- null if rect is null, otherwise the bounding rectangle
eventToNode
public JCOutlinerNode eventToNode(Event ev)
- Gets the node in which the event occurred.
eventInShortcut
public boolean eventInShortcut(Event ev,
JCOutlinerNode node)
- Returns true if the node is a folder and the event is within the
folder's shortcut button.
sortByColumn
public void sortByColumn(int column,
JCSortInterface sort_if)
- Sorts the nodes in the list in ascending order based on a specified column,
using the String equivalents of each value.
- Parameters:
- sort_if - An optional interface whose compare method is called during
sorting, to provide a mechanism for the application to specify whether one
object is greater than another (similar to qsort's compare function).
If this parameter is null, the column is sorted by numerical or string
comparison as applicable.
- Overrides:
- sortByColumn in class JCMultiColumnWindow
sortByColumn
public void sortByColumn(int column,
JCSortInterface sort_if,
int direction)
- Sorts the nodes in the list based on a specified column,
using the String equivalents of each value.
- Parameters:
- sort_if - An optional interface whose compare method is called during
sorting, to provide a mechanism for the application to specify whether one
object is greater than another (similar to qsort's compare function).
If this parameter is null, the column is sorted by numerical or string
comparison as applicable.
- direction - sort direction: ASCENDING or DESCENDING
- Overrides:
- sortByColumn in class JCMultiColumnWindow
getDragAndDropPolicy
public int getDragAndDropPolicy()
- Gets the DragAndDropPolicy value.
- See Also:
- setDragAndDropPolicy
setDragAndDropPolicy
public void setDragAndDropPolicy(int v)
- Sets whether the outliner can be used as a drag and/or drop site.
- Parameters:
- v - DRAGDROP_NONE (default), DRAGDROP_TARGET, DRAGDROP_SOURCE, DRAGDROP_ALL
All Packages Class Hierarchy This Package Previous Next Index