<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<f:subview id="tTreeStraightforwardSubviewID">
	<style type="text/css">
.LeftTreePane {
	
}

.RightTreePane {
	
}

.TreeContainer {
	overflow: auto;
	height: 400px;
	border: 3px inset gray;
}
</style>

	<a4j:outputPanel id="tTreeRNAPanelID">
		<h:panelGrid columns="1"
			rendered="#{pVisability.tTreeStraightforwardSubviewID}">
			<h:outputText value="Tree with recursiveTreeNodesAdaptor"
				style="color: red" />
			<rich:tree>
				<rich:treeNodesAdaptor nodes="#{tTreeRNA.treeRNAroots}" var="root">
					<rich:treeNode>
						<h:outputText value="#{root.name}" />
					</rich:treeNode>
					<rich:recursiveTreeNodesAdaptor var="dir" roots="#{root.dirs}"
						nodes="#{dir.dirs}">
						<rich:treeNodesAdaptor nodes="#{dir.packages}" var="package">
							<rich:treeNode>
								<h:outputText value="#{package.name}" />
							</rich:treeNode>
						</rich:treeNodesAdaptor>
						<rich:treeNode>
							<h:outputText value="#{dir.name}" />
						</rich:treeNode>
					</rich:recursiveTreeNodesAdaptor>
				</rich:treeNodesAdaptor>
			</rich:tree>
			<rich:separator height="10" />
		</h:panelGrid>
	</a4j:outputPanel>
	
	<a4j:outputPanel id="tTreeDNDPanelID">
		<h:panelGrid columns="1"
			rendered="#{pVisability.tTreeDefaultSubviewID}">
			<h:outputText value="Tree with Drag and Drop functionality"
				style="color: red" />

			<rich:dragIndicator id="treeIndicator">
				<f:facet name="single">
					<f:verbatim>{marker} {nodeParam}({treeParam})</f:verbatim>
				</f:facet>
			</rich:dragIndicator>

			<h:panelGrid columns="2" columnClasses="LeftTreePane,RightTreePane">

				<h:panelGroup id="leftContainer" layout="block"
					styleClass="TreeContainer">
					<h:outputText escape="false"
						value="Selected Node: <b>#{tTreeDND.leftSelectedNodeTitle}</b>"
						id="selectedNodeL" />

					<rich:tree id="leftTree" style="width:300px"
						nodeSelectListener="#{tTreeDND.processLSelection}"
						reRender="selectedNodeL, leftContainer" ajaxSubmitSelection="true"
						switchType="client" value="#{tTreeDND.treeNodeLeft}"
						changeExpandListener="#{tTreeDND.onExpand}"
						binding="#{tTreeDND.leftTree}"
						onselected="window.status='selectedNode: '+event.selectedNode;"
						onexpand="window.status='expandedNode: '+event.expandedNode"
						oncollapse="window.status='collapsedNode: '+event.collapsedNode"
						dropListener="#{tTreeDND.onDrop}"
						dragListener="#{tTreeDND.onDrag}" dragIndicator="treeIndicator"
						acceptedTypes="treeNodeR" dragType="treeNodeL" rowKeyVar="key"
						var="item">

						<rich:dndParam name="treeParam" value="leftTree" />
					</rich:tree>

				</h:panelGroup>

				<h:panelGroup id="rightContainer" layout="block"
					styleClass="TreeContainer">
					<h:outputText escape="false"
						value="Selected Node: <b>#{tTreeDND.rightSelectedNodeTitle}</b>"
						id="selectedNodeR" />

					<rich:tree id="rightTree" style="width:300px"
						nodeSelectListener="#{tTreeDND.processRSelection}"
						reRender="selectedNodeR,rightContainer" ajaxSubmitSelection="true"
						switchType="client" value="#{tTreeDND.treeNodeRight}"
						changeExpandListener="#{tTreeDND.onExpand}"
						binding="#{tTreeDND.rightTree}"
						onselected="window.status='selectedNode: '+event.selectedNode;"
						onexpand="window.status='expandedNode: '+event.expandedNode"
						oncollapse="window.status='collapsedNode: '+event.collapsedNode"
						rowKeyVar="key" dropListener="#{tTreeDND.onDrop}"
						dragListener="#{tTreeDND.onDrag}" dragIndicator="treeIndicator"
						acceptedTypes="treeNodeL" dragType="treeNodeR" var="item">

						<rich:dndParam name="treeParam" value="rightTree" />
					</rich:tree>
				</h:panelGroup>
			</h:panelGrid>
			<rich:separator height="10" />
		</h:panelGrid>
	</a4j:outputPanel>
</f:subview>