1 19 20 package org.netbeans.modules.xml.wsdl.ui.view.treeeditor; 21 22 import java.awt.Image ; 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.List ; 26 27 import org.netbeans.modules.xml.schema.model.Schema; 28 import org.netbeans.modules.xml.wsdl.model.Import; 29 import org.openide.nodes.Node; 30 import org.openide.util.NbBundle; 31 import org.openide.util.Utilities; 32 33 34 35 41 public class XSDImportNode extends ImportNode { 42 43 Image ICON = Utilities.loadImage 44 ("org/netbeans/modules/xml/wsdl/ui/view/resources/import-include-redefine.png"); 45 46 public XSDImportNode(Import wsdlConstruct) { 47 super(new XSDImportNodeChildren(wsdlConstruct), 48 wsdlConstruct); 49 } 50 51 52 @Override 53 public Image getIcon(int type) { 54 return ICON; 55 } 56 57 @Override 58 public Image getOpenedIcon(int type) { 59 return ICON; 60 } 61 62 @Override 63 public String getTypeDisplayName() { 64 return NbBundle.getMessage(XSDImportNode.class, "LBL_XSDImportNode_TypeDisplayName"); 65 } 66 67 @Override 68 protected void updateDisplayName() { 69 Import imp = (Import) getWSDLComponent(); 70 setDisplayName(imp.getLocation()); 71 } 72 73 public static class XSDImportNodeChildren extends GenericWSDLComponentChildren { 74 75 private Import mWsdlConstruct; 76 77 public XSDImportNodeChildren(Import wsdlConstruct) { 78 super(wsdlConstruct); 79 this.mWsdlConstruct = wsdlConstruct; 80 } 81 82 @Override 83 protected Node[] createNodes(Object key) { 84 if (key instanceof Schema) { 85 Schema schema = (Schema) key; 86 NodesFactory factory = NodesFactory.getInstance(); 87 Node node = factory.create(schema); 88 node.setDisplayName(this.mWsdlConstruct.getNamespace()); 89 return new Node[] { node }; 90 } 91 return super.createNodes(key); 92 } 93 94 @Override 95 @SuppressWarnings ("unchecked") 96 protected Collection getKeys() { 97 ArrayList keys = new ArrayList (); 98 List list = mWsdlConstruct.getModel().findSchemas(mWsdlConstruct.getNamespace()); 99 if (list != null && list.size() > 0) { 100 Schema schema = (Schema) list.get(0); 101 if (schema != null) { 102 keys.add(schema); 103 } 104 } 105 keys.addAll(super.getKeys()); 106 return keys; 107 } 108 109 } 110 } 111 | Popular Tags |