<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils, com.novell.emframe.fw.FwUtils" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources"); %>
   
 <%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<iman:stringtable bundle="DevResources"/>
<iman:stringtable bundle="BaseResources"/>
<HTML>
<HEAD>
<TITLE><%= c.toDisplay(c.string("ClassInfo.Title")) %></TITLE>
<LINK rel="stylesheet" href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
</HEAD>
<STYLE>
.gray
{
background-color: #bfbfbf;
}
</STYLE>
<!------------------------------ JAVA SCRIPT STARTS HERE ------------------------------------->

<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
<SCRIPT language="JavaScript">

var w = 700;
var h = 500;
LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;
settings='width='+w+',height='+h+',top='+TopPosition+',left='+ LeftPosition+',scrollbars='+'yes'+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';

var currentClass;

function nextSelected()
{
   if (getSelectedClass())
   {
      document.ShowClassInfoForm.elements["nextState"].value="getSelectedClass";
      document.ShowClassInfoForm.elements["merge"].value="base.ShowClassInfo";
      document.ShowClassInfoForm.elements["Task.SelectedButton"].value="nextSelected";
      document.ShowClassInfoForm.submit();
   }
}

function getSelectedClass()
{
   var optOpt = document.ShowClassInfoForm.AvailableClass.options;
   var selectedItem  = document.ShowClassInfoForm.AvailableClass.selectedIndex;
   if (selectedItem >= 0 )// if nothing is selected, selectedItem = -1
   {
   		document.ShowClassInfoForm.elements["SelectedClass"].value=optOpt[selectedItem].value;
   		return true;
   }
   return false;
}

/*
This was used when optional, mandatory and naming attributes were listed in separate boxes
function infoSelected(taskid,newInstance)
{

<% if (session.getAttribute("DeviceType").equals("default")) { %>
if(checkAttrSelection())
{
currentClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
var SelectedAttr=document.ShowClassInfoForm.elements["SelectedAttribute"].value;
window.location.href="webacc?taskId="+taskid+"&SelectedAttribute="+urlEncode(SelectedAttr)+"&SelectedClass="+urlEncode(currentClass)+"&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>"
document.ShowClassInfoForm.elements["SelectedAttribute"].value="";
}
<% } else { %>
if(checkAttrSelection())
{
var SelectedAttr=document.ShowClassInfoForm.elements["SelectedAttribute"].value;
currentClass=document.ShowClassInfoForm.elements["SelectedClass"].value
// if this is the first time trying to open a new windwo then open a new window
if(!window.myWindow||myWindow.closed)
{
myWindow = window.open("webacc?taskId=" + taskid + "&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedAttribute=" + urlEncode(SelectedAttr)+ "&SelectedClass="+urlEncode(currentClass)+"&onComplete=close","",settings);
}
// else the window already has been open, don't open another window
else
{
myWindow.location="webacc?taskId=" + taskid + "&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedAttribute=" + urlEncode(SelectedAttr)+"&SelectedClass="+urlEncode(currentClass)+"&onComplete=close"
}
if(myWindow.focus)
{
myWindow.focus();
}
document.ShowClassInfoForm.elements["SelectedAttribute"].value="";
}
<% } %>
}*/
function infoSelected(taskid,newInstance,selectedAttr)
{
   <% if (session.getAttribute("DeviceType").equals("default")) { %>
      currentClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
      window.location.href="webacc?taskId="+taskid+"&SelectedAttribute="+urlEncode(selectedAttr)+"&SelectedClass="+urlEncode(currentClass)+"&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>"
   <% } else { %>
      currentClass=document.ShowClassInfoForm.elements["SelectedClass"].value
      // if this is the first time trying to open a new windwo then open a new window
      if(!window.myWindow||myWindow.closed)
      {
         myWindow = window.open("webacc?taskId=" + taskid + "&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedAttribute=" + urlEncode(selectedAttr)+ "&SelectedClass="+urlEncode(currentClass)+"&onComplete=close","",settings);
      }
      // else the window already has been open, don't open another window
      else
      {
         myWindow.location="webacc?taskId=" + taskid + "&merge=base.ShowAttrInfoFromClass&nextState=getSelectedAttribute&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedAttribute=" + urlEncode(selectedAttr)+"&SelectedClass="+urlEncode(currentClass)+"&onComplete=close"
      }
      if(myWindow.focus)
      {
         myWindow.focus();
      }
      <% } %>
      }
