Group Renderer
com\esri\adf\sample\graphics\MyGraphicsTocLayerContent.java
/* Copyright 2010 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions.
* 
*/
package com.esri.adf.sample.graphics;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.WebOverview;
import com.esri.adf.web.data.WebToc;
import com.esri.adf.web.data.graphics.GraphicsTocLayerContent;
import com.esri.adf.web.data.query.WebQuery;
import com.esri.adf.web.faces.event.TocEvent;

public class MyGraphicsTocLayerContent extends GraphicsTocLayerContent {
  private static final long serialVersionUID = 1L;

  public static final SelectItem graphicsMenu1 = new SelectItem("Remove Layer", "Remove Layer", "Remove Layer");

  public static final ArrayList<SelectItem> commonItems = new ArrayList<SelectItem>();

  static {
    commonItems.add(graphicsMenu1);
  }

  @Override
  public List<SelectItem> getContextMenuItems() {
    return MyGraphicsTocLayerContent.commonItems;
  }

  @Override
  public void handleContextMenuEvent(String contextMenuItemValue, TocEvent args) throws Exception {
    if ("Remove Layer".equals(contextMenuItemValue)) {
      this.tocFunc.getResource().removeGraphicsLayer(this.layer);
      WebContext context = args.getWebContext();
      WebToc toc = context.getWebToc();
      if (toc != null) {
        toc.init(this.tocFunc);
      }
      WebOverview overview = context.getWebOverview();
      if (overview != null) {
        overview.exportImage();
      }
      WebQuery query = context.getWebQuery();
      if (query != null) {
        query.init(context);
      }
      context.refresh();
      return;
    }
    super.handleContextMenuEvent(contextMenuItemValue, args);
  }
}