1 19 package org.netbeans.modules.xml.axi; 20 21 import java.util.List ; 22 import org.netbeans.modules.xml.schema.model.SchemaComponent; 23 24 30 public abstract class AXIContainer extends AXIComponent { 31 32 35 public AXIContainer(AXIModel model) { 36 super(model); 37 } 38 39 42 public AXIContainer(AXIModel model, SchemaComponent schemaComponent) { 43 super(model, schemaComponent); 44 } 45 46 49 public AXIContainer(AXIModel model, AXIComponent sharedComponent) { 50 super(model, sharedComponent); 51 } 52 53 56 public String getName() { 57 return name; 58 } 59 60 63 public void setName(String name) { 64 String oldName = getName(); 65 if( (oldName == null && name == null) || 66 (oldName != null && oldName.equals(name)) ) { 67 return; 68 } 69 70 this.name = name; 71 firePropertyChangeEvent(PROP_NAME, oldName, name); 72 } 73 74 78 public void addCompositor(Compositor compositor) { 79 insertAtIndex(Compositor.PROP_COMPOSITOR, compositor, 0); 80 } 81 82 85 public void removeCompositor(Compositor compositor) { 86 removeChild(Compositor.PROP_COMPOSITOR, compositor); 87 } 88 89 94 public void addElement(AbstractElement child) { 95 if(this instanceof Element) { 96 AXIType type = ((Element)this).getType(); 97 if(type != null && type instanceof ContentModel) { 98 ((ContentModel)type).addElement(child); 99 return; 100 } 101 } 102 103 Compositor c = getCompositor(); 105 if(c == null) { 106 c = getModel().getComponentFactory().createSequence(); 107 addCompositor(c); 108 } 109 c.appendChild(AbstractElement.PROP_ELEMENT, child); 111 } 112 113 116 public void removeElement(AbstractElement element) { 117 removeChild(AbstractElement.PROP_ELEMENT, element); 118 } 119 120 123 public void addAttribute(AbstractAttribute attribute) { 124 appendChild(AbstractAttribute.PROP_ATTRIBUTE, attribute); 125 } 126 127 130 public void removeAttribute(AbstractAttribute attribute) { 131 removeChild(AbstractAttribute.PROP_ATTRIBUTE, attribute); 132 } 133 134 137 public Compositor getCompositor() { 138 if(getChildren().size() > 0) { 139 AXIComponent component = getChildren().get(0); 140 if(component instanceof Compositor) 141 return (Compositor)component; 142 } 143 return null; 144 } 145 146 149 public final List <AbstractAttribute> getAttributes() { 150 return getChildren(AbstractAttribute.class); 151 } 152 153 protected String name; 154 155 public static final String PROP_NAME = "name"; } 157 | Popular Tags |