<%--
<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.transformer.layout.Layout"%>
<%@ page import="com.eactive.eai.transformer.layout.LayoutItem"%>
<%@ page import="com.eactive.eai.transformer.layout.LayoutManager"%>
<%@ page import="com.eactive.eai.transformer.util.TransformKeys"%>
<%@ page import="java.util.HashMap"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-compat-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui-compat"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-compat-template"%>

<%!
	/**
	* <pre>
	* 문자열을 받아서 널이면 제로스트링을, 아니면 트림된 문자열을 리턴.
	* </pre>
	* @param	String		변환 대상
	* @return	'String'
	*/
	public static String checkNull( String str ) {

		String sResult = new String();
		if ( str == null ) {
			sResult = "";
		}
		else {
			sResult = str.trim();
		}
		return sResult;
	}
    
    StringBuffer html = new StringBuffer();
     
	private void makeItem(LayoutItem item) 
    {
        makeHTML(item);
        try{
            if (!item.isField() && (item.getChildCount() != 0)) {
                for (int i = 0; i < item.getChildCount(); i++) {
                    if (item.getChild(i).getIndex() == -1) {
                        makeItem(item.getChild(i));
                    }
                }
            }    
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("LayoutEdit.jsp error");   
        }
	}
    
    private void makeHTML(LayoutItem item) {
        
        if(item.isMessage())
            html.append("<TR align=\'center'  height=25 bgcolor='#e9e1fd'  onmouseover=this.style.background='#F6F6F6' onmouseout=this.style.background='#e9e1fd'>");
        else if (item.isGroup())
            html.append("<TR align=\'center'  height=25 bgcolor='#cbf1f8' onClick=\"javascript:goto('"+checkNull(item.getLayoutName())+"', '"+checkNull(item.getName())+"');\" onmouseover=this.style.background='#F6F6F6' onmouseout=this.style.background='#cbf1f8'>");
        else
            html.append("<TR align=\'center'  height=25 bgcolor='#ffffff' onClick=\"javascript:goto('"+checkNull(item.getLayoutName())+"', '"+checkNull(item.getName())+"');\" onmouseover=this.style.background='#F6F6F6' onmouseout=this.style.background='#FFFFFF'>");    
        
        html.append("    <TD class='txt' align=\'center'>"+item.getSeqNo()+"</td>");  
        html.append("    <td class='txt' align='left' style=\"PADDING-LEFT: 10px\">&nbsp;"+checkNull(item.getName())+"</td>");
        html.append("    <td class='txt' style=\"PADDING-LEFT: 10px\">"+TransformKeys.getLoutItemNodePtrnID(item.getNodeTypeId())+"</td>");
        html.append("    <td class='txt' style=\"PADDING-LEFT: 10px\">"+TransformKeys.getType(item.getItemTypeId())+"</td>");
        html.append("    <td class='txt' style=\"PADDING-LEFT: 10px\">"+checkNull(item.getRefInfo())+"</td> ");  
        html.append("     <td class='txt' align=\'center' style=\"PADDING-LEFT: 10px\">"+checkNull(item.getOccType())+"</td>");
        html.append("    <td class='txt' align=\'center' style=\"PADDING-LEFT: 10px\">"+item.getOccMax()+"</td>");
        html.append("    <td class='txt' align=\'center' style=\"PADDING-LEFT: 10px\">"+item.getOccMin()+"</td>");
        html.append(" </TR> ");

    }
%>

<%
    
    
    LayoutManager manager = LayoutManager.getManager();
    String key[] = manager.getAllLayoutName();
    
    String selected = request.getParameter("layoutNames");
    if(selected == null && key.length>=1) {
        selected  = key[0];
    }
   
    Layout layout = null;
  
    if(selected!=null) {
        layout = manager.getLayoutByName(selected);
    }
    
    LayoutItem root = null;
    if (layout != null)
        root = layout.getRootItem();
    
    String str = ""; 
    if (root != null ){
        makeItem(root);
        str = html.toString();
        html = new StringBuffer();
    }
    
%>


<html>
    <head>
        <title>
            Transform Layout Manager
        </title>
         <script>
        function doAction() {
            document.frm.submit();
        }
        
        function goto(layoutName, itemName) {
            
            var  one = document.frm;
            one.layoutName.value = layoutName;
            one.itemName.value = itemName;
            
            one.action = "<%=request.getContextPath()%>/mgr/transformer/layoutItem.jsp";
            one.submit();
            //var url = 'layoutItem.jsp?layoutName='+layoutName+'&itemName='+itemName;
            //msgWindow=window.open(url);
        }
        
        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>Transform Layout Configuration</b> <br><br>
        </p>
        <form name="frm" action="">
        <input type=hidden name="layoutName" value="">
        <input type=hidden name="itemName" value="">
        
        <table border='0' width="800" >
        <tr>
        <td align='left'>
        <table width="450" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' width='180' bgcolor="#ccccff"><label value="레이아웃명 : "/>&nbsp;</td>
            <td align='left'>&nbsp;<select name="layoutNames" onchange="doAction();">
            <%
                for(int i=0;i<key.length;i++) {
            %>
                <option value="<%=key[i]%>" <%= (key[i].equals(selected)) ? "selected" : "" %>><%=key[i]%>
            <%           
                }
            %></select>
            </td>
        </tr>
        </table>
        </td>

        </tr>
        </table><br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' width='350' bgcolor="#003366">&nbsp; <font color="yellow"><b>Layout정보</b> &nbsp;</font></td>
            
        </tr>

<%
    if(layout != null ){
        
%>

        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 레이아웃명 : &nbsp;</td>
            <td align='left'>&nbsp;<%=layout.getName()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 레이아웃유형명 : &nbsp;</td>
            <td align='left'>&nbsp;<%=layout.getLayoutType().getName()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 레이아웃설명 : &nbsp;</td>
            <td align='left'>&nbsp;<%=layout.getDescription()%></td>
        </tr>
        
<%
} else {
%>    
        <tr bgcolor='white'>
            <td align='center' colspan="2" >&nbsp; 요청하신 Layout 정보가 없습니다. &nbsp;</td>
        </tr>

<%
}
%>
        </table>
<br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        
        <tr bgcolor='white'>
            <td align="center" bgcolor="#ccccff">일련번호</td>
            <td align="center" bgcolor="#ccccff">레이아웃항목명</td> 
            <td align="center" bgcolor="#ccccff">노드타입</td> 
            <td align="center" bgcolor="#ccccff">항목유형</td>
            <td align="center" bgcolor="#ccccff">참조정보</td>  
            <td align="center" bgcolor="#ccccff">발생유형</td> 
            <td align="center" bgcolor="#ccccff">최대발생</td> 
            <td align="center" bgcolor="#ccccff">최소발생</td>
        </tr>
                <tr bgcolor='white'>
                    <td align='right' colspan='8' width='350' bgcolor="#003366">
                    &nbsp;
                    <font color="yellow"><b>LayoutItem 정보</b> &nbsp;</font></td>
                </tr>
        
        
        <%=str%>
        </table>
        </form>
    </body>
</html>
--%>