- java.lang.Object
-
- com.iamsoft.util.ui.swing.AbstractRearrangeableTreeModel
-
- com.iamsoft.util.ui.swing.DefaultRearrangeableTreeModel
-
- All Implemented Interfaces:
RearrangeableTreeModel
,TreeModel
public class DefaultRearrangeableTreeModel extends AbstractRearrangeableTreeModel
Assumes that all nodes are MutableTreeNodes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultRearrangeableTreeModel.ExampleApplet
An applet that demonstrates how to use rearrangeable models.-
Nested classes/interfaces inherited from class com.iamsoft.util.ui.swing.AbstractRearrangeableTreeModel
AbstractRearrangeableTreeModel.HorizontalDirection, AbstractRearrangeableTreeModel.PromotionBehavior, AbstractRearrangeableTreeModel.VerticalDirection
-
Nested classes/interfaces inherited from interface com.iamsoft.util.ui.swing.RearrangeableTreeModel
RearrangeableTreeModel.IllegalNodeMoveException
-
-
Constructor Summary
Constructors Constructor Description DefaultRearrangeableTreeModel(DefaultTreeModel pModel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultTreeModel
getModel()
protected void
insertNodes(TreePath pParentPath, Collection<Object> pNodes, int pIdx)
Used by rearrangement methods to shuffle nodes around.static void
main(String[] pArgs)
Opens a window with sample tree and rearrangement buttons.protected void
removeNodes(TreePath pParentPath, Map<Integer,Object> pNodes)
Used by rearrangement methods to shuffle nodes around.-
Methods inherited from class com.iamsoft.util.ui.swing.AbstractRearrangeableTreeModel
addTreeModelListener, canDemote, canMoveDown, canMoveUp, canPromote, demote, findNewPath, getChild, getChildCount, getIndexOfChild, getOldToNewPaths, getPromotionBehavior, getRoot, isLeaf, move, move, moveDown, moveUp, promote, removeTreeModelListener, setPromotionBehavior, valueForPathChanged
-
-
-
-
Constructor Detail
-
DefaultRearrangeableTreeModel
public DefaultRearrangeableTreeModel(DefaultTreeModel pModel)
-
-
Method Detail
-
getModel
public DefaultTreeModel getModel()
- Overrides:
getModel
in classAbstractRearrangeableTreeModel
-
insertNodes
protected void insertNodes(TreePath pParentPath, Collection<Object> pNodes, int pIdx)
Description copied from class:AbstractRearrangeableTreeModel
Used by rearrangement methods to shuffle nodes around. If rearrangement methods are overridden, a blank implementation will suffice. Implementation may choose to ignore pIdx- Specified by:
insertNodes
in classAbstractRearrangeableTreeModel
- Parameters:
pParentPath
- Path to parent of nodes to be inserted.pNodes
- Nodes to be appended (in order).pIdx
- Index of insertion. May be ignored if model wishes to impose its own node ordering strategy.- See Also:
AbstractRearrangeableTreeModel.demote(java.util.Collection)
,AbstractRearrangeableTreeModel.promote(java.util.Collection)
,AbstractRearrangeableTreeModel.moveUp(java.util.Collection)
,AbstractRearrangeableTreeModel.moveDown(java.util.Collection)
-
removeNodes
protected void removeNodes(TreePath pParentPath, Map<Integer,Object> pNodes)
Description copied from class:AbstractRearrangeableTreeModel
Used by rearrangement methods to shuffle nodes around. If rearrangement methods are overridden, a blank implementation will suffice. pNodes is guaranteed to be sorted in such a way that ordered removal should succeed. That is, indices are in descending order.- Specified by:
removeNodes
in classAbstractRearrangeableTreeModel
- Parameters:
pParentPath
- Path to parent of nodes to be inserted.pNodes
- Map from desired insertion index to node object.- See Also:
AbstractRearrangeableTreeModel.demote(java.util.Collection)
,AbstractRearrangeableTreeModel.promote(java.util.Collection)
,AbstractRearrangeableTreeModel.moveUp(java.util.Collection)
,AbstractRearrangeableTreeModel.moveDown(java.util.Collection)
-
main
public static void main(String[] pArgs)
Opens a window with sample tree and rearrangement buttons.
-
-