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 28 34 public class SchemaElementsViewRoot extends TreeNode 35 { 36 37 private List <AttributeTypeWrapper> aTChildren; 38 39 40 private List <ObjectClassWrapper> ocChildren; 41 42 43 47 public SchemaElementsViewRoot() 48 { 49 super( null ); 50 } 51 52 53 56 public String toString() 57 { 58 return "SchemaElementsViewRoot"; } 60 61 62 68 public void addAttributeType( AttributeTypeWrapper atw ) 69 { 70 if ( aTChildren == null ) 71 { 72 aTChildren = new ArrayList <AttributeTypeWrapper>(); 73 } 74 75 if ( !aTChildren.contains( atw ) ) 76 { 77 aTChildren.add( atw ); 78 } 79 } 80 81 82 88 public void addObjectClass( ObjectClassWrapper ocw ) 89 { 90 if ( ocChildren == null ) 91 { 92 ocChildren = new ArrayList <ObjectClassWrapper>(); 93 } 94 95 if ( !ocChildren.contains( ocw ) ) 96 { 97 ocChildren.add( ocw ); 98 } 99 } 100 101 102 108 public List <AttributeTypeWrapper> getAttributeTypes() 109 { 110 if ( aTChildren == null ) 111 { 112 aTChildren = new ArrayList <AttributeTypeWrapper>(); 113 } 114 115 return aTChildren; 116 } 117 118 119 125 public List <ObjectClassWrapper> getObjectClasses() 126 { 127 if ( ocChildren == null ) 128 { 129 ocChildren = new ArrayList <ObjectClassWrapper>(); 130 } 131 132 return ocChildren; 133 } 134 135 136 139 public void addChild( ITreeNode node ) 140 { 141 if ( node instanceof AttributeTypeWrapper ) 142 { 143 addAttributeType( ( AttributeTypeWrapper ) node ); 144 } 145 else if ( node instanceof ObjectClassWrapper ) 146 { 147 addObjectClass( ( ObjectClassWrapper ) node ); 148 } 149 } 150 151 152 155 public boolean addAllChildren( Collection <? extends ITreeNode> c ) 156 { 157 for ( ITreeNode child : c ) 158 { 159 addChild( child ); 160 } 161 return true; 162 } 163 164 165 168 public void removeChild( ITreeNode node ) 169 { 170 if ( node instanceof AttributeTypeWrapper ) 171 { 172 removeAttributeType( ( AttributeTypeWrapper ) node ); 173 } 174 else if ( node instanceof ObjectClassWrapper ) 175 { 176 removeObjectClass( ( ObjectClassWrapper ) node ); 177 } 178 } 179 180 181 187 private void removeAttributeType( AttributeTypeWrapper wrapper ) 188 { 189 if ( aTChildren != null ) 190 { 191 aTChildren.remove( wrapper ); 192 } 193 } 194 195 196 202 private void removeObjectClass( ObjectClassWrapper wrapper ) 203 { 204 if ( ocChildren != null ) 205 { 206 ocChildren.remove( wrapper ); 207 } 208 } 209 210 211 214 public List <ITreeNode> getChildren() 215 { 216 List <ITreeNode> children = new ArrayList <ITreeNode>(); 217 children.addAll( getAttributeTypes() ); 218 children.addAll( getObjectClasses() ); 219 return children; 220 } 221 } 222 | Popular Tags |