1 19 20 package org.netbeans.modules.xml.xsd; 21 22 import java.beans.FeatureDescriptor ; 23 import java.util.Enumeration ; 24 import java.util.WeakHashMap ; 25 import org.netbeans.modules.xml.api.model.*; 26 27 32 public class XSDGrammarQueryProvider extends GrammarQueryManager { 33 34 private static final WeakHashMap schemas = new WeakHashMap (); 35 36 public XSDGrammarQueryProvider() { 37 } 38 39 public Enumeration enabled(GrammarEnvironment ctx) { 40 41 if (ctx.getFileObject() == null) { 42 return null; 43 } 44 45 XSDGrammarResolver ret = XSDGrammarResolver.createResolver(ctx); 46 if (ret != null) { 47 schemas.put(ctx.getFileObject(), ret); 49 return org.openide.util.Enumerations.singleton (ret.getTarget()); 50 } 51 52 return null; 53 } 54 55 public FeatureDescriptor getDescriptor() { 56 return new FeatureDescriptor (); 57 } 58 59 public GrammarQuery getGrammar(GrammarEnvironment env) { 60 return (XSDGrammarResolver) schemas.remove(env.getFileObject()); 61 } 62 } | Popular Tags |