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

📄 contextmenuitemtaskmanager.java

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

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

import javax.faces.component.UIComponent;

import org.w3c.dom.Element;

import com.esri.adf.web.util.XMLUtil;

/**
 * Manages a collection of Context Menu Item Tasks.  These are Tasks
 * that are loaded via a Context Menu Item within the Table Of
 * Contents.  This object will manage the initialization and opening
 * of a collection of Context Menu Item Tasks.  Users of this object
 * will be able open a Task via an invocation of 
 * {@link #setOpen(IContextMenuItemTask)}.  This object will also
 * handle the rendering of XML to the browser so that the browser can
 * open the appropriate Task UI.  This object will only be able to have
 * one Task open at a time.  Subsequent calls to {@link #setContextMenuItemTasks(List)}
 * will overwrite the previous Task that was to be opened.
 */
public class ContextMenuItemTaskManager {

	/**
	 * Container for Context Menu Item Tasks.
	 */
	private final List<IContextMenuItemTask> m_ctxMenuItemTasks;
	
	/**
	 * Task that should be opened in the viewer.
	 */
	private IContextMenuItemTask m_openTask;
	
	/**
	 * Constructs a new <code>ContextMenuItemTaskManager</code> and
	 * initializes the internal containers.
	 */
	public ContextMenuItemTaskManager () {
		m_ctxMenuItemTasks = new ArrayList<IContextMenuItemTask>();
	}
	
	/**
	 * Sets the collection of Context Menu Item Tasks within this
	 * object.  Each Context Menu Item Task will be initialized with
	 * this object via an invocation of 
	 * {@link IContextMenuItemTask#setContextMenuItemTaskManager(ContextMenuItemTaskManager)}.
	 * Any Context Menu Item Tasks that were set previously will be removed,
	 * before the new tasks are added.  If <code>null</code> is passed 
	 * as an argument, the collection is left intact and no operation
	 * is performed.
	 * 
	 * @param tasks  Collection of Context Menu Item Tasks.
	 */
	public void setContextMenuItemTasks (List<IContextMenuItemTask> tasks) {
		if (tasks != null) {
			m_ctxMenuItemTasks.clear();
			
			for (IContextMenuItemTask task : tasks) {
				task.setContextMenuItemTaskManager(this);
				m_ctxMenuItemTasks.add(task);
			}
		}
	}
	
	/**
	 * Sets the Context Menu Item Task to be opened.  During rendering
	 * of the response to the browser, the Task UI will be flagged to
	 * be opened within the browser.  This method is usually invoked
	 * within the event handling of a Context Menu Event.
	 * 
	 * @param task		Task to be opened.
	 */
	public void setOpen (IContextMenuItemTask task) {
		m_openTask = task;
	}

	/**
	 * Renders the necessary XML in order to flag the browser that
	 * the a Task UI is to be opened.  This method only renders XML
	 * if there was a previous call to {@link #setOpen(IContextMenuItemTask)}.
	 * 
	 * @param parentElement  Parent XML element.
	 * @param component  Reference to a UIComponent that the rendering
	 * 					is associated with, typically the {@link TocControl}.
	 */
	public void open(Element parentElement, UIComponent component) {
		
		if (m_openTask != null) {
			Element anElement = XMLUtil.createElement("context-menu-item-task", 
													  null, 
													  parentElement);
		    anElement.setAttribute("taskId", m_openTask.getTaskId());
		    m_openTask = null;
		}
	}
}

⌨️ 快捷键说明

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