Record Class TreeDrop<V,N extends AbstractTreeNode<V,N>>
- Type Parameters:
V- the type of the row valuesN- the type of the node- Record Components:
node- the dragged nodetarget- the row under the cursorlocation- the place relative to target
The same TreeDrop goes to two receivers. While the user moves the node over the rows, the rules of TreeDragAndDrop get it (withinParent(), sameLevel(), forbid(), rule()). If at least one rule returns false, the node cannot be dropped at this place. When the user releases the node, the action given to dragAndDrop() gets the TreeDrop. The action must move the object in the model. After the action the tree itself moves the row of the node with all its children, so a refresh of the tree is not needed.
Drop place
Location sets the place relative to the target row:- ON: the node becomes the last child of target.
- BEFORE: the node goes before target, under the same parent.
- AFTER: the node goes after target, under the same parent.
The level of a node is the number of its ancestors: 0 for a root, 1 for its children. fromLevel() returns the level of the node before the drop, and toLevel() returns the level after it. The rules forbid(fromLevel, toLevel), withinParent(level) and sameLevel(level) check these levels.
Drops that do not arrive
Only one node can be dragged, and only inside the same tree. Group nodes (isGroup()) cannot be dragged and are never the target. The tree forbids a drop of a node onto itself or onto its descendants before the rules are checked. So the rules and the action never get such a TreeDrop.- Author:
- Ionov Ivan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe drop place relative to the target row: ON, BEFORE or AFTER. -
Constructor Summary
ConstructorsConstructorDescriptionTreeDrop(N node, N target, TreeDrop.Location location) Creates an instance of aTreeDroprecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.intfinal inthashCode()Returns a hash code value for this object.location()Returns the value of thelocationrecord component.node()Returns the value of thenoderecord component.target()Returns the value of thetargetrecord component.inttoLevel()final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
newParent
- Returns:
- the new parent of the node: target for ON, the parent of target for BEFORE and AFTER, or null if the node becomes a root
-
fromLevel
public int fromLevel()- Returns:
- the level of the node before the drop, 0 for a root
-
toLevel
public int toLevel()- Returns:
- the level of the node after the drop, 0 for a root
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
node
Returns the value of thenoderecord component.- Returns:
- the value of the
noderecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
location
Returns the value of thelocationrecord component.- Returns:
- the value of the
locationrecord component
-