Class ElementNode
- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- com.nomagic.magicdraw.dependencymatrix.datamodel.ElementNode
-
- All Implemented Interfaces:
com.nomagic.magicdraw.grouping.GroupNode<ElementNode>,java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,javax.swing.tree.MutableTreeNode,javax.swing.tree.TreeNode
@OpenApi public class ElementNode extends javax.swing.tree.DefaultMutableTreeNode implements com.nomagic.magicdraw.grouping.GroupNode<ElementNode>, java.lang.Comparable
Tree node which represents instance of anElementNote: children of the node often does NOT represent the owned elements of the model Element, tree model can be constructed by different criteria- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.nomagic.magicdraw.dependencymatrix.datamodel.grouping.ScopeElementNodeIDProviderelementNodeIDProviderprivate booleanexpandedprivate inthashCodeprivate java.util.Map<Element,java.lang.Integer>indexesprivate java.lang.StringnodeIDprivate ElementNodeoriginalprivate booleanrealShows if this element belongs to the model.
-
Constructor Summary
Constructors Constructor Description ElementNode(Element element)Creates new node, which has element inside.ElementNode(Element element, boolean real)ElementNode(Element element, boolean real, com.nomagic.magicdraw.dependencymatrix.datamodel.grouping.ScopeElementNodeIDProvider nodeIDProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(javax.swing.tree.MutableTreeNode newChild)voidaddGroupNode(ElementNode node)intcompareTo(java.lang.Object o)booleanequals(java.lang.Object o)java.util.Enumeration<ElementNode>getBreadthFirstEnumeration()ElementNodegetChild(Element element)Finds node which represents provided element between this node's direct childrenjava.util.List<ElementNode>getChildren()java.util.Enumeration<ElementNode>getDepthFirstEnumeration()ElementgetElement()ElementNodegetGroupNodeChildAt(int index)java.util.List<ElementNode>getGroupNodeChildren()Get all children as single listintgetGroupNodeIndex(ElementNode node)ElementNodegetGroupNodeParent()ElementNode[]getGroupNodePath()intgetIndex(Element element)java.lang.StringgetNodeID()ElementNodegetOriginal()ElementNodegetParent()inthashCode()booleanisExpanded()booleanisInfinityNode()Nodes which represent recursive branches are marked as infinite nodes, meaning the rest of the infinite branch is cut off bellow this nodebooleanisReal()Tells if this node belongs to the model represented by the treevoidremove(int childIndex)voidremoveGroupNode(ElementNode node)private voidresetIndexCache()voidsetExpanded(boolean expanded)voidsetOriginal(ElementNode original)voidsetReal(boolean real)Does this node belong to the model or it is only as grouping element (parent node)java.lang.StringtoString()-
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
-
-
-
-
Field Detail
-
elementNodeIDProvider
@CheckForNull protected com.nomagic.magicdraw.dependencymatrix.datamodel.grouping.ScopeElementNodeIDProvider elementNodeIDProvider
-
real
private boolean real
Shows if this element belongs to the model. Tree can have two types of nodes: which belongs to the model, and those who are only group parents. Some group elements can belong to the model too (e.g. Package element can be either group parent or model element)
-
expanded
private boolean expanded
-
nodeID
@CheckForNull private java.lang.String nodeID
-
hashCode
private int hashCode
-
indexes
private java.util.Map<Element,java.lang.Integer> indexes
-
original
@CheckForNull private ElementNode original
-
-
Constructor Detail
-
ElementNode
public ElementNode(@CheckForNull Element element)Creates new node, which has element inside.- Parameters:
element- tree node information
-
ElementNode
public ElementNode(@CheckForNull Element element, boolean real)- Parameters:
element- tree node informationreal-falseif this node does not belong to the model (is parent only) Default value:true
-
ElementNode
public ElementNode(@CheckForNull Element element, boolean real, @CheckForNull com.nomagic.magicdraw.dependencymatrix.datamodel.grouping.ScopeElementNodeIDProvider nodeIDProvider)
-
-
Method Detail
-
getElement
@CheckForNull @OpenApi public Element getElement()
- Specified by:
getElementin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Returns:
- model element represented by this node
-
getParent
@OpenApi public ElementNode getParent()
- Specified by:
getParentin interfacejavax.swing.tree.TreeNode- Overrides:
getParentin classjavax.swing.tree.DefaultMutableTreeNode
-
getChildren
@OpenApi public java.util.List<ElementNode> getChildren()
- Returns:
- direct children of this node
-
getChild
@CheckForNull public ElementNode getChild(Element element)
Finds node which represents provided element between this node's direct children- Specified by:
getChildin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Parameters:
element- element for which to search node- Returns:
- node which represents this element or null
-
isReal
@OpenApi public boolean isReal()
Tells if this node belongs to the model represented by the tree- Specified by:
isRealin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Returns:
- true if this node truly belongs to the model represented by the tree
false if this node is only a grouping node for viewing and collapsing purposes
-
isExpanded
@OpenApi public boolean isExpanded()
- Returns:
- true if node is currently expanded, meaning child nodes are visible
-
isInfinityNode
@OpenApi public boolean isInfinityNode()
Nodes which represent recursive branches are marked as infinite nodes, meaning the rest of the infinite branch is cut off bellow this node- Specified by:
isInfinityNodein interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Returns:
- true if the branch is infinitely recursive and is cut below this node.
-
getBreadthFirstEnumeration
public java.util.Enumeration<ElementNode> getBreadthFirstEnumeration()
- Specified by:
getBreadthFirstEnumerationin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
getDepthFirstEnumeration
public java.util.Enumeration<ElementNode> getDepthFirstEnumeration()
- Specified by:
getDepthFirstEnumerationin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
add
public void add(javax.swing.tree.MutableTreeNode newChild)
- Overrides:
addin classjavax.swing.tree.DefaultMutableTreeNode
-
addGroupNode
public void addGroupNode(ElementNode node)
- Specified by:
addGroupNodein interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
getGroupNodeIndex
public int getGroupNodeIndex(ElementNode node)
- Specified by:
getGroupNodeIndexin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
getIndex
public int getIndex(@CheckForNull Element element)- Specified by:
getIndexin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
resetIndexCache
private void resetIndexCache()
-
removeGroupNode
public void removeGroupNode(ElementNode node)
- Specified by:
removeGroupNodein interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
remove
public void remove(int childIndex)
- Specified by:
removein interfacejavax.swing.tree.MutableTreeNode- Overrides:
removein classjavax.swing.tree.DefaultMutableTreeNode
-
getGroupNodeParent
public ElementNode getGroupNodeParent()
- Specified by:
getGroupNodeParentin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
getGroupNodeChildren
public java.util.List<ElementNode> getGroupNodeChildren()
Get all children as single list- Specified by:
getGroupNodeChildrenin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Returns:
- children (recursive)
-
getGroupNodeChildAt
public ElementNode getGroupNodeChildAt(int index)
- Specified by:
getGroupNodeChildAtin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
setReal
public final void setReal(boolean real)
Does this node belong to the model or it is only as grouping element (parent node)- Specified by:
setRealin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>- Parameters:
real-trueif this node belongs to the model
-
setExpanded
public final void setExpanded(boolean expanded)
-
getNodeID
public java.lang.String getNodeID()
-
getGroupNodePath
public ElementNode[] getGroupNodePath()
- Specified by:
getGroupNodePathin interfacecom.nomagic.magicdraw.grouping.GroupNode<ElementNode>
-
getOriginal
public ElementNode getOriginal()
-
setOriginal
public void setOriginal(@CheckForNull ElementNode original)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(@Nonnull java.lang.Object o)- Specified by:
compareToin interfacejava.lang.Comparable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjavax.swing.tree.DefaultMutableTreeNode
-
-