public IPart calcChildNavigation(
     IBranchPart branch, IBranchPart sourceChild, String navReqType, boolean sequential) {
   if (GEF.REQ_NAV_LEFT.equals(navReqType)) {
     Column2 row = getColumn(branch);
     Cell2 cell = row.findCellByItem(sourceChild);
     if (cell != null) {
       Cell2 prev = row.getPreviousCell(cell);
       if (prev == null) {
         if (!sequential) return branch.getTopicPart();
       }
     }
   } else if (GEF.REQ_NAV_UP.equals(navReqType)) {
     Column2 row = getColumn(branch);
     Item2 item = row.findItem(sourceChild);
     if (item != null) {
       Item2 prev = item.getPreviousItem();
       if (prev != null) return prev.getBranch().getTopicPart();
     }
   } else if (GEF.REQ_NAV_DOWN.equals(navReqType)) {
     Column2 row = getColumn(branch);
     Item2 item = row.findItem(sourceChild);
     if (item != null) {
       Item2 next = item.getNextItem();
       if (next != null) return next.getBranch().getTopicPart();
     }
   }
   return super.calcChildNavigation(branch, sourceChild, navReqType, sequential);
 }
 public void decorateCreateRequest(IBranchPart branch, IBranchPart sourceChild, Request request) {
   Column2 col = getColumn(branch);
   Cell2 cell = col.findCellByItem(sourceChild);
   if (cell != null) {
     RowHead rowHead = cell.getOwnedRow().getHead();
     request.setParameter(
         MindMapUI.PARAM_PROPERTY_PREFIX + Core.Labels, new HashSet<String>(rowHead.getLabels()));
   }
 }
  protected Point calcMovePosition(IBranchPart branch, IBranchPart child, ParentSearchKey key) {
    List<Integer> disables = getDisableBranches(branch);

    int index = calcInsIndex(branch, key, true);
    int oldIndex = getOldIndex(branch, child);
    IInsertion insertion = calcInsertion(branch, key);
    int itemIndex = insertion == null ? -1 : insertion.getIndex();
    if (disables != null) {
      if (disables.contains(index)) {
        oldIndex = index;
      } else if (disables.contains(index - 1) && itemIndex != 0) {
        index--;
        oldIndex = index;
        itemIndex--;
      }
    }

    Column2 col = getColumn(branch);
    Cell2 cell = col.findCell(key.getCursorPos());
    List<Item2> items = cell.getItems();

    Dimension inventSize = key.getInvent().getSize();
    Dimension insSize = key.getFigure().getSize();

    if (items.isEmpty())
      return new Point(
          getFigureLocation(branch.getFigure()).x,
          cell.getY()
              + (insSize.height < cell.getHeight() ? insSize.height / 2 : cell.getHeight() / 2));

    if (index == oldIndex
        || (index == -1 && !items.get(items.size() - 1).getBranch().getFigure().isEnabled())) {
      IBranchPart sub =
          items.get(itemIndex == items.size() ? items.size() - 1 : itemIndex).getBranch();
      if (cell.equals(col.findCellByItem(sub)))
        return getFigureLocation(sub.getFigure())
            .getTranslated(
                (inventSize.width - sub.getTopicPart().getFigure().getSize().width) / 2, 0);
    }

    return calcInsertPosition(branch, child, key);
  }
  protected int getOldIndex(IBranchPart branch, IBranchPart child) {
    Column2 col = getColumn(branch);

    if (branch.equals(child.getParentBranch())) {
      Cell2 cell = col.findCellByItem(child);
      int count = 0;
      for (int i = 0; i < col.getCells().indexOf(cell); i++)
        count += col.getCells().get(i).getItems().size();
      Item2 item = col.findItem(child);
      return count + cell.getItems().indexOf(item);
    } else {
      int index = 0;
      for (Cell2 cell : col.getCells()) {
        for (Item2 item : cell.getItems()) {
          if (!item.getBranch().getFigure().isEnabled()) return index;
          index++;
        }
      }
    }

    return -1;
  }