<%@ page import="com.novell.emframe.dev.*,
                 com.novell.admin.ns.nds.NDSNamespace,
                 com.novell.application.console.snapin.ObjectEntry,
                 com.novell.admin.common.exceptions.SPIException"%>
<%@  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" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<iman:stringtable bundle="DevResources" />
<iman:stringtable bundle="FwResources" />


<%
   TaskContext taskContext = eMFrameFactory.getTaskContext(request);
   boolean isContainer = false;
   try
   {
      String targetPack = request.getParameter("eDir$target");
      String[] targets = eMFrameUtils.unpack(targetPack, taskContext);
      ObjectEntry treeOE = (ObjectEntry) taskContext.getAuthenticationBroker().getAPIObject("NDSNamespace");
      NDSNamespace ns = (NDSNamespace) treeOE.getNamespace();
      ObjectEntry objectEntry = ns.getObjectEntry(targets[0]);
      isContainer = objectEntry.getObjectType().isContainer();
   }
   catch(Throwable e)
   {
      D.log(e);
   }
%>

<SCRIPT>
   var editingIndex = -1;
   var isTargetContainer = <%= isContainer %>;
   var readOnly = <%= (String)pageContext.findAttribute("TimestampEditor_readOnly") %>;
   var singleValued = <%= (String)pageContext.findAttribute("TimestampEditor_singleValued") %>;
</SCRIPT>
<SCRIPT src="<%= session.getAttribute("ModulesPath") %>/fw/javascripts/TimestampEditorScripts.js"></SCRIPT>


<TABLE cellpadding="0" cellspacing="0">
   <TR>
      <TD>
         <SELECT name="Timestamp_Editor" id="Timestamp_Editor" size=10 style="WIDTH: 350px; height:175px;">
         <x:forEach select="$TimestampEditor_xmlNodeSet/value">
            <c:set var="secs"><x:out select="./seconds"/></c:set>
            <c:set var="replica"><x:out select="./replica"/></c:set>
            <c:set var="eventid"><x:out select="./event"/></c:set>
            <fmt:parseNumber var="rawDate"><x:out select="./seconds"/></fmt:parseNumber> 
            
            <%
               String secs = (String)pageContext.findAttribute("secs");
               String replica = (String)pageContext.findAttribute("replica");
               String eventid = (String)pageContext.findAttribute("eventid");  
               String pack = eMFrameUtils.pack(new String[]{secs, replica, eventid}, taskContext);               
            %>

            <OPTION value="<%= pack %>"><x:out select="./seconds"/> - <x:out select="./replica"/> - <x:out select="./event"/>
         </x:forEach>
         </SELECT>
      </TD>

		<% 
			String readOnly = (String)pageContext.findAttribute("TimestampEditor_readOnly");
			String singleValued = (String)pageContext.findAttribute("TimestampEditor_singleValued");
	  		if (readOnly.equalsIgnoreCase("TRUE"))
	  		{	  			
	  			if (singleValued.equalsIgnoreCase("TRUE"))
	  			{
		%>
    	  			<TD valign="top"><A href="javascript:editTimestampItem(true, true)"><IMG alt="<iman:string key="Widgets.editItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconedit.gif" border="0"></A><iman:spacer/></TD>
		<%
	  			}
	  			else
	  			{
		%>      		
					<TD valign="top"><A href="javascript:editTimestampItem(true, false)"><IMG alt="<iman:string key="Widgets.editItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconedit.gif" border="0"></A><iman:spacer/></TD>
		<%	      			
	  			}
	  		}
	  		else
			{
	  			if (singleValued.equalsIgnoreCase("TRUE"))
	  			{		  	
		%>
    	  			<TD valign="top"><A href="javascript:addTimestampItem(true)"><IMG name="addIcon" alt="<iman:string key="Widgets.addItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconadd.gif" border="0"></a><iman:spacer/></TD>
	  				<TD valign="top"><A href="javascript:deleteTimestampItem()"><IMG alt="<iman:string key="Widgets.removeItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconremove.gif" border="0"></A><iman:spacer/></TD>				
					<TD valign="top"><A href="javascript:editTimestampItem(false, true)"><IMG alt="<iman:string key="Widgets.editItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconedit.gif" border="0"></A><iman:spacer/></TD>
		<%
	  			}
	  			else
	  			{		  		
		%>      		
	      			<TD valign="top"><A href="javascript:addTimestampItem(false)"><IMG alt="<iman:string key="Widgets.addItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconadd.gif" border="0"></a><iman:spacer/></TD>
	  				<TD valign="top"><A href="javascript:deleteTimestampItem()"><IMG alt="<iman:string key="Widgets.removeItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconremove.gif" border="0"></A><iman:spacer/></TD>				
					<TD valign="top"><A href="javascript:editTimestampItem(false, false)"><IMG alt="<iman:string key="Widgets.editItem"/>" src="<%= session.getAttribute("ModulesPath") %>/dev/images/iconedit.gif" border="0"></A><iman:spacer/></TD>
		<%	      			
	  			}
			}
		%>
   </TR>
</TABLE>


