/**
  * Performs the node-move-actions (invokes methods of the manager...)
  *
  * @param event
  * @return returns true, if move was successfull
  */
 private boolean movePage(final MoveTreeNodeEvent event) {
   final CPManager cpMgm = CPManager.getInstance();
   final String movedNodeId = event.getNodeId();
   cpMgm.moveElement(cp, movedNodeId, event.getNewParentNodeId(), event.getPosition());
   cpMgm.writeToFile(cp);
   selectTreeNodeById(movedNodeId);
   return true;
 }
  /** Event-handling from controllers */
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == cmc) {
      if (event.equals(CloseableModalController.CLOSE_MODAL_EVENT)) {
        removeAsListenerAndDispose(cmc);
        cmc = null;
        removeAsListenerAndDispose(uploadCtr);
        uploadCtr = null;
      }
    } else if (source == uploadCtr) {
      if (event instanceof NewCPPageEvent) {
        // TODO:GW Is it necessary to set component dirty?
        // getInitialComponent().setDirty(true);
        fireEvent(ureq, event);
      }
      // Dispose the cmc and the podcastFormCtr.
      cmc.deactivate();
      removeAsListenerAndDispose(cmc);
      cmc = null;
      removeAsListenerAndDispose(uploadCtr);
      uploadCtr = null;
    } else if (source == treeCtr) {
      // event from extJSTree (TreeController)
      if (event instanceof MoveTreeNodeEvent) {
        /** move * */
        final MoveTreeNodeEvent moveEvent = (MoveTreeNodeEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(moveEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        final MoveTreeNodeEvent newmoveEvent =
            new MoveTreeNodeEvent(
                treeModel.getIdentifierForNodeID(moveEvent.getNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getOldParentNodeId()),
                treeModel.getIdentifierForNodeID(moveEvent.getNewParentNodeId()),
                moveEvent.getPosition());

        final boolean success = movePage(newmoveEvent);
        // setResult is important. If sucess is not true, the ajax tree will
        // popup a dialog with error-msg
        moveEvent.setResult(success, "Error", "Error while moving node");

      } else if (event instanceof TreeNodeClickedEvent) {
        /** click * */
        TreeNodeClickedEvent clickedEvent = (TreeNodeClickedEvent) event;
        final String selectedNodeID = treeModel.getIdentifierForNodeID(clickedEvent.getNodeId());

        currentPage = new CPPage(selectedNodeID, cp);

        clickedEvent = new TreeNodeClickedEvent(currentPage.getIdentifier());
        fireEvent(ureq, clickedEvent);
      } else if (event instanceof TreeNodeModifiedEvent) {
        /** a node (name) has been modified * */
        fireEvent(ureq, event);
      }
    } else if (source == dialogCtr) {
      // event from dialog (really-delete-dialog)
      if (event != Event.CANCELLED_EVENT) {
        final int position = DialogBoxUIFactory.getButtonPos(event);

        // 0 = delete with resource
        // 1 = delete without resource
        // 2 = cancel
        if (position == 0 || position == 1) {
          boolean deleteResource = false;
          if (position == 0) {
            // Delete element including files
            deleteResource = true;
          }
          final String parentIdentifier = getParentIdentifier();

          // finally delete the page
          deletePage(currentPage.getIdentifier(), deleteResource);

          if (parentIdentifier != null) {
            contentCtr.displayPage(ureq, parentIdentifier);
          }
        } else {
          // Cancel dialog and close window.
        }
      }
    }
  }