1 19 package org.netbeans.modules.xml.axi; 20 21 import java.io.IOException ; 22 import org.netbeans.modules.xml.axi.impl.AXIModelImpl; 23 import org.netbeans.modules.xml.schema.model.SchemaModel; 24 import org.netbeans.modules.xml.xam.AbstractModelFactory; 25 import org.netbeans.modules.xml.xam.ModelSource; 26 import org.openide.filesystems.FileObject; 27 import org.openide.util.Lookup; 28 import org.openide.util.lookup.Lookups; 29 30 35 public class AXIModelFactory extends AbstractModelFactory<AXIModel> { 36 37 40 private AXIModelFactory() { 41 } 42 43 46 public static AXIModelFactory getDefault() { 47 return instance; 48 } 49 50 53 public AXIModel getModel(SchemaModel schemaModel) { 54 FileObject file = (FileObject)schemaModel.getModelSource(). 55 getLookup().lookup(FileObject.class); 56 Lookup lookup = null; 57 if(file == null) { 58 Object [] objectsToLookup = {schemaModel}; 59 lookup = Lookups.fixed(objectsToLookup); 60 } else { 61 Object [] objectsToLookup = {schemaModel, file}; 62 lookup = Lookups.fixed(objectsToLookup); 63 } 64 ModelSource source = new ModelSource(lookup, true); 65 assert(source != null); 66 return getModel(source); 67 } 68 69 73 protected AXIModel getModel(ModelSource modelSource) { 74 Lookup lookup = modelSource.getLookup(); 75 assert lookup.lookup(SchemaModel.class) != null; 76 return super.getModel(modelSource); 77 } 78 79 82 protected Object getKey(ModelSource modelSource) { 83 return modelSource.getLookup().lookup(SchemaModel.class); 84 } 85 86 89 protected AXIModel createModel(ModelSource modelSource) { 90 return new AXIModelImpl(modelSource); 91 } 92 93 99 private static AXIModelFactory instance = new AXIModelFactory(); 100 } 101 | Popular Tags |