private static boolean isNullBlockInstance(Long blockID) { if (blockID == null) { return true; } else if (blockID.equals(Block.NULL)) { return true; } else if (Block.getBlock(blockID) == null) { return true; } else if (Block.getBlock(blockID).getBlockID() == null) { return true; } else if (Block.getBlock(blockID).getBlockID().equals(Block.NULL)) { return true; } else if (RenderableBlock.getRenderableBlock(blockID) == null) { return true; } else if (RenderableBlock.getRenderableBlock(blockID).getBlockID() == null) { return true; } else if (RenderableBlock.getRenderableBlock(blockID).getBlockID().equals(Block.NULL)) { return true; } else { return false; } }
public static RenderableBlock makeRenderable( Workspace workspace, BlockNode node, WorkspaceWidget widget) { String genusName = node.getGenusName(); // genusName may not be null RenderableBlock renderable = BlockUtilities.getBlock(workspace, genusName, node.getLabel()); if (renderable == null) { throw new RuntimeException("No children block exists for this genus: " + genusName); } Block block = Block.getBlock(renderable.getBlockID()); // assume not null widget.blockDropped(renderable); for (int i = 0; i < node.getChildren().size(); i++) { BlockConnector socket = block.getSocketAt(i); BlockNode child = node.getChildren().get(i); RenderableBlock childRenderable = makeRenderable(workspace, child, widget); Block childBlock = Block.getBlock(childRenderable.getBlockID()); // link blocks BlockLink link; if (childBlock.hasPlug()) { link = BlockLinkChecker.canLink(workspace, block, childBlock, socket, childBlock.getPlug()); } else if (childBlock.hasBeforeConnector()) { link = BlockLinkChecker.canLink( workspace, block, childBlock, socket, childBlock.getBeforeConnector()); } else { link = null; } // assume link is not null link.connect(); workspace.notifyListeners( new WorkspaceEvent( workspace, RenderableBlock.getRenderableBlock(link.getPlugBlockID()).getParentWidget(), link, WorkspaceEvent.BLOCKS_CONNECTED)); } if (node.getAfterNode() != null) { BlockConnector socket = block.getAfterConnector(); // assume has after connector BlockNode child = node.getAfterNode(); RenderableBlock childRenderable = makeRenderable(workspace, child, widget); Block childBlock = Block.getBlock(childRenderable.getBlockID()); // link blocks BlockLink link; if (childBlock.hasPlug()) { link = BlockLinkChecker.canLink(workspace, block, childBlock, socket, childBlock.getPlug()); } else if (childBlock.hasBeforeConnector()) { link = BlockLinkChecker.canLink( workspace, block, childBlock, socket, childBlock.getBeforeConnector()); } else { link = null; } // assume link is not null link.connect(); workspace.notifyListeners( new WorkspaceEvent( workspace, RenderableBlock.getRenderableBlock(link.getPlugBlockID()).getParentWidget(), link, WorkspaceEvent.BLOCKS_CONNECTED)); } return renderable; }