function addSelected(taskid,newInstance)
{
   <% if (session.getAttribute("DeviceType").equals("default")) { %>
      if(checkClassSelection())
      {
         var SelectedClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
         var url = "webacc?NPService=fw.LaunchService&NPAction=Delegate&launcher=base.ClassInformation&lifecycle=Recreate&delegate="+taskid+"&SelectedClass="+urlEncode(SelectedClass)+"&merge=base.AddAttrFromClass&nextState=getSelectedClass&Task.SelectedButton=nextSelected";

         window.location.href = url;
//         window.location.href="webacc?taskId="+taskid+"&oldTaskId=base.ClassInformation&SelectedClass="+urlEncode(SelectedClass)+"&merge=base.AddAttrFromClass&nextState=getSelectedClass&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&onComplete=return:merge=base.ShowClassInfo%26error=dev.GenErr%26Task.SelectedButton=nextSelected%26nextState=getSelectedClass%26SelectedClass="+urlEncode(SelectedClass)
      }
   <% } else { %>
   if(checkClassSelection())
   {
      var SelectedClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
      var url = "webacc?NPService=fw.LaunchService&NPAction=Launch&launcher=fw.CloseWindow&lifecycle=New&launch=" + taskid + "&merge=base.AddAttrFromClass&nextState=getSelectedClass&Task.SelectedButton=nextSelected&SelectedClass=" + urlEncode(SelectedClass);

      // if this is the first time trying to open a new windwo then open a new window
      if(!window.myWindow||myWindow.closed)
      {
         myWindow = window.open(url,"",settings);
      }
      // else the window already has been open, don't open another window
      else
      {
         window.location=url;
      }
      if(myWindow.focus)
      {
         myWindow.focus();
      }
   }
   <% } %>
}

function viewSuper(taskid,newInstance)
{
   <% if (session.getAttribute("DeviceType").equals("default")) { %>
      if(checkClassSelection())
      {
         var SelectedClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
         window.location.href="webacc?taskId="+taskid+"&oldTaskId=base.ClassInformation&SelectedClass="+urlEncode(SelectedClass)+"&merge=base.ViewSuperClass&nextState=getSuperClass&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&onComplete=return:merge=base.ShowClassInfo%26error=dev.GenErr%26Task.SelectedButton=nextSelected%26nextState=getSelectedClass%26SelectedClass="+urlEncode(SelectedClass)
      }
   <% } else { %>
      if(checkClassSelection())
      {
         var SelectedClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
         // if this is the first time trying to open a new windwo then open a new window
         if(!window.myWindow||myWindow.closed)
         {
            myWindow = window.open("webacc?taskId=" + taskid + "&merge=base.ViewSuperClass&nextState=getSuperClass&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedClass=" + urlEncode(SelectedClass)+ "&onComplete=close","",settings);
         }
         // else the window already has been open, don't open another window
         else
         {
            window.location="webacc?taskId=" + taskid + "&merge=base.ViewSuperClass&nextState=getSuperClass&Task.SelectedButton=nextSelected&User.context=<%= c.var("User.context") %>&newInstance=" + newInstance + "&SelectedClass=" + urlEncode(SelectedClass)+ "&onComplete=close"
         }
         if(myWindow.focus)
         {
            myWindow.focus();
         }
      }
   <% } %>
}
/*
function deSelect1()
{
var oOpt = document.ShowClassInfoForm.OptionalAttr.options;
var selectedItem  = document.ShowClassInfoForm.OptionalAttr.selectedIndex;
var oOptLength = document.ShowClassInfoForm.OptionalAttr.length;
for (var i = 0; i < oOptLength; i++)
{
if (oOpt[i].selected)
{
document.ShowClassInfoForm.MandatoryAttr.selectedIndex=-1;
document.ShowClassInfoForm.NamingAttr.selectedIndex=-1;
document.ShowClassInfoForm.elements["SelectedAttribute"].value=oOpt[i].value;
}
}
}
function deSelect2()
{
var mOpt = document.ShowClassInfoForm.MandatoryAttr.options;
var mOptLength = document.ShowClassInfoForm.MandatoryAttr.length;
for (var i = 0; i < mOptLength; i++)
{
if (mOpt[i].selected)
{
document.ShowClassInfoForm.OptionalAttr.selectedIndex=-1;
document.ShowClassInfoForm.NamingAttr.selectedIndex=-1;
document.ShowClassInfoForm.elements["SelectedAttribute"].value=mOpt[i].value;
}
}
}
function deSelect3()
{
var nOpt = document.ShowClassInfoForm.NamingAttr.options;
var nOptLength = document.ShowClassInfoForm.NamingAttr.length;
for (var i = 0; i < nOptLength; i++)
{
if (nOpt[i].selected)
{
document.ShowClassInfoForm.OptionalAttr.selectedIndex=-1;
document.ShowClassInfoForm.MandatoryAttr.selectedIndex=-1;
document.ShowClassInfoForm.elements["SelectedAttribute"].value=nOpt[i].value;
}
}
}*/
function checkAttrSelection()
{
   var SelectedAttr=document.ShowClassInfoForm.elements["SelectedAttribute"].value;
   if(SelectedAttr == "")
   {
      alert("<%= c.toScript(c.string("ShowClassInfo.MustSelectAttribute")) %>");
      return false;
   }
   return true;
}

