Fix paste on illegal component (call the cops)
This commit is contained in:
parent
41cf976bf8
commit
67cf6a69f2
@ -424,13 +424,13 @@ public class RocketActions {
|
|||||||
*/
|
*/
|
||||||
private Pair<RocketComponent, Integer> getPastePosition(RocketComponent srcComponent, RocketComponent destComponent) {
|
private Pair<RocketComponent, Integer> getPastePosition(RocketComponent srcComponent, RocketComponent destComponent) {
|
||||||
if (destComponent == null)
|
if (destComponent == null)
|
||||||
return null;
|
return new Pair<>(null, null);
|
||||||
|
|
||||||
if (srcComponent == null)
|
if (srcComponent == null)
|
||||||
return null;
|
return new Pair<>(null, null);
|
||||||
|
|
||||||
if (destComponent.isCompatible(srcComponent))
|
if (destComponent.isCompatible(srcComponent))
|
||||||
return new Pair<RocketComponent, Integer>(destComponent, destComponent.getChildCount());
|
return new Pair<>(destComponent, destComponent.getChildCount());
|
||||||
|
|
||||||
RocketComponent parent = destComponent.getParent();
|
RocketComponent parent = destComponent.getParent();
|
||||||
return getPastePositionFromParent(srcComponent, destComponent, parent);
|
return getPastePositionFromParent(srcComponent, destComponent, parent);
|
||||||
@ -443,7 +443,7 @@ public class RocketActions {
|
|||||||
return new Pair<>(parent, index);
|
return new Pair<>(parent, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return new Pair<>(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -780,8 +780,14 @@ public class RocketActions {
|
|||||||
pasted.get(i).getComponentName()),
|
pasted.get(i).getComponentName()),
|
||||||
trans.get("RocketActions.PasteAct.invalidPosition.title"), JOptionPane.WARNING_MESSAGE);
|
trans.get("RocketActions.PasteAct.invalidPosition.title"), JOptionPane.WARNING_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
positions.get(i).getU().addChild(pasted.get(i), positions.get(i).getV());
|
RocketComponent parent = positions.get(i).getU();
|
||||||
successfullyPasted.add(pasted.get(i));
|
RocketComponent child = pasted.get(i);
|
||||||
|
if (parent != null && parent.isCompatible(child)) {
|
||||||
|
parent.addChild(child, positions.get(i).getV());
|
||||||
|
successfullyPasted.add(pasted.get(i));
|
||||||
|
} else {
|
||||||
|
log.warn("Pasted component {} is not compatible with {}", child, parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user