private void next(mxCell cell, List<String> task) {
    if (cell == null
        || StringUtils.equals(cell.getAttribute(ActivityGraphConverter.GRAPH_TYPE), "UserTask")) {

      return;
    }
    int count = cell.getEdgeCount();
    for (int i = 0; i < count; i++) {
      mxCell edge = (mxCell) cell.getEdgeAt(i);
      mxCell source = (mxCell) edge.getSource();
      mxCell target = (mxCell) edge.getTarget();
      mxCell next = null;
      if (target != null && target.getId().equals(cell.getId())) {
        continue;
      }
      if (target == null) {

        return;
      }
      if (StringUtils.equals(target.getAttribute(ActivityGraphConverter.GRAPH_TYPE), "UserTask")) {
        next(target, task);
      }
      task.add(ActivityGraphConverter.EDITOR_SHAPE_ID_PREFIX + target.getId());
    }
  }
 public void selectNodes(mxCell[] cells) {
   Set<String> lids = new HashSet<String>();
   if (cells != null) {
     for (mxCell cell : cells) {
       lids.add(cell.getId());
     }
   }
   if (hasChanges(lids)) {
     graph.setSelectionCells(cells);
     graph.refresh();
   }
 }
  protected boolean hasChanges(Set<String> cells) {
    // graphSelections is always not null
    Object[] graphSelections = graph.getSelectionCells();

    if (cells == null) {
      return graphSelections.length != 0;
    }
    if (graphSelections.length != cells.size()) {
      return true;
    }

    for (int i = 0; i < graphSelections.length; i++) {
      mxCell graphCell = (mxCell) graphSelections[i];
      if (!cells.contains(graphCell.getId())) {
        return true;
      }
    }
    return false;
  }
  private void getPreNextTask(mxCell cell, List<String> task, boolean next) {
    if (cell == null || cell.isEdge()) return;
    int count = cell.getEdgeCount();
    for (int i = 0; i < count; i++) {
      mxCell edge = (mxCell) cell.getEdgeAt(i);
      mxCell source = (mxCell) edge.getSource();
      mxCell target = (mxCell) edge.getTarget();
      mxCell preNext = null;
      if (next) {
        if (target != null && target.getId().equals(cell.getId())) {
          continue;
        }
        preNext = target;
      } else {
        if (source != null && source.getId().equals(cell.getId())) {
          mxCell sourceParent = (mxCell) source.getParent();
          if (!StringUtils.equals(
              sourceParent.getAttribute(ActivityGraphConverter.GRAPH_TYPE),
              ActivityGraphConverter.GRAPH_SUBPROCESS)) {
            continue;
          }
        }
        preNext = source;
        mxCell sourceParent = (mxCell) source.getParent();
        if (source != null
            && StringUtils.equals(
                source.getAttribute(ActivityGraphConverter.GRAPH_TYPE), "startEvent")
            && StringUtils.equals(
                sourceParent.getAttribute(ActivityGraphConverter.GRAPH_TYPE),
                ActivityGraphConverter.GRAPH_SUBPROCESS)) {
          preNext = sourceParent;
        }

        if (source == null
            && StringUtils.equals(
                cell.getAttribute(ActivityGraphConverter.GRAPH_TYPE), "startEvent")) {
          preNext = (mxCell) cell.getParent();
        }
      }
      if (preNext == null) return;

      //
      // if(StringUtils.equals(preNext.getAttribute(ActivityGraphConverter.GRAPH_TYPE),ActivityGraphConverter.GRAPH_SUBPROCESS)){
      //                int childCount=cell.getChildCount();
      //                for(int j=0;j<childCount;j++){
      //                    mxCell child=(mxCell)cell.getChildAt(j);
      //                    getPreNextTask(child,task,next);
      //                }
      //            }

      if (StringUtils.equals(
              preNext.getAttribute(ActivityGraphConverter.GRAPH_TYPE),
              ActivityGraphConverter.GRAPH_GATEWAY)
          || StringUtils.equals(
              preNext.getAttribute(ActivityGraphConverter.GRAPH_TYPE),
              ActivityGraphConverter.GRAPH_SUBPROCESS)) {
        getPreNextTask(preNext, task, next);
      } else {
        task.add(ActivityGraphConverter.EDITOR_SHAPE_ID_PREFIX + preNext.getId());
      }
    }
  }