<%--
  -- @(#)tasks.jsp	1.3 02/03/03
  -- Copyright 2001 Sun Microsystems, Inc., All Rights Reserved.
  -- A page to display the tasks.
  -- @version 1.3, 02/03/03
  -- @author Xuefeng Yao
  --
  --%>

<%@ page language="java" contentType="text/html" %>
<%@ taglib uri="/WEB-INF/tlds/app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/tlds/component.tld" prefix="component" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/component.tld" prefix="component" %>
<%@ page import="com.sun.jade.web.util.BreadCrumbBean" %>


<script language="JavaScript1.2" src="../js/checkbox.js">
</script>
<script language="JavaScript1.2" src="../js/util.js">
</script>


<script language="JavaScript">

 
  function LinkUp(theForm) {
      ret = numOfChecked(document.taskListForm,"taskName");
      for (var i = 0; i < theForm.actions.options.length; i++) {
	   if (theForm.actions.options[i].selected) 
	        if (theForm.actions.options[i].value == "abort") {
                    if (ret[0] == 0) {
        	          alert('<bean:message key="note.atLeastOneTaskToAbort"/>');
		          return;
                    } else {
                          document.taskListForm.submit();
                          return;
                    }

                } else if (theForm.actions.options[i].value == "reschedule") {
	             if (ret[0] == 0) {
        		  alert('<bean:message key="note.OneTaskToReschedule"/>');
			  return;
                     } else if (ret[0] > 1) {
        		  alert('<bean:message key="note.justOneTaskToReschedule"/>');
			  return;
                     }  else {
                          window.location="/jade/jsp/rescheduleTask.jsp?taskName=" + ret[1];
                     }
		
	        }
      }
         
  }

</script>


<app:taskLog />

<% 
   String sortedProperty = request.getParameter("sortedProperty");
   String sortRule = request.getParameter("sortRule");
%>

<app:sortOption/>
<jsp:setProperty name="sortOption" property="beanListName" value="tasks"/>
<jsp:setProperty name="sortOption" property="beanClassName" value="com.sun.jade.taskManager.Task"/>
<jsp:setProperty name="sortOption" property="propertyList" value="name,user,description,priority,maxDuration"/>
<jsp:setProperty name="sortOption" property="sortedProperty" value="<%=sortedProperty%>"/>
<jsp:setProperty name="sortOption" property="sortRule" value="<%=sortRule%>"/>
<app:sort/>

<html:html locale="true">

<jsp:include page="header.jsp"/>

<body bgcolor="#FFFFFF" leftmargin="0" marginwidth="0" marginheight="0" topmargin="0">

  <jsp:include page="masthead.jsp">
    <jsp:param name="category"    value="tasks"/>
  </jsp:include>

<app:breadCrumb/>

<%      
        java.util.ArrayList breadCrumb = new java.util.ArrayList();
        BreadCrumbBean bcb1 = new BreadCrumbBean();		
        bcb1.setDisplayName("tasks");      
        breadCrumb.add(bcb1);

        pageContext.setAttribute("breadCrumbBeanList",breadCrumb);
%>

<component:breadCrumb beanListName = "breadCrumbBeanList" />

<form name="taskListForm" method="POST" action="/jade/taskList.do>
<input type=hidden name="submitControl" value="">

<DIV class="content-layout">

<component:bigHorizontalSpacer />
<div class="table-title-text"><bean:message key="title.taskList"/></div>
<component:smallHorizontalSpacer />

          <select size="1" name="actions" onChange="javascript:LinkUp(this.form)">
          <option value="title"><bean:message key="option.taskActions"/></option>
          <option value="abort"><bean:message key="option.abort"/></option>
          <option value="reschedule"><bean:message key="option.reschedule"/></option>         
          </select>

<component:smallHorizontalSpacer />
<component:table propertyList="name,user,description,priority,maxDuration" 
                 categoryList="header.name,header.user,header.description,header.priority,header.maxDuration"
                 beanListName="tasks"
                 beanClassName="com.sun.jade.taskManager.Task" 
                 hasSort="yes" 
                 hasCheckbox="yes" checkboxName="taskName" checkboxValue="name" 
		 wrap="nowrap,nowrap,nowrap,nowrap,nowrap,nowrap"
                 formName="taskListForm" sourcePage="tasks.jsp" />  

</DIV>


</form>
</body>
</html:html>

