public abstract class AbstractRearrangeableTreeModel extends Object implements RearrangeableTreeModel
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRearrangeableTreeModel.HorizontalDirection
Promote/demote.
|
static class |
AbstractRearrangeableTreeModel.PromotionBehavior |
protected static class |
AbstractRearrangeableTreeModel.VerticalDirection |
RearrangeableTreeModel.IllegalNodeMoveException
Constructor and Description |
---|
AbstractRearrangeableTreeModel(TreeModel pModel) |
AbstractRearrangeableTreeModel(TreeModel pModel,
AbstractRearrangeableTreeModel.PromotionBehavior pPromotionBehavior) |
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener pListener) |
boolean |
canDemote(Collection<TreePath> pPaths)
True as long as a sibling exists above each selected node and !pPaths.isEmpty().
|
boolean |
canMoveDown(Collection<TreePath> pPaths)
True as long as a sibling exists below each selected node and !pPaths.isEmpty().
|
boolean |
canMoveUp(Collection<TreePath> pPaths)
True as long as a sibling exists above each selected node and !pPaths.isEmpty().
|
boolean |
canPromote(Collection<TreePath> pPaths)
True if !pPaths.isEmpty() and root and its direct descendents are not selected.
|
void |
demote(Collection<TreePath> pPaths)
Move nodes one level further from the root.
|
protected TreePath |
findNewPath(TreePath pPath)
Identify new path by seeing if argument path starts with a path that exists in old
to new path map.
|
Object |
getChild(Object pParent,
int pIdx) |
int |
getChildCount(Object pParent) |
int |
getIndexOfChild(Object pParent,
Object pChild) |
protected TreeModel |
getModel() |
protected Map<TreePath,TreePath> |
getOldToNewPaths()
Map from original to new path for elements that were moved.
|
protected AbstractRearrangeableTreeModel.PromotionBehavior |
getPromotionBehavior() |
Object |
getRoot() |
protected abstract void |
insertNodes(TreePath pParentPath,
Collection<Object> pNodes,
int pIdx)
Used by rearrangement methods to shuffle nodes around.
|
boolean |
isLeaf(Object pNode) |
protected void |
move(Collection<TreePath> pPaths,
AbstractRearrangeableTreeModel.HorizontalDirection pDir)
Promote or demote.
|
protected void |
move(Collection<TreePath> pPaths,
AbstractRearrangeableTreeModel.VerticalDirection pDir)
Move up or down.
|
void |
moveDown(Collection<TreePath> pPaths)
Move nodes one space lower (swap with successors).
|
void |
moveUp(Collection<TreePath> pPaths)
Move nodes one space higher (swap with predecessors).
|
void |
promote(Collection<TreePath> pPaths)
Moves shallowest nodes first.
|
protected abstract void |
removeNodes(TreePath pParentPath,
Map<Integer,Object> pNodes)
Used by rearrangement methods to shuffle nodes around.
|
void |
removeTreeModelListener(TreeModelListener pListener) |
protected void |
setPromotionBehavior(AbstractRearrangeableTreeModel.PromotionBehavior pPromotionBehavior) |
void |
valueForPathChanged(TreePath pPath,
Object pNewValue) |
public AbstractRearrangeableTreeModel(TreeModel pModel)
public AbstractRearrangeableTreeModel(TreeModel pModel, AbstractRearrangeableTreeModel.PromotionBehavior pPromotionBehavior)
protected TreeModel getModel()
protected Map<TreePath,TreePath> getOldToNewPaths()
protected AbstractRearrangeableTreeModel.PromotionBehavior getPromotionBehavior()
protected void setPromotionBehavior(AbstractRearrangeableTreeModel.PromotionBehavior pPromotionBehavior)
public void addTreeModelListener(TreeModelListener pListener)
addTreeModelListener
in interface TreeModel
public void removeTreeModelListener(TreeModelListener pListener)
removeTreeModelListener
in interface TreeModel
public int getChildCount(Object pParent)
getChildCount
in interface TreeModel
public int getIndexOfChild(Object pParent, Object pChild)
getIndexOfChild
in interface TreeModel
public void valueForPathChanged(TreePath pPath, Object pNewValue)
valueForPathChanged
in interface TreeModel
public boolean canPromote(Collection<TreePath> pPaths)
canPromote
in interface RearrangeableTreeModel
public boolean canDemote(Collection<TreePath> pPaths)
canDemote
in interface RearrangeableTreeModel
public boolean canMoveUp(Collection<TreePath> pPaths)
canMoveUp
in interface RearrangeableTreeModel
public boolean canMoveDown(Collection<TreePath> pPaths)
canMoveDown
in interface RearrangeableTreeModel
protected abstract void insertNodes(TreePath pParentPath, Collection<Object> pNodes, int pIdx) throws RearrangeableTreeModel.IllegalNodeMoveException
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.RearrangeableTreeModel.IllegalNodeMoveException
demote(java.util.Collection)
,
promote(java.util.Collection)
,
moveUp(java.util.Collection)
,
moveDown(java.util.Collection)
protected abstract void removeNodes(TreePath pParentPath, Map<Integer,Object> pNodes) throws RearrangeableTreeModel.IllegalNodeMoveException
pParentPath
- Path to parent of nodes to be inserted.pNodes
- Map from desired insertion index to node object.RearrangeableTreeModel.IllegalNodeMoveException
demote(java.util.Collection)
,
promote(java.util.Collection)
,
moveUp(java.util.Collection)
,
moveDown(java.util.Collection)
public void promote(Collection<TreePath> pPaths) throws RearrangeableTreeModel.IllegalNodeMoveException
promote
in interface RearrangeableTreeModel
pPaths
- Paths to be moved.RearrangeableTreeModel.IllegalNodeMoveException
public void demote(Collection<TreePath> pPaths) throws RearrangeableTreeModel.IllegalNodeMoveException
RearrangeableTreeModel
demote
in interface RearrangeableTreeModel
pPaths
- Paths to be moved.RearrangeableTreeModel.IllegalNodeMoveException
protected void move(Collection<TreePath> pPaths, AbstractRearrangeableTreeModel.HorizontalDirection pDir) throws RearrangeableTreeModel.IllegalNodeMoveException
protected void move(Collection<TreePath> pPaths, AbstractRearrangeableTreeModel.VerticalDirection pDir) throws RearrangeableTreeModel.IllegalNodeMoveException
public void moveDown(Collection<TreePath> pPaths) throws RearrangeableTreeModel.IllegalNodeMoveException
RearrangeableTreeModel
moveDown
in interface RearrangeableTreeModel
pPaths
- Paths to be moved.RearrangeableTreeModel.IllegalNodeMoveException
public void moveUp(Collection<TreePath> pPaths) throws RearrangeableTreeModel.IllegalNodeMoveException
RearrangeableTreeModel
moveUp
in interface RearrangeableTreeModel
pPaths
- Paths to be moved.RearrangeableTreeModel.IllegalNodeMoveException
Copyright © 2023. All rights reserved.