1 19 20 25 26 package org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer; 27 28 import org.netbeans.modules.xml.schema.model.SchemaComponent; 29 import org.openide.util.HelpCtx; 30 import org.netbeans.modules.xml.schema.model.LocalAttribute; 32 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 33 import org.netbeans.modules.xml.schema.model.LocalSimpleType; 34 import org.netbeans.modules.xml.schema.model.SchemaComponentFactory; 35 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 36 import org.netbeans.modules.xml.schema.ui.nodes.categorized.customizer.AttributeCustomizer.AttributeTypeStyle; 37 38 43 public class AdvancedLocalAttributeCustomizer extends AttributeCustomizer<LocalAttribute> 44 { 45 46 static final long serialVersionUID = 1L; 47 48 51 public AdvancedLocalAttributeCustomizer( 52 SchemaComponentReference<LocalAttribute> reference) 53 { 54 this(reference, null, null); 55 } 56 57 public AdvancedLocalAttributeCustomizer( 58 SchemaComponentReference<LocalAttribute> reference, 59 SchemaComponent parent, GlobalSimpleType currentGlobalSimpleType) 60 { 61 super(reference, parent, currentGlobalSimpleType); 62 } 63 64 67 protected void initializeModel() 68 { 69 LocalAttribute attribute = getReference().get(); 70 if(!hasParent()) 71 { 72 _setType(_getType()); 73 } 74 else if (attribute.getType() != null) 75 { 76 _setType(attribute.getType().get()); 77 } 78 else 79 { 80 _setType(attribute.getInlineType()); 81 } 82 } 83 84 88 protected void setModelType() 89 { 90 LocalAttribute attribute = getReference().get(); 91 92 AttributeTypeStyle newStyle = getUIStyle(); 93 if(newStyle == AttributeTypeStyle.EXISTING) 94 { 95 GlobalSimpleType newType = getUIType(); 96 _setType(newType); 97 if(attribute.getInlineType()!=null) 98 { 99 attribute.setInlineType(null); 100 } 101 SchemaComponentFactory factory = attribute.getModel().getFactory(); 102 attribute.setType(factory.createGlobalReference( 103 newType, GlobalSimpleType.class, attribute)); 104 } 105 else 106 { 107 if(attribute.getType()!=null) 108 { 109 attribute.setType(null); 110 } 111 LocalSimpleType lt = createLocalType(); 112 attribute.setInlineType(lt); 113 _setType(lt); 114 } 115 } 116 117 public HelpCtx getHelpCtx() 118 { 119 return new HelpCtx(AdvancedLocalAttributeCustomizer.class); 120 } 121 } 122 | Popular Tags |