1 19 20 package org.netbeans.modules.xml.schema.ui.nodes.schema; 21 22 import java.lang.reflect.InvocationTargetException ; 23 import java.util.Map ; 24 import org.openide.nodes.Children; 25 import org.openide.nodes.PropertySupport; 26 import org.openide.nodes.Sheet; 27 import org.openide.util.NbBundle; 28 import org.netbeans.modules.xml.schema.model.Import; 29 import org.netbeans.modules.xml.schema.model.SchemaComponentReference; 30 import org.netbeans.modules.xml.schema.ui.nodes.*; 31 32 36 public class ImportNode extends SchemaComponentNode<Import> 37 { 38 42 public ImportNode(SchemaUIContext context, 43 SchemaComponentReference<Import> reference, 44 Children children) 45 { 46 super(context,reference,children); 47 setIconBaseWithExtension( 48 "org/netbeans/modules/xml/schema/ui/nodes/resources/import-include-redefine.png"); 49 } 50 51 52 @Override  53 protected Sheet createSheet() 54 { 55 Sheet sheet = super.createSheet(); 56 Sheet.Set props = sheet.get(Sheet.PROPERTIES); 57 if (props == null) { 58 props = Sheet.createPropertiesSet(); 59 sheet.put(props); 60 } 61 Property nsProp = new PropertySupport.ReadOnly( 63 Import.NAMESPACE_PROPERTY, String .class, 64 NbBundle.getMessage(ImportNode.class,"PROP_Namespace_DisplayName"), 65 NbBundle.getMessage(ImportNode.class,"HINT_Namespace_ShortDesc") 66 ) 67 { 68 public Object getValue() throws 69 IllegalAccessException ,InvocationTargetException  70 { 71 return getReference().get().getNamespace(); 72 } 73 }; 74 props.put(nsProp); 75 76 Property slProp = new PropertySupport.ReadOnly( 78 Import.SCHEMA_LOCATION_PROPERTY, String .class, 79 NbBundle.getMessage(ImportNode.class,"PROP_SchemaLocation_DisplayName"), 80 NbBundle.getMessage(ImportNode.class,"HINT_SchemaLocation_ShortDesc") 81 ) 82 { 83 public Object getValue() throws 84 IllegalAccessException ,InvocationTargetException  85 { 86 return getReference().get().getSchemaLocation(); 87 } 88 }; 89 props.put(slProp); 90 91 Property prefixProp = new PropertySupport.ReadOnly( 93 "prefix", String .class, 95 NbBundle.getMessage(ImportNode.class,"PROP_Prefix_DisplayName"), 96 NbBundle.getMessage(ImportNode.class,"HINT_Prefix_ShortDesc") 97 ) 98 { 99 public Object getValue() throws 100 IllegalAccessException ,InvocationTargetException  101 { 102 Map <String ,String > prefixMap = 103 getReference().get().getModel().getSchema().getPrefixes(); 104 String namespace = getReference().get().getNamespace(); 105 if(prefixMap.containsValue(namespace)) 106 { 107 for (Map.Entry <String ,String > entry :prefixMap.entrySet()) 108 { 109 if (entry.getValue().equals(namespace)) 110 { 111 return entry.getKey(); 112 } 113 } 114 } 115 return null; 116 } 117 }; 118 props.put(prefixProp); 119 120 return sheet; 121 } 122 123 @Override  124 protected void updateDisplayName() { 125 fireDisplayNameChange("NotTheDefaultName", getDefaultDisplayName()); 127 } 128 129 @Override  130 public String getHtmlDisplayName() { 131 String name = getDefaultDisplayName() + 132 " {" + getReference().get().getNamespace() + "}"; 133 return applyHighlights(name); 134 } 135 136 @Override  137 public String getTypeDisplayName() { 138 return NbBundle.getMessage(ImportNode.class, 139 "LBL_ImportNode_TypeDisplayName"); 140 } 141 } 142 | Popular Tags |