1 19 20 28 29 package org.netbeans.modules.xml.schema.abe.nodes; 30 31 import java.io.IOException ; 32 import java.util.ArrayList ; 33 import java.util.List ; 34 import javax.swing.Action ; 35 import org.netbeans.modules.xml.axi.AXIComponent; 36 import org.netbeans.modules.xml.axi.AXIDocument; 37 import org.netbeans.modules.xml.axi.SchemaGenerator; 38 import org.netbeans.modules.xml.schema.abe.InstanceUIContext; 39 import org.netbeans.modules.xml.schema.abe.NamespacePanel; 40 import org.netbeans.modules.xml.schema.abe.nodes.properties.BaseABENodeProperty; 41 import org.netbeans.modules.xml.schema.abe.nodes.properties.DesignPatternProperty; 42 import org.netbeans.modules.xml.schema.abe.nodes.properties.FormPropertyEditor; 43 import org.netbeans.modules.xml.schema.abe.nodes.properties.NamespaceProperty; 44 import org.netbeans.modules.xml.schema.abe.nodes.properties.StringEditor; 45 import org.netbeans.modules.xml.schema.abe.wizard.SchemaTransformPatternSelectionUI; 46 import org.netbeans.modules.xml.schema.model.Form; 47 import org.netbeans.modules.xml.xam.ui.actions.GoToAction; 48 import org.openide.actions.NewAction; 49 import org.openide.actions.PropertiesAction; 50 import org.openide.nodes.Node; 51 import org.openide.nodes.Sheet; 52 import org.openide.util.NbBundle; 53 import org.openide.util.actions.SystemAction; 54 import org.openide.util.datatransfer.NewType; 55 56 60 public class NamespaceNode extends ABEAbstractNode{ 61 62 63 public NamespaceNode(AXIComponent axiComponent, InstanceUIContext instanceUIContext) { 64 super(axiComponent, instanceUIContext); 65 } 66 67 protected void populateProperties(Sheet sheet) { 68 Sheet.Set set = sheet.get(Sheet.PROPERTIES); 69 if(set == null) { 70 set = sheet.createPropertiesSet(); 71 } 72 73 try { 74 Node.Property attrFormProp = new BaseABENodeProperty( 76 getAXIComponent(), 77 Form.class, AXIDocument.PROP_ATTRIBUTE_FORM_DEFAULT, NbBundle.getMessage(NamespaceNode.class,"PROP_AttributeFormDefault_DisplayName"), NbBundle.getMessage(NamespaceNode.class,"PROP_AttributeFormDefault_ShortDescription"), FormPropertyEditor.class 82 ); 83 set.put(new SchemaModelFlushWrapper(getAXIComponent(),attrFormProp, getContext())); 84 85 Node.Property elementFormProp = new BaseABENodeProperty( 87 getAXIComponent(), 88 Form.class, AXIDocument.PROP_ELEMENT_FORM_DEFAULT, NbBundle.getMessage(NamespaceNode.class,"PROP_ElementFormDefault_DisplayName"), NbBundle.getMessage(NamespaceNode.class,"PROP_ElementFormDefault_ShortDescription"), FormPropertyEditor.class 93 ); 94 set.put(new SchemaModelFlushWrapper(getAXIComponent(),elementFormProp, getContext())); 95 96 Node.Property versionProp = new BaseABENodeProperty( 98 getAXIComponent(), 99 String .class, 100 AXIDocument.PROP_VERSION, 101 NbBundle.getMessage(NamespaceNode.class,"PROP_Version_DisplayName"), NbBundle.getMessage(NamespaceNode.class,"PROP_Version_ShortDescription"), StringEditor.class 104 ); 105 set.put(new SchemaModelFlushWrapper(getAXIComponent(), versionProp, getContext())); 106 107 Node.Property tnsProp = new NamespaceProperty( 109 getAXIComponent(), 110 AXIDocument.PROP_TARGET_NAMESPACE, 111 NbBundle.getMessage(NamespaceNode.class,"PROP_TargetNamespace_DisplayName"), NbBundle.getMessage(NamespaceNode.class,"PROP_TargetNamespace_ShortDescription"), NbBundle.getMessage(NamespaceNode.class,"LBL_NamespaceNode_TypeDisplayName") ); 115 set.put(new SchemaModelFlushWrapper(getAXIComponent(), tnsProp, getContext())); 116 117 } catch (Exception ex) { 126 } 127 128 sheet.put(set); 129 } 130 131 public Action [] getActions(boolean b) { 132 return ALL_ACTIONS; 133 } 134 135 public String getName(){ 136 String namespace = ""; 137 AXIDocument root = (AXIDocument) super.getAXIComponent(); 138 if(root != null) { 139 namespace = ((AXIDocument) super.getAXIComponent()). 140 getTargetNamespace(); 141 if(namespace == null) 142 namespace = NbBundle.getMessage( 143 NamespacePanel.class, "LBL_NO_NAMESPACE"); 144 } 145 return namespace; 146 } 147 148 private static final SystemAction[] ALL_ACTIONS= 149 new SystemAction[] 150 { 151 SystemAction.get(NewAction.class), 152 null, 153 SystemAction.get(GoToAction.class), 154 null, 155 SystemAction.get(PropertiesAction.class) 156 }; 157 158 public NewType[] getNewTypes() { 159 if(!canWrite()) 160 return new NewType[0]; 161 List <NewType> ntl = new ArrayList <NewType>(); 162 NewType nt = new NewType(){ 164 public void create() throws IOException { 165 getContext().setUserInducedEventMode(true); 166 try{ 167 getContext().getNamespacePanel().addElement(); 168 }finally{ 169 getContext().setUserInducedEventMode(false); 170 } 171 } 172 public String getName() { 173 return NbBundle.getMessage(NamespaceNode.class, "LBL_NEW_GLOBAL_ELEMENT_ACTION"); 174 } 175 }; 176 ntl.add(nt); 177 nt = new NewType(){ 179 public void create() throws IOException { 180 getContext().setUserInducedEventMode(true); 181 try{ 182 getContext().getNamespacePanel().addComplexType(); 183 }finally{ 184 getContext().setUserInducedEventMode(false); 185 } 186 } 187 public String getName() { 188 return NbBundle.getMessage(NamespaceNode.class, "LBL_NEW_GLOBAL_COMPLEX_TYPE_ACTION"); 189 } 190 }; 191 ntl.add(nt); 192 return ntl.toArray(new NewType[ntl.size()]); 193 } 194 195 protected String getTypeDisplayName() { 196 return NbBundle.getMessage(AttributeNode.class,"LBL_Document"); 197 } 198 199 public void destroy() throws IOException { 200 } 202 } 203 | Popular Tags |