1 19 20 package org.netbeans.modules.xml.schema.ui.nodes.schema; 21 22 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 23 import org.netbeans.modules.xml.schema.model.List; 24 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 25 import org.netbeans.modules.xml.schema.model.SimpleTypeDefinition; 26 import org.netbeans.modules.xml.schema.model.SimpleTypeRestriction; 27 import org.netbeans.modules.xml.schema.ui.nodes.*; 28 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DerivationTypeProperty; 29 import org.openide.nodes.Children; 30 import org.openide.nodes.Sheet; 31 import org.openide.nodes.Node.Property; 32 import org.openide.util.NbBundle; 33 37 public class GlobalSimpleTypeNode extends SchemaComponentNode<GlobalSimpleType> 38 { 39 43 public GlobalSimpleTypeNode(SchemaUIContext context, 44 SchemaComponentReference<GlobalSimpleType> reference, 45 Children children) 46 { 47 super(context,reference,children); 48 49 setIconBaseWithExtension( 50 "org/netbeans/modules/xml/schema/ui/nodes/resources/"+ 51 "simpletype.png"); 52 } 53 54 55 59 @Override 60 public String getTypeDisplayName() 61 { 62 return NbBundle.getMessage(GlobalSimpleTypeNode.class, 63 "LBL_GlobalSimpleTypeNode_TypeDisplayName"); } 65 66 @Override 67 protected GlobalSimpleType getSuperDefinition() 68 { 69 SimpleTypeDefinition definition = getReference().get().getDefinition(); 70 GlobalSimpleType gt = null; 71 if(definition instanceof SimpleTypeRestriction) 72 { 73 SimpleTypeRestriction str = (SimpleTypeRestriction)definition; 74 if(str.getBase()!=null) 75 { 76 gt = str.getBase().get(); 77 } 78 } 79 if(definition instanceof List) 80 { 81 List list = (List)definition; 82 GlobalSimpleType gst = null; 83 if(list.getType()!=null) 84 { 85 gt = list.getType().get(); 86 } 87 } 88 return gt; 89 } 90 91 protected String getSuperDefinitionName() 92 { 93 String rawString = null; 94 SimpleTypeDefinition definition = getReference().get().getDefinition(); 95 GlobalSimpleType gt = null; 96 if(definition instanceof SimpleTypeRestriction) { 97 SimpleTypeRestriction str = (SimpleTypeRestriction)definition; 98 if(str.getBase()!=null) { 99 rawString = str.getBase().getRefString(); 100 } 101 } 102 if(definition instanceof List) { 103 List list = (List)definition; 104 GlobalSimpleType gst = null; 105 if(list.getType()!=null) { 106 rawString = list.getType().getRefString(); 107 } 108 } 109 int i = rawString!=null?rawString.indexOf(':'):-1; 110 if (i != -1 && i < rawString.length()) { 111 rawString = rawString.substring(i); 112 } 113 return rawString; 114 } 115 116 @Override 117 protected Sheet createSheet() { 118 Sheet sheet = super.createSheet(); 119 Sheet.Set set = sheet.get(Sheet.PROPERTIES); 120 try { 121 Property finalProp = new DerivationTypeProperty( 123 getReference().get(), 124 GlobalSimpleType.FINAL_PROPERTY, 125 NbBundle.getMessage(GlobalSimpleTypeNode.class,"PROP_Final_DisplayName"), NbBundle.getMessage(GlobalSimpleTypeNode.class,"HINT_Final_ShortDesc"), getTypeDisplayName() 128 ); 129 set.put(new SchemaModelFlushWrapper(getReference().get(), finalProp)); 130 131 } catch (NoSuchMethodException nsme) { 132 assert false : "properties should be defined"; 133 } 134 135 return sheet; 136 } 137 } 138 | Popular Tags |