1 20 package org.apache.directory.ldapstudio.schemas.view.views.wrappers; 21 22 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.List ; 26 27 import org.eclipse.swt.graphics.Image; 28 29 30 36 public abstract class TreeNode implements ITreeNode 37 { 38 39 protected List <ITreeNode> fChildren; 40 41 42 protected ITreeNode fParent; 43 44 45 51 public TreeNode( ITreeNode parent ) 52 { 53 fParent = parent; 54 } 55 56 57 60 public Image getImage() 61 { 62 return null; 63 } 64 65 66 69 public boolean hasChildren() 70 { 71 if ( fChildren == null ) 72 { 73 return true; 74 } 75 76 return !fChildren.isEmpty(); 77 } 78 79 80 83 public ITreeNode getParent() 84 { 85 return fParent; 86 } 87 88 89 92 public void setParent( ITreeNode parent ) 93 { 94 fParent = parent; 95 } 96 97 98 101 public List <ITreeNode> getChildren() 102 { 103 if ( fChildren == null ) 104 { 105 fChildren = new ArrayList <ITreeNode>(); 106 } 107 108 return fChildren; 109 } 110 111 112 115 public void addChild( ITreeNode node ) 116 { 117 if ( fChildren == null ) 118 { 119 fChildren = new ArrayList <ITreeNode>(); 120 } 121 122 if ( !fChildren.contains( node ) ) 123 { 124 fChildren.add( node ); 125 } 126 } 127 128 129 132 135 138 public void removeChild( ITreeNode node ) 139 { 140 if ( fChildren != null ) 141 { 142 fChildren.remove( node ); 143 } 144 } 145 146 147 150 public boolean addAllChildren( Collection <? extends ITreeNode> c ) 151 { 152 if ( fChildren == null ) 153 { 154 fChildren = new ArrayList <ITreeNode>(); 155 } 156 157 return fChildren.addAll( c ); 158 } 159 } 160 | Popular Tags |