spot = SwingUtilities.convertPoint(
this.blockCanvas.getCanvas(),
this.focusManager.getCanvasPoint(),
widget.getJComponent());
} else {
RenderableBlock focusRenderable = workspace.getEnv().getRenderableBlock(focusManager.getFocusBlockID());
widget = focusRenderable.getParentWidget();
spot = focusRenderable.getLocation();
}
if (widget == null) {
// TODO: To be examined and fixed, occurs on macs
JOptionPane.showMessageDialog(frame, "Please click somewhere on the canvas first.",
"Error", JOptionPane.PLAIN_MESSAGE);
//throw new RuntimeException("Why are we adding a block to a null widget?");
} else {
// checks to see if the copied block still exists
if (BlockUtilities.blockExists(workspace, node)) {
//create mirror block and mirror childrens
spot.translate(10, 10);
RenderableBlock mirror = BlockUtilities.makeRenderable(workspace, node, widget);
mirror.setLocation(spot);
mirror.moveConnectedBlocks(); // make sure the childrens are placed correctly
} else {
//TODO: future version, allow them to paste
JOptionPane.showMessageDialog(frame, "You cannot paste blocks that are currently NOT on the canvas."
+ "\nThis function will be available in a future version.\n", "Error", JOptionPane.PLAIN_MESSAGE);
}