1 19 package org.netbeans.modules.xml.axi; 20 21 import java.util.List ; 22 import org.netbeans.modules.xml.axi.impl.AXIDocumentImpl; 23 import org.netbeans.modules.xml.axi.impl.AXIModelImpl; 24 import org.netbeans.modules.xml.axi.impl.AXIModelBuilderQuery; 25 import org.netbeans.modules.xml.axi.impl.ModelAccessImpl; 26 import org.netbeans.modules.xml.schema.model.SchemaComponent; 27 import org.netbeans.modules.xml.schema.model.SchemaModel; 28 import org.netbeans.modules.xml.xam.AbstractModel; 29 import org.netbeans.modules.xml.xam.ModelAccess; 30 import org.netbeans.modules.xml.xam.ModelSource; 31 import org.netbeans.modules.xml.xam.Component; 32 import org.openide.filesystems.FileObject; 33 34 39 public abstract class AXIModel extends AbstractModel<AXIComponent> { 40 41 44 public AXIModel(ModelSource modelSource) { 45 super(modelSource); 46 this.factory = new AXIComponentFactory(this); 47 this.root = new AXIDocumentImpl(this, getSchemaModel().getSchema()); 48 this.modelAccess = new ModelAccessImpl(this); 49 } 50 51 54 public abstract List <AXIModel> getReferencedModels(); 55 56 59 public abstract SchemaGenerator.Pattern getSchemaDesignPattern(); 60 61 64 public abstract void setSchemaDesignPattern(SchemaGenerator.Pattern p); 65 66 70 public SchemaModel getSchemaModel() { 71 return (SchemaModel)getModelSource().getLookup(). 72 lookup(SchemaModel.class); 73 } 74 75 78 public AXIDocument getRoot() { 79 return root; 80 } 81 82 85 public AXIComponentFactory getComponentFactory() { 86 return factory; 87 } 88 89 92 public boolean isReadOnly() { 93 ModelSource ms = getModelSource(); 94 assert(ms != null); 95 if (ms.isEditable()) { 96 FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class); 97 assert(fo != null); 98 return !fo.canWrite(); 99 } 100 return true; 101 } 102 103 106 public boolean canView(SchemaComponent component) { 107 AXIModelBuilderQuery factory = new AXIModelBuilderQuery((AXIModelImpl)this); 108 return factory.canView(component); 109 } 110 111 public ModelAccess getAccess() { 115 return modelAccess; 116 } 117 118 public void addChildComponent(Component parent, Component child, int index) { 119 AXIComponent axiParent = (AXIComponent)parent; 120 AXIComponent axiChild = (AXIComponent)child; 121 axiParent.addChildAtIndex(axiChild, index); 122 } 123 124 public void removeChildComponent(Component child) { 125 AXIComponent axiChild = (AXIComponent)child; 126 AXIComponent axiParent = axiChild.getParent(); 127 axiParent.removeChild(axiChild); 128 } 129 130 136 private AXIComponentFactory factory; 137 138 141 private ModelAccess modelAccess; 142 143 146 private AXIDocument root; 147 } 148 | Popular Tags |