1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.selectors; 21 22 import org.openide.nodes.Children; 23 import org.openide.nodes.Node; 24 import org.openide.nodes.AbstractNode; 25 import org.openide.util.lookup.Lookups; 26 27 import java.util.Collection ; 28 import java.util.List ; 29 import java.util.ArrayList ; 30 import java.util.Collections ; 31 32 38 final class BranchNodeChildren extends Children.Keys { 39 40 private final Node headNode = new AbstractNode(Children.LEAF, Lookups.singleton("HEAD")); private final SymbolicNamesNode branchesNode = SymbolicNamesNode.create(org.openide.util.NbBundle.getMessage(BranchNodeChildren.class, "BK2008")); 42 private final SymbolicNamesNode tagsNode = SymbolicNamesNode.create(org.openide.util.NbBundle.getMessage(BranchNodeChildren.class, "BK2009")); 43 44 48 public void setBranches(Collection branches) { 49 branchesNode.setNames(branches); 50 } 51 52 56 public void setTags(Collection tags) { 57 tagsNode.setNames(tags); 58 } 59 60 protected void addNotify() { 61 List nodes = new ArrayList (3); 62 headNode.setName("HEAD"); nodes.add(headNode); 64 nodes.add(branchesNode); 65 nodes.add(tagsNode); 66 setKeys(nodes); 67 } 68 69 protected void removeNotify() { 70 setKeys(Collections.EMPTY_SET); 71 } 72 73 protected Node[] createNodes(Object key) { 74 return new Node[]{ (Node) key}; 75 } 76 77 private static final class SymbolicNamesNode extends AbstractNode { 78 79 public static SymbolicNamesNode create(String displayName) { 80 Children kids = new SNChildren(); 81 SymbolicNamesNode node = new SymbolicNamesNode(kids); 82 node.setName(displayName); 83 return node; 84 } 85 86 public void setNames(Collection names) { 87 SNChildren kids = (SNChildren) getChildren(); 88 kids.setNames(names); 89 } 90 91 private SymbolicNamesNode(Children children) { 92 super(children); 93 } 94 95 private static class SNChildren extends Children.Keys { 96 97 private SNChildren() { 98 AbstractNode waitNode = new AbstractNode(Children.LEAF); 99 waitNode.setDisplayName(org.openide.util.NbBundle.getMessage(BranchNodeChildren.class, "BK2010")); 100 setKeys(Collections.singleton(waitNode)); 101 } 102 103 public void setNames(Collection names) { 104 if (names.size() == 0) { 105 AbstractNode waitNode = new AbstractNode(Children.LEAF); 106 waitNode.setDisplayName(org.openide.util.NbBundle.getMessage(BranchNodeChildren.class, "BK2011")); 107 setKeys(Collections.singleton(waitNode)); 108 } else { 109 setKeys(names); 110 } 111 } 112 113 protected Node[] createNodes(Object key) { 114 if (key instanceof Node) { 115 return new Node[] {(Node) key}; 116 } else { 117 String name = (String ) key; 118 Node node = new AbstractNode(Children.LEAF, Lookups.singleton(name)); 119 node.setDisplayName(name); 120 return new Node[] {node}; 121 } 122 } 123 } 124 } 125 126 } 127 | Popular Tags |