Changeset 7485
- Timestamp:
- 05/06/08 09:03:42 (5 years ago)
- Location:
- ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/wavedev
- Files:
-
- 4 modified
-
Component.java (modified) (6 diffs)
-
Node.java (modified) (1 diff)
-
Platform.java (modified) (1 diff)
-
PyWrapper.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/wavedev/Component.java
r7482 r7485 1 1 package edu.vt.ossie.wavedev; 2 2 3 import org.python.core.PyException; 3 4 import org.python.core.PyList; 4 5 import org.python.core.PyObject; … … 35 36 public PyList getChildren() 36 37 { 37 return getPorts(); 38 return isDevice() 39 ? getAssignedComponents() 40 : getPorts(); 41 } 42 43 44 // ---------------------------------------------------------- 45 @Override 46 public boolean allowChildrenToExpand() 47 { 48 // Don't let components allocated to a device be expandable 49 return isDevice() 50 ? false 51 : super.allowChildrenToExpand(); 38 52 } 39 53 … … 44 58 // Should this check to see if "device" is found in the type? 45 59 return !"resource".equals(getType()); 60 } 61 62 63 // ---------------------------------------------------------- 64 public void assignToDevice(Component device) 65 { 66 System.out.println( 67 "assignToDevice: " + this + "(" + isDevice() + ") -> " + device); 68 if (!isDevice()) 69 { 70 // First, remove from old device 71 Component oldDevice = getDevice(); 72 if (oldDevice != null) 73 { 74 try 75 { 76 oldDevice.getAssignedComponents().remove(pyObject()); 77 } 78 catch (PyException e) 79 { 80 // object was not in list 81 } 82 } 83 84 // Now add to new device 85 setDevice(device); 86 setNode(device.getNode()); 87 device.getAssignedComponents().append(pyObject()); 88 } 89 } 90 91 92 // ---------------------------------------------------------- 93 public PyList getAssignedComponents() 94 { 95 if (!hasAttribute(ASSIGNED_COMPONENTS)) 96 { 97 setAssignedComponents(new PyList()); 98 } 99 return getList(ASSIGNED_COMPONENTS); 100 } 101 102 103 // ---------------------------------------------------------- 104 public void setAssignedComponents(PyList components) 105 { 106 put(ASSIGNED_COMPONENTS, components); 46 107 } 47 108 … … 131 192 public void setDevice(Component device) 132 193 { 133 put(DEVICE, device .pyObject());194 put(DEVICE, device); 134 195 } 135 196 … … 145 206 public void setNode(Node node) 146 207 { 147 put(NODE, node .pyObject());208 put(NODE, node); 148 209 } 149 210 … … 237 298 private static final String UUID = "uuid"; 238 299 239 240 // self.uuid = uuidgen() 300 private static final String ASSIGNED_COMPONENTS = "xAssignedComponents"; 301 241 302 // self.file_uuid = uuidgen() 242 303 // self.ace = False -
ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/wavedev/Node.java
r7482 r7485 73 73 74 74 // ---------------------------------------------------------- 75 public void EnsureDevicesAreParented() 76 { 77 for (Component c : getDevicesAsArray()) 78 { 79 c.setNode(this); 80 } 81 } 82 83 84 // ---------------------------------------------------------- 75 85 public void addNewDevice(Component template, Component after) 76 86 { 87 Component copy = (Component)factory().wrap(template.deepcopy()); 88 copy.setNode(this); 77 89 addAfter( 78 90 getDevices(), 79 template.deepcopy(),91 copy.pyObject(), 80 92 (after == null) 81 93 ? null -
ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/wavedev/Platform.java
r7482 r7485 62 62 public void addNewNode(Node template, Node after) 63 63 { 64 Node copy = (Node)factory().wrap(template.deepcopy()); 65 copy.EnsureDevicesAreParented(); 64 66 addAfter( 65 67 getNodes(), 66 template.deepcopy(),68 copy.pyObject(), 67 69 (after == null) 68 70 ? null -
ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/wavedev/PyWrapper.java
r7482 r7485 211 211 * @param value The new value for the attribute 212 212 */ 213 public void put(String attribute, PyWrapper value) 214 { 215 try 216 { 217 pyObject().__setattr__(attribute, 218 value == null ? Py.None : value.pyObject()); 219 } 220 catch (Exception e) 221 { 222 e.printStackTrace(); 223 } 224 } 225 226 227 // ---------------------------------------------------------- 228 /** 229 * Set an attribute in the object. 230 * @param attribute The name of the attribute to set 231 * @param value The new value for the attribute 232 */ 213 233 public void put(String attribute, PyObject value) 214 234 { 215 235 try 216 236 { 217 pyObject().__setattr__(attribute, value );237 pyObject().__setattr__(attribute, value == null ? Py.None : value); 218 238 } 219 239 catch (Exception e)