Author: indika
Date: Mon Jan 21 01:36:04 2008
New Revision: 12576

Log:

add gui support for add resources


Modified:
   
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/proxyservices.js
   
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/commons.xsl
   
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
   
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl

Modified: 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/proxyservices.js
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/proxyservices.js
        (original)
+++ 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/js/proxyservices.js
        Mon Jan 21 01:36:04 2008
@@ -797,23 +797,20 @@
     if (browsername.indexOf(IE_BROWSER_NAME) != -1) {
         prefix = "syn:";
     }
+    var wsdl = internalmodel.proxy.getElementsByTagName(prefix + 
"publishWSDL");
 
     if (document.getElementById("wsdl_ref") != undefined) {
 
-        var refwsdl = internalmodel.proxy.getElementsByTagName(prefix + 
"publishWSDL");
-        if (refwsdl.length != 0) {
-            internalmodel.proxy.removeChild(refwsdl[0]);
+        if (wsdl.length != 0) {
+            internalmodel.proxy.removeChild(wsdl[0]);
         }
 
         if (document.getElementById("wsdl_ref").value != "") {
             internalmodel.proxy.appendChild(createesbelement(
                     "<syn:publishWSDL key='" + 
document.getElementById("wsdl_ref").value + "' 
xmlns:syn='http://ws.apache.org/ns/synapse'/>"));
         }
-    }
+    } else if (document.getElementById("wsdl_uri") != undefined) {
 
-    if (document.getElementById("wsdl_uri") != undefined) {
-
-        var wsdl = internalmodel.proxy.getElementsByTagName(prefix + 
"publishWSDL");
         if (wsdl.length != 0) {
             internalmodel.proxy.removeChild(wsdl[0]);
         }
@@ -823,6 +820,41 @@
                     "<syn:publishWSDL uri='" + 
document.getElementById("wsdl_uri").value + "' 
xmlns:syn='http://ws.apache.org/ns/synapse'/>"));
         }
     }
+
+    wsdl = internalmodel.proxy.getElementsByTagName(prefix + "publishWSDL");
+    if (wsdl == null || wsdl == undefined || wsdl.length == 0) {
+        return;
+    }
+    var existingresources = wsdl[0].getElementsByTagName(prefix + "resource");
+    if (existingresources != null) {
+        while (existingresources.length > 0) {
+            var child = existingresources[existingresources.length - 1];
+            if (child != null) {
+                wsdl[0].removeChild(child);
+            }
+        }
+    }
+    var resources = document.getElementById("wsdl_resources_id");
+    if (resources != null) {
+        if (resources.childNodes != null && resources.childNodes.length != 0) {
+            for (var i = 0; i < resources.childNodes.length; i++) {
+                var resource = resources.childNodes[i];
+                if (resource != null) {
+                    var location = resource.childNodes[0].childNodes[0].value;
+                    var key = resource.childNodes[1].childNodes[0].value;
+                    if (key != null && location != null) {
+                        if (validate) {
+                            if (key != "" && location != "") {
+                                
wsdl[0].appendChild(createesbelement("<syn:resource location='" + 
trim(location) + "'  key='" + trim(key) + "' 
xmlns:syn='http://ws.apache.org/ns/synapse'/>"));
+                            }
+                        } else {
+                            
wsdl[0].appendChild(createesbelement("<syn:resource location='" + 
trim(location) + "'  key='" + trim(key) + "' 
xmlns:syn='http://ws.apache.org/ns/synapse'/>"));
+                        }
+                    }
+                }
+            }
+        }
+    }
 };
 
 function geteditingposition() {
@@ -1701,3 +1733,59 @@
         }
     }
 }
+
+function deleteresource(location) {
+    
+    if (proxydatacollect["step4"]() == -1) {
+        return;
+    }
+
+    var wsdl = internalmodel.proxy.getElementsByTagName("publishWSDL");
+    if (wsdl == null || wsdl == undefined || wsdl.length==0) {
+        wsdl = internalmodel.proxy.getElementsByTagName("syn:publishWSDL");
+    }
+    if (wsdl == null || wsdl == undefined || wsdl.length==0) {
+        return;
+    }
+    var child = wsdl[0].childNodes[location-1];
+    if (child == null || child == undefined) {
+        return;
+    }
+    wsdl[0].removeChild(child);
+    addeditwrapper(4);
+}
+
+function addresource() {
+    
+    if (proxydatacollect["step4"]() == -1) {
+        return;
+    }
+
+    var wsdl = internalmodel.proxy.getElementsByTagName("publishWSDL");
+    if (wsdl == null || wsdl == undefined || wsdl.length == 0) {
+        wsdl = internalmodel.proxy.getElementsByTagName("syn:publishWSDL");
+    }
+    if (wsdl == null || wsdl == undefined || wsdl.length == 0) {
+        esbwarning("Resources only could be defined if either wsdl uri or 
registry key has been defined", TYPE_INFO);
+        return;
+    }
+
+    wsdl[0].appendChild(createesbelement("<syn:resource 
xmlns:syn='http://ws.apache.org/ns/synapse' location='' 
key=''></syn:resource>"));
+    addeditwrapper(4);
+}
+
+function resourcekeyfromregistry(index) {
+    var panelId = ("mypanel" + index).toString();
+    registrybrowser("saveresourcekeyfromregistry", "dicardregistrybrowser", 
index, 1, panelId);
+}
+
+function saveresourcekeyfromregistry(index) {
+    var regKey = getRegistryKey();
+    var keyid = ("resource_key" + index).toString();
+    var divcontrol = document.getElementById("registryPanel");
+    divcontrol.innerHTML = "";
+    var resourceref = document.getElementById(keyid.toString());
+    if (resourceref != undefined && resourceref != null) {
+        resourceref.value = regKey;
+    }
+}
\ No newline at end of file

Modified: 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/commons.xsl
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/commons.xsl
 (original)
+++ 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/commons.xsl
 Mon Jan 21 01:36:04 2008
@@ -86,6 +86,20 @@
         </tr>
 
     </xsl:template>
+
+    <xsl:template name="syn-resource-view">
+
+        <tr>
+            <td>
+                <xsl:value-of select="@location"/>
+            </td>
+            <td>
+                <xsl:value-of select="@key"/>
+            </td>
+        </tr>
+
+    </xsl:template>
+    
     <xsl:template name="syn-feature-edit">
         <tr>
             <xsl:attribute name="name">syn-feature</xsl:attribute>

Modified: 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
     (original)
+++ 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_edit.xsl
     Mon Jan 21 01:36:04 2008
@@ -40,7 +40,7 @@
                         </td>
                         </tr>
                         <tr>
-                        <td style="width:160px;" class="indent-small 
form-sub-field">Reference key</td>
+                        <td style="width:160px;" 
class="indent-small">Reference key</td>
                         <td align="left">
                         <input id="wsdl_ref"  type="text" size="20" 
class="esb-edit_disabled">
                             <xsl:attribute name="DISABLED"/>
@@ -61,7 +61,7 @@
                            </td>
                            </tr>
                            <tr>
-                        <td class="indent-small form-sub-field" 
style="width:160px;">
+                        <td class="indent-small" style="width:160px;">
                             Source URL
                         </td>
                         <td>
@@ -109,9 +109,48 @@
             </xsl:otherwise>
         </xsl:choose>
                </table>
+        <xsl:if test="count(self::node()//syn:resource)!=0">
+            <div style="margin-left:20px;">Resources</div>
+            <div id="common_table_content">
+                <table border="0" cellpadding="0" cellspacing="0" 
style="margin-left:10px;">
+                    <thead>
+                        <tr>
+                            <th>Location</th>
+                            <th>Key</th>
+                            <th/>
+                            <th/>
+                        </tr>
+                    </thead>
+                    <tbody id="wsdl_resources_id">
+                        <xsl:call-template name="resource_keys_template">
+                            <xsl:with-param name="value">
+                                <xsl:value-of
+                                        
select="count(self::node()//syn:resource)"/>
+                            </xsl:with-param>
+                            <xsl:with-param name="limit">
+                                <xsl:value-of
+                                        
select="count(self::node()//syn:resource)"/>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </tbody>
+                </table>
+            </div>
+        </xsl:if>
+        <xsl:if test="(syn:publishWSDL/@uri) or (syn:publishWSDL/@key) or 
((syn:publishWSDL) and not(syn:publishWSDL/@uri) and 
not(syn:publishWSDL/@key))">
+            <!--<label class="sub-small-title">Add Reference</label>           
         -->
+            <xsl:element name="input">
+                <xsl:attribute name="type">button</xsl:attribute>
+                <xsl:attribute name="class">panelbutton_default</xsl:attribute>
+                <xsl:attribute name="href">#</xsl:attribute>
+                <xsl:attribute name="style">margin-left: 20px;</xsl:attribute>
+                <xsl:attribute name="value">Add Reference</xsl:attribute>
+                <xsl:attribute name="onClick">javascript:addresource();return 
false;
+                </xsl:attribute>
+            </xsl:element>
+        </xsl:if>
         <table cellpadding="0" cellspacing="0" border="0" class="data-table">
                <tr>
-               <td style="width:170px;">Load service on startup</td>
+               <td style="width:170px;height:40px;">Load service on 
startup</td>
                <td>
                    <xsl:choose>
                        <xsl:when test="@startOnLoad != 'true'">
@@ -125,5 +164,65 @@
                </tr>
            </table>
     </xsl:template>
+    <xsl:template name="resource_keys_template">
+        <xsl:param name="value"/>
+        <xsl:param name="limit"/>
+        <xsl:if test="$value != 0">
+            <xsl:call-template name="resource_key_template">
+                <xsl:with-param name="index" select="($limit +1) - $value"/>
+            </xsl:call-template>
+            <xsl:call-template name="resource_keys_template">
+                <xsl:with-param name="value" select="$value - 1"/>
+                <xsl:with-param name="limit" select="$limit"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+    <xsl:template name="resource_key_template" 
xmlns:syn="http://ws.apache.org/ns/synapse";>
+        <xsl:param name="index"/>
+        <tr>
+            <td>
+                <input type="text" class="esb-edit" size="40"
+                       id="location">
+                    <xsl:attribute name="value">
+                        <xsl:value-of 
select="self::node()//syn:resource[$index]/@location"/>
+                    </xsl:attribute>
+                </input>
+            </td>
+            <td>
+                <input type="text" size="40" name="resource_key"
+                       class="esb-edit_disabled">
+                    <xsl:attribute name="id">
+                        <xsl:value-of select="concat('resource_key',$index)"/>
+                    </xsl:attribute>
+                    <xsl:attribute name="value">
+                        <xsl:value-of 
select="self::node()//syn:resource[$index]/@key"/>
+                    </xsl:attribute>
+                    <xsl:attribute name="DISABLED"/>
+                </input>
+            </td>
+            <td>
+                <xsl:element name="img">
+                    <xsl:attribute name="style">margin-left: 
3em;</xsl:attribute>
+                    <xsl:attribute name="src">
+                        extensions/core/images/registry_picker.gif
+                    </xsl:attribute>
+                    <xsl:attribute name="title">Registry
+                        Browser
+                    </xsl:attribute>
+                    <xsl:attribute name="onClick">
+                        javascript:resourcekeyfromregistry('<xsl:value-of 
select="$index"/>');return false;
+                    </xsl:attribute>
+                </xsl:element>
+            </td>
+            <td>
+                <a href='#' id='delete_link'>
+                    <xsl:attribute name="onclick">
+                        javascript:deleteresource('<xsl:value-of 
select="$index"/>');return false;
+                    </xsl:attribute>
+                    &#160;&#160;&#160;&#160;
+                </a>
+            </td>
+        </tr>
+    </xsl:template>
 
 </xsl:stylesheet>
\ No newline at end of file

Modified: 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl
==============================================================================
--- 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl
     (original)
+++ 
branches/esb/java/1.6/esb/java/modules/distribution/src/main/www/extensions/core/xslt/proxyservices/proxy_misc_view.xsl
     Mon Jan 21 01:36:04 2008
@@ -24,7 +24,7 @@
         <!--<label class="content-description">-->
             <!--Configure miscellaneous options for the proxy service.-->
         <!--</label>-->
-        
+
         <xsl:if test="syn:publishWSDL">
                <table cellpadding="0" cellspacing="0" border="0" 
class="data-table">
                <tr>
@@ -58,10 +58,32 @@
                     </xsl:otherwise>
             </xsl:choose>
             </table>
+            <br/>
+            <xsl:if test="count(self::node()//syn:resource)!=0">
+                <div style="margin-left:20px;">Resources</div>
+                <div id="common_table_content">
+                    <table  style="margin-left:10px;">
+                        <tr>
+                            <th>Location</th>
+                            <th>Key</th>
+                        </tr>
+                        <xsl:call-template name="resources_view_template">
+                            <xsl:with-param name="value">
+                                <xsl:value-of
+                                        
select="count(self::node()//syn:resource)"/>
+                            </xsl:with-param>
+                            <xsl:with-param name="limit">
+                                <xsl:value-of
+                                        
select="count(self::node()//syn:resource)"/>
+                            </xsl:with-param>
+                        </xsl:call-template>
+                    </table>
+                </div>
+            </xsl:if>
         </xsl:if>
         <table cellpadding="0" cellspacing="0" border="0" class="data-table">
         <tr>
-        <td style="width:170px;">Load service on startup</td>
+        <td style="width:170px;margin-left:20px;">Load service on startup</td>
         <td>
             <xsl:choose>
                 <xsl:when test="@startOnLoad != 'true'">
@@ -75,5 +97,31 @@
         </tr>
         </table>
     </xsl:template>
+    <xsl:template name="resources_view_template">
+        <xsl:param name="value"/>
+        <xsl:param name="limit"/>
+        <xsl:if test="$value != 0">
+            <xsl:call-template name="resource_view_template">
+                <xsl:with-param name="index" select="($limit +1) - $value"/>
+            </xsl:call-template>
+            <xsl:call-template name="resources_view_template">
+                <xsl:with-param name="value" select="$value - 1"/>
+                <xsl:with-param name="limit" select="$limit"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+    <xsl:template name="resource_view_template" 
xmlns:syn="http://ws.apache.org/ns/synapse";>
+        <xsl:param name="index"/>
+        <xsl:if test="(self::node()//syn:resource[$index]/@location) and 
(self::node()//syn:resource[$index]/@key)">
+        <tr>
+            <td>
+                <xsl:value-of 
select="self::node()//syn:resource[$index]/@location"/>
+            </td>
+            <td>
+                <xsl:value-of 
select="self::node()//syn:resource[$index]/@key"/>
+            </td>
+        </tr>
+        </xsl:if>
+    </xsl:template>
 
 </xsl:stylesheet>
\ No newline at end of file

_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to