1 19 20 package org.netbeans.modules.xml.schema.ui.nodes.schema; 21 22 import org.netbeans.modules.xml.schema.model.GlobalType; 23 import org.netbeans.modules.xml.schema.model.LocalElement; 24 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 25 import org.netbeans.modules.xml.schema.ui.basic.editors.MaxOccursEditor; 26 import org.netbeans.modules.xml.schema.ui.nodes.*; 27 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BaseSchemaProperty; 28 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BooleanProperty; 29 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DefaultProperty; 30 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.DerivationTypeProperty; 31 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.FixedProperty; 32 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.NonNegativeIntegerProperty; 33 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.FormProperty; 34 import org.openide.nodes.Children; 35 import org.openide.nodes.Node; 36 import org.openide.nodes.Node.Property; 37 import org.openide.nodes.Sheet; 38 import org.openide.util.NbBundle; 39 40 44 public class LocalElementNode extends SchemaComponentNode<LocalElement> 45 { 46 50 public LocalElementNode(SchemaUIContext context, 51 SchemaComponentReference<LocalElement> reference, 52 Children children) { 53 super(context,reference,children); 54 55 setIconBaseWithExtension( 56 "org/netbeans/modules/xml/schema/ui/nodes/resources/element.png"); 57 } 58 59 60 64 @Override 65 public String getTypeDisplayName() { 66 return NbBundle.getMessage(LocalElementNode.class, 67 "LBL_LocalElementNode_TypeDisplayName"); } 69 70 @Override 71 protected GlobalType getSuperDefinition() 72 { 73 LocalElement sc = getReference().get(); 74 GlobalType gt = null; 75 if(sc.getType()!=null) 76 gt = sc.getType().get(); 77 return gt; 78 } 79 80 @Override 81 protected Sheet createSheet() { 82 Sheet sheet = super.createSheet(); 83 Sheet.Set set = sheet.get(Sheet.PROPERTIES); 84 try { 85 88 Node.Property nillableProp = new BooleanProperty( 90 getReference().get(), LocalElement.NILLABLE_PROPERTY, NbBundle.getMessage(LocalElementNode.class,"PROP_Nillable_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_Nillable_ShortDescription"), true ); 96 set.put(new SchemaModelFlushWrapper(getReference().get(),nillableProp)); 97 98 Node.Property fixedProp = new FixedProperty( 100 getReference().get(), NbBundle.getMessage(LocalElementNode.class,"PROP_Fixed_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_Fixed_ShortDescription") ); 104 set.put(new SchemaModelFlushWrapper(getReference().get(),fixedProp)); 105 106 Node.Property defaultProp = new DefaultProperty( 108 getReference().get(), NbBundle.getMessage(LocalElementNode.class,"PROP_Default_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_Default_ShortDescription") ); 112 set.put(new SchemaModelFlushWrapper(getReference().get(),defaultProp)); 113 114 if (getReference().get().allowsFullMultiplicity()) { 115 116 Property maxOccursProp = new BaseSchemaProperty( 118 getReference().get(), String .class, 120 LocalElement.MAX_OCCURS_PROPERTY, 121 NbBundle.getMessage(LocalElementNode.class,"PROP_MaxOccurs_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_MaxOccurs_ShortDescription"), MaxOccursEditor.class 124 ); 125 set.put(new SchemaModelFlushWrapper(getReference().get(), maxOccursProp)); 126 127 } 128 133 Property minOccursProp = new NonNegativeIntegerProperty( 135 getReference().get(), LocalElement.MIN_OCCURS_PROPERTY, 137 NbBundle.getMessage(LocalElementNode.class,"PROP_MinOccurs_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_MinOccurs_ShortDescription") ); 140 set.put(new SchemaModelFlushWrapper(getReference().get(), minOccursProp)); 141 142 Node.Property formProp = new FormProperty( 144 getReference().get(), LocalElement.FORM_PROPERTY, NbBundle.getMessage(LocalElementNode.class,"PROP_Form_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"PROP_Form_ElementShortDescription") ); 149 set.put(new SchemaModelFlushWrapper(getReference().get(),formProp)); 150 151 Node.Property blockProp = new DerivationTypeProperty( 153 getReference().get(), 154 LocalElement.BLOCK_PROPERTY, 155 NbBundle.getMessage(LocalElementNode.class,"PROP_Block_DisplayName"), NbBundle.getMessage(LocalElementNode.class,"HINT_Block_ShortDesc"), getTypeDisplayName() 158 ); 159 set.put(new SchemaModelFlushWrapper(getReference().get(), blockProp)); 160 161 162 } catch (NoSuchMethodException nsme) { 163 assert false : "properties should be defined"; 164 } 165 166 return sheet; 167 } 168 169 } 170 | Popular Tags |