|
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.JPanel com.jidesoft.swing.LabeledTextField com.jidesoft.grid.QuickFilterField com.jidesoft.tree.QuickTreeFilterField
public class QuickTreeFilterField
QuickTreeFilterField
works along with any TreeModel to provide filtering feature.
QuickTreeFilterField filterField = new QuickTreeFilterField(anyTreeModel);
Later on, when you display the JTree, instead using your original tree model, use getDisplayTreeModel()
.
JTree tree = new JTree(filterField.getDisplayTreeModel());
filterField.setTree(tree); // optional. Only if you want the selection to be kept before and
after filtering.
Usually you place QuickTreeFilterField
somewhere close to the JTree in the user interface. User can type
in any text in the text field, you will see the JTree automatically display the data that matches with the text.
QuickFilterField
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class com.jidesoft.grid.QuickFilterField |
---|
QuickFilterField.FieldFilter |
Nested classes/interfaces inherited from class com.jidesoft.swing.LabeledTextField |
---|
LabeledTextField.PopupMenuCustomizer |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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 |
PROPERTY_HIDE_EMPTY_PARENT_NODE
The property to determine if a parent node should be hidden when all its children nodes are filtered away. |
static String |
PROPERTY_KEEP_ALL_CHILDREN
The property to determine if all its children nodes should be kept when a parent node matches the searching text. |
static String |
PROPERTY_MATCHES_LEAF_NODE_ONLY
The property to determine if only leaf nodes should be matched with the searching text. |
Fields inherited from class com.jidesoft.grid.QuickFilterField |
---|
_filter, _searchingText, PROPERTY_CASE_SENSITIVE, PROPERTY_FROM_END, PROPERTY_FROM_START, PROPERTY_REGEX_ENABLED, PROPERTY_SEARCH_TEXT, PROPERTY_WILDCARD_ENABLED |
Fields inherited from class com.jidesoft.swing.LabeledTextField |
---|
_button, _contextMenuKeyStroke, _customizer, _hintLabel, _hintText, _icon, _label, _labelText, _showHintTextWhenFocused, _textField |
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 | |
---|---|
QuickTreeFilterField()
Creates an empty QuickTreeFilterField . |
|
QuickTreeFilterField(TreeModel treeModel)
Creates a QuickTreeFilterField using the specified treeModel. |
Method Summary | |
---|---|
void |
applyFilter(String text)
Applies the filter with the seaching text. |
protected JidePopupMenu |
createContextMenu()
Creates the the context menu. |
protected FilterableTreeModel |
createDisplayTreeModel(TreeModel treeModel)
Creates the FilterableTreeModel . |
FilterableTreeModel |
getDisplayTreeModel()
Gets the display tree model. |
JTree |
getTree()
Gets the tree that is using the displayTreeModel. |
TreeModel |
getTreeModel()
Gets the tree model. |
protected String |
getTreeResourceString(String key)
Gets the localized string from resource bundle. |
boolean |
isHideEmptyParentNode()
Returns the value of hideEmptyParentNode property. |
boolean |
isKeepAllChildren()
If a parent node matches, all its children will be kept if this flag is true. |
boolean |
isMatchesLeafNodeOnly()
If the filters matches the leaf node only. |
void |
setHideEmptyParentNode(boolean hideEmptyParentNode)
Sets the value of hideEmptyParentNode property. |
void |
setKeepAllChildren(boolean keepAllChildren)
Sets the value of keepAllChildren property. |
void |
setMatchesLeafNodeOnly(boolean matchesLeafNodeOnly)
Sets the value of matchesLeafNodeOnly property. |
void |
setTree(JTree tree)
Sets the tree that is using the displayTreeModel. |
void |
setTreeModel(TreeModel treeModel)
Sets the tree model used by this component. |
Methods inherited from class com.jidesoft.swing.LabeledTextField |
---|
calculateContextMenuLocation, createLabel, createTextField, customizePopupMenu, getBaseline, getButton, getContextMenuKeyStroke, getHintText, getIcon, getLabel, getLabelText, getPopupMenuCustomizer, getText, getTextField, initLayout, isShowHintTextWhenFocused, setColumns, setContextMenuKeyStroke, setEnabled, setHintText, setIcon, setLabelText, setPopupMenuCustomizer, setShowHintTextWhenFocused, setText, showContextMenu, updateUI |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String PROPERTY_HIDE_EMPTY_PARENT_NODE
public static final String PROPERTY_MATCHES_LEAF_NODE_ONLY
public static final String PROPERTY_KEEP_ALL_CHILDREN
Constructor Detail |
---|
public QuickTreeFilterField()
QuickTreeFilterField
. This method is useless since QuickTreeFilterField
has to
have a tree model in order to work correctly. So we have this method in place mainly to make it JavaBean
compatible. You must call setTreeModel(TreeModel)
after you create QuickTreeFilterField
using
this constructor.
public QuickTreeFilterField(TreeModel treeModel)
QuickTreeFilterField
using the specified treeModel.
treeModel
- the TreeModelMethod Detail |
---|
public boolean isHideEmptyParentNode()
isMatchesLeafNodeOnly()
returns true.
public void setHideEmptyParentNode(boolean hideEmptyParentNode)
hideEmptyParentNode
- true or falsepublic boolean isMatchesLeafNodeOnly()
public void setMatchesLeafNodeOnly(boolean matchesLeafNodeOnly)
matchesLeafNodeOnly
- true or falsepublic boolean isKeepAllChildren()
public void setKeepAllChildren(boolean keepAllChildren)
keepAllChildren
- the flagprotected JidePopupMenu createContextMenu()
QuickTreeFilterField
. You can override this method if you want to customize the popup menu. The
three menu items' name are "Filter.matchLeafNodeOnly", "Filter.hideNodesWithoutChildren" and
"Filter.keepAllChildren" respectively. If you need to remove any of the menu items, you can always look it up by
name and remove it.
createContextMenu
in class QuickFilterField
public void applyFilter(String text)
applyFilter
in class QuickFilterField
text
- the searching textpublic void setTreeModel(TreeModel treeModel)
treeModel
- the TreeModelprotected FilterableTreeModel createDisplayTreeModel(TreeModel treeModel)
FilterableTreeModel
. By default, it will always create a new
FilterableTreeModel
that wraps the treeModel but you can always override it to return an existing
FilterableTreeModel
if you want.
treeModel
- the tree model.
FilterableTreeModel
that wraps the tree model.public TreeModel getTreeModel()
public FilterableTreeModel getDisplayTreeModel()
QuickTreeFilterField
doesn't modify the tree model that you passed in but
wrap it in FilterableTreeModel. So if you want to display the result after being filtered, you should use this
method to get the display tree model and set it to your tree.
public JTree getTree()
public void setTree(JTree tree)
QuickTreeFilterField
what the tree is, the selection will be gone.
Please note, this method will be set displayTreeModel onto the tree. You still need to call getDisplayTreeModel()
to get the model and set it to the tree.
tree
- the JTreeprotected String getTreeResourceString(String key)
key
- the resource key
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |