<!--
 * Copyright (c) 2001, 2006, Oracle. All rights reserved.  
 *
 *      NAME
 *       cloneWiz_PrePost.uix
 *
 *      NOTES
 *       get pre and post scripts, if any to execute before/after OUI cloning
 *

 * MODIFIED   (MM/DD/YY)  VERSION
 *    amani    07/31/06 - Backport amani_bug-4870299 from main
 *    amani  05/02/06 - For OAC fix. 
 *    audupi   08/28/05 - Adding 'Select' button for Pre/post scripts 
 *    anusharm 07/19/05 - removing sorting in properties table 
 *    audupi   07/12/05 - 4463483 - Including summary for tables 
 *    audupi   07/07/05 - 4467739 - Addition of maximum length for text-input 
 *    gpalrech 05/09/05 - bug 4253151 - add warning icon
 *    anusharm 04/21/05 - rootAddNode instr 
 *    anusharm 04/01/05 - sudo for pre,post scripts 
 *    anusharm 02/27/05 - adding checkboxes 
 *    anusharm 02/16/05 - anusharm_clcrs
 *    anusharm 02/08/05 - creation 
 *  @author  anusharm
 *
-->

<page xmlns="http://bali.us.oracle.com/cabo/baja"
      xmlns:baja="http://bali.us.oracle.com/cabo/baja"
      xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
      xmlns:marlin="http://bali.us.oracle.com/cabo/marlin"
      xmlns:html="http://www.w3.org/TR/REC-html40"
      xmlns:data="http://bali.us.oracle.com/cabo/marlin">

 <baja:head  xmlns="http://bali.us.oracle.com/cabo/marlin"
              xmlns:uix="http://bali.us.oracle.com/cabo/marlin"
              xmlns:html="http://www.w3.org/TR/REC-html40">

   <dataScope>
      <contents>

      
      <head xmlns="http://xmlns.oracle.com/uix/ui"
         uix:title="pageTitle@getPageTitle"/>
      </contents>
      <provider>
        <data name="getPageTitle">
          <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeData" method="getPageTitle"/>
        </data>
      </provider>
    </dataScope>
 </baja:head>

    <!-- special handler to load help topic -->
    
   <handlers>
    <event name="null">
      <method class="oracle.sysman.eml.ecm.OnlineHelp"
              method="loadCloneHomeHelpTopic"/>
    </event>
   </handlers>


  <baja:content xmlns="http://bali.us.oracle.com/cabo/marlin">

   <body>
   <contents>


   <dataScope>
      <contents>

<script>
<contents>
  function doSelectPrepostScript(whichScript)
  {
    // create the path to use to invoke the LOV page
    var contextpath = document.cloneWiz_PrePost.contextPath.value;
    var path = contextpath + "ecm/cloneHome/searchSelectPrePost";
    var imagepath = document.cloneWiz_PrePost.imagePath.value;
    var redir = imagepath + "cabo/jsps/frameRedirect.jsp?redirect="+path;

    var prepostCallBackFunc = "";
    if (whichScript == "pre")
    {
      prepostCallBackFunc = processPreScriptSelection;
    }
    else if (whichScript == "post")
    {
      prepostCallBackFunc = processPostScriptSelection;
    }
    else
    {
      return false;
    }

    openWindow(top,
               redir,
               'lovWindow',
               {width:500, height:400},
                true,
                'dialog',
                prepostCallBackFunc);

    return false;

  }
  function processPreScriptSelection(lovwin, event)
  {
    var retVal = lovwin.returnValue;
    if (retVal!=(void 0))
    {
      // parse return value to get prescriptCmd+runAsRoot
      i = retVal.indexOf("+");
      if (i == 0)
      { // no pre-script.
        return;
      }
      var prescriptCmd = retVal.substr(0,i);
      document.cloneWiz_PrePost.preScriptLoc.value = prescriptCmd;
      document.cloneWiz_PrePost.preScriptChk.checked = true;
      var isPreScriptSudo = "";
      if (i != retVal.length-1)
      {
        isPreScriptSudo = retVal.substring(i+1).toLowerCase();
      }
      if ("true" == isPreScriptSudo || "1" == isPreScriptSudo)
      { // run-as-root.
        document.cloneWiz_PrePost.preSudoChk.checked = true;
      }
      else
      {
        document.cloneWiz_PrePost.preSudoChk.checked = false;
      }
    }
  }
  function processPostScriptSelection(lovwin, event)
  {
    var retVal = lovwin.returnValue;
    if (retVal!=(void 0))
    {
      // parse return value to get postscriptCmd+runAsRoot
      i = retVal.indexOf("+");
      if (i == 0)
      { // no post-script.
        return;
      }
      var postscriptCmd = retVal.substr(0,i);
      document.cloneWiz_PrePost.postScriptLoc.value = postscriptCmd;
      document.cloneWiz_PrePost.postScriptChk.checked = true;
      var isPostScriptSudo = "";
      if (i != retVal.length-1)
      {
        isPostScriptSudo = retVal.substring(i+1).toLowerCase();
      }
      if ("true" == isPostScriptSudo || "1" == isPostScriptSudo)
      { // run-as-root.
        document.cloneWiz_PrePost.postSudoChk.checked = true;
      }
      else
      {
        document.cloneWiz_PrePost.postSudoChk.checked = false;
      }
    }
  }
