AdfRichUIPeer.createPeerClass(AdfRichUIPeer, "AdfDhtmlPanelCollectionPeer", false);
AdfDhtmlPanelCollectionPeer.InitSubclass = function() {
  this._AUTO_HEIGHT_TOP_ID = "_ahTp";
  this._AUTO_HEIGHT_BOTTOM_ID = "_ahBt";
  this._AUTO_HEIGHT_CENTER_ID = "_ahCt";
  this._AGGREGATED_CHILD_ID = "_afrAC";
  this._HIDDEN_COL_COUNT = "_afrHCC";
  this._COLUMN_CONTEXT_MENU_ID = "_clmCxt";
  this._TOOLBAR_SPACER_ID = "_tbrSpr";
  this._FREEZE_MENUITEM_ID = "_frzMn";
  this._UNFREEZE_MENUITEM_ID = "_ufzMn";
  this._FREEZE_TOOLBARITEM_ID = "_frzTbr";
  this._DETACH_MENUITEM_ID = "_dchMn";
  this._DETACH_TOOLBARITEM_ID = "_dchTbr";
  this._SORT_ASCENDING_MENUITEM_ID = "_srtAsc";
  this._SORT_DESCENDING_MENUITEM_ID = "_srtDsc";
  this._SORT_ADVANCED_MENUITEM_ID = "_srtAvd";
  this._REORDER_MENUITEM_ID = "_rdrMn";
  this._RESIZECOLUMN_MENUITEM_ID = "_rszClm";
  this._QBE_TOOLBARITEM_ID = "_qbeTbr";
  this._QBE_MENUITEM_ID = "_qbeMn";
  this._WRAP_MENUITEM_ID = "_wrpMn";
  this._WRAP_TOOLBARITEM_ID = "_wrpTbr";
  this._VIEW_MENU_ID = "_vw";
  this._COLUMNS_MENU_ID = "_clmns";
  this._COLUMNS_SHOWALL_MENUITEM_ID = "_shwAll";
  this._COLUMNS_SHOWCOLUMN_MENUITEM_ID = "_shwClm";
  this._COLUMNS_SHOWMORE_MENUITEM_ID = "_shwMr";
  this._ROWS_SELECTED_TEXT_ID = "_rwSctT";
  this._ROWS_SELECTED_COUNT_ID = "_rwSctC";
  this._COLUMNS_HIDDEN_TEXT_ID = "_clmHdnT";
  this._COLUMNS_HIDDEN_COUNT_ID = "_clmHdnC";
  this._COLUMNS_FROZEN_TEXT_ID = "_clmFrzT";
  this._COLUMNS_FROZEN_COUNT_ID = "_clmFrzC";
  this._EXPAND_MENUITEM_ID = "_xpdItm";
  this._EXPAND_ALL_BELOW_MENUITEM_ID = "_xpdBlw";
  this._COLLAPSE_ALL_BELOW_MENUITEM_ID = "_cpsBlw";
  this._EXPAND_ALL_MENUITEM_ID = "_xpdAll";
  this._COLLAPSE_ALL_MENUITEM_ID = "_cpsAll";
  this._SHOW_AS_TOP_MENUITEM_ID = "_shwTp";
  this._GO_TO_TOP_MENUITEM_ID = "_goTp";
  this._SCROLL_TO_FIRST_MENUITEM_ID = "_sclFst";
  this._SCROLL_TO_LAST_MENUITEM_ID = "_sclLst";
  this._SHOW_AS_TOP_TOOLBARITEM_ID = "_shwTpTbr";
  this._GO_UP_TOOLBARITEM_ID = "_upTbr";
  this._GO_TO_TOP_TOOLBARITEM_ID = "_tpTbr";
  this._COL_IDS_WITH_MENUS_KEY = "_afrClmWMn";
  this._DIALOG_TYPE_SORT = "_afrSortDialog";
  this._DIALOG_TYPE_SORT_ID = "sortDlg";
  this._DIALOG_TYPE_SHOW_COLS = "_afrShowColsDialog";
  this._DIALOG_TYPE_REORDER_COLS = "_afrReorderDialog";
  this._DIALOG_TYPE_RESIZE_COL = "_afrResizeColDialog";
  this._SHOWCOLUMNS_DIALOG_SHUTTLE_ID = "_shwClmDS";
  this._POPUP_ID = "_PCPop";
  this._SORT_DIALOG_CHOICE_ID = "_srtDlgC";
  this._SORT_DIALOG_RADIO_ID = "_srtDlgR";
  this._MAX_SORT_COLUMNS = 3;
  this._RESIZECOLUMN_DIALOG_SPIN_ID = "_rszDSpn";
  this._RESIZECOLUMN_DIALOG_SELECTONE_ID = "_rszDSct1";
  this._DETACH_DIALOG_CONTAINER_ID = "_dchDlgC";
  this._DETACH_DIALOG_WRAPPER_ID = "_dchDlgW";
  this._DETACH_DIALOG_POPUP_ID = "_dchDlgP";
  this._ROWS_SELECTED_TEXT = null;
  this._COLUMNS_HIDDEN_TEXT = null;
  this._COLUMNS_FROZEN_TEXT = null;
  this._ALL_TEXT = null;
  AdfRichUIPeer.addComponentEventHandlers(this, AdfActionEvent.ACTION_EVENT_TYPE, AdfDialogEvent.EVENT_TYPE, AdfPopupClosedEvent.POPUP_CLOSED_EVENT_TYPE, AdfTableShowColumnsEvent.SHOW_COLUMN_EVENT_TYPE, AdfValueChangeEvent.VALUE_CHANGE_TYPE, AdfPopupOpeningEvent.POPUP_OPENING_EVENT_TYPE);
  var actionMap = this._ACTION_HANDLER_MAP = {};
  var pt = AdfDhtmlPanelCollectionPeer.prototype;
  actionMap[this._FREEZE_MENUITEM_ID] = pt.freezeColumns;
  actionMap[this._UNFREEZE_MENUITEM_ID] = pt.unfreezeColumns;
  actionMap[this._FREEZE_TOOLBARITEM_ID] = pt.toggleFreeze;
  actionMap[this._DETACH_MENUITEM_ID] = actionMap[this._DETACH_TOOLBARITEM_ID] = pt.detach;
  actionMap[this._SORT_ASCENDING_MENUITEM_ID] = pt.sortAscending;
  actionMap[this._SORT_DESCENDING_MENUITEM_ID] = pt.sortDescending;
  actionMap[this._SORT_ADVANCED_MENUITEM_ID] = pt.sortAdvanced;
  actionMap[this._REORDER_MENUITEM_ID] = pt.reorderColumns;
  actionMap[this._QBE_TOOLBARITEM_ID] = pt.showQBE;
  actionMap[this._QBE_MENUITEM_ID] = pt.showQBE;
  actionMap[this._RESIZECOLUMN_MENUITEM_ID] = pt.resizeColumn;
  actionMap[this._WRAP_MENUITEM_ID] = actionMap[this._WRAP_TOOLBARITEM_ID] = pt.wrapColumns;
  actionMap[this._COLUMNS_SHOWALL_MENUITEM_ID] = pt.showAllColumns;
  actionMap[this._COLUMNS_SHOWCOLUMN_MENUITEM_ID] = pt.showColumn;
  actionMap[this._COLUMNS_SHOWMORE_MENUITEM_ID] = pt.showMoreColumns;
  actionMap[this._EXPAND_MENUITEM_ID] = pt.expandNode;
  actionMap[this._EXPAND_ALL_BELOW_MENUITEM_ID] = pt.expandAllNodesBelow;
  actionMap[this._COLLAPSE_ALL_BELOW_MENUITEM_ID] = pt.collapseAllNodesBelow;
  actionMap[this._EXPAND_ALL_MENUITEM_ID] = pt.expandAllNodes;
  actionMap[this._COLLAPSE_ALL_MENUITEM_ID] = pt.collapseAllNodes;
  actionMap[this._SHOW_AS_TOP_MENUITEM_ID] = pt.showNodeAsTop;
  actionMap[this._GO_TO_TOP_MENUITEM_ID] = pt.goToTopNode;
  actionMap[this._SCROLL_TO_FIRST_MENUITEM_ID] = pt.scrollToFirst;
  actionMap[this._SCROLL_TO_LAST_MENUITEM_ID] = pt.scrollToLast;
  actionMap[this._SHOW_AS_TOP_TOOLBARITEM_ID] = pt.showNodeAsTop;
  actionMap[this._GO_UP_TOOLBARITEM_ID] = pt.goUpNode;
  actionMap[this._GO_TO_TOP_TOOLBARITEM_ID] = pt.goToTopNode
};
AdfDhtmlPanelCollectionPeer.prototype.Init = function(component, usage) {
  AdfDhtmlPanelCollectionPeer.superclass.Init.call(this, component, usage);
  this._aggregatedChild = null;
  this._hasColumns = false;
  this._isStandAloneTree = false;
  this._isTree = false;
  this._isInitialized = false;
  this._hasColumnSelection = false;
  this._hasMultiRowSelection = false
};
AdfDhtmlPanelCollectionPeer.prototype.toolboxRefreshNotify = function() {
  this.updateRowSelectionContext();
  this.updateStandardMenuToolbarItems()
};
AdfDhtmlPanelCollectionPeer.prototype._initialize = function() {
  if(!this._isInitialized) {
    var childComp = this._aggregatedChild;
    if(!childComp) {
      var childId = this.getDomElement().getAttribute(AdfDhtmlPanelCollectionPeer._AGGREGATED_CHILD_ID);
      childComp = this._aggregatedChild = AdfPage.PAGE.findComponent(childId)
    }
    var isTable = childComp instanceof AdfRichTable;
    var isTreeTable = childComp instanceof AdfRichTreeTable;
    var isTree = childComp instanceof AdfRichTree;
    this._isStandAloneTree = isTree;
    this._hasColumns = isTable || isTreeTable;
    this._isTree = isTreeTable || isTree;
    if(!isTree) {
      var columnSelection = childComp.getColumnSelection();
      if(columnSelection != null) {
        columnSelection = columnSelection.toLowerCase()
      }
      this._hasColumnSelection = columnSelection != null && (columnSelection == "single" || columnSelection == "multiple");
      var rowSelection = childComp.getRowSelection();
      if(rowSelection != null) {
        rowSelection = rowSelection.toLowerCase()
      }
      this._hasMultiRowSelection = rowSelection != null && rowSelection.toLowerCase().indexOf("multiple") != -1
    }
    this._isInitialized = true;
    var component = this.getComponent();
    if(component.getProperty("_afrDetached")) {
      this._detachContent(component)
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.resetState = function() {
  var childId = this.getDomElement().getAttribute(AdfDhtmlPanelCollectionPeer._AGGREGATED_CHILD_ID);
  this._aggregatedChild = AdfPage.PAGE.findComponent(childId)
};
AdfDhtmlPanelCollectionPeer.prototype.updateStandardMenuToolbarItems = function() {
  this._initialize();
  if(!this._hasColumns) {
    return
  }
  var page = AdfPage.PAGE;
  var tableComponent = this._aggregatedChild, tablePeer = tableComponent.getPeer();
  var component = this.getComponent(), clientId = component.getClientId();
  var selectedColumns = tablePeer.__getSelectedColumns();
  var hasSelectedColumns = selectedColumns.length > 0;
  var sortAscendingMenuItem;
  var sortDescendingMenuItem;
  sortAscendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SORT_ASCENDING_MENUITEM_ID);
  sortDescendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SORT_DESCENDING_MENUITEM_ID);
  if(sortAscendingMenuItem && sortDescendingMenuItem) {
    var hasSortableColumns = false;
    if(hasSelectedColumns) {
      for(var i = selectedColumns.length - 1;i >= 0;--i) {
        var col = selectedColumns[i];
        if(col && col.getSortProperty() && col.getSortable()) {
          hasSortableColumns = true;
          break
        }
      }
    }else {
      var columns = tablePeer.__getVisibleLeafColumns();
      for(var i = columns.length - 1;i >= 0;--i) {
        var col = columns[i];
        if(col && col.getSortProperty() && col.getSortable()) {
          hasSortableColumns = true;
          break
        }
      }
    }
    if(!hasSortableColumns) {
      sortAscendingMenuItem.getParent().setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }else {
      sortAscendingMenuItem.getParent().setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
      this._updateSortMenuItems(tableComponent, selectedColumns, sortAscendingMenuItem, sortDescendingMenuItem)
    }
  }
  if(!this._hasColumnSelection) {
    return
  }
  var lnf = page.getLookAndFeel();
  var nodeStampColumnSelected = hasSelectedColumns ? this._isNodeStampColumnSelected(tableComponent, selectedColumns) : false;
  var freezeDisabled = this._isFreezeDisabled(selectedColumns);
  var freezeMenuItem, unfreezeMenuItem, freezeToolbarItem, resizeColumnMenuItem, wrapMenuItem, wrapToolbarItem;
  resizeColumnMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._RESIZECOLUMN_MENUITEM_ID);
  freezeMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._FREEZE_MENUITEM_ID);
  if(freezeMenuItem) {
    unfreezeMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._UNFREEZE_MENUITEM_ID)
  }
  freezeToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._FREEZE_TOOLBARITEM_ID);
  if(freezeMenuItem) {
    var hasFrozenColumn = this._hasFrozenColumn();
    freezeMenuItem.setProperty("disabled", freezeDisabled, false, AdfUIComponent.PROPAGATE_LOCALLY);
    freezeMenuItem.setProperty("visible", !hasFrozenColumn, false, AdfUIComponent.PROPAGATE_LOCALLY);
    unfreezeMenuItem.setProperty("visible", hasFrozenColumn, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(freezeToolbarItem) {
    freezeToolbarItem.setProperty("selected", hasFrozenColumn, false, AdfUIComponent.PROPAGATE_LOCALLY);
    var freezeTip = hasFrozenColumn ? lnf.getTranslatedString("af_panelCollection.TIP_BUTTON_UNFREEZE") : lnf.getTranslatedString("af_panelCollection.TIP_BUTTON_FREEZE");
    freezeToolbarItem.setProperty("shortDesc", freezeTip, false, AdfUIComponent.PROPAGATE_LOCALLY);
    if(!freezeToolbarItem.getSelected()) {
      freezeToolbarItem.setProperty("disabled", freezeDisabled, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
  }
  wrapMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._WRAP_MENUITEM_ID);
  wrapToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._WRAP_TOOLBARITEM_ID);
  var wrapMenuItemDisabled = !hasSelectedColumns || nodeStampColumnSelected;
  var columnIsWrapped = !wrapMenuItemDisabled && !selectedColumns[0].getNoWrap();
  if(wrapMenuItem) {
    wrapMenuItem.setProperty("disabled", wrapMenuItemDisabled, false, AdfUIComponent.PROPAGATE_LOCALLY);
    wrapMenuItem.setProperty("selected", columnIsWrapped, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(wrapToolbarItem) {
    wrapToolbarItem.setProperty("disabled", wrapMenuItemDisabled, false, AdfUIComponent.PROPAGATE_LOCALLY);
    wrapToolbarItem.setProperty("selected", columnIsWrapped, false, AdfUIComponent.PROPAGATE_LOCALLY);
    var wrapTip = columnIsWrapped ? lnf.getTranslatedString("af_panelCollection.TIP_BUTTON_UNWRAP") : lnf.getTranslatedString("af_panelCollection.TIP_BUTTON_WRAP");
    wrapToolbarItem.setProperty("shortDesc", wrapTip, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(resizeColumnMenuItem) {
    resizeColumnMenuItem.setProperty("disabled", !hasSelectedColumns, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
};
AdfDhtmlPanelCollectionPeer.prototype._isFreezeDisabled = function(selectedColumns) {
  var tableComponent = this._aggregatedChild, tablePeer = tableComponent.getPeer();
  var selectedColumnCount = selectedColumns.length;
  var hasSelectedColumns = selectedColumnCount > 0;
  if(!hasSelectedColumns) {
    return true
  }
  var leafColumns = tablePeer.__getVisibleLeafColumns();
  var visibleColumnCount = leafColumns.length;
  if(visibleColumnCount < 2) {
    return true
  }
  if(selectedColumnCount == 1) {
    if(tableComponent.getFreezeDirection() == "end") {
      var firstLeafColumn = leafColumns[0];
      if(selectedColumns[0] == firstLeafColumn) {
        return true
      }
    }else {
      var lastLeafColumn = leafColumns[leafColumns.length - 1];
      if(selectedColumns[0] == lastLeafColumn) {
        return true
      }
    }
  }
  var lastSelectedColumn = selectedColumns[selectedColumnCount - 1];
  var topParent = this._getRootColumn(lastSelectedColumn, tablePeer);
  if(topParent != null) {
    var selectedNode = lastSelectedColumn.getPeer().getDomElement();
    var parentNode = topParent.getPeer().getDomElement();
    var agent = AdfAgent.AGENT;
    if(agent.getIntAttribute(parentNode, "_d_index", -1) + parseInt(parentNode.colSpan) - 1 != agent.getIntAttribute(selectedNode, "_d_index", -1)) {
      return true
    }
  }
  return false
};
AdfDhtmlPanelCollectionPeer.prototype._getRootColumn = function(column, tablePeer) {
  var topParent = null;
  var parentColumn = tablePeer.__getParentColumn(column);
  while(parentColumn != null) {
    topParent = parentColumn;
    parentColumn = tablePeer.__getParentColumn(parentColumn)
  }
  return topParent
};
AdfDhtmlPanelCollectionPeer.prototype._hasFrozenColumn = function() {
  return this._getFrozenColumn(this._aggregatedChild) != null
};
AdfDhtmlPanelCollectionPeer.prototype._getFrozenColumn = function(tableComponent) {
  var tablePeer = tableComponent.getPeer();
  var leafColumns = tablePeer.__getVisibleLeafColumns();
  var leafCount = leafColumns.length;
  for(var i = 0;i < leafCount;i++) {
    var col = leafColumns[i];
    if(!col) {
      continue
    }
    if(col && col.getFrozen()) {
      return col
    }
    var topParent = this._getRootColumn(col, tablePeer);
    if(topParent != null) {
      if(topParent.getFrozen()) {
        return topParent
      }
      var parentNode = topParent.getPeer().getDomElement();
      i += parseInt(parentNode.colSpan) - 1
    }
  }
  return null
};
AdfDhtmlPanelCollectionPeer.prototype._isNodeStampColumnSelected = function(tableComponent, selectedColumns) {
  if(!this._isTree) {
    return false
  }
  var nodestampColumn = tableComponent.getPeer().getNodeStampColumn();
  for(var i = 0;i < selectedColumns.length;i++) {
    if(selectedColumns[i] == nodestampColumn) {
      return true
    }
  }
  return false
};
AdfDhtmlPanelCollectionPeer.prototype._updateSortMenuItems = function(tableComponent, selectedColumns, sortAscendingMenuItem, sortDescendingMenuItem) {
  if(selectedColumns.length == 1) {
    var col = selectedColumns[0];
    if(col.getSortProperty() && col.getSortable()) {
      sortAscendingMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
      sortDescendingMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
      var sortOrder = AdfDhtmlTableBasePeer.__getSortOrderForColumn(col.getClientId());
      if(sortOrder == true) {
        sortAscendingMenuItem.setProperty("selected", true, false, AdfUIComponent.PROPAGATE_LOCALLY);
        sortDescendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
      }else {
        if(sortOrder == false) {
          sortDescendingMenuItem.setProperty("selected", true, false, AdfUIComponent.PROPAGATE_LOCALLY);
          sortAscendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
        }else {
          sortAscendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
          sortDescendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
        }
      }
      return
    }
  }
  sortAscendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
  sortAscendingMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY);
  sortDescendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
  sortDescendingMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
};
AdfDhtmlPanelCollectionPeer.prototype.updateStandardStatusbarItems = function() {
  this._initialize();
  if(this._isStandAloneTree) {
    return
  }
  var tableComponent = this._aggregatedChild, tablePeer = tableComponent.getPeer();
  var leafColumns = tablePeer.__getVisibleLeafColumns();
  var frozenCount = 0, hiddenCount = 0;
  for(var i = leafColumns.length - 1;i >= 0;i--) {
    var col = leafColumns[i];
    if(col) {
      if(col.getFrozen()) {
        frozenCount++
      }else {
        if(frozenCount > 0 && !col.getRowHeader()) {
          frozenCount++
        }else {
          var topParent = this._getRootColumn(col, tablePeer);
          if(topParent != null) {
            var parentNode = topParent.getPeer().getDomElement();
            var colSpan = parseInt(parentNode.colSpan);
            i -= colSpan - 1;
            if(topParent.getFrozen()) {
              frozenCount += colSpan
            }
          }
        }
      }
    }
  }
  if(tablePeer._freezeColumnsToEnd()) {
    var columns = tablePeer.__getVisibleLeafColumns();
    var colCount = columns.length;
    frozenCount = colCount - frozenCount + 1
  }
  hiddenCount = tablePeer.getDomElement().getAttribute(AdfDhtmlPanelCollectionPeer._HIDDEN_COL_COUNT);
  var component = this.getComponent(), clientId = component.getClientId();
  var page = AdfPage.PAGE;
  if(this._hasColumns) {
    var textItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_FROZEN_TEXT_ID);
    var countItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_FROZEN_COUNT_ID);
    if(textItem) {
      if(!AdfDhtmlPanelCollectionPeer._COLUMNS_FROZEN_TEXT) {
        AdfDhtmlPanelCollectionPeer._COLUMNS_FROZEN_TEXT = textItem.getValue()
      }
      textItem.setProperty("value", frozenCount > 0 ? AdfDhtmlPanelCollectionPeer._COLUMNS_FROZEN_TEXT : "", false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(countItem) {
      if(frozenCount > 0) {
        countItem.setProperty("value", frozenCount.toString(), false, AdfUIComponent.PROPAGATE_LOCALLY)
      }else {
        countItem.setProperty("value", "", false, AdfUIComponent.PROPAGATE_LOCALLY)
      }
    }
  }
  textItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_HIDDEN_TEXT_ID);
  countItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_HIDDEN_COUNT_ID);
  if(textItem) {
    if(!AdfDhtmlPanelCollectionPeer._COLUMNS_HIDDEN_TEXT) {
      AdfDhtmlPanelCollectionPeer._COLUMNS_HIDDEN_TEXT = textItem.getValue()
    }
    textItem.setProperty("value", hiddenCount > 0 ? AdfDhtmlPanelCollectionPeer._COLUMNS_HIDDEN_TEXT : "", false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(countItem) {
    if(hiddenCount > 0) {
      countItem.setProperty("value", hiddenCount.toString(), false, AdfUIComponent.PROPAGATE_LOCALLY)
    }else {
      countItem.setProperty("value", "", false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.updateRowSelectionContext = function() {
  this._initialize();
  var tableComponent = this._aggregatedChild;
  var isSelectAll = false, selectCount = 0, firstRowKey = null, state = tableComponent.getSelectedRowKeys();
  for(var prop in state) {
    if(prop == AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY) {
      isSelectAll = state[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY];
      break
    }
    if(selectCount == 0) {
      firstRowKey = prop
    }
    selectCount++
  }
  if(this._hasMultiRowSelection) {
    this._updateRowSelectionCount(isSelectAll, selectCount)
  }
  if(this._isTree) {
    this._updateTreeRowSelectionContext(tableComponent, isSelectAll, selectCount, firstRowKey)
  }
};
AdfDhtmlPanelCollectionPeer.prototype._updateRowSelectionCount = function(isSelectAll, selectCount) {
  var page = AdfPage.PAGE;
  var component = this.getComponent(), clientId = component.getClientId();
  var textItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._ROWS_SELECTED_TEXT_ID);
  var countItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._ROWS_SELECTED_COUNT_ID);
  if(textItem) {
    if(!AdfDhtmlPanelCollectionPeer._ROWS_SELECTED_TEXT) {
      AdfDhtmlPanelCollectionPeer._ROWS_SELECTED_TEXT = textItem.getValue()
    }
    textItem.setProperty("value", isSelectAll || selectCount > 0 ? AdfDhtmlPanelCollectionPeer._ROWS_SELECTED_TEXT : "", false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(countItem) {
    if(isSelectAll) {
      if(!AdfDhtmlPanelCollectionPeer._ALL_TEXT) {
        AdfDhtmlPanelCollectionPeer._ALL_TEXT = page.getLookAndFeel().getTranslatedString("af_panelCollection.LABEL_STATUSBARITEM_ROWS_SELECTED_ALL")
      }
      if(selectCount > 0) {
        countItem.setProperty("value", "", false, AdfUIComponent.PROPAGATE_LOCALLY)
      }else {
        countItem.setProperty("value", AdfDhtmlPanelCollectionPeer._ALL_TEXT, false, AdfUIComponent.PROPAGATE_LOCALLY)
      }
    }else {
      if(selectCount > 0) {
        countItem.setProperty("value", selectCount.toString(), false, AdfUIComponent.PROPAGATE_LOCALLY)
      }else {
        countItem.setProperty("value", "", false, AdfUIComponent.PROPAGATE_LOCALLY)
      }
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype._updateTreeRowSelectionContext = function(treeComponent, isSelectAll, selectCount, firstRowKey) {
  this._initialize();
  var component = this.getComponent();
  var clientId = component.getClientId();
  var treePeer = treeComponent.getPeer();
  var page = AdfPage.PAGE;
  var expandMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._EXPAND_MENUITEM_ID);
  var expandAllBelowMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._EXPAND_ALL_BELOW_MENUITEM_ID);
  var collapseAllBelowMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLLAPSE_ALL_BELOW_MENUITEM_ID);
  var showAsTopMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SHOW_AS_TOP_MENUITEM_ID);
  var goToTopMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._GO_TO_TOP_MENUITEM_ID);
  var scrollToFirstMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SCROLL_TO_FIRST_MENUITEM_ID);
  var scrollToLastMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SCROLL_TO_LAST_MENUITEM_ID);
  var showAsTopToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SHOW_AS_TOP_TOOLBARITEM_ID);
  var goUpToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._GO_UP_TOOLBARITEM_ID);
  var goToTopToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._GO_TO_TOP_TOOLBARITEM_ID);
  var sortAscendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._SORT_ASCENDING_MENUITEM_ID);
  var sortDescendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._SORT_DESCENDING_MENUITEM_ID);
  if(firstRowKey && !treePeer.FindRowByKey(firstRowKey)) {
    firstRowKey = null
  }
  var hasPathStamp = treePeer.hasPathStamp();
  var isLeafNode = false;
  var isExpanded = false;
  if(isSelectAll || firstRowKey == null || selectCount > 1) {
    if(expandMenuItem) {
      expandMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(sortAscendingMenuItem) {
      sortAscendingMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(sortDescendingMenuItem) {
      sortDescendingMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(expandAllBelowMenuItem) {
      expandAllBelowMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(collapseAllBelowMenuItem) {
      collapseAllBelowMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(showAsTopMenuItem) {
      showAsTopMenuItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(showAsTopToolbarItem) {
      showAsTopToolbarItem.setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
  }else {
    var isFocusRow = firstRowKey == treeComponent.getFocusRowKey();
    isLeafNode = treePeer.isLeaf(firstRowKey);
    var nodeDepth = treePeer.getDepth(firstRowKey);
    var isMultiRoot = treePeer.isMultiRoot();
    isExpanded = treeComponent.isPathExpanded(firstRowKey);
    if(expandMenuItem) {
      expandMenuItem.setProperty("disabled", isLeafNode, false, AdfUIComponent.PROPAGATE_LOCALLY);
      expandMenuItem.setProperty("selected", !isExpanded, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(hasPathStamp) {
      var disabled = isFocusRow || isLeafNode || !isMultiRoot && nodeDepth == 0;
      if(showAsTopMenuItem) {
        showAsTopMenuItem.setProperty("disabled", disabled, false, AdfUIComponent.PROPAGATE_LOCALLY)
      }
      if(showAsTopToolbarItem) {
        showAsTopToolbarItem.setProperty("disabled", disabled, false, AdfUIComponent.PROPAGATE_LOCALLY)
      }
    }
    if(sortAscendingMenuItem && sortDescendingMenuItem) {
      var nodeStampCol = treePeer.getNodeStampColumn();
      if(nodeStampCol) {
        if(nodeStampCol.getSortProperty() && nodeStampCol.getSortable()) {
          sortAscendingMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
          sortDescendingMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
          sortAscendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
          sortDescendingMenuItem.setProperty("selected", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
        }
      }
    }
    if(expandAllBelowMenuItem) {
      expandAllBelowMenuItem.setProperty("disabled", isLeafNode, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(collapseAllBelowMenuItem) {
      collapseAllBelowMenuItem.setProperty("disabled", isLeafNode || !isExpanded, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
  }
  var disableGoToTop = !treePeer.isSelectorIconVisible();
  if(goToTopMenuItem) {
    goToTopMenuItem.setProperty("disabled", disableGoToTop, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(goToTopToolbarItem) {
    goToTopToolbarItem.setProperty("disabled", disableGoToTop, false, AdfUIComponent.PROPAGATE_LOCALLY);
    goUpToolbarItem.setProperty("disabled", disableGoToTop, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(scrollToLastMenuItem) {
    scrollToLastMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
  if(scrollToFirstMenuItem) {
    scrollToFirstMenuItem.setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.showColumnContextMenu = function(domEvent, alignElement) {
  this._initialize();
  if(!this._hasColumns) {
    return
  }
  var tableComponent = this._aggregatedChild, tablePeer = tableComponent.getPeer();
  var page = AdfPage.PAGE;
  var component = this.getComponent(), clientId = component.getClientId();
  var columnContextMenu = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID);
  var sortAscendingMenuItem, sortDescendingMenuItem, freezeMenuItem, unfreezeMenuItem;
  if(columnContextMenu) {
    var hasFrozenColumn = this._hasFrozenColumn();
    var selectedColumns = tablePeer.__getSelectedColumns();
    sortAscendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._SORT_ASCENDING_MENUITEM_ID);
    sortDescendingMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._SORT_DESCENDING_MENUITEM_ID);
    freezeMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._FREEZE_MENUITEM_ID);
    if(freezeMenuItem) {
      unfreezeMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._UNFREEZE_MENUITEM_ID)
    }
    if(freezeMenuItem) {
      freezeMenuItem.setProperty("disabled", this._isFreezeDisabled(selectedColumns), false, AdfUIComponent.PROPAGATE_LOCALLY);
      freezeMenuItem.setProperty("visible", !hasFrozenColumn, false, AdfUIComponent.PROPAGATE_LOCALLY);
      unfreezeMenuItem.setProperty("visible", hasFrozenColumn, false, AdfUIComponent.PROPAGATE_LOCALLY)
    }
    if(sortAscendingMenuItem) {
      var noColumnSortable = true;
      for(var i = selectedColumns.length - 1;i >= 0;i--) {
        var col = selectedColumns[i];
        if(col.getSortProperty() && col.getSortable()) {
          noColumnSortable = false;
          break
        }
      }
      if(noColumnSortable) {
        sortAscendingMenuItem.getParent().setProperty("disabled", true, false, AdfUIComponent.PROPAGATE_LOCALLY)
      }else {
        sortAscendingMenuItem.getParent().setProperty("disabled", false, false, AdfUIComponent.PROPAGATE_LOCALLY);
        this._updateSortMenuItems(tableComponent, selectedColumns, sortAscendingMenuItem, sortDescendingMenuItem)
      }
    }
    tablePeer.showContextMenu(domEvent, columnContextMenu.getClientId(), null, alignElement, null, tableComponent.getClientId())
  }
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentAction = function(componentEvent) {
  var source = componentEvent.getSource();
  var clientId = source.getClientId();
  var actionMap = AdfDhtmlPanelCollectionPeer._ACTION_HANDLER_MAP;
  for(var key in actionMap) {
    if(clientId.indexOf(key) >= 0) {
      actionMap[key].call(this, componentEvent);
      componentEvent.cancel();
      componentEvent.stopBubbling();
      break
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.showAllColumns = function() {
  var table = this._aggregatedChild;
  var showEvent = new AdfTableShowColumnsEvent(table, null, "showAll");
  var page = AdfPage.PAGE;
  page.queueEventToServer(showEvent);
  this._updateShowColMenuItems(true);
  this._checkUpdateViewMenu("all")
};
AdfDhtmlPanelCollectionPeer.prototype._updateShowColMenuItems = function(showAll, visibleColIds) {
  var page = AdfPage.PAGE;
  var component = this.getComponent(), clientId = component.getClientId();
  if(!this._columnIdWithMenus) {
    var expando = AdfAgent.AGENT.getAttribute(this.getDomElement(), AdfDhtmlPanelCollectionPeer._COL_IDS_WITH_MENUS_KEY);
    this._columnIdWithMenus = eval(expando)
  }
  var colIdsWithMenus = this._columnIdWithMenus;
  var menuItemPrefix = AdfDhtmlPanelCollectionPeer._COLUMNS_SHOWCOLUMN_MENUITEM_ID;
  var ccMenuItemPrefix = AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID;
  var columnContextMenu = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID);
  if(columnContextMenu) {
    page.addPartialTargets(columnContextMenu)
  }
  if(colIdsWithMenus) {
    for(var i = colIdsWithMenus.length - 1;i >= 0;--i) {
      var colId = colIdsWithMenus[i];
      var menuId = clientId + ":" + menuItemPrefix + colId;
      var menuItem = page.findComponent(menuId);
      menuId = clientId + ":" + ccMenuItemPrefix + menuItemPrefix + colId;
      var columnContextMenuItem = page.findComponent(menuId);
      if(menuItem != null) {
        var setSelected = showAll || AdfCollections.indexOf(visibleColIds, colId) != -1;
        menuItem.setSelected(setSelected);
        page.addPartialTargets(menuItem);
        if(columnContextMenuItem != null) {
          columnContextMenuItem.setSelected(setSelected);
          page.addPartialTargets(columnContextMenuItem)
        }
      }
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.showColumn = function(componentEvent) {
  var page = AdfPage.PAGE;
  var component = this.getComponent();
  var clientId = component.getClientId();
  var sourceId = componentEvent.getSource().getClientId();
  var menuItemPrefix = AdfDhtmlPanelCollectionPeer._COLUMNS_SHOWCOLUMN_MENUITEM_ID;
  var columnId = sourceId.substr(sourceId.indexOf(menuItemPrefix) + menuItemPrefix.length);
  columnId = columnId.replace(/_afrSep_/g, ":");
  var table = this._aggregatedChild;
  var column = table.findComponent(columnId);
  var showEvent = new AdfTableShowColumnsEvent(table, table.getClientId() + ":" + columnId, column ? "hide" : "show");
  page.queueEventToServer(showEvent);
  var ccPrefixIndex = sourceId.indexOf(AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID);
  var menuItemId, menuItem;
  if(ccPrefixIndex >= 0) {
    menuItemId = clientId + ":" + menuItemPrefix + columnId;
    menuItem = page.findComponent(menuItemId)
  }else {
    menuItemId = clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + menuItemPrefix + columnId;
    menuItem = page.findComponent(menuItemId)
  }
  if(menuItem) {
    menuItem.setSelected(column == null);
    AdfPage.PAGE.addPartialTargets(menuItem)
  }
  this._checkUpdateViewMenu(column ? "hide" : "show")
};
AdfDhtmlPanelCollectionPeer.prototype._checkUpdateViewMenu = function(action) {
  var numColumnsShown;
  if(action != "multiple") {
    var table = this._aggregatedChild;
    var tablePeer = table.getPeer();
    var cols = tablePeer.__getVisibleLeafColumns();
    numColumnsShown = cols.length;
    for(var i = 0;i < numColumnsShown;++i) {
      var col = cols[i];
      if(col && col.getRowHeader()) {
        --numColumnsShown;
        break
      }
    }
  }
  switch(action) {
    case "show":
      if(numColumnsShown != 1) {
        return
      }
      break;
    case "hide":
      if(numColumnsShown != 2) {
        return
      }
      break;
    case "all":
      if(numColumnsShown >= 2) {
        return
      }
      break;
    default:
      break
  }
  var component = this.getComponent();
  var clientId = component.getClientId();
  var viewMenuItem = AdfPage.PAGE.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._VIEW_MENU_ID);
  if(viewMenuItem) {
    AdfPage.PAGE.addPartialTargets(viewMenuItem)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.toggleFreeze = function() {
  if(this._hasFrozenColumn(this._aggregatedChild)) {
    this.unfreezeColumns()
  }else {
    this.freezeColumns()
  }
};
AdfDhtmlPanelCollectionPeer.prototype.freezeColumns = function() {
  var table = this._aggregatedChild;
  var tablePeer = table.getPeer();
  if(this._hasFrozenColumn(table)) {
    this.unfreezeColumns()
  }
  var lastSelectedColumn = null;
  var leafColumns = tablePeer.__getVisibleLeafColumns();
  var colCount = leafColumns.length;
  var colNum = colCount - 1;
  while(lastSelectedColumn == null && colNum >= 0) {
    var col = leafColumns[colNum];
    if(col && col.getSelected() && colNum != colCount - 1) {
      lastSelectedColumn = col
    }
    colNum--
  }
  if(lastSelectedColumn != null) {
    var topParent = this._getRootColumn(lastSelectedColumn, tablePeer);
    if(topParent != null) {
      lastSelectedColumn = topParent
    }
    lastSelectedColumn.setProperty(AdfRichColumn.FROZEN, true, true);
    AdfPage.PAGE.addPartialTargets(table)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.unfreezeColumns = function() {
  var table = this._aggregatedChild;
  frozenColumn = this._getFrozenColumn(table);
  if(frozenColumn != null) {
    frozenColumn.setProperty(AdfRichColumn.FROZEN, false, true);
    AdfPage.PAGE.addPartialTargets(table)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.isDetached = function() {
  return this.getComponent().getProperty("_afrDetached")
};
AdfDhtmlPanelCollectionPeer.prototype.ComponentRemoved = function(component) {
  if(component.getProperty("_afrDetached")) {
    this._ignoreDetachSetProp = true;
    var page = AdfPage.PAGE;
    var contentNode = this._getDOMContent();
    page.removeComponentsInSubtree(contentNode)
  }
  AdfDhtmlPanelCollectionPeer.superclass.ComponentRemoved.call(this, component)
};
AdfDhtmlPanelCollectionPeer.prototype._getDOMContent = function() {
  var agent = AdfAgent.AGENT;
  var contentNode;
  var tablePeer = this._aggregatedChild.getPeer();
  var heightAutoSized = tablePeer.isHeightAutoSized();
  if(heightAutoSized) {
    var component = this.getComponent();
    var clientId = component.getClientId();
    var domDocument = this.getDomDocument();
    contentNode = domDocument.createElement("div");
    contentNode.style.cssText = "position:absolute;width:100%;height:100%";
    var topId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_TOP_ID);
    var topNode = agent.getElementById(topId);
    var ctrId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_CENTER_ID);
    var ctrNode = agent.getElementById(ctrId);
    var bottomId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_BOTTOM_ID);
    var bottomNode = agent.getElementById(bottomId);
    if(topNode) {
      contentNode.appendChild(topNode)
    }
    if(ctrNode) {
      contentNode.appendChild(ctrNode)
    }
    if(bottomNode) {
      contentNode.appendChild(bottomNode)
    }
  }else {
    var rootElement = this.getDomElement();
    contentNode = rootElement.firstChild;
    while(contentNode && contentNode.nodeType != 1) {
      contentNode = contentNode.nextSibling
    }
  }
  return contentNode
};
AdfDhtmlPanelCollectionPeer.prototype.__getAutoHeightTopFacetId = function() {
  return AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_TOP_ID
};
AdfDhtmlPanelCollectionPeer.prototype.__getAutoHeightBottomFacetId = function() {
  return AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_BOTTOM_ID
};
AdfDhtmlPanelCollectionPeer.prototype._restoreDOMContent = function() {
  var component = this.getComponent();
  var tablePeer = this._aggregatedChild.getPeer();
  var heightAutoSized = tablePeer.isHeightAutoSized();
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var rootElement = this.getDomElement();
  var wrapperId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_WRAPPER_ID);
  var wrapperNode = agent.getElementById(wrapperId);
  if(heightAutoSized) {
    var topId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_TOP_ID);
    var topNode = agent.getElementById(topId);
    var ctrId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_CENTER_ID);
    var ctrNode = agent.getElementById(ctrId);
    var bottomId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._AUTO_HEIGHT_BOTTOM_ID);
    var bottomNode = agent.getElementById(bottomId);
    if(bottomNode) {
      rootElement.insertBefore(bottomNode, rootElement.firstChild)
    }
    if(ctrNode) {
      rootElement.insertBefore(ctrNode, rootElement.firstChild)
    }
    if(topNode) {
      rootElement.insertBefore(topNode, rootElement.firstChild)
    }
    wrapperNode.removeChild(wrapperNode.firstChild)
  }else {
    rootElement.insertBefore(wrapperNode.firstChild, rootElement.firstChild)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.detach = function() {
  var component = this.getComponent();
  if(component.getProperty("_afrDetached")) {
    this.hidePopup(component, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_POPUP_ID);
    return
  }
  component.setProperty("_afrDetached", true, false, true);
  this._detachContent(component)
};
AdfDhtmlPanelCollectionPeer.prototype._detachContent = function(component) {
  var clientId = component.getClientId();
  var containerId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_CONTAINER_ID);
  var agent = AdfAgent.AGENT;
  var page = AdfPage.PAGE;
  var containerNode = agent.getElementById(containerId);
  if(containerNode) {
    var dlgRootNode = containerNode.firstChild;
    while(dlgRootNode && dlgRootNode.nodeType != 1) {
      dlgRootNode = dlgRootNode.nextSibling
    }
    var tablePeer = this._aggregatedChild.getPeer();
    var scrollPos = tablePeer.__getScrollPos();
    var contentNode = this._getDOMContent();
    var rootElement = this.getDomElement();
    var wrapperId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_WRAPPER_ID);
    var wrapperNode = agent.getElementById(wrapperId);
    wrapperNode.className = rootElement.className;
    var dialogClientId = dlgRootNode.id;
    AdfAssert.assertString(dialogClientId);
    var dialog = page.findComponent(dialogClientId);
    AdfAssert.assertPrototype(dialog, AdfRichPanelWindow);
    var windowWidth = agent.getWindowWidth(), windowHeight = agent.getWindowHeight();
    dialog.setContentWidth(Math.max(100, windowWidth - 60));
    dialog.setContentHeight(Math.max(100, windowHeight - 80));
    wrapperNode.appendChild(contentNode);
    var posX = AdfPage.PAGE.getLocaleContext().isRightToLeft() ? 6 : 1;
    var hints = {};
    hints[AdfDhtmlPopupHints.MOUSEPOSITION] = {x:posX, y:1};
    hints[AdfDhtmlPopupHints.MODAL] = true;
    this.showPopup(component, dlgRootNode, hints, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_POPUP_ID);
    var heightAutoSized = tablePeer.isHeightAutoSized();
    if(heightAutoSized) {
      tablePeer.__fixPanelCollectionDimensions(false);
      page.doResizeNotifyDom(tablePeer.getDomElement(), true)
    }
    var detachToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._DETACH_TOOLBARITEM_ID);
    var detachMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._DETACH_MENUITEM_ID);
    if(detachToolbarItem) {
      detachToolbarItem.setSelected(true);
      var attachTip = page.getLookAndFeel().getTranslatedString("af_panelCollection.TIP_BUTTON_REDUCE");
      detachToolbarItem.setShortDesc(attachTip)
    }
    if(detachMenuItem) {
      detachMenuItem.setSelected(true)
    }
    if(scrollPos != null) {
      tablePeer.__restoreScrollerPositions(scrollPos.x, scrollPos.y)
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.PopupClosed = function(component, contentDom, popupId) {
  AdfDhtmlPanelCollectionPeer.superclass.PopupClosed.call(this, component, contentDom);
  var agent = AdfAgent.AGENT;
  var isCanceledByDomReplace = "true" == contentDom.getAttribute(AdfDhtmlPopupWindow.__REPLACEDOM_EXPANDO);
  if(popupId == AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_POPUP_ID) {
    var tablePeer = this._aggregatedChild.getPeer(), scrollPos = tablePeer.__getScrollPos();
    var page = AdfPage.PAGE;
    var clientId = component.getClientId();
    this._restoreDOMContent();
    var rootElement = this.getDomElement();
    var containerId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlPanelCollectionPeer._DETACH_DIALOG_CONTAINER_ID);
    var containerNode = agent.getElementById(containerId);
    containerNode.appendChild(contentDom);
    if(isCanceledByDomReplace) {
      return
    }
    var detachToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._DETACH_TOOLBARITEM_ID);
    var detachMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._DETACH_MENUITEM_ID);
    if(detachMenuItem) {
      detachMenuItem.setSelected(false)
    }
    if(detachToolbarItem) {
      detachToolbarItem.setSelected(false);
      var detachTip = page.getLookAndFeel().getTranslatedString("af_panelCollection.TIP_BUTTON_DETACH");
      detachToolbarItem.setShortDesc(detachTip)
    }
    if(!this._ignoreDetachSetProp) {
      component.setProperty("_afrDetached", false, false, true)
    }
    var heightAutoSized = tablePeer.isHeightAutoSized();
    if(heightAutoSized) {
      tablePeer.__fixPanelCollectionDimensions(false);
      var tableDataBody = tablePeer.GetDataBody();
      tableDataBody.style.height = "auto";
      page.doResizeNotifyDom(tablePeer.getDomElement(), true)
    }else {
      page.doResizeNotifyDom(rootElement, false)
    }
    if(scrollPos != null) {
      tablePeer.__restoreScrollerPositions(scrollPos.x, scrollPos.y)
    }
    if(detachToolbarItem && detachToolbarItem.getParent() && AdfAgent.AGENT.getPlatform() == AdfAgent.IE_PLATFORM) {
      AdfPage.PAGE.addPartialTargets(detachToolbarItem.getParent())
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype._getTheSelectedColumn = function(table) {
  var leafColumns = table.getPeer().__getVisibleLeafColumns();
  var selectedColumn = null, colCount = leafColumns.length;
  for(var i = 0;i < colCount;i++) {
    var col = leafColumns[i];
    if(col && col.getSelected()) {
      selectedColumn = col;
      break
    }
  }
  return selectedColumn
};
AdfDhtmlPanelCollectionPeer.prototype._triggerSortEvent = function(ascending) {
  this._initialize();
  var table = this._aggregatedChild;
  var selectedCol = this._getTheSelectedColumn(table);
  if(selectedCol) {
    var sortProperty = selectedCol.getSortProperty();
    if(sortProperty) {
      AdfAssert.assertBoolean(ascending);
      var sortOrder = AdfDhtmlTableBasePeer.__getSortOrderForColumn(selectedCol.getClientId());
      if(sortOrder != ascending) {
        AdfTableUtils.queueSortEvent(table, sortProperty, ascending)
      }
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.sortAscending = function() {
  this._triggerSortEvent(true)
};
AdfDhtmlPanelCollectionPeer.prototype.sortDescending = function() {
  this._triggerSortEvent(false)
};
AdfDhtmlPanelCollectionPeer.prototype.sortAdvanced = function() {
  this._showAdvancedDialog(AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT)
};
AdfDhtmlPanelCollectionPeer.prototype.reorderColumns = function() {
  this._showAdvancedDialog(AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_REORDER_COLS)
};
AdfDhtmlPanelCollectionPeer.prototype.showMoreColumns = function(tableId, event) {
  this._showAdvancedDialog(AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SHOW_COLS)
};
AdfDhtmlPanelCollectionPeer.prototype._showAdvancedDialog = function(type) {
  var component = this.getComponent(), clientId = component.getClientId();
  var page = AdfPage.PAGE;
  var event = new AdfPanelCollectionDialogFetchEvent(component, type);
  page.queueEventToServer(event);
  this._openedDialogType = type;
  var popup = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._POPUP_ID);
  popup.show()
};
AdfDhtmlPanelCollectionPeer.prototype.showQBE = function() {
  var table = this._aggregatedChild;
  var component = this.getComponent(), clientId = component.getClientId();
  var page = AdfPage.PAGE;
  var filterVisible = !table.getFilterVisible();
  table.setProperty(AdfRichTable.FILTER_VISIBLE, filterVisible, true);
  page.addPartialTargets(table);
  var queryEvent = new AdfQueryEvent(table);
  if(!filterVisible) {
    queryEvent.setClearAll(true)
  }
  table.queueEvent(queryEvent);
  var filterToolbarItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._QBE_TOOLBARITEM_ID);
  var filterMenuItem = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._QBE_MENUITEM_ID);
  filterToolbarItem.setSelected(filterVisible);
  if(filterMenuItem) {
    filterMenuItem.setSelected(filterVisible)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.resizeColumn = function() {
  this._showAdvancedDialog(AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_RESIZE_COL)
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentPopupOpening = function(componentEvent) {
  if(null == this._openedDialogType) {
    return
  }
  if(this._openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT) {
    var component = this.getComponent(), clientId = component.getClientId();
    var dialogId = clientId + ":" + AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT_ID;
    var dialog = AdfPage.PAGE.findComponent(dialogId);
    dialog.getPeer().__setDefaultButtonDisabled(dialogId, true)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentValueChange = function(componentEvent) {
  if(null == this._openedDialogType) {
    return
  }
  if(this._openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT) {
    var component = this.getComponent(), clientId = component.getClientId();
    var page = AdfPage.PAGE;
    var maxSortColumns = AdfDhtmlPanelCollectionPeer._MAX_SORT_COLUMNS;
    var enableOKButton = false;
    for(var i = 0;i < maxSortColumns;++i) {
      var choice = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SORT_DIALOG_CHOICE_ID + i);
      if(choice != null && choice.getValue()) {
        enableOKButton = true
      }
    }
    var dialogId = clientId + ":" + AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT_ID;
    var dialog = page.findComponent(dialogId);
    dialog.getPeer().__setDefaultButtonDisabled(dialogId, !enableOKButton)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentPopupClosed = function(componentEvent) {
  delete this._openedDialogType
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentDialog = function(componentEvent) {
  if(null == this._openedDialogType) {
    return
  }
  var dialogShouldClose = true;
  if(componentEvent.getOutcome() == AdfDialogEvent.OUTCOME_OK) {
    var openedDialogType = this._openedDialogType;
    if(openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SORT) {
      this._handleAdvancedSortOK(componentEvent)
    }else {
      if(openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SHOW_COLS || openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_REORDER_COLS) {
        this._handleShowColumnsOK(componentEvent)
      }else {
        if(openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_RESIZE_COL) {
          dialogShouldClose = this._handleResizeColumnOK(componentEvent)
        }
      }
    }
    componentEvent.cancel();
    if(dialogShouldClose) {
      var component = this.getComponent(), clientId = component.getClientId();
      var page = AdfPage.PAGE;
      var popup = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._POPUP_ID);
      popup.hide()
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype._handleAdvancedSortOK = function(componentEvent) {
  var component = this.getComponent(), clientId = component.getClientId();
  var page = AdfPage.PAGE;
  var sortProps = [], sortOrders = [];
  var maxSortColumns = AdfDhtmlPanelCollectionPeer._MAX_SORT_COLUMNS;
  for(var i = 0;i < maxSortColumns;++i) {
    var choice = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SORT_DIALOG_CHOICE_ID + i);
    if(choice != null && choice.getValue()) {
      var radio = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SORT_DIALOG_RADIO_ID + i);
      sortProps.push(choice.getValue());
      sortOrders.push("Ascending" == radio.getValue())
    }
  }
  AdfTableUtils.queueSortEvent(this._aggregatedChild, sortProps, sortOrders)
};
AdfDhtmlPanelCollectionPeer.prototype._handleShowColumnsOK = function(componentEvent) {
  var table = this._aggregatedChild;
  var component = this.getComponent(), clientId = component.getClientId();
  var page = AdfPage.PAGE;
  var shuttle = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._SHOWCOLUMNS_DIALOG_SHUTTLE_ID);
  var shuttleValue = shuttle.getSubmittedValue();
  var showColumns = this._openedDialogType == AdfDhtmlPanelCollectionPeer._DIALOG_TYPE_SHOW_COLS;
  var eventType = showColumns ? "showColumns" : "reorderColumns";
  var showEvent = new AdfTableShowColumnsEvent(table, shuttleValue, eventType);
  page.queueEventToServer(showEvent);
  if(showColumns) {
    this._updateShowColMenuItems(false, shuttleValue);
    this._checkUpdateViewMenu("multiple")
  }else {
    var columnsMenu = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_MENU_ID);
    if(columnsMenu) {
      page.addPartialTargets(columnsMenu)
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype._handleResizeColumnOK = function(componentEvent) {
  var table = this._aggregatedChild;
  var tablePeer = table.getPeer();
  var component = this.getComponent();
  var clientId = component.getClientId();
  var page = AdfPage.PAGE;
  var spinClientId = clientId + ":" + AdfDhtmlPanelCollectionPeer._RESIZECOLUMN_DIALOG_SPIN_ID;
  var spin = page.findComponent(spinClientId);
  var selectOne = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._RESIZECOLUMN_DIALOG_SELECTONE_ID);
  var colWidth = spin.getValue();
  var selectedColumns = tablePeer.__getSelectedColumns();
  var columnCount = selectedColumns.length;
  var minMaxError = false;
  var minAllowed = 1;
  var maxAllowed = 1E3;
  var selectOneValue = selectOne.getValue();
  if(selectOneValue == "Pixel") {
    minAllowed = spin.getProperty("_rszDSpnMinPix");
    if(colWidth < minAllowed) {
      minMaxError = true
    }
  }else {
    if(selectOneValue == "Percent") {
      maxAllowed = 100;
      if(colWidth < minAllowed || colWidth > maxAllowed) {
        minMaxError = true
      }
    }
  }
  if(minMaxError) {
    AdfPage.PAGE.clearMessages(spinClientId);
    var detailString = TrFastMessageFormatUtils["format"](spin.getProperty("_rszDSpnErrDtl"), null, null, minAllowed, maxAllowed);
    var message = new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR, spin.getProperty("_rszDSpnErrMsg"), detailString);
    AdfPage.PAGE.addMessage(spinClientId, message, false);
    AdfPage.PAGE.showMessages(spinClientId);
    return false
  }else {
    AdfPage.PAGE.clearMessages(spinClientId)
  }
  if(selectOneValue == "Percent") {
    colWidth = tablePeer.__getPixelWidthFromPercent(colWidth)
  }
  for(var c = 0;c < columnCount;c++) {
    colWidth = Math.max(colWidth, selectedColumns[c].getMinimumWidth())
  }
  for(var i = 0;i < columnCount;i++) {
    selectedColumns[i].setProperty(AdfRichColumn.WIDTH, colWidth, true)
  }
  return true
};
AdfDhtmlPanelCollectionPeer.prototype.wrapColumns = function() {
  var table = this._aggregatedChild;
  var leafColumns = table.getPeer().__getVisibleLeafColumns();
  var selectedColumns = [], colCount = leafColumns.length;
  for(var i = 0;i < colCount;i++) {
    var col = leafColumns[i];
    if(col && col.getSelected()) {
      selectedColumns.push(col)
    }
  }
  var noWrap;
  colCount = selectedColumns.length;
  for(var i = 0;i < colCount;i++) {
    var col = selectedColumns[i];
    if(i == 0) {
      noWrap = !col.getNoWrap()
    }
    col.setProperty(AdfRichColumn.NO_WRAP, noWrap, true);
    AdfPage.PAGE.addPartialTargets(table)
  }
};
AdfDhtmlPanelCollectionPeer.prototype.HandleComponentShowColumns = function(componentEvent) {
  if(componentEvent.getShowType() == "reorderColumn") {
    var component = this.getComponent(), clientId = component.getClientId();
    var page = AdfPage.PAGE;
    var columnsMenu = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMNS_MENU_ID);
    if(columnsMenu) {
      if(!this._hasColumnSelection) {
        page.addPartialTargets(columnsMenu)
      }else {
        var columnsContextMenu = page.findComponent(clientId + ":" + AdfDhtmlPanelCollectionPeer._COLUMN_CONTEXT_MENU_ID + AdfDhtmlPanelCollectionPeer._COLUMNS_MENU_ID);
        page.addPartialTargets(columnsMenu, columnsContextMenu)
      }
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.expandNode = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  var expandAction = null;
  var state = treeTable.getSelectedRowKeys();
  for(var prop in state) {
    AdfAssert.assert(prop != AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY, "expand node cannot be invoked on selectAll");
    isLeafNode = treeTablePeer.isLeaf(prop);
    isExpanded = treeTable.isPathExpanded(prop);
    if(expandAction == null) {
      expandAction = !isExpanded
    }
    if(!isLeafNode) {
      if(expandAction && !isExpanded) {
        treeTable.setDisclosedRowKey(prop, true);
        break
      }else {
        if(!expandAction && isExpanded) {
          treeTable.setDisclosedRowKey(prop, false);
          break
        }
      }
    }
  }
};
AdfDhtmlPanelCollectionPeer.prototype.expandAllNodesBelow = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  var state = treeTable.getSelectedRowKeys();
  for(var prop in state) {
    treeTablePeer.discloseAll(prop, true);
    break
  }
};
AdfDhtmlPanelCollectionPeer.prototype.collapseAllNodesBelow = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  var state = treeTable.getSelectedRowKeys();
  for(var prop in state) {
    treeTablePeer.discloseAll(prop, false);
    break
  }
};
AdfDhtmlPanelCollectionPeer.prototype.expandAllNodes = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  treeTablePeer.discloseAll("", true)
};
AdfDhtmlPanelCollectionPeer.prototype.collapseAllNodes = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  treeTablePeer.discloseAll("", false)
};
AdfDhtmlPanelCollectionPeer.prototype.showNodeAsTop = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  var state = treeTable.getSelectedRowKeys();
  for(var prop in state) {
    treeTablePeer.showAsTop(prop);
    break
  }
};
AdfDhtmlPanelCollectionPeer.prototype.scrollToLast = function() {
  var treeTable = this._aggregatedChild;
  treeTable.setProperty("displayRow", null, false, AdfUIComponent.PROPAGATE_NEVER);
  treeTable.setProperty("displayRow", "last", false, AdfUIComponent.PROPAGATE_ALWAYS)
};
AdfDhtmlPanelCollectionPeer.prototype.scrollToFirst = function() {
  var treeTable = this._aggregatedChild;
  treeTable.setProperty("displayRow", null, false, AdfUIComponent.PROPAGATE_NEVER);
  treeTable.setProperty("displayRow", "first", false, AdfUIComponent.PROPAGATE_ALWAYS)
};
AdfDhtmlPanelCollectionPeer.prototype.goToTopNode = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  treeTablePeer.showAsTop(null)
};
AdfDhtmlPanelCollectionPeer.prototype.goUpNode = function() {
  var treeTable = this._aggregatedChild;
  var treeTablePeer = treeTable.getPeer();
  treeTablePeer.goUp()
};
