&ifdef xINHOUSEx
/*!**********************************************************************

  module: wqtreebuttons.htm.6w

  -----------------------------------------------------------------------

  responsible:  Wolfgang Auer (D025911 - Wolfgang.Auer@SAP-AG.de)

  special area: SQLStudio WebSQL

  description:  window with buttons to work with stored statement tree

  see also:     

  -----------------------------------------------------------------------


************************************************************************/
&endif
<!------------------------------------------------------------------------>
<!--                                                                    -->
<!--  module: wqtreebuttons.htm                                            -->
<!--                                                                    -->
<!--  ----------------------------------------------------------------    -->
<!--                                                                    -->
<!--  special area: Web SQL                                                -->
<!--                                                                    -->
<!--  description:  window with buttons to work with stored statement   -->
<!--  tree                                                                -->
<!--                                                                    -->
<!--  see also:                                                            -->
<!--                                                                    -->
<!--  ----------------------------------------------------------------    -->
<!--                                                                    -->
<!--                                                                    -->
<!------------------------------------------------------------------------>
<script language="JavaScript">
<!--

function moveToFolder(link)
{

    var input,out,text,path,item,itemname;

    text = 'Move ';
    if(parent.isSelectedItemAPath(0) == false)

        item = 'File ';        
    else
        item = 'Folder ';        
    

    text = text + item;

    path = parent.getSelectedItemParent(0);
    //root path is not allowed
    if(path == '') return;

    itemname = parent.getSelectedItemName(0);
    //invalid item name
    if(itemname == '') return;

    text = text + itemname;
    text = text + ' to :'

    input =  prompt(text,'');    
    
    if(input){

        if(input.length > 0) {

            if(parent.checkInputString(input) == false){

                alert("Invalid "+item+"name !")
                return;
            }

            out = path +  itemname;

            document.frmHelper.actiontotake.value = out;
            document.frmHelper.newitem.value = input;
            document.frmHelper.action = link;
            document.frmHelper.target = "tree"
            document.frmHelper.submit();
            parent.frames[2].location.href = parent.CreateWebSQLURL("dsql=clear");
        }
    }
}

function renameItem(link)
{
    var input,out,text,path,item,itemname;

    text = 'Rename ';
    if(parent.isSelectedItemAPath(0) == false)

        item = 'File';        
    else
        item = 'Folder';        
    

    text = text + item + ' ';

    path = parent.getSelectedItemParent(0);
    //root path is not allowed
    if(path == '') return;

    itemname = parent.getSelectedItemName(0);
    //invalid item name
    if(itemname == '') return;

    text = text + itemname;
    text = text + ' to :'

    input =  prompt(text,'');
    
    if(input){

        if(input.length > 0) {

            if(parent.checkInputString(input) == false){

                alert("Invalid "+item+"name !");
                return;
            }

            out = path + itemname;

            document.frmHelper.actiontotake.value = out;
            document.frmHelper.newitem.value = path + input;
            document.frmHelper.action= link;
            document.frmHelper.target = "tree";
            document.frmHelper.submit();
        }
    }    
}

function createFolder(link)
{
    var path;
    var input = new String();
    var out;

    if(parent.isSelectedItemAPath(0) == false){

        alert('No Parent Folder selected !');
        return;
    }

    path = parent.getSelectedItemPath(0);
    
    input = prompt('Create Folder in ' + path +' :','New Folder');

    if(input){

        if(path == '/')
            out = path + input;
        else
            out = path + '/' + input;

        if(input.length > 0) {
            if(parent.checkInputString(input) == false){
            
                alert("Invalid Foldername !")
                return;            
            }                    
            document.frmHelper.actiontotake.value = out;
            document.frmHelper.action= link;
            document.frmHelper.target = "tree";
            document.frmHelper.submit();    
        }
    }
}

function deleteItem(link)
{
    var input,text,path;    

    text = 'Delete ';
    if(parent.isSelectedItemAPath(0) == false){

        text = text + 'File ';
        link = link+'file';        
    }
    else{
        text = text + 'Folder ';
        link = link+'folder';        
    }    
    
    path = parent.getSelectedItemPath(0);

    //root path is not allowed
    if(path == '/') return;

    text = text + path + ' ?';
    input = confirm(text);    
    
    if(input == true){

         document.frmHelper.actiontotake.value = path;
         document.frmHelper.action= link;
         document.frmHelper.target = "tree";
         document.frmHelper.submit();

         parent.frames[2].location.href = parent.CreateWebSQLURL("dsql=clear");
         
    }
}

function exportItem(link)
{
    var text;
    var path;  
      
    text = 'Delete ';
    
    if(parent.isSelectedItemAPath(0) == false){
        link = link+'file';        
    }
    else{
        link = link+'folder';        
    }    
    
    path = parent.getSelectedItemPath(0);

    document.frmHelper.actiontotake.value = path;
    document.frmHelper.action= link;
    document.frmHelper.target = "tree";
    document.frmHelper.submit();
         
}

