1 19 20 package org.netbeans.modules.xml.schema.ui.nodes.categorized; 21 22 import org.netbeans.modules.xml.schema.model.Enumeration; 23 import org.netbeans.modules.xml.schema.model.SimpleType; 24 import org.openide.nodes.AbstractNode; 25 import org.openide.nodes.Children; 26 import org.openide.nodes.Node; 27 import org.openide.nodes.NodeAdapter; 28 import org.openide.util.NbBundle; 29 import org.netbeans.modules.xml.schema.model.SchemaComponent; 30 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 31 import org.netbeans.modules.xml.schema.ui.nodes.DefaultExpandedCookie; 32 import org.netbeans.modules.xml.schema.ui.nodes.SchemaComponentNode; 33 import org.netbeans.modules.xml.schema.ui.nodes.SchemaUIContext; 34 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 35 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 36 import org.netbeans.modules.xml.schema.model.List; 37 import org.netbeans.modules.xml.schema.model.LocalSimpleType; 38 import org.netbeans.modules.xml.schema.model.SimpleTypeDefinition; 39 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction; 40 41 45 public class SimpleTypeChildren<C extends SimpleType> 46 extends CategorizedChildren<C> 47 { 48 52 public SimpleTypeChildren(SchemaUIContext context, 53 SchemaComponentReference<C> reference) { 54 super(context,reference); 55 } 56 57 58 62 protected java.util.List <Node> createKeys() { 63 java.util.List <Node> keys=super.createKeys(); 64 65 int index=0; 66 67 if (keys.size() > 0 && keys.get(0) instanceof DetailsNode) 69 index=1; 70 71 LocalSimpleType inlineType = null; 72 SimpleTypeDefinition definition = getReference().get().getDefinition(); 73 if(definition instanceof SimpleTypeRestriction) { 74 SimpleTypeRestriction str = (SimpleTypeRestriction)definition; 75 inlineType = str.getInlineType(); 76 } 77 if(definition instanceof List) { 78 List list = (List)definition; 79 inlineType = list.getInlineType(); 80 } 81 if(definition instanceof SimpleTypeRestriction || 82 definition instanceof List) { 83 for (int i=0;i<keys.size();i++) { 84 Node n = keys.get(i); 85 SchemaComponentNode scn = (SchemaComponentNode)n.getCookie 86 (SchemaComponentNode.class); 87 if(scn!=null && scn.getReference().get()==definition) { 88 index = i; 89 keys.remove(index); 90 break; 91 } 92 } 93 } 94 if(inlineType != null) { 95 Node inlineNode= 96 getContext().getFactory().createNode(inlineType); 97 98 DefaultExpandedCookie expanded=(DefaultExpandedCookie) 99 inlineNode.getCookie(DefaultExpandedCookie.class); 100 if (expanded!=null) 101 expanded.setDefaultExpanded(true); 102 103 keys.add(index++,inlineNode); 104 } 105 if(definition instanceof SimpleTypeRestriction) { 106 java.util.List <Enumeration> enumChildren = 108 definition.getChildren(Enumeration.class); 109 for(Enumeration e:enumChildren) { 110 keys.add(index++,getContext().getFactory().createNode(e)); 111 } 112 } 113 return keys; 114 } 115 } 116 | Popular Tags |