View Javadoc
1 /* 2 * Created on 08.mar.2003 3 * 4 * To change this generated comment go to 5 * Window>Preferences>Java>Code Generation>Code and Comments 6 */ 7 package net.sf.panoptes.model.node; 8 9 import java.util.List; 10 11 import net.sf.panoptes.model.component.registry.ComponentEntry; 12 import net.sf.panoptes.model.component.registry.ComponentName; 13 import net.sf.panoptes.model.component.registry.ComponentRegistry; 14 15 /*** 16 * Represents a component query node which will list the query results 17 * as it's children. 18 * 19 * @see net.sf.panoptes.model.component.IComponent 20 * @see net.sf.panoptes.model.component.registry.ComponentName 21 * @see net.sf.panoptes.model.node.INode 22 * @author Dag Liodden 23 * 24 */ 25 public class ComponentQueryNode implements INode { 26 27 private String iconName; 28 29 private NodeDescriptor configDescriptor; 30 31 private ComponentName query; 32 33 private ComponentRegistry componentRegistry; 34 35 /*** 36 * Constructs a new object which will query a registry for components. 37 * 38 * @param componentRegistry the registry to query 39 * @param query the query 40 */ 41 public ComponentQueryNode(ComponentRegistry componentRegistry, ComponentName query) { 42 this.componentRegistry = componentRegistry; 43 this.query = query; 44 } 45 46 /* (non-Javadoc) 47 * @see net.sf.panoptes.view.configurator.INode#getConfigDescriptor() 48 */ 49 public NodeDescriptor getConfigDescriptor() { 50 if (configDescriptor != null) return configDescriptor; 51 else return new NodeDescriptor(query.toString(), "Group of components in query " + query.toString()); 52 } 53 54 /* (non-Javadoc) 55 * @see net.sf.panoptes.view.configurator.INode#getChildren() 56 */ 57 public INode[] getChildren() { 58 List entries = componentRegistry.findEntries(query); 59 INode[] comps = new INode[entries.size()]; 60 for (int i = 0; i < comps.length; i++) { 61 comps[i] = ((ComponentEntry) entries.get(i)).getComponent(); 62 } 63 return comps; 64 } 65 66 /* (non-Javadoc) 67 * @see net.sf.panoptes.view.configurator.INode#getIconName() 68 */ 69 public String getIconName() { 70 if (iconName != null) return iconName; 71 else return INode.ICON_QUERY_FOLDER; 72 } 73 /*** 74 * Sets the configDescriptor. If this is not set, the default will be used. 75 * @param configDescriptor The configDescriptor to set 76 */ 77 public void setConfigDescriptor(NodeDescriptor configDescriptor) { 78 this.configDescriptor = configDescriptor; 79 } 80 81 /* (non-Javadoc) 82 * @see net.sf.panoptes.view.configurator.INode#acceptsChildren() 83 */ 84 public boolean acceptsChildren() { 85 return false; 86 } 87 88 /*** 89 * @param iconName 90 */ 91 public void setIconName(String iconName) { 92 this.iconName = iconName; 93 } 94 95 }

This page was automatically generated by Maven