public void add(ActionPair pair) {
        XmlAction dcDo = Tools.deepCopy(pair.getDoAction());
        XmlAction dcUndo = Tools.deepCopy(pair.getUndoAction());
        long currentTime = System.currentTimeMillis();
        if ((actionPairList.size() > 0)
                && (actionFrameStarted || currentTime - timeOfLastAdd < TIME_TO_BEGIN_NEW_ACTION)) {
            // the actions are gathered in one compound action.
            ActionPair firstPair = (ActionPair) actionPairList.get(0);
            CompoundAction action;
            CompoundAction remedia;
            if (!(firstPair.getDoAction() instanceof CompoundAction)
                    || !(firstPair.getUndoAction() instanceof CompoundAction)) {
                action = new CompoundAction();
                action.addChoice(firstPair.getDoAction());
                remedia = new CompoundAction();
                remedia.addChoice(firstPair.getUndoAction());
                actionPairList.remove(0);
                actionPairList.add(0, new ActionPair(action, remedia));
                firstPair = (ActionPair) actionPairList.get(0);
            } else {
                action = (CompoundAction) firstPair.getDoAction();
                remedia = (CompoundAction) firstPair.getUndoAction();
            }
            action.addChoice(dcDo);
            remedia.addAtChoice(0, dcUndo);
        } else {
            ActionPair storagePair = new ActionPair(dcDo, dcUndo);
            actionPairList.add(0, storagePair);
            // and cut vector, if bigger than given size:
            int maxEntries = 100;
            try {
                maxEntries = new Integer(controller.getFrame().getProperty(
                        "undo_levels")).intValue();
            } catch (NumberFormatException e) {
                freemind.main.Resources.getInstance().logException(e);
            }
            while (actionPairList.size() > maxEntries) {
                actionPairList.remove(actionPairList.size() - 1); // remove
                // last elt
            }
        }
        startActionFrame();
        timeOfLastAdd = currentTime;
    }