<%
  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
  import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
%>

<div class="UIFormWithTitle">
  <div class="TitleBar"><%=_ctx.appRes(uicomponent.getId() + ".title")%></div>
	<% uiform.begin() %>
  <div class="HorizontalLayout">
  	<table class="UIFormGrid">	  
  		<tr>
	      <td class="FieldLabel" style="display:none"><label for="id"><%=_ctx.appRes("Getmail.dialog.label.id")%></label></td>
	      <td class="FieldComponent" style="display:none">
		      <%
		        String[] fieldId = ["jcrPath=/node", "mixintype=mix:affectedNodeTypes", "editable=false", "visible=if-not-null"] ;
						uicomponent.addMixinField("id", fieldId) ;  
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="actionName"><%=_ctx.appRes("Getmail.dialog.label.name")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldName = ["jcrPath=/node/exo:name", "validate=empty,XSSValidator"];
		        uicomponent.addTextField("actionName", _ctx.appRes("Getmail.dialog.label.name"), fieldName);
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="lifecycle"><%=_ctx.appRes("Getmail.dialog.label.lifecycle")%></label></td>
	      <td class="FieldComponent">
	      <% 
          String[] fieldLifecycle = ["jcrPath=/node/exo:lifecyclePhase", 
                                     "options=read,node_added,node_removed,property_added,property_removed,property_changed",
                                     "multiValues=true", "onchange=true","size=5","validate=empty"] ;
          uicomponent.addSelectBoxField("lifecycle", fieldLifecycle) ;
        %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="protocol"><%=_ctx.appRes("Getmail.dialog.label.protocol")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldProtocol = ["jcrPath=/node/exo:protocol", "options=pop3,imap"] ; 
		        uicomponent.addSelectBoxField("protocol", fieldProtocol) 
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="host"><%=_ctx.appRes("Getmail.dialog.label.host")%></label></td>
	      <td class="FieldComponent">
		      <% 
		       	String[] fieldHost = ["jcrPath=/node/exo:host", "validate=empty"] ;
		        uicomponent.addTextField("host", fieldHost)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="port"><%=_ctx.appRes("Getmail.dialog.label.port")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldPort = ["jcrPath=/node/exo:port", "validate=empty,number"] ;
		        uicomponent.addTextField("port", fieldPort)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="folder"><%=_ctx.appRes("Getmail.dialog.label.folder")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldFolder = ["jcrPath=/node/exo:folder", "Inbox"] ;
		        uicomponent.addTextField("folder", fieldFolder)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="userName"><%=_ctx.appRes("Getmail.dialog.label.username")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldUsername = ["jcrPath=/node/exo:userName", "support@exoplatform.com", "validate=email"] ;
		        uicomponent.addTextField("userName", fieldUsername)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="password"><%=_ctx.appRes("Getmail.dialog.label.password")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldPassword = ["jcrPath=/node/exo:password", "type=password"] ;
		        uicomponent.addTextField("password", fieldPassword)  ;
		      %>
		    </td>
		  </tr>
		  <tr>                        
        <td class="FieldLabel"><label for="isDeep"><%=_ctx.appRes("Getmail.dialog.label.isDeep")%></label></td>
        <td class="FieldComponent"> 
        <% 
          String[] fieldDeep = ["jcrPath=/node/exo:isDeep", "defaultValues=true"];         
          uicomponent.addCheckBoxField("isDeep", fieldDeep);
        %>
        </td>
      </tr>
      <tr>                        
        <td class="FieldLabel"><label for="nodetypes"><%=_ctx.appRes("Getmail.dialog.label.nodetypes")%></label></td>
        <td class="FieldComponent"> 
        <% 
          String[] fieldnodetypes = ["jcrPath=/node/exo:nodeTypeName", "selectorAction=selectNodeTypes", "multiValues=true", "selectorClass=org.exoplatform.ecm.webui.nodetype.selector.UINodeTypeSelector", "selectorIcon=SelectPath24x24Icon", "validate=empty", "editable=false"];         
          uicomponent.addActionField("nodetypes", fieldnodetypes);
        %>
        </td>
      </tr>
		  <tr>
	      <td class="FieldLabel"><label for="description"><%=_ctx.appRes("Getmail.dialog.label.description")%></label></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldDescription = ["jcrPath=/node/exo:description"] ;         
						uicomponent.addTextAreaField("description", fieldDescription) ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><label for="storePath"><%=_ctx.appRes("Getmail.dialog.label.stote-path")%></label></td>
	      <td class="FieldComponent">
		      <% 
  		      def sessionProvider = WCMCoreUtils.getUserSessionProvider();
  		      def nodeHierarchyCreator = WCMCoreUtils.getService(NodeHierarchyCreator.class);
  		      def userNode = nodeHierarchyCreator.getUserNode(sessionProvider, 
  		                                                      uicomponent.getSession().getUserID());
		        def storePath = userNode.getPath() + "/Private/Mail";
		        String[] fieldStorePath = ["jcrPath=/node/exo:storePath", storePath] ;
		        uicomponent.addTextField("storePath", fieldStorePath)  ;
		      %>
		    </td>
		  </tr>
		  <tr>                       
        <td class="FieldLabel"><label for="affectedNodetypes"><%=_ctx.appRes("Getmail.dialog.label.affectedNodeTypeNames")%></label></td>
        <td class="FieldComponent">
        <% 
          String[] fieldAffectedNodetypes = ["jcrPath=/node/exo:affectedNodeTypeNames", "selectorAction=selectAffectedNodeTypes", "multiValues=true", "selectorClass=org.exoplatform.ecm.webui.nodetype.selector.UINodeTypeSelector", "selectorIcon=SelectPath24x24Icon", "validate=empty", "editable=false"];
          uicomponent.addActionField("affectedNodetypes", fieldAffectedNodetypes);
        %>
      </tr> 
		</table>
    <%/* start render action*/%>
		<%uiform.processRenderAction()%>
		<%/* end render action*/%>
  </div>
  <%uiform.end()%>
</div>