@Override
	public void undo() {		
		// Shorthand
		JoeTree tree = parent.getTree();
		OutlineLayoutManager layout = tree.getDocument().panel.layout;

		tree.setSelectedNodesParent(parent);
		
		// Replace Everything
		for (int i = 0, limit = primitives.size(); i < limit; i++) {
			primitives.get(i).undo();
		}

		// Find fallback node for drawing and editing
		if (tree.getSelectedNodes().size() <= 0) {
			Node fallbackNode = ((PrimitiveUndoableReplace) primitives.get(primitives.size() - 1)).getNewNode();
			if (fallbackNode != null) {
				fallbackNode = fallbackNode.next();
				if (fallbackNode.isRoot()) {
					fallbackNode = fallbackNode.prevUnSelectedNode();
					if (fallbackNode.isRoot()) {
						tree.setSelectedNodesParent(tree.getRootNode());
					} else {
						layout.setNodeToDrawFrom(fallbackNode, tree.getVisibleNodes().indexOf(fallbackNode));
						tree.setSelectedNodesParent(fallbackNode.getParent());
						tree.addNodeToSelection(fallbackNode);
					}
				} else {
					tree.setSelectedNodesParent(fallbackNode.getParent());
					tree.addNodeToSelection(fallbackNode);
				}
			}
		}
		
		Node newSelectedNode = determineNewSelectedNode(tree);
		
		tree.setEditingNode(newSelectedNode);
		tree.setCursorPosition(0);
		tree.setCursorMarkPosition(0);
		tree.setComponentFocus(OutlineLayoutManager.ICON);
		
		layout.draw(newSelectedNode, OutlineLayoutManager.ICON);
	}