var popupWin;

function importItem(link)
{
    var path;    
    var form;

    if(parent.isSelectedItemAPath(0) == false) {
        link = link+'file';
    }
    else{
        link = link+'folder';        
    }    
    path = parent.getSelectedItemPath(0);
    
    form = "<html>\n" +
           "    <head>\n" +
           "        <title>File Import</title>\n" +
           "        <link rel='stylesheet' href='/WARoot/Styles/sapdbweb.css' type='text/css'>\n" +
           "    </head>\n" +
           "    <body class='BdyStd' topmargin='0' leftmargin='0'>\n" +
           "        <center>\n" +
           "            <table border='0' cellspacing='0' cellpadding='0'>\n" +
           "                <tr>\n" +
           "                    <td height='10' colspan='5'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +
           "                    </td>\n" +    
           "                </tr>\n" +    
           "                <tr>\n" +
           "                    <td colspan='5'>\n" +
           "                        <center>Choose A File To Import</center>\n" +
           "                    </td>\n" +    
           "                </tr>\n" +    
           "                <tr>\n" +
           "                    <td height='10' colspan='5'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +
           "                    </td>\n" +    
           "                </tr>\n" +    
           "                <tr>\n" +
           "                    <td colspan='5' style='background:url(/WARoot/Images/1x1.gif)'>\n" +
           "                        <form name='frmImport' METHOD='POST' target='tree' action='" + 
                                     link + 
                                     "' ENCTYPE='multipart/form-data' onSubmit='setTimeout(\"window.close()\",1000)'>\n" +
           "                        <input class='input_field' type='file' name='import' size='50%'></input>\n" +
           "                    </td>\n" +
           "                </tr>\n" +
           "                <tr>\n" +
           "                    <td height='10' colspan='5'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +
           "                    </td>\n" +    
           "                </tr>\n" +    
           "                <tr>\n" +
           "                    <td width='20'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +    
           "                    </td>\n" +
           "                    <td>\n" +
           "                        <a href='javascript:document.frmImport.submit();window.close()' class='BtnEmph'>Confirm</a>\n" +
           "                    </td>\n" +
           "                    <td width='40'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +
           "                    </td>\n" +
           "                    <td>\n" +
           "                        <a href='javascript:window.close();' class='BtnStd'>Cancel</a>\n" +
           "                    </td>\n" +
           "                    <td width='20'>\n" +
           "                        <img src='/WARoot/Images/1x1.gif' width='5' height='5'>\n" +
           "                    </td>\n" +
           "                </tr>\n" +        
           "                <input type='hidden' name='actiontotake' value='" + path + "'></input>\n" +        
           "                </form>\n" +
           "            </table>\n" +
           "        </center>\n" +
           "    </body>\n" +
           "</html>\n";

    popupWin = window.open("", "puWin",  "width=480,height=150,dependent");
    popupWin.document.open("text/html", "replace");
    popupWin.document.write(form);
    popupWin.document.close();  
    popupWin.focus();  
}

function closePopup() {
    if (popupWin && popupWin.open && !popupWin.closed) popupWin.close();
}

function TreeButton(text,link,script,disable)
{
		if(disable)
			document.write(' <span class="BtnStdDsbl"><nobr>' + text + '</nobr></span>');			
		else{
			document.write('<a href= "javascript:' + script);
			document.write('(\'');
			document.write(link);
			document.write('\')"');
			document.write('class="BtnStd">' + text + '</a>');
		}
}

-->
</script>
<body class="BdyStd" topmargin="10" leftmargin="10" onUnload="closePopup()">
<table border="0" cellspacing="0" cellpadding="0">
    <form name="frmHelper" METHOD="POST" target="tree" action="?tree">
        <input type="hidden" name="actiontotake" value="">
        <input type="hidden" name="newitem" value="">
    </form>
    <tr>
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Create Folder&nbsp;&nbsp;&nbsp;',parent.CreateWebSQLURL("createnewfolder"),'createFolder',false);</script></td>    
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Rename',parent.CreateWebSQLURL("renameitem"),'renameItem',false);</script></td>
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Import&nbsp;',parent.CreateWebSQLURL("importitem"),'importItem',false);</script></td>
        <td width="10"></td>
    </tr>    
    <tr>
        <td  height="1" colspan="7" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="1" height="2"></td>                
    </tr>                    
    <tr>
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Move To Folder',parent.CreateWebSQLURL("movetofolder"),'moveToFolder',false);</script></td>
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Delete&nbsp;&nbsp;&nbsp;',parent.CreateWebSQLURL("deleteitem"),'deleteItem',false);</script></td>
        <td height="1" class="STbvCellLayout"><img src="/WARoot/Images/1x1.gif" width="5" height="1"></td>
        <td><script>TreeButton('Export',parent.CreateWebSQLFileExportURL("exportitem"),'exportItem',false);</script></td>
        <td width="10"></td>        
    </tr></table></body>