function checkClassSelection()
{
   var SelectedClass=document.ShowClassInfoForm.elements["SelectedClass"].value;
   if(SelectedClass == "")
   {
      alert("<%= c.toScript(c.string("ShowClassInfo.MustSelectClass")) %>");
      return false;
   }
   return true;
}
function restore()
{

   var SelectedClass = document.ShowClassInfoForm.elements["SelectedClass"].value;
   var optOpt        = document.ShowClassInfoForm.AvailableClass.options;
   var OptLength     = document.ShowClassInfoForm.AvailableClass.length;
   if(SelectedClass != " ")
   {
      for (var i = 0; i < OptLength; i++)
      {
         if (SelectedClass == optOpt[i].value)
         {
            optOpt[i].selected=true;
         }
      }
   }
   else
   {
      document.ShowClassInfoForm.AvailableClass[0].selected=true;
   }
   document.ShowClassInfoForm.AvailableClass.focus();
//var manAttrOpt  = document.ShowClassInfoForm.MandatoryAttr.options;
//var optAttrOpt  = document.ShowClassInfoForm.OptionalAttr.options;
//var nameAttrOpt = document.ShowClassInfoForm.NamingAttr.options;
}
</SCRIPT>

<BODY text="#000000" link="#000000" vlink="#000000" alink="#000000" bgcolor="#FFFFFF"onload="restore();">
<FORM name="ShowClassInfoForm" method=post action="webacc">

<!------------------------ BEGIN WEBACCESS VARIABLES ---------------------------->

<INPUT type="hidden" name="merge" value="">
<INPUT type="hidden" name="error" value="dev.GenErr">
<INPUT type="hidden" name="User.context" value="<%= c.var("User.context") %>">
<INPUT type="hidden" name="nextState" value="">
<INPUT type="hidden" name="taskId" value="<%= c.var("taskId") %>">
<INPUT type="hidden" name="Task.SelectedButton" value="">
<INPUT type="hidden" name="SelectedClass" value="<%= c.var("SelectedClass") %>">
<INPUT type="hidden" name="SelectedAttribute" value="<%= c.var("SelectedAttribute") %>">

<% c.set("TaskHeader.title", c.string("ClassInfo.Title"));
   c.set("TaskHeader.iconUrl", "dir/schema.gif");
   c.set("TaskHeader.iconAlt", c.string("SchemaManagementDisplayName"));
   c.set("TaskHeader.helpFile", "base/schemaclass_manager.html"); %>
<jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />

<!----------------------------- CONTENT TABLE --------------------------------------->

<!--******** Selection Area *******-->

