1 19 20 package org.netbeans.modules.xml.schema.ui.nodes.schema; 21 22 import org.netbeans.modules.xml.schema.model.ComplexContent; 23 import org.netbeans.modules.xml.schema.model.ComplexContentDefinition; 24 import org.netbeans.modules.xml.schema.model.ComplexContentRestriction; 25 import org.netbeans.modules.xml.schema.model.ComplexExtension; 26 import org.netbeans.modules.xml.schema.model.ComplexTypeDefinition; 27 import org.netbeans.modules.xml.schema.model.GlobalType; 28 import org.netbeans.modules.xml.schema.model.LocalComplexType; 29 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 30 import org.netbeans.modules.xml.schema.model.SimpleContent; 31 import org.netbeans.modules.xml.schema.model.SimpleContentDefinition; 32 import org.netbeans.modules.xml.schema.model.SimpleContentRestriction; 33 import org.netbeans.modules.xml.schema.model.SimpleExtension; 34 import org.netbeans.modules.xml.schema.ui.nodes.*; 35 36 import org.openide.nodes.Children; 37 import org.openide.nodes.Node.Property; 38 import org.openide.nodes.Sheet; 39 import org.openide.util.NbBundle; 40 41 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BooleanProperty; 42 46 public class LocalComplexTypeNode extends SchemaComponentNode<LocalComplexType> 47 { 48 52 public LocalComplexTypeNode(SchemaUIContext context, 53 SchemaComponentReference<LocalComplexType> reference, 54 Children children) 55 { 56 super(context,reference,children); 57 setIconBaseWithExtension( 58 "org/netbeans/modules/xml/schema/ui/nodes/resources/"+ 59 "complextype.png"); 60 } 61 62 63 protected GlobalType getSuperDefinition() 64 { 65 ComplexTypeDefinition definition = getReference().get().getDefinition(); 66 GlobalType gt = null; 67 if(definition instanceof ComplexContent) 68 { 69 ComplexContentDefinition contentDef = 70 ((ComplexContent)definition).getLocalDefinition(); 71 if (contentDef instanceof ComplexContentRestriction) 72 { 73 ComplexContentRestriction ccr = (ComplexContentRestriction)contentDef; 74 if(ccr.getBase()!= null) 75 { 76 gt=ccr.getBase().get(); 77 } 78 } 79 if (contentDef instanceof ComplexExtension) 80 { 81 ComplexExtension ce = (ComplexExtension)contentDef; 82 if(ce.getBase()!= null) 83 { 84 gt=ce.getBase().get(); 85 } 86 } 87 } 88 else if(definition instanceof SimpleContent) 89 { 90 SimpleContentDefinition contentDef = 91 ((SimpleContent)definition).getLocalDefinition(); 92 if (contentDef instanceof SimpleContentRestriction) 93 { 94 SimpleContentRestriction scr = (SimpleContentRestriction)contentDef; 95 if(scr.getBase()!= null) 96 { 97 gt=scr.getBase().get(); 98 } 99 } 100 if (contentDef instanceof SimpleExtension) 101 { 102 SimpleExtension se = (SimpleExtension)contentDef; 103 if(se.getBase()!= null) 104 { 105 gt=se.getBase().get(); 106 } 107 } 108 } 109 return gt; 110 } 111 112 @Override 113 protected Sheet createSheet() { 114 Sheet sheet = super.createSheet(); 115 Sheet.Set set = sheet.get(Sheet.PROPERTIES); 116 try { 117 Property mixedProp = new BooleanProperty( 119 getReference().get(), LocalComplexType.MIXED_PROPERTY, NbBundle.getMessage(LocalComplexTypeNode.class,"PROP_Mixed_DisplayName"), NbBundle.getMessage(LocalComplexTypeNode.class,"PROP_Mixed_ShortDescription"), true ); 125 set.put(new SchemaModelFlushWrapper(getReference().get(), mixedProp)); 126 } catch (NoSuchMethodException nsme) { 127 assert false : "properties should be defined"; 128 } 129 return sheet; 130 } 131 132 133 137 @Override 138 public String getTypeDisplayName() 139 { 140 return NbBundle.getMessage(LocalComplexTypeNode.class, 141 "LBL_LocalComplexTypeNode_TypeDisplayName"); } 143 } 144 | Popular Tags |