private List<INode> getSelectedNodes() {
    List<SelectionItem> selections =
        mEditor.getCanvasControl().getSelectionManager().getSelections();
    List<INode> nodes = new ArrayList<INode>(selections.size());
    for (SelectionItem item : selections) {
      nodes.add(item.getNode());
    }

    return nodes;
  }
  /** Updates the layout contents based on the current selection */
  void updateSelection() {
    NodeProxy parent = null;
    LayoutCanvas canvas = mEditor.getCanvasControl();
    SelectionManager selectionManager = canvas.getSelectionManager();
    List<SelectionItem> selections = selectionManager.getSelections();
    if (selections.size() > 0) {
      // TODO: better handle multi-selection -- maybe we should disable it or
      // something.
      // What if you select children with different parents? Of different types?
      // etc.
      NodeProxy node = selections.get(0).getNode();
      if (node != null && node.getParent() != null) {
        parent = (NodeProxy) node.getParent();
      }
    }

    if (parent == null) {
      // Show the background's properties
      CanvasViewInfo root = canvas.getViewHierarchy().getRoot();
      if (root == null) {
        return;
      }
      parent = canvas.getNodeFactory().create(root);
      selections = Collections.emptyList();
    }

    RulesEngine engine = mEditor.getRulesEngine();
    List<NodeProxy> selectedNodes = new ArrayList<NodeProxy>();
    for (SelectionItem item : selections) {
      selectedNodes.add(item.getNode());
    }
    List<RuleAction> actions = new ArrayList<RuleAction>();
    engine.callAddLayoutActions(actions, parent, selectedNodes);

    // Place actions in the correct order (the actions may come from different
    // rules and should be merged properly via sorting keys)
    Collections.sort(actions);

    // Add in actions for the child as well, if there is exactly one.
    // These are not merged into the parent list of actions; they are appended
    // at the end.
    int index = -1;
    String label = null;
    if (selectedNodes.size() == 1) {
      List<RuleAction> itemActions = new ArrayList<RuleAction>();
      NodeProxy selectedNode = selectedNodes.get(0);
      engine.callAddLayoutActions(itemActions, selectedNode, null);
      if (itemActions.size() > 0) {
        Collections.sort(itemActions);

        if (!(itemActions.get(0) instanceof RuleAction.Separator)) {
          actions.add(RuleAction.createSeparator(0));
        }
        label = selectedNode.getStringAttr(ANDROID_URI, ATTR_ID);
        if (label != null) {
          label = BaseViewRule.stripIdPrefix(label);
          index = actions.size();
        }
        actions.addAll(itemActions);
      }
    }

    if (!updateActions(actions)) {
      updateToolbar(actions, index, label);
    }
    mPrevActions = actions;
  }