</contents>
</script>

        <form name="cloneWiz_PrePost" method="POST">
        <contents>
            <formValue name="FromURLHidden" uix:value="calledFrom@getInfo"/>
            <formValue name="contextPath" uix:value="contextPath@getContextPath"/>
            <formValue name="imagePath" uix:value="imagePath@getImagePath"/>

        <pageLayout xmlns="http://bali.us.oracle.com/cabo/marlin"
            uix:title="pageTitle@getHeaderTitle">

          <mediumAdvertisement>
            <include baja:node="../../oemBanner" />
          </mediumAdvertisement>

          <globalButtons>
            <include baja:node="../../globalButtonBar" />
          </globalButtons>
          <marlin:tabs>
            <include baja:node="../../globalTabs" />
          </marlin:tabs>
          <marlin:pageHeader>
            <include baja:node="../../globalHeader" />
          </marlin:pageHeader>

          <pageButtons>
            <include baja:node="cloneWiz_Footer"/>
          </pageButtons>

	  <pageStatus>
	    <styledText styleClass="OraInstructionText" uix:text="INSTR_PREPOST@ResourceBundle"/>
	  </pageStatus>

          <location>
            <include baja:node="cloneWiz_Train"/>
          </location>

          <copyright>
            <include baja:node="../../copyright"/>
          </copyright>

        <contents>

		<messageBox automatic="true" />
		<switcher uix:childName="status@prepost" childName="success">
	            <case name="failure">
		        <messageBox automatic="false"
			    uix:text="errHdr@prepost"
	                    uix:message="errMsg@prepost"
		            messageType="error" />
	            </case>
		    <case name="success">
			<stackLayout>
			<contents>

			<tableLayout width="80%" hAlign="center">
			<contents>
				
			<rowLayout>
			<contents>
			<styledText styleClass="OraInstructionText" uix:text="INSTR_TGT_PROPS@ResourceBundle"/>
			</contents>
			</rowLayout>

			<rowLayout>
			<contents>
			<table
			  width="50%"
			  name="paramTable"
			  formSubmitted="true"
			  uix:tableData="tableData@prepost"
			  uix:columnHeaderData="columnHeaderData@prepost"
        uix:summary="SUMMARY_PREPOSTTABLE@ResourceBundle">

			  <tableFormat tableBanding="rowBanding"/>

			  <columnHeaderStamp>
				<text uix:text="columnHeaderText"
					  uix:value="value"/>
				<!--<boundAttribute name="sortable">
				<defaulting>
				    <dataObject uix:source="(value)@sortColumnHeader"/>
				    <dataObject select="sort"/>
				</defaulting>
				</boundAttribute>
				</sortableHeader>-->
			  </columnHeaderStamp>

			  <columnHeaderData>
			    <col  id="hdrparam" value="param"   uix:columnHeaderText="HDR_PARAM_NAME@ResourceBundle"/>
			    <col  id="hdrdesc" value="desc"   uix:columnHeaderText="HDR_PARAM_DESC@ResourceBundle"/>
			  </columnHeaderData>

			  <contents>
			  <styledText name="param" uix:text="param" headers="hdrparam"/>
			  <styledText name="desc" uix:text="desc" headers="hdrdesc"/>
			  </contents>
			</table>
			</contents>
			</rowLayout>

			</contents>
			</tableLayout>
						
			

				<header uix:text="HDR_PRECLONE_SCRIPT@ResourceBundle">
				  <contents>
					
					<styledText styleClass="OraInstructionText" uix:text="INSTR_PRE_OP@ResourceBundle"/>
					<html:br/>
					<html:br/>
					<tableLayout>
					<contents>
					<rowLayout>
						<contents>
						<cellFormat>
						<contents>
							<checkBox name="preScriptChk" id="preScriptChk" uix:textAndAccessKey="CHK_EXECUTE@ResourceBundle" uix:checked="executePre@prepost" />
	 					</contents>
						</cellFormat>
						</contents>
					</rowLayout>

					<labeledFieldLayout columns="0" fieldWidth="0" labelWidth="200" width="0">
					<contents>
						<messageLovField columns="50" id="preScriptLoc" name="preScriptLoc" onClick="doSelectPrepostScript('pre')" uix:prompt="LBL_SCRIPT_LOC@ResourceBundle" uix:text="preScriptLoc@prepost" uix:searchDesc="STEP_PAGE_PREPOST@ResourceBundle" maximumLength="255" />
					</contents>
					</labeledFieldLayout>

					<labeledFieldLayout columns="0" fieldWidth="0" labelWidth="207" width="0">
						<contents>
						<cellFormat width="50%" hAlign="left">
						<contents>
						<checkBox name="preSudoChk" id="preSudoChk" uix:textAndAccessKey="CHK_AS_SUDO@ResourceBundle" uix:checked="executePreSudo@prepost" uix:rendered="preSudoRender@prepost"/>
						
						</contents>
						</cellFormat>
						</contents>
					</labeledFieldLayout>
					</contents>
					</tableLayout>
					

					
				  </contents>
				</header>

				<header uix:text="HDR_ROOT_SCRIPT@ResourceBundle" uix:rendered="renderRoot@prepost">
				  <contents>
					<styledText styleClass="OraInstructionText" uix:text="INSTR_ROOT_OP@ResourceBundle"/>
					<styledText styleClass="OraInstructionText" uix:text="INSTR_ROOT_ADD_NODE@ResourceBundle" uix:rendered="isCRS@prepost"/>
					<html:br/>
					<html:br/>
					
					<rowLayout>
						<contents>
						<cellFormat>
						<contents>
							<checkBox name="rootScriptChk" id="rootScriptChk" uix:textAndAccessKey="CHK_EXECUTE@ResourceBundle" uix:checked="executeRoot@prepost" />
