<%
  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"><%=_ctx.appRes("Getmail.dialog.label.id")%></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"><%=_ctx.appRes("Getmail.dialog.label.name")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldName = ["jcrPath=/node/exo:name", "validate=empty"];
		        uicomponent.addTextField("actionName", fieldName);
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.lifecycle")%></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"><%=_ctx.appRes("Getmail.dialog.label.protocol")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldProtocol = ["jcrPath=/node/exo:protocol", "options=pop3,imap"] ; 
		        uicomponent.addSelectBoxField("protocol", fieldProtocol) 
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.host")%></td>
	      <td class="FieldComponent">
		      <% 
		       	String[] fieldHost = ["jcrPath=/node/exo:host", "validate=empty"] ;
		        uicomponent.addTextField("host", fieldHost)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.port")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldPort = ["jcrPath=/node/exo:port", "validate=empty,number"] ;
		        uicomponent.addTextField("port", fieldPort)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.folder")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldFolder = ["jcrPath=/node/exo:folder", "Inbox"] ;
		        uicomponent.addTextField("folder", fieldFolder)  ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.username")%></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"><%=_ctx.appRes("Getmail.dialog.label.password")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldPassword = ["jcrPath=/node/exo:password", "type=password"] ;
		        uicomponent.addTextField("password", fieldPassword)  ;
		      %>
		    </td>
		  </tr>
		  <tr>                        
        <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.isDeep")%></td>
        <td class="FieldComponent"> 
        <% 
          String[] fieldDeep = ["jcrPath=/node/exo:isDeep", "defaultValues=true"];         
          uicomponent.addCheckBoxField("isDeep", fieldDeep);
        %>
        </td>
      </tr>
      <tr>                        
        <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.nodetypes")%></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"><%=_ctx.appRes("Getmail.dialog.label.description")%></td>
	      <td class="FieldComponent">
		      <% 
		        String[] fieldDescription = ["jcrPath=/node/exo:description"] ;         
						uicomponent.addTextAreaField("description", fieldDescription) ;
		      %>
		    </td>
		  </tr>
		  <tr>
	      <td class="FieldLabel"><%=_ctx.appRes("Getmail.dialog.label.stote-path")%></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"><%=_ctx.appRes("Getmail.dialog.label.affectedNodeTypeNames")%></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>