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.component; 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.node.Node; 14 import net.sf.panoptes.model.node.NodeDescriptor; 15 16 import org.eclipse.swt.graphics.Image; 17 18 /*** 19 * Represents a component query node which will list the query results 20 * as it's children. 21 * 22 * @see net.sf.panoptes.model.component.IComponent 23 * @see net.sf.panoptes.model.component.registry.ComponentName 24 * @see net.sf.panoptes.model.node.Node 25 * @author Dag Liodden 26 * 27 */ 28 public class ComponentQuery extends Component { 29 30 private ComponentName query = null; 31 32 /*** 33 * Allow multiple queries with the same query pattern in the registry 34 */ 35 private static int nextId = 1; 36 37 private Image icon; 38 private NodeDescriptor configDescriptor; 39 private int id = nextId++; 40 41 /*** 42 * Constructs a new object which will query a registry for components. 43 * 44 * @param componentRegistry the registry to query 45 * @param query the query 46 */ 47 public ComponentQuery() { 48 } 49 50 public void setQuery(ComponentName query) { 51 this.query = query; 52 } 53 54 public void init() { 55 56 } 57 58 /* (non-Javadoc) 59 * @see net.sf.panoptes.view.configurator.Node#getConfigDescriptor() 60 */ 61 public NodeDescriptor getConfigDescriptor() { 62 if (configDescriptor != null) return configDescriptor; 63 else return new NodeDescriptor(query.toString(), "Group of components in query " + query.toString()); 64 } 65 66 /* (non-Javadoc) 67 * @see net.sf.panoptes.view.configurator.Node#getChildren() 68 */ 69 public Node[] getChildren() { 70 List entries = getComponentRegistry().findEntries(query); 71 Component[] comps = new Component[entries.size()]; 72 for (int i = 0; i < comps.length; i++) { 73 comps[i] = ((ComponentEntry) entries.get(i)).getComponent(); 74 } 75 return comps; 76 } 77 78 /* (non-Javadoc) 79 * @see net.sf.panoptes.view.configurator.Node#getIconName() 80 */ 81 public Image getIcon() { 82 if (icon != null) return icon; 83 else return Node.ICON_QUERY_FOLDER; 84 } 85 /*** 86 * Sets the configDescriptor. If this is not set, the default will be used. 87 * @param configDescriptor The configDescriptor to set 88 */ 89 public void setConfigDescriptor(NodeDescriptor configDescriptor) { 90 this.configDescriptor = configDescriptor; 91 } 92 93 /* (non-Javadoc) 94 * @see net.sf.panoptes.view.configurator.Node#acceptsChildren() 95 */ 96 public boolean acceptsChildren() { 97 return false; 98 } 99 100 public void setIcon(Image icon) { 101 this.icon = icon; 102 } 103 104 /* (non-Javadoc) 105 * @see net.sf.panoptes.model.node.Node#getConfiguratorScripts() 106 */ 107 public String[] getConfiguratorScripts() { 108 // TODO Auto-generated method stub 109 return null; 110 } 111 112 /*** 113 * @return 114 */ 115 public ComponentName getQuery() { 116 return query; 117 } 118 119 /*** 120 * @return 121 */ 122 public int getId() { 123 return id; 124 } 125 126 }

This page was automatically generated by Maven