protected void restoreHeader() {
   layout.getNorth().setVisible(true);
   max.setImage(ThemeManager.getThemeResource(IMAGES_UPARROW_PNG));
   showHeader.setVisible(false);
   pnlHead.detach();
   headerContainer.appendChild(pnlHead);
   Clients.resize(pnlHead);
   updateHeaderCollapsedPreference(false);
 }
 protected void collapseHeader() {
   layout.getNorth().setVisible(false);
   max.setImage(ThemeManager.getThemeResource(IMAGES_DOWNARROW_PNG));
   showHeader.setVisible(true);
   pnlHead.detach();
   if (headerPopup == null) {
     headerPopup = new Window();
     headerPopup.setSclass("desktop-header-popup");
     headerPopup.setVflex("true");
     headerPopup.setVisible(false);
     headerPopup.addEventListener(
         Events.ON_OPEN,
         new EventListener<OpenEvent>() {
           @Override
           public void onEvent(OpenEvent event) throws Exception {
             if (!event.isOpen()) {
               if (showHeader.isPressed()) showHeader.setPressed(false);
             }
           }
         });
   }
   headerPopup.appendChild(pnlHead);
   updateHeaderCollapsedPreference(true);
 }
  public void onEvent(Event event) {
    Component comp = event.getTarget();
    String eventName = event.getName();

    if (eventName.equals(Events.ON_CLICK)) {
      if (comp == max) {
        if (layout.getNorth().isVisible()) {
          collapseHeader();
        } else {
          restoreHeader();
        }
      } else if (comp == showHeader) {
        showHeader.setPressed(true);
        if (pnlHead.getParent() != headerPopup) headerPopup.appendChild(pnlHead);
        LayoutUtils.openPopupWindow(showHeader, headerPopup, "after_start");
      } else if (comp == contextHelp) {
        layout.getEast().setVisible(true);
        layout.getEast().setOpen(true);
        contextHelp.setVisible(false);
        updateHelpCollapsedPreference(false);
      } else if (comp instanceof ToolBarButton) {
        ToolBarButton btn = (ToolBarButton) comp;

        if (btn.getAttribute("AD_Menu_ID") != null) {
          int menuId = (Integer) btn.getAttribute("AD_Menu_ID");
          if (menuId > 0) onMenuSelected(menuId);
        }
      }
    } else if (eventName.equals(ON_ACTIVITIES_CHANGED_EVENT)) {
      @SuppressWarnings("unchecked")
      Map<String, Object> map = (Map<String, Object>) event.getData();
      Integer notice = (Integer) map.get("notice");
      Integer request = (Integer) map.get("request");
      Integer workflow = (Integer) map.get("workflow");
      Integer unprocessed = (Integer) map.get("unprocessed");
      boolean change = false;
      if (notice != null && notice.intValue() != noOfNotice) {
        noOfNotice = notice.intValue();
        change = true;
      }
      if (request != null && request.intValue() != noOfRequest) {
        noOfRequest = request.intValue();
        change = true;
      }
      if (workflow != null && workflow.intValue() != noOfWorkflow) {
        noOfWorkflow = workflow.intValue();
        change = true;
      }
      if (unprocessed != null && unprocessed.intValue() != noOfUnprocessed) {
        noOfUnprocessed = unprocessed.intValue();
        change = true;
      }
      if (change) updateUI();
    } else if (event instanceof ZoomEvent) {
      Clients.clearBusy();
      ZoomEvent ze = (ZoomEvent) event;
      if (ze.getData() != null && ze.getData() instanceof MQuery) {
        AEnv.zoom((MQuery) ze.getData());
      }
    } else if (event instanceof DrillEvent) {
      Clients.clearBusy();
      DrillEvent de = (DrillEvent) event;
      if (de.getData() != null && de.getData() instanceof MQuery) {
        MQuery query = (MQuery) de.getData();
        executeDrill(query);
      }
    }
  }