<TABLE name="ClassSelectionTable" border="0" cellspacing="0" cellpadding="2" width="100%">
   <TR valign="baseline" >
      <TD align="left" colspan="2"> &nbsp; </TD>
   </TR>
   <TR valign="baseline">
      <TD align="left" class="instructions" colspan="2"><%= c.toDisplay(c.string("ShowClassSelectClass")) %>
   </TR>
   <TR valign="baseline">
      <TD align="left" class="mediumtext" colspan="2">&nbsp;
   </TR>
   <TR valign="baseline">
      <TD align="left" class="mediumtext" colspan="2"><%= c.toDisplay(c.string("SchemaAvailCls")) %>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext" width="33%" rowspan="2">
         <SELECT name="AvailableClass" size="6" style="WIDTH: 250px">         
            <c:forEach items="${AvailableClassList}" var="className">
           		<OPTION value="<c:out value='${className}'/>"><iman:nobr><c:out value="${className}"/></iman:nobr></OPTION>         
            </c:forEach>            
         </SELECT>
         <br>
         <br>
          <a href="#" onClick="nextSelected()" onKeyDown="if(event.keyCode==13){nextSelected();}"><img src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.View.image") %>" alt="<%= c.toDisplay(c.string("Button.View.alt")) %>" title="<%= c.toDisplay(c.string("Button.View.alt")) %>" border=0/></a>
      </TD>
   </TR>
</TABLE>


