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.LocalElement; 32 import org.netbeans.modules.xml.schema.model.GlobalType; 33 import org.netbeans.modules.xml.schema.model.LocalType; 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.ElementCustomizer.ElementTypeStyle; 37 38 43 public class AdvancedLocalElementCustomizer extends ElementCustomizer<LocalElement> 44 { 45 46 static final long serialVersionUID = 1L; 47 48 51 public AdvancedLocalElementCustomizer( 52 SchemaComponentReference<LocalElement> reference) 53 { 54 this(reference, null); 55 } 56 57 public AdvancedLocalElementCustomizer( 58 SchemaComponentReference<LocalElement> reference, 59 SchemaComponent parent) 60 { 61 super(reference, parent); 62 } 63 64 67 protected void initializeModel() 68 { 69 LocalElement element = getReference().get(); 70 if (element.getType() != null) 71 { 72 _setType(element.getType().get()); 73 } 74 else 75 { 76 _setType(element.getInlineType()); 77 } 78 } 79 80 84 protected void setModelType() 85 { 86 LocalElement element = getReference().get(); 87 SchemaComponentFactory factory = element.getModel().getFactory(); 88 89 ElementTypeStyle newStyle = getUIStyle(); 90 GlobalType newType = getUIType(); 91 _setType(newType); 92 if(newStyle == ElementTypeStyle.EXISTING) 93 { 94 if(element.getInlineType()!=null) 95 { 96 element.setInlineType(null); 97 } 98 element.setType(factory.createGlobalReference( 99 newType, GlobalType.class, element)); 100 } 101 else 102 { 103 if(element.getType()!=null) 104 { 105 element.setType(null); 106 } 107 LocalType lt = createLocalType(factory, newStyle, newType); 108 element.setInlineType(lt); 109 } 110 } 111 112 public HelpCtx getHelpCtx() 113 { 114 return new HelpCtx(AdvancedLocalElementCustomizer.class); 115 } 116 } 117 | Popular Tags |