<html:br/>
                                      <image uix:source="warningImage@prepost"/>
                                      <spacer width="3"/>
                                      <styledText styleClass="OraInlineErrorText" uix:text="ROOT_SH_WARNING@ResourceBundle"/>
	 					</contents>
						</cellFormat>
						</contents>
					</rowLayout>
					<labeledFieldLayout columns="0" fieldWidth="0" labelWidth="200" width="0">
					<contents>
						<messageTextInput columns="50" id="rootScriptLoc" name="rootScriptLoc" uix:text="rootScriptLoc@prepost" uix:prompt="LBL_SCRIPT_LOC@ResourceBundle" maximumLength="255" />
					</contents>
					</labeledFieldLayout>
				  </contents>
				</header>

				<header uix:text="HDR_POSTCLONE_SCRIPT@ResourceBundle">
				  <contents>
					<styledText styleClass="OraInstructionText" uix:text="INSTR_POST_OP@ResourceBundle"/>
					<html:br/>
					<html:br/>
					<tableLayout>
					<contents>
					<rowLayout>
						<contents>
						<cellFormat>
						<contents>
							<checkBox name="postScriptChk" id="postScriptChk" uix:textAndAccessKey="CHK_EXECUTE@ResourceBundle" uix:checked="executePost@prepost" />
	 					</contents>
						</cellFormat>
						</contents>
					</rowLayout>

					<labeledFieldLayout columns="0" fieldWidth="0" labelWidth="200" width="0">
					<contents>
						<messageLovField  columns="50" id="postScriptLoc" name="postScriptLoc" onClick="doSelectPrepostScript('post')" uix:prompt="LBL_SCRIPT_LOC@ResourceBundle" uix:text="postScriptLoc@prepost" uix:searchDesc="STEP_PAGE_PREPOST@ResourceBundle" maximumLength="255"/>
					</contents>
					</labeledFieldLayout>

					<labeledFieldLayout columns="0" fieldWidth="0" labelWidth="207" width="0">
						<contents>
						<cellFormat width="50%" hAlign="left">
						<contents>
						<checkBox name="postSudoChk" id="postSudoChk" uix:textAndAccessKey="CHK_AS_SUDO@ResourceBundle" uix:checked="executePostSudo@prepost" uix:rendered="postSudoRender@prepost"/>
						</contents>
						</cellFormat>
						</contents>
					</labeledFieldLayout>
					</contents>
					</tableLayout>

				  </contents>
				</header>
				
			</contents>
			</stackLayout>
	
		</case>
	        </switcher>

	</contents>
        </pageLayout>

     </contents>
     </form>


     </contents>

      <provider>

      <data name="ResourceBundle">
       <bundle class = "oracle.sysman.eml.ecm.cloneHome.util.CloneHomeResourceBundle"/>
      </data>

      <data name="getContextPath">
          <method class="oracle.sysman.eml.ecm.ContextPathData" 
          method="getContextPath"/>
      </data>

      <data name="getImagePath">
          <method class="oracle.sysman.eml.ecm.ContextPathData" 
          method="getImagePath"/>
      </data>

      <data name="navStep">
        <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeData"
         method="getWizardStep"/>
      </data>

      <data name="getPageTitle">
          <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeData" 
            method="getPageTitle"/>
      </data>

      <data name="getHeaderTitle">
          <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeData" 
            method="getHeaderTitle"/>
      </data>

      <data name="prepost">
          <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeData"
            method="populatePrePost"/>
      </data>

      </provider>

    </dataScope>

     </contents>
     </body>


  </baja:content>

   <handlers>

      <!-- This handles the next/prev buttons in the results table -->
 
      <event name="goto" source="homeNav">
        <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeHandler"
         method="stepNext"/>
      </event>

     <event name="cancel">
       <method class="oracle.sysman.eml.ecm.cloneHome.CloneHomeHandler"
        method="returnToCaller"/>
     </event>

  </handlers>

</page>

