<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<iman:stringtable bundle="FwResources"/>
<iman:stringtable bundle="DevResources"/>


<HTML>
<HEAD>
   <LINK rel="stylesheet" href="<c:out value="${ContextPath}" />/portal/modules/dev/css/hf_style.css">
   <SCRIPT src="<c:out value="${ContextPath}" />/portal/modules/fw/javascripts/Studio.js"></SCRIPT>
   <iman:eMFrameScripts/>
   <iman:mvedScripts/>
   <iman:osScripts/>

   <SCRIPT>

      function showCurrentOrder()
      {
         var url = "frameservice?taskId=dev.Empty&merge=fw.Studio_pageOrder";
         window.open(url, "PageOrderDlg", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=600");
      }

      function onExit()
      {
         var openerForm = opener.document.pluginProperties;
         var form = document.form;

         openerForm.labelAboveControl.value = "" + document.form.labelAboveControl.checked;
         openerForm.displayName.value = document.form.displayName.value;

         <c:choose>
            <c:when test="${pluginType=='create'}">
               openerForm.modifyTask.value = document.form.modifyTask.value;
               openerForm.addToCreateObject.value = "" + document.form.addToCreateObject.checked;
            </c:when>
            <c:when test="${pluginType=='page'}">
               openerForm.objectTypeNameReg.value = mvGetValuesAsPack("objectTypeNameReg");

               <%-- Validate that the page order is a number between 0 and 1000 --%>

               var val = document.form.pageOrder.value;

               if(val.length>4)
               {
                  alert("<iman:string key="Studio.pageOrderErrorMsg"/>");
                  return false;
               }

               for(var i=0; i < val.length; i++)
               {
                  if(val[i]<'0' || val[i]>'9')
                  {
                     alert("<iman:string key="Studio.pageOrderErrorMsg"/>");
                     return false;
                  }
               }

               openerForm.pageOrder.value = val;

            </c:when>
            <c:otherwise>
               openerForm.mooEnabled.value = "" + document.form.mooEnabled.checked;

               openerForm.objectTypeNameReg.value = pack([document.form.objectTypeNameReg.value]);

               openerForm.tcClassName.value = form.tcClassName.options[form.tcClassName.selectedIndex].value;

               var index = document.form.tcClassName.selectedIndex;
               if(index==1)
               {
                  openerForm.tcStaticList.value = mvGetValuesAsPack("tcStaticList");
               }
               else if(index==2)
               {
                  openerForm.tcListObjectName.value = form.tcListObjectName.value;
               }
            </c:otherwise>
         </c:choose>




         window.close();
      }

      function updateTc()
      {
         var index = document.form.tcClassName.selectedIndex;

         if(index==0)
         {
            document.getElementById("tcListObjectNameDiv").style.display = "none";
            document.getElementById("tcStaticListDiv").style.display = "none";
         }
         else if(index==1)
         {
            document.getElementById("tcListObjectNameDiv").style.display = "none";
            document.getElementById("tcStaticListDiv").style.display = "block";
         }
         else if(index==2)
         {
            document.getElementById("tcListObjectNameDiv").style.display = "block";
            document.getElementById("tcStaticListDiv").style.display = "none";
         }

      }

      function doInit()
      {
         var className = "<c:out value="${tcClassName}"/>";

         if(className=="com.novell.emframe.fw.StaticListTargetChooser")
         {
            document.form.tcClassName.selectedIndex = 1;
         }
         else if(className=="com.novell.emframe.fw.ListTargetChooser")
         {
            document.form.tcClassName.selectedIndex = 2;
         }
         else
         {
            document.form.tcClassName.selectedIndex = 0;
         }

         updateTc();
      }
   </SCRIPT>
</HEAD>

<BODY onLoad="doInit()">
<FORM name="form">

   <iman:taskHeader titleKey="Studio.advancedProperties" titleBundle="FwResources"/><BR>

   <TABLE>

      <TR><TD><iman:nobr><iman:string key="Studio.displayName"/></iman:nobr></TD><TD width="100%"><INPUT type="text" name="displayName" value="<c:out value="${param.displayName}"/>" style="width:<iman:string key="UI.textboxPixel"/>"></TD></TR>
      <TR><TD colspan="2"><INPUT type="checkbox" name="labelAboveControl" value="true" <c:if test="${param.labelAboveControl=='true'}">checked</c:if>>&nbsp;<iman:string key="TaskBuilder.LabelsAboveControls"/></TD></TR>



      <iman:unpack var="objectTypeNameRegArray" value="${param.objectTypeNameReg}"/>
      <c:choose>
         <c:when test="${pluginType=='create'}">
            <TR><TD colspan="2">
               <INPUT type="checkbox" name="addToCreateObject" value="true" <c:if test="${param.addToCreateObject=='true'}">checked</c:if>><iman:string key="Studio.addToCreateObjectTask"/>
            </TD></TR>

            <c:set var="modifyTask" value="${param.modifyTask}"/>
            <c:if test="${empty modifyTask}">
               <c:set var="modifyTask" value="base.ModifyObject"/>
            </c:if>

            <TR>
               <TD nowrap><iman:string key="Studio.modifyTaskToLaunch"/></TD>
               <TD><INPUT type="text" name="modifyTask" value="<c:out value="${modifyTask}"/>"></TD>
            </TR>
         </c:when>
         <c:when test="${param.pluginType=='task'}">
            <TR><TD colspan="2"><INPUT type="checkbox" name="mooEnabled" value="true" <c:if test="${param.mooEnabled=='true'}">checked</c:if>>&nbsp;<iman:string key="TaskBuilder.MultipleObjectEnabled"/></TD></TR>
            <TR>
               <TD><iman:string key="Studio.objectType"/></TD>
               <TD>
                  <INPUT type="text" name="objectTypeNameReg" id="objectTypeNameReg" value="<c:out value="${objectTypeNameRegArray[0]}"/>" style="width:<iman:string key="UI.textboxPixel"/>">
                  <iman:objectClassBroswer fieldId="objectTypeNameReg"/>
               </TD>
            </TR>

            <TR>
               <TD nowrap valign="top"><iman:string key="Studio.targetChooser"/></TD>
               <TD>
                  <select name="tcClassName" onChange="updateTc()" style="width:<iman:string key="UI.textboxPixel"/>">
                     <option value="none"><iman:string key="Studio.defaultTc"/></option>
                     <option value="com.novell.emframe.fw.StaticListTargetChooser"><iman:string key="Studio.staticListTc"/></option>
                     <option value="com.novell.emframe.fw.ListTargetChooser"><iman:string key="Studio.listTc"/></option>
                  </select>

                  <div id="tcStaticListDiv" style="display:none">
                     <table cellpadding="0" cellspacing="0">
                        <tr>
                           <td><iman:string key="Studio.listMembers"/></td><td><iman:mved name="tcStaticList" items="${tcStaticList}" objectTypeName="*"/></td>
                        </tr>
                     </table>
                  </div>

                  <div id="tcListObjectNameDiv" style="display:none">
                     <table cellpadding="0" cellspacing="0">
                        <tr>
                           <td><iman:string key="Studio.listObject"/></td><td><input type="text" name="tcListObjectName" value="<c:out value="${tcListObjectName}"/>" style="width:<iman:string key="UI.textboxPixel"/>"/> <iman:os typeFilter="List,Group" control="tcListObjectName" /></td>
                        </tr>
                     </table>
                  </div>

               </TD>
            </TR>

         </c:when>
         <c:when test="${param.pluginType=='page'}">
            <TR>
               <TD><iman:string key="Studio.objectType"/></TD>
               <TD>
                  <TABLE cellpadding="0" cellspacing="0">
                     <TR>
                        <TD><iman:mved name="objectTypeNameReg" items="${objectTypeNameRegArray}" /></TD>
                        <TD><iman:objectClassBroswer mvedName="objectTypeNameReg" /></TD>
                     </TR>
                  </TABLE>
               </TD>
            </TR>
            <TR>
               <TD nowrap><iman:string key="Studio.pageOrderPrompt"/></TD>
               <TD><INPUT type="text" name="pageOrder" value="<c:out value="${pageOrder}"/>">&nbsp;<a href="Javascript: showCurrentOrder()"><iman:string key="Studio.seeCurrentOrder"/></a></TD>
            </TR>
         </c:when>
         <c:otherwise>
               <INPUT type="hidden" name="objectTypeNameReg" value="<c:out value="${objectTypeNameRegArray[0]}"/>">
         </c:otherwise>
      </c:choose>

   </TABLE>


   <BR>
   <iman:bar/>
   <iman:button key="OK" onClick="onExit();"/>
   <iman:button key="Cancel" onClick="window.close()"/>

   <iman:dump toResponse="false"/> 

</FORM>
</BODY>
</HTML>
