|
@@ -226,19 +226,16 @@ public class Controller {
|
|
|
public void deleteSmartDevice(SmartDevice toDelete) {
|
|
|
if (toDelete == null)
|
|
|
return;
|
|
|
- // Remove from Links
|
|
|
- for (Link link : toDelete.getLinks())
|
|
|
- removeSmartDeviceFromLink(toDelete, link);
|
|
|
- // Remove Links from Device
|
|
|
- toDelete.getLinks().clear();
|
|
|
|
|
|
// Delete Connections
|
|
|
for (Port p : toDelete.getPorts()) {
|
|
|
//Skip ports that are not connected
|
|
|
if(p.getConnection()==null)continue;
|
|
|
+ this.removeDeviceFromConnection(p, p.getConnection());
|
|
|
+
|
|
|
/**
|
|
|
* Connection of the current port
|
|
|
- */
|
|
|
+ *
|
|
|
Connection c = p.getConnection();
|
|
|
|
|
|
//remove from protocol
|
|
@@ -253,8 +250,17 @@ public class Controller {
|
|
|
if (sd != null && sd != p)
|
|
|
sd.getOwner().removePort(sd);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
+
|
|
|
+ // Remove from Links
|
|
|
+ LinkedList<Link> links = new LinkedList<Link>(toDelete.getLinks());
|
|
|
+ for (Link link : links)
|
|
|
+ removeSmartDeviceFromLink(toDelete, link);
|
|
|
+ links.clear();
|
|
|
+ // Remove Links from Device
|
|
|
+ toDelete.getLinks().clear();
|
|
|
+
|
|
|
//Remove all ports from the device
|
|
|
toDelete.getPorts().clear();
|
|
|
model.getDevices().remove(toDelete);
|