1 19 20 package org.netbeans.modules.java.ui.nodes.elements; 21 22 import org.netbeans.modules.java.ui.nodes.SourceNodeFactory; 23 import org.netbeans.jmi.javamodel.JavaEnum; 24 import org.netbeans.jmi.javamodel.EnumConstant; 25 import org.openide.nodes.Node; 26 27 import javax.jmi.reflect.JmiException; 28 import java.util.Collection ; 29 import java.util.List ; 30 import java.util.LinkedList ; 31 import java.util.Iterator ; 32 33 36 public final class EnumChildren extends ClassChildren { 37 public EnumChildren(SourceNodeFactory factory, JavaEnum element) { 38 super(factory, element); 39 } 40 41 public Class getFilterClass() { 42 return EnumFilter.class; 43 } 44 45 protected Node[] createNodesImpl(Object key) throws JmiException { 46 if (key instanceof EnumConstant) { 47 EnumConstant ec = (EnumConstant) key; 48 hookNodeName(ec); 49 return new Node[] { getFactory().createEnumConstantNode(ec) }; 50 } 51 52 return super.createNodesImpl(key); 53 } 54 55 protected List getKeysOfType(Collection elements, int elementType) { 56 List keys; 58 if ((elementType & EnumFilter.CONSTANTS) != 0) { 59 keys = new LinkedList (); 60 for (Iterator it = elements.iterator(); it.hasNext();) { 61 Object member = it.next(); 62 if ((elementType & EnumFilter.CONSTANTS) != 0 && member instanceof EnumConstant) { 63 keys.add(member); 64 } 65 } 66 } else { 67 keys = super.getKeysOfType(elements, elementType); 68 } 69 return keys; 70 } 71 72 protected int[] getOrder() { 73 return (filter == null || (filter.getOrder() == null)) 74 ? EnumFilter.DEFAULT_ORDER : filter.getOrder(); 75 } 76 77 protected void refreshAllKeys() { 78 refreshKeys(EnumFilter.ALL); 79 } 80 } 81 | Popular Tags |