private boolean processor(List ori, List newList, List nullLevelHandle, boolean doChange)
      throws SemanticException {
    boolean isLevelRemoved = false;
    for (int i = nullLevelHandle.size() - 1; i >= 0; i--) {
      int index = ((Integer) nullLevelHandle.get(i)).intValue();
      if (doChange) {
        viewHandle.removeLevel(index);
      }
      isLevelRemoved = true;
    }

    for (int i = 0; i < ori.size(); i++) {
      LevelHandle tempHandle = (LevelHandle) ori.get(i);
      if (!newList.contains(tempHandle)) {
        if (doChange) {
          viewHandle.removeLevel(tempHandle.getQualifiedName());
        }
        isLevelRemoved = true;
      }
    }

    Collections.sort(newList, new LevelComparator());
    if (doChange) {
      for (int i = 0; i < newList.size(); i++) {
        LevelHandle tempHandle = (LevelHandle) newList.get(i);
        if (viewHandle.getLevel(tempHandle.getQualifiedName()) == null) {
          insertLevelHandle(tempHandle, i);
        }
      }
    }
    return isLevelRemoved;
  }
 protected List getChildrenList(Object parent) {
   if (parent instanceof TabularDimensionHandle) {
     List children = new ArrayList();
     try {
       TabularDimensionHandle handle = (TabularDimensionHandle) parent;
       CrosstabReportItemHandle xtabHandle = getCrosstabReportItemHandle();
       for (int i = 0; i < xtabHandle.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE); i++) {
         DimensionViewHandle dimensionHandle =
             xtabHandle.getDimension(ICrosstabConstants.ROW_AXIS_TYPE, i);
         if (dimensionHandle.getCubeDimension().equals(handle))
           children.add(dimensionHandle.getLevel(0).getCubeLevel());
       }
       for (int i = 0;
           i < xtabHandle.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE);
           i++) {
         DimensionViewHandle dimensionHandle =
             xtabHandle.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE, i);
         if (dimensionHandle.getCubeDimension().equals(handle))
           children.add(dimensionHandle.getLevel(0).getCubeLevel());
       }
     } catch (ExtendedElementException e) {
     }
     return children;
   } else if (parent instanceof LevelHandle) {
     List children = new ArrayList();
     LevelHandle levelHandle = (LevelHandle) parent;
     try {
       CrosstabReportItemHandle xtabHandle = getCrosstabReportItemHandle();
       for (int i = 0; i < xtabHandle.getDimensionCount(ICrosstabConstants.ROW_AXIS_TYPE); i++) {
         DimensionViewHandle dimensionHandle =
             xtabHandle.getDimension(ICrosstabConstants.ROW_AXIS_TYPE, i);
         LevelViewHandle levelViewHandle =
             dimensionHandle.getLevel(levelHandle.getQualifiedName());
         if (levelViewHandle != null)
           if (dimensionHandle.getLevelCount() > levelViewHandle.getIndex() + 1)
             children.add(dimensionHandle.getLevel(levelViewHandle.getIndex() + 1).getCubeLevel());
       }
       for (int i = 0;
           i < xtabHandle.getDimensionCount(ICrosstabConstants.COLUMN_AXIS_TYPE);
           i++) {
         DimensionViewHandle dimensionHandle =
             xtabHandle.getDimension(ICrosstabConstants.COLUMN_AXIS_TYPE, i);
         LevelViewHandle levelViewHandle =
             dimensionHandle.getLevel(levelHandle.getQualifiedName());
         if (levelViewHandle != null)
           if (dimensionHandle.getLevelCount() > levelViewHandle.getIndex() + 1)
             children.add(dimensionHandle.getLevel(levelViewHandle.getIndex() + 1).getCubeLevel());
       }
     } catch (ExtendedElementException e) {
     }
     return children;
   }
   return super.getChildrenList(parent);
 }
  private void insertLevelHandle(LevelHandle levelHandle, int pos) throws SemanticException {

    CrosstabReportItemHandle reportHandle = viewHandle.getCrosstab();
    // int viewCount = viewHandle.getLevelCount( );

    DataItemHandle dataHandle =
        CrosstabAdaptUtil.createColumnBindingAndDataItem(
            (ExtendedItemHandle) reportHandle.getModelHandle(), levelHandle);

    LevelViewHandle levelViewHandle = viewHandle.insertLevel(levelHandle, pos);
    CrosstabCellHandle cellHandle = levelViewHandle.getCell();

    cellHandle.addContent(dataHandle);

    ActionHandle actionHandle = levelHandle.getActionHandle();
    if (actionHandle != null) {
      List source = new ArrayList();
      source.add(actionHandle.getStructure());
      List newAction = ModelUtil.cloneStructList(source);
      dataHandle.setAction((Action) newAction.get(0));
    }

    CrosstabUtil.addLabelToHeader(levelViewHandle);
  }
 public int compare(Object o1, Object o2) {
   LevelHandle handle1 = (LevelHandle) o1;
   LevelHandle handle2 = (LevelHandle) o2;
   return handle1.getIndex() - handle2.getIndex();
 }