View Javadoc
1 /* 2 * Created on 07.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.ArrayList; 10 11 import org.eclipse.swt.graphics.Image; 12 13 import net.sf.panoptes.model.component.Component; 14 import net.sf.panoptes.model.component.registry.ComponentName; 15 import net.sf.panoptes.model.component.registry.ComponentNotFoundException; 16 import net.sf.panoptes.model.component.registry.ComponentRegistry; 17 18 /*** 19 * Instances of this class are placeholders or "shortcuts" for other components. They 20 * are used to enable a single component to be displayed and manipulated in several 21 * places in the hierarchy at the same time. 22 * 23 * @author dag@liodden.no 24 * @see net.sf.panoptes.model.component.IComponent 25 * @see net.sf.panoptes.model.node.Node 26 * @version 0.1 27 * 28 */ 29 public class SymLinkNode extends Node { 30 31 private ComponentName componentName; 32 private ComponentRegistry componentRegistry; 33 private NodeDescriptor configDescriptor = null; 34 private Image icon = null; 35 private ArrayList configuratorScripts = new ArrayList(); 36 37 /*** 38 * Creates a new instance. 39 * 40 * @param componentRegistry the registry in which the component this instance is placeholder for lives 41 * @param componentName the <code>ComponentName</code> of the component 42 */ 43 public SymLinkNode(ComponentRegistry componentRegistry, ComponentName componentName) { 44 this.componentRegistry = componentRegistry; 45 this.componentName = componentName; 46 } 47 48 public NodeDescriptor getConfigDescriptor() { 49 if (configDescriptor != null) 50 return configDescriptor; 51 else 52 try { 53 return componentRegistry.get(componentName).getComponent().getConfigDescriptor(); 54 } catch (ComponentNotFoundException e) { 55 return new NodeDescriptor( 56 "(" + componentName.toString() + ")", 57 "Placeholder for " + componentName.toString() + " which isnt' registered at the moment."); 58 } 59 } 60 61 public Node[] getChildren() { 62 try { 63 return componentRegistry.get(componentName).getComponent().getChildren(); 64 } catch (ComponentNotFoundException e) { 65 return new Component[0]; 66 } 67 } 68 69 public Image getIcon() { 70 if (icon != null) return icon; 71 else 72 try { 73 return componentRegistry.get(componentName).getComponent().getIcon(); 74 } catch (ComponentNotFoundException e) { 75 return Node.ICON_BROKEN_LINK; 76 } 77 } 78 79 public void setIcon(Image icon) { 80 this.icon = icon; 81 } 82 83 public Component dereference() throws ComponentNotFoundException { 84 return (Component) componentRegistry.get(componentName).getComponent(); 85 } 86 87 /* (non-Javadoc) 88 * @see net.sf.panoptes.view.configurator.Node#acceptsChildren() 89 */ 90 public boolean acceptsChildren() { 91 return false; 92 } 93 94 /*** 95 * @param descriptor 96 */ 97 public void setConfigDescriptor(NodeDescriptor configDescriptor) { 98 this.configDescriptor = configDescriptor; 99 } 100 101 public void addConfiguratorScript(String script) { 102 configuratorScripts.add(script); 103 } 104 105 /* (non-Javadoc) 106 * @see net.sf.panoptes.model.node.Node#getConfiguratorScripts() 107 */ 108 public String[] getConfiguratorScripts() { 109 return (String[]) configuratorScripts.toArray(new String[configuratorScripts.size()]); 110 } 111 112 }

This page was automatically generated by Maven