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.GlobalAttribute; 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 AdvancedGlobalAttributeCustomizer extends AttributeCustomizer<GlobalAttribute> 44 { 45 46 static final long serialVersionUID = 1L; 47 48 51 public AdvancedGlobalAttributeCustomizer( 52 SchemaComponentReference<GlobalAttribute> reference) 53 { 54 this(reference, null, null); 55 } 56 57 public AdvancedGlobalAttributeCustomizer( 58 SchemaComponentReference<GlobalAttribute> reference, 59 SchemaComponent parent, GlobalSimpleType currentGlobalSimpleType) 60 { 61 super(reference, parent, currentGlobalSimpleType); 62 } 63 64 65 68 protected void initializeModel() 69 { 70 GlobalAttribute attribute = getReference().get(); 71 if(!hasParent()) 72 { 73 _setType(_getType()); 74 } 75 else if (attribute.getType() != null) 76 { 77 _setType(attribute.getType().get()); 78 } 79 else 80 { 81 _setType(attribute.getInlineType()); 82 } 83 } 84 85 89 protected void setModelType() 90 { 91 GlobalAttribute attribute = getReference().get(); 92 93 AttributeTypeStyle newStyle = getUIStyle(); 94 if(newStyle == AttributeTypeStyle.EXISTING) 95 { 96 GlobalSimpleType newType = getUIType(); 97 _setType(newType); 98 if(attribute.getInlineType()!=null) 99 { 100 attribute.setInlineType(null); 101 } 102 SchemaComponentFactory factory = attribute.getModel().getFactory(); 103 attribute.setType(factory.createGlobalReference( 104 newType, GlobalSimpleType.class, attribute)); 105 } 106 else 107 { 108 if(attribute.getType()!=null) 109 { 110 attribute.setType(null); 111 } 112 LocalSimpleType lt = createLocalType(); 113 attribute.setInlineType(lt); 114 _setType(lt); 115 } 116 } 117 118 public HelpCtx getHelpCtx() 119 { 120 return new HelpCtx(AdvancedGlobalAttributeCustomizer.class); 121 } 122 } 123 | Popular Tags |