<%@ 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="treeSubviewID">
		<a4j:outputPanel ajaxRendered="true">
			<h:messages />
		</a4j:outputPanel>

		<rich:tree id="tree" switchType="#{bean.switchType}" value="#{bean.data}" var="data"
			nodeFace="#{data.name != 'param-value' ? 'input' : 'text'}" changeExpandListener="#{bean.onExpand}"
			nodeSelectListener="#{bean.onSelect}" binding="#{bean.tree}" onselected="window.status='selectedNode: '+event.selectedNode;"
			onexpand="window.status='expandedNode: '+event.expandedNode" oncollapse="window.status='collapsedNode: '+ event.collapsedNode"
			ajaxSubmitSelection="true" reRender="outputText, selectOneListbox" preserveModel="none" dragIndicator="treeIndicator"
			immediate="false" acceptedTypes="file1" dragType="#{bean.dragOn ? 'file1' : ''}" iconCollapsed="#{bean.iconCollapsed}"
			iconExpanded="#{bean.iconExpanded}" iconLeaf="#{bean.iconLeaf}" icon="#{bean.icon}" dropListener="#{bean.processDrop}"
			onclick="print('onclickInputID', 'onclick work!')" ondblclick="print('ondblclickInputID', 'ondblclick work!')"
			ondragend="print('ondragendInputID', 'ondragend work!')" ondragenter="print('ondragenterInputID', 'ondragenter work!')"
			ondragexit="print('ondragexitInputID', 'ondragexit work!')" ondragstart="print('ondragstartInputID', 'ondragstart work!')"
			ondrop="print('ondropInputID', 'ondrop work!')" ondropend="print('ondropendInputID', 'ondropend work!')"
			onkeydown="print('onkeydownInputID', 'onkeydown work!')" onkeypress="print('onkeypressInputID', 'onkeypress work!')"
			onkeyup="print('onkeyupInputID', 'onkeyup work!')" onmousedown="print('onmousedownInputID', 'onmousedown work!')"
			onmousemove="print('onmousemoveInputID', 'onmousemove work!')" onmouseout="print('onmouseoutInputID', 'onmouseout work!')"
			onmouseover="print('onmouseoverInputID', 'onmouseover work!')" onmouseup="print('onmouseupInputID', 'onmouseup work!')">

			<f:facet name="icon">
				<h:outputText value="icon" rendered="#{bean.renderFacets}" />
			</f:facet>
			<f:facet name="iconLeaf">
				<h:outputText value="leaf" rendered="#{bean.renderFacets}" />
			</f:facet>
			<f:facet name="iconExpanded">
				<h:outputText value="expanded" rendered="#{bean.renderFacets}" />
			</f:facet>
			<f:facet name="iconCollapsed">
				<h:outputText value="collapsed" rendered="#{bean.renderFacets}" />
			</f:facet>

			<dnd:dndParam name="treeParam" value="Tree Parameter" />
			<dnd:dndParam name="accept" value="accept" />

			<rich:treeNode type="input" dropListener="#{bean.processDrop}"
				oncollapse="Element.removeClassName(event['treeItem'].getElement(), 'colored')"
				onexpand="Element.addClassName(event['treeItem'].getElement(), 'colored')">
				<h:outputText value="#{data} : " />
				<h:inputText value="#{data.name}" required="true" styleClass="inputs">
				</h:inputText>

				<dnd:dndParam name="nodeParam" value="Node Parameter" />

			</rich:treeNode>
			<rich:treeNode type="text" nodeClass="customNode" acceptedTypes="file2" onselected="return false;">
				<h:outputText value="#{data}" />
			</rich:treeNode>
		</rich:tree>

		<f:verbatim>
			<br />
		</f:verbatim>

		<h:outputText value="Enter path to expand:" />
		<h:inputText value="#{bean.pathToExpand}">
			<a4j:support event="onchange" reRender="tree" action="#{bean.expandNode}" />
		</h:inputText>

		<rich:separator></rich:separator>

		<h:panelGrid columns="2">
			<h:outputText value="Change tree switchType:" />
			<h:selectOneRadio value="#{bean.switchType}" onclick="submit()">
				<f:selectItem itemLabel="client" itemValue="client" />
				<f:selectItem itemLabel="server" itemValue="server" />
				<f:selectItem itemLabel="ajax" itemValue="ajax" />
			</h:selectOneRadio>

			<h:outputText value="Drag switch:" />
			<h:selectBooleanCheckbox value="#{bean.dragOn}" onchange="submit();"></h:selectBooleanCheckbox>

			<h:outputText value="Render facets:" />
			<h:selectBooleanCheckbox value="#{bean.renderFacets}" onchange="submit();"></h:selectBooleanCheckbox>

			<h:commandButton value="#{bean.commandButtonCaption}" actionListener="#{bean.changeIcons}" />
		</h:panelGrid>

		<f:verbatim>
			<br />
			<br />
		</f:verbatim>

		<rich:tree id="testTree" var="_data" switchType="ajax" ajaxSubmitSelection="true" preserveModel="none" value="#{bean.data1}"
			nodeSelectListener="#{bean.onSelectInc}" nodeFace="node">
			<rich:treeNode type="node">
				<h:outputText value="#{_data}" />
			</rich:treeNode>
		</rich:tree>
		<rich:separator></rich:separator>
		<h:outputText value="Tree without treeNode:"></h:outputText>
		<rich:separator></rich:separator>

		<rich:tree switchType="client" style="width:300px" value="#{pathwayBean.pathwayTree}" var="item" nodeFace="#{item.type}">
			<rich:treeNode type="library">
				<h:outputText value="#{item.type}" />
			</rich:treeNode>
			<rich:treeNode type="pathway">
				<h:outputText value="#{item.name}" />
			</rich:treeNode>
			<rich:treeNode type="organism">
				<h:outputText value="#{item.name}" />
			</rich:treeNode>
		</rich:tree>

		<rich:spacer></rich:spacer>
</f:subview>
