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.openide.nodes.Children; 28 import org.openide.nodes.Node.Property; 29 import org.openide.nodes.Sheet; 30 import org.openide.util.NbBundle; 31 32 import org.netbeans.modules.xml.schema.model.GlobalComplexType; 33 import org.netbeans.modules.xml.schema.model.GlobalType; 34 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 35 import org.netbeans.modules.xml.schema.model.SimpleContent; 36 import org.netbeans.modules.xml.schema.model.SimpleContentDefinition; 37 import org.netbeans.modules.xml.schema.model.SimpleContentRestriction; 38 import org.netbeans.modules.xml.schema.model.SimpleExtension; 39 import org.netbeans.modules.xml.schema.ui.nodes.*; 40 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BooleanProperty; 41 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DerivationTypeProperty; 42 43 47 public class GlobalComplexTypeNode extends SchemaComponentNode<GlobalComplexType> 48 { 49 53 public GlobalComplexTypeNode(SchemaUIContext context, 54 SchemaComponentReference<GlobalComplexType> reference, 55 Children children) { 56 super(context,reference,children); 57 58 setIconBaseWithExtension( 59 "org/netbeans/modules/xml/schema/ui/nodes/resources/"+ 60 "complextype.png"); 61 } 62 63 64 68 @Override 69 public String getTypeDisplayName() { 70 return NbBundle.getMessage(GlobalComplexTypeNode.class, 71 "LBL_GlobalComplexTypeNode_TypeDisplayName"); } 73 74 protected GlobalType getSuperDefinition() 75 { 76 ComplexTypeDefinition definition = getReference().get().getDefinition(); 77 GlobalType gt = null; 78 if(definition instanceof ComplexContent) 79 { 80 ComplexContentDefinition contentDef = 81 ((ComplexContent)definition).getLocalDefinition(); 82 if (contentDef instanceof ComplexContentRestriction) 83 { 84 ComplexContentRestriction ccr = (ComplexContentRestriction)contentDef; 85 if(ccr.getBase()!= null) 86 { 87 gt=ccr.getBase().get(); 88 } 89 } 90 if (contentDef instanceof ComplexExtension) 91 { 92 ComplexExtension ce = (ComplexExtension)contentDef; 93 if(ce.getBase()!= null) 94 { 95 gt=ce.getBase().get(); 96 } 97 } 98 } 99 else if(definition instanceof SimpleContent) 100 { 101 SimpleContentDefinition contentDef = 102 ((SimpleContent)definition).getLocalDefinition(); 103 if (contentDef instanceof SimpleContentRestriction) 104 { 105 SimpleContentRestriction scr = (SimpleContentRestriction)contentDef; 106 if(scr.getBase()!= null) 107 { 108 gt=scr.getBase().get(); 109 } 110 } 111 if (contentDef instanceof SimpleExtension) 112 { 113 SimpleExtension se = (SimpleExtension)contentDef; 114 if(se.getBase()!= null) 115 { 116 gt=se.getBase().get(); 117 } 118 } 119 } 120 return gt; 121 } 122 123 protected String getSuperDefinitionName() 124 { 125 String rawString = null; 126 ComplexTypeDefinition definition = getReference().get().getDefinition(); 127 if(definition instanceof ComplexContent) 128 { 129 ComplexContentDefinition contentDef = 130 ((ComplexContent)definition).getLocalDefinition(); 131 if (contentDef instanceof ComplexContentRestriction) 132 { 133 ComplexContentRestriction ccr = (ComplexContentRestriction)contentDef; 134 if(ccr.getBase()!= null) 135 { 136 rawString=ccr.getBase().getRefString(); 137 } 138 } 139 if (contentDef instanceof ComplexExtension) 140 { 141 ComplexExtension ce = (ComplexExtension)contentDef; 142 if(ce.getBase()!= null) 143 { 144 rawString=ce.getBase().getRefString(); 145 } 146 } 147 } 148 else if(definition instanceof SimpleContent) 149 { 150 SimpleContentDefinition contentDef = 151 ((SimpleContent)definition).getLocalDefinition(); 152 if (contentDef instanceof SimpleContentRestriction) 153 { 154 SimpleContentRestriction scr = (SimpleContentRestriction)contentDef; 155 if(scr.getBase()!= null) 156 { 157 rawString=scr.getBase().getRefString(); 158 } 159 } 160 if (contentDef instanceof SimpleExtension) 161 { 162 SimpleExtension se = (SimpleExtension)contentDef; 163 if(se.getBase()!= null) 164 { 165 rawString=se.getBase().getRefString(); 166 } 167 } 168 } 169 int i = rawString!=null?rawString.indexOf(':'):-1; 170 if (i != -1 && i < rawString.length()) { 171 rawString = rawString.substring(i); 172 } 173 return rawString; 174 } 175 176 @Override 177 protected Sheet createSheet() { 178 Sheet sheet = super.createSheet(); 179 Sheet.Set set = sheet.get(Sheet.PROPERTIES); 180 try { 181 184 185 Property abstractProp = new BooleanProperty( 187 getReference().get(), GlobalComplexType.ABSTRACT_PROPERTY, NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Abstract_DisplayName"), NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Abstract_ShortDescription"), true ); 193 set.put(new SchemaModelFlushWrapper(getReference().get(), abstractProp)); 194 195 Property mixedProp = new BooleanProperty( 197 getReference().get(), GlobalComplexType.MIXED_PROPERTY, NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Mixed_DisplayName"), NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Mixed_ShortDescription"), true ); 203 set.put(new SchemaModelFlushWrapper(getReference().get(), mixedProp)); 204 205 Property finalProp = new DerivationTypeProperty( 207 getReference().get(), 208 GlobalComplexType.FINAL_PROPERTY, 209 NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Final_DisplayName"), NbBundle.getMessage(GlobalComplexTypeNode.class,"HINT_Final_ShortDesc"), getTypeDisplayName() 212 ); 213 set.put(new SchemaModelFlushWrapper(getReference().get(), finalProp)); 214 215 Property blockProp = new DerivationTypeProperty( 217 getReference().get(), 218 GlobalComplexType.BLOCK_PROPERTY, 219 NbBundle.getMessage(GlobalComplexTypeNode.class,"PROP_Block_DisplayName"), NbBundle.getMessage(GlobalComplexTypeNode.class,"HINT_Block_ShortDesc"), getTypeDisplayName() 222 ); 223 set.put(new SchemaModelFlushWrapper(getReference().get(), blockProp)); 224 } catch (NoSuchMethodException nsme) { 225 assert false : "properties should be defined"; 226 } 227 228 return sheet; 229 } 230 231 } 232 | Popular Tags |