<% if (c.var("SelectedClass").equals("") == false) { %>
<!---********** Information Area ********-->
<jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />

<br>
<TABLE border="0" cellspacing="0" cellpadding="2" width="100%">
   <TR valign="baseline" >
      <TD align="left" class="mediumtext" width="36%"><%= c.toDisplay(c.string("ShowClassFlags")) %>
   <TD align="left" class="mediumtext" width="64%">&nbsp;
   </TR>
   <TR valign="baseline">
      <TD width="36%" class="mediumtext">
   <TEXTAREA class="gray" name="ClassFlags" rows="4" cols="30" style="BACKGROUND-COLOR: #bfbfbf" readonly bg><% c.set("i", "0");    while (c.lt(c.var("i"), c.var("ClassInfoFlags.Count"))) { %><%= c.toDisplay(c.var("ClassInfoFlags.Element."+c.var("i"))) %><% out.print("\n");%><% c.inc("i");
   } %></TEXTAREA>
      </TD>
      <TD width="64%" class="mediumtext" valign="top">
         <p><% if (c.var("showAddAttributeLink").equals("true")) { %>&nbsp;&nbsp;<A HREF="#"onClick="javascript:addSelected('base.AddAttribute',false);return false"><%= c.toDisplay(c.string("ShowClass.AddNewAttr")) %></A><BR> <% } %>
         &nbsp;&nbsp;<A HREF="#"onClick="javascript:viewSuper('base.ClassInformation',false);return false"><%= c.toDisplay(c.string("ShowClass.ViewSuper")) %></A></p>
      </TD>
   </TR>
</TABLE>

<br>
<TABLE>
   <TR valign="baseline">
      <TD width="36%" class="mediumtext"><%= c.toDisplay(c.string("ShowClassCanBe")) %> </TD>
      <TD width="64%" class="mediumtext">&nbsp;</TD>
   </TR>
</TABLE>

<% if (c.gt(c.var("ClassInfoCont.Count"), "0")) { %>
<!--********* Container Area **********************-->
<TABLE width=170 height=65 border="2" rules="none" bgcolor="#bfbfbf" cellpadding="0" cellspacing="0">
   <TR>
      <TD class="mediumtext">
         <DIV id="scroll1" style="width:193;height:62;background-color:#bfbfbf;overflow:auto;">
            <TABLE>
            <% c.set("i", "0");
               while (c.lt(c.var("i"), c.var("ClassInfoCont.Count"))) { %>
               <TR valign="baseline">
                  <TD></TD>
                  <TD class="mediumtext"><img src="<%= c.getModulesUrl() %>/dev/images/dir/<%= c.var("ClassInfoCont.Element."+c.var("i")+ ".image") %>" alt="<%= c.toDisplay(c.var("ClassInfoCont.Element."+c.var("i"))) %>" title="<%= c.toDisplay(c.var("ClassInfoCont.Element."+c.var("i"))) %>"></TD>
                  <TD class="mediumtext"><%= c.toDisplay(c.var("ClassInfoCont.Element."+c.var("i"))) %></TD>
            <% c.inc("i");
               } %>
               </TR>
            </TABLE>
         </DIV>
      </TD>
   </TR>
</TABLE>
<% } else { %>
<TEXTAREA class="gray" name="ClassContainers" rows="3" cols="22" style="BACKGROUND-COLOR: #bfbfbf" readonly bg><% c.set("i", "0");    while (c.lt(c.var("i"), c.var("ClassInfoCont.Count"))) { %><%= c.toDisplay(c.var("ClassInfoCont.Element."+c.var("i"))) %><% c.inc("i");
   } %></TEXTAREA>
<% } %>

<br>

<TABLE>
   <TR>
      <TD class="mediumtext" width="64%"> <%= c.toDisplay(c.string("ShowClass.Attr")) %>:</TD>
   </TR>
</TABLE>

<!---********** Attribute Information Area ********-->

<TABLE width="380" height="115" border="2" rules="none" bgcolor="#bfbfbf" cellpadding="0" cellspacing="0">
   <TR>
      <TD>
         <DIV id="scroll1" style="width:373;height:115;background-color:#bfbfbf;overflow:auto;">
            <TABLE>
            <% if (c.gt(c.var("attribs.count"), "0")) { %>
               <TR>
                  <TD></TD>
                  <TD class="mediumtext"><%= c.toDisplay(c.string("ShowClass.Name")) %></TD>
                  <TD class="mediumtext"><%= c.toDisplay(c.string("ShowClass.ManAttr")) %></TD>
                  <TD class="mediumtext"><%= c.toDisplay(c.string("ShowClass.NameAttr")) %></TD>
               </TR>
            <% } %>
            <!--- Displays the attributes --->
            <% c.set("i", "0");
               while (c.lt(c.var("i"), c.var("attribs.count"))) { %>
               <TR>
                  <TD class="mediumtext"><img src="<%= c.getModulesUrl() %>/dev/images/dir/<%= c.var("attribs."+c.var("i")+ ".image") %>" alt="<%= c.toDisplay(c.var("attrbs."+c.var("i")+ ".name")) %>" title="<%= c.toDisplay(c.var("attrbs."+c.var("i")+ ".name")) %>"></TD>
                  <TD class="mediumtext"><A HREF="#" onClick="infoSelected('base.AttributeInformation',false,'<%= c.toScript(c.var("attribs."+c.var("i")+ ".name")) %>');return false;"><%= c.toDisplay(c.var("attribs."+c.var("i")+ ".name")) %></A></TD>
                  <TD align="left"><INPUT type="Checkbox" name="CB1" value="<%= c.toDisplay(c.var("attributes."+c.var("i")+ ".name")) %>" disabled <% if (c.var("attribs."+c.var("i")+ ".mandatory").equals("true")) { %> checked<% } %>></TD>
                  <TD align="left"><INPUT type="Checkbox" name="CB2" value="<%= c.toDisplay(c.var("attributes."+c.var("i")+ ".name")) %>" disabled <% if (c.var("attribs."+c.var("i")+ ".naming").equals("true")) { %> checked<% } %>></TD>
               </TR>
            <% c.inc("i");
               } %>
            </TABLE>
         </DIV>
      </TD>
   </TR>
</TABLE>

<br>
<TABLE border="0" cellspacing="0" cellpadding="2" width="90%">
   <TR valign="baseline">
      <TD align="left" class="mediumtext"><%= c.toDisplay(c.string("SchemaID")) %></TD>
   </TR>
   <TR>
      <TD rowspan=2 class="mediumtext"><INPUT class="gray" type="text" name="ClassASNID" value="<%= c.toDisplay(c.var("ASNID")) %>" size="25" readonly></TD>
   </TR>
</TABLE>
<% } %>
<!------------------------- BUTTON TABLE --------------------------->
<TABLE width="100%" border="0" cellspacing="0" cellpadding="2" height="25">
   <TR>
      <TD><jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" /></TD>
   </TR>
   <TR>
      <TD>
<!--         <A HREF="webacc?taskId=fw.HomePage&merge=fw.HomePage&User.context=<%= c.var("User.context") %>"><IMG name="Close" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Close.image") %>" alt="<%= c.toDisplay(c.string("Button.Close.alt")) %>" title="<%= c.toDisplay(c.string("Button.Close.alt")) %>" border=0></A>-->
		<iman:cancelBtn key="Close"/>
      </TD>
   </TR>
</TABLE>
</FORM>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>

