⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tocresourcecontent.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.common.contextmenus;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.model.SelectItem;

import com.esri.adf.web.faces.event.TocEvent;

/**
 * Extension of {@link com.esri.solutions.jitk.web.data.TocResourceContent}
 * in order to integrate custom {@link IContextMenuItem} objects.  This
 * object depends on a managed bean within Faces named "ResourceContextMenus".
 * ResourceContextMenus is the container for all Resource Context Menu Items.
 * The ResourceContextMenuItems will be needed when building the list of
 * Context Menu Items for the Table Of Contents for GIS Resource nodes.
 * 
 * <p>
 * When a Context Menu event arrives, this implementation determines if there
 * is an associated {@link IContextMenuItem} object.  If there is an
 * association, then the {@link IContextMenuItem#handleContextMenuEvent(TocEvent)}
 * is invoked.
 * </p>
 * 
 * <p>
 * When this implementation builds the list of Context Menu Items, the list
 * will be initialized with the default Context Menu Items provided by the
 * super class.  Then, the list of {@link IContextMenuItem} objects will
 * be iterated through.  A call to {@link IResourceContextMenuItem#shouldDisplay(com.esri.adf.web.data.GISResource)}
 * is invoked.  If shouldDisplay returns <code>true</code> then
 * {@link IContextMenuItem#createSelectItem()} is invoked and the SelectItem
 * object is added to the list of Context Menu Items.
 */
public class TocResourceContent extends
		com.esri.solutions.jitk.web.data.TocResourceContent {

	private static final long serialVersionUID = -4328987962580214104L;

	/**
	 * Maps values from the SelectItem created by a Context Menu Item to
	 * the Context Menu Item object.  Used for looking up the
	 * {@link IContextMenuItem} object in order to delegate to its
	 * event handler implementation. 
	 */
	private Map<Object, IContextMenuItem> m_contextMenuItems;
	
	/**
	 * Constructs a new <code>TocResourceContent</code> object.
	 */
	public TocResourceContent () {
		m_contextMenuItems = new LinkedHashMap<Object, IContextMenuItem>();
		
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.data.TocResourceContent#getContextMenuItems()
	 */
	public List<SelectItem> getContextMenuItems() {
		List<SelectItem> items = super.getContextMenuItems();
		
		FacesContext fc = FacesContext.getCurrentInstance();
		ValueBinding vb = fc.getApplication().createValueBinding("#{ResourceContextMenus}");
		ResourceContextMenuItems contextMenuItems = (ResourceContextMenuItems) vb.getValue(fc);
		
		for (IResourceContextMenuItem menuItem : contextMenuItems.getContextMenuItems()) {
			if (!menuItem.shouldDisplay(getResource())) {
				continue;
			}
			SelectItem item = menuItem.createSelectItem();
			
			m_contextMenuItems.put(item.getValue(), menuItem);
			
			items.add(item);
		}
		
		return items;
	}


	/*
	 * (non-Javadoc)
	 * @see com.esri.adf.web.data.TocResourceContent#handleContextMenuEvent(java.lang.String, com.esri.adf.web.faces.event.TocEvent)
	 */
	public void handleContextMenuEvent(String contextMenuItemValue, TocEvent event)
			throws Exception {
		
		IContextMenuItem ctxMenuItem = m_contextMenuItems.get(contextMenuItemValue);
		
		if (ctxMenuItem != null) {
			ctxMenuItem.handleContextMenuEvent(event);
		} else {
			super.handleContextMenuEvent(contextMenuItemValue, event);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -