Extend removal mechanism for all wires.

This commit is contained in:
Sergio Martínez Portela 2020-06-01 16:49:38 +02:00
parent 8b3bbfee78
commit af9352de42
5 changed files with 28 additions and 11 deletions

View File

@ -368,9 +368,7 @@ public class CanvasView extends View implements PartGrid {
List<OutputConnector> outputConnectors = part.getOutputConnectors(); List<OutputConnector> outputConnectors = part.getOutputConnectors();
if (outputConnectors != null) { if (outputConnectors != null) {
for (OutputConnector outputConnector : outputConnectors) { for (OutputConnector outputConnector : outputConnectors) {
if (outputConnector instanceof SignalRoundOutputConnector) { List<SignalWire> wires = outputConnector.getWires();
SignalRoundOutputConnector conn = (SignalRoundOutputConnector) outputConnector;
List<SignalWire> wires = conn.getWires();
if (wires == null) { if (wires == null) {
continue; continue;
} }
@ -383,7 +381,6 @@ public class CanvasView extends View implements PartGrid {
} }
} }
} }
}
return null; return null;
} }

View File

@ -97,6 +97,7 @@ public class AnyRoundOutputConnector implements Drawable, AnyOutputConnector,
@Override @Override
public void unlinkWire(AnyWire wire) { public void unlinkWire(AnyWire wire) {
_wires.remove(wire); _wires.remove(wire);
_connections.remove(wire.getAttachedTo());
} }
@Override @Override
@ -162,6 +163,11 @@ public class AnyRoundOutputConnector implements Drawable, AnyOutputConnector,
return _part.query(lastValue); return _part.query(lastValue);
} }
@Override
public List<AnyWire> getWires() {
return _wires;
}
public int getX() { public int getX() {
return _centerX; return _centerX;
} }

View File

@ -96,6 +96,7 @@ public class BooleanRoundOutputConnector implements Drawable, BooleanOutputConne
@Override @Override
public void unlinkWire(BooleanWire wire) { public void unlinkWire(BooleanWire wire) {
_wires.remove(wire); _wires.remove(wire);
_connections.remove(wire.getAttachedTo());
} }
@Override @Override
@ -160,4 +161,9 @@ public class BooleanRoundOutputConnector implements Drawable, BooleanOutputConne
public Object query(Object lastValue) { public Object query(Object lastValue) {
return _part.query(lastValue); return _part.query(lastValue);
} }
@Override
public List<BooleanWire> getWires() {
return _wires;
}
} }

View File

@ -96,6 +96,7 @@ public class StringRoundOutputConnector implements Drawable, StringOutputConnect
@Override @Override
public void unlinkWire(StringWire wire) { public void unlinkWire(StringWire wire) {
_wires.remove(wire); _wires.remove(wire);
_connections.remove(wire.getAttachedTo());
} }
@Override @Override
@ -160,4 +161,9 @@ public class StringRoundOutputConnector implements Drawable, StringOutputConnect
public Object query(Object lastValue) { public Object query(Object lastValue) {
return _part.query(lastValue); return _part.query(lastValue);
} }
@Override
public List<StringWire> getWires() {
return _wires;
}
} }

View File

@ -25,4 +25,6 @@ public interface OutputConnector<T extends WireDataType,
void send(T data); void send(T data);
Object query(Object lastValue); Object query(Object lastValue);
List<T2> getWires();
} }