Author: upul
Date: Wed Dec 12 20:26:27 2007
New Revision: 11037
Log:
added include key add, delete feature for script mediator
Modified:
trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/script_mediator.js
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_edit.xsl
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_view.xsl
Modified:
trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/script_mediator.js
==============================================================================
---
trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/script_mediator.js
(original)
+++
trunk/esb/java/modules/distribution/src/main/www/extensions/core/js/mediators/script_mediator.js
Wed Dec 12 20:26:27 2007
@@ -96,6 +96,9 @@
esbwarning("Language and Registry key must be specified",
TYPE_INFO);
return false;
}
+
+ updatescriptmediator(mediator, true);
+
}
return true;
};
@@ -202,3 +205,84 @@
var mediator = getnestedmediator(internalmodel.sequence, position);
mediator.setAttribute("language", language)
}
+
+function addScriptInclude(position) {
+ validate_save_mode = false;
+ var script_edit_div = document.getElementById("script_edit_div");
+ var mediator = getnestedmediator(internalmodel.sequence, position);
+ updatescriptmediator(mediator, false);
+
+ if (script_edit_div != null && mediator != null) {
+ var includeElement = createesbelement("<syn:include key=''
xmlns:syn='http://ws.apache.org/ns/synapse'/>");
+ mediator.appendChild(includeElement);
+ processXML(mediator, "mediators/script_edit.xsl", script_edit_div);
+ }
+}
+
+var currentIncludeIndex = null;
+function includeKeyFromRegistry(index, position) {
+ currentIncludeIndex = index;
+ var panelId = ("mypanel" + index).toString();
+ registrybrowser("saveIncludeKeyFromRegistry", "dicardregistrybrowser",
position, 1, panelId);
+}
+
+function saveIncludeKeyFromRegistry(position) {
+ var regKey = getRegistryKey();
+ var keyid = ("include_key" + currentIncludeIndex).toString();
+ var divcontrol = document.getElementById("registryPanel");
+ divcontrol.innerHTML = "";
+ var includeRef = document.getElementById(keyid.toString());
+ if (includeRef != undefined && includeRef != null) {
+ includeRef.value = regKey;
+ }
+}
+
+function includeKeyDelete(index, position) {
+ var script_edit_div = document.getElementById("script_edit_div");
+ var mediator = getnestedmediator(internalmodel.sequence, position);
+ var keyid = ("include_key" + index).toString();
+ var includeRef = document.getElementById(keyid.toString());
+
+ var deleteKey = includeRef.value;
+ var kids = mediator.childNodes;
+ var numkids = kids.length;
+ for(var i = 0; i < numkids; i++) {
+ if(kids[i].getAttribute("key") == deleteKey) {
+ mediator.removeChild(kids[i]);
+ break;
+ }
+ }
+
+ processXML(mediator, "mediators/script_edit.xsl", script_edit_div);
+}
+
+function updatescriptmediator(mediator, validate) {
+ var schemakeys = document.getElementsByName("include_key");
+ var k = schemakeys.length;
+
+ var prefix = "";
+ if (browsername.indexOf(IE_BROWSER_NAME) != -1) {
+ prefix = "syn:";
+ }
+ var existingschemakeys = mediator.getElementsByTagName(prefix + "include");
+ if (browsername.indexOf(IE_BROWSER_NAME) == -1) {
+ while (existingschemakeys.length > 0) {
+ mediator.removeChild(existingschemakeys[existingschemakeys.length
- 1]);
+ }
+ } else {
+ for(var i=0; i<existingschemakeys.length; i++) {
+ mediator.removeChild(existingschemakeys[i]);
+ }
+ }
+ var validkeyfound = false;
+ for (var x = 0; x < k; x++) {
+ if (schemakeys[x].value != undefined && schemakeys[x].value != null &&
schemakeys[x].value != "") {
+ validkeyfound = true;
+ var schemakey = createesbelement("<syn:include key='" +
schemakeys[x].value + "' xmlns:syn='http://ws.apache.org/ns/synapse'/>");
+// schemakey.setAttribute("key", schemakeys[x].value);
+ mediator.appendChild(schemakey);
+ }
+ }
+
+ return true;
+}
Modified:
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_edit.xsl
==============================================================================
---
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_edit.xsl
(original)
+++
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_edit.xsl
Wed Dec 12 20:26:27 2007
@@ -152,7 +152,7 @@
javascript:scriptkeyfromregistry('<xsl:value-of
select="@esb_med_pos"/>');return false;
</xsl:attribute>
</xsl:element>
- </td>
+ </td>
</tr>
</xsl:variable>
<xsl:variable name="function">
@@ -171,8 +171,9 @@
</input>
</td>
</tr>
- </xsl:variable>
-
+ </xsl:variable>
+
+
<xsl:if test="not(@inline or @noninline)">
<xsl:if test="not(@key)">
<table border="0" style="margin-left: 3em; width: 300px;">
@@ -190,8 +191,43 @@
<xsl:copy-of select="$language"/>
<xsl:copy-of select="$key"/>
<xsl:copy-of select="$function"/>
- </table>
- </xsl:if>
+ </table>
+
+ <div id="script_include_keys" style="margin-left:3em">
+ <br/>
+ <xsl:if test="count(self::node()//syn:include)!=0">
+ <p>Include keys</p>
+ <br/>
+ <table border="0" style="margin-left: 3em; width:
150px;">
+ <tbody>
+ <xsl:call-template
name="script_includes_template">
+ <xsl:with-param name="value">
+ <xsl:value-of
+
select="count(self::node()//syn:include)"/>
+ </xsl:with-param>
+ <xsl:with-param name="limit">
+ <xsl:value-of
+
select="count(self::node()//syn:include)"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </tbody>
+ </table>
+ </xsl:if>
+ <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:
3em;</xsl:attribute>
+ <xsl:attribute name="value">Add</xsl:attribute>
+ <xsl:attribute
name="onClick">javascript:addScriptInclude('<xsl:value-of
select="@esb_med_pos"/>');return false;
+ </xsl:attribute>
+ </xsl:element>
+ <label style='margin-left: 20px;'>Add include key</label>
+ <br/>
+ </div>
+
+
+ </xsl:if>
</xsl:if>
<xsl:if test="@inline">
@@ -208,9 +244,98 @@
<xsl:copy-of select="$language"/>
<xsl:copy-of select="$key"/>
<xsl:copy-of select="$function"/>
- </table>
+ </table>
+
+
+ <div id="script_include_keys" style="margin-left:3em">
+ <br/>
+ <xsl:if test="count(self::node()//syn:include)!=0">
+ <p>Include keys</p>
+ <br/>
+ <table border="0" style="margin-left: 3em; width:
150px;">
+ <tbody>
+ <xsl:call-template
name="script_includes_template">
+ <xsl:with-param name="value">
+ <xsl:value-of
+
select="count(self::node()//syn:include)"/>
+ </xsl:with-param>
+ <xsl:with-param name="limit">
+ <xsl:value-of
+
select="count(self::node()//syn:include)"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </tbody>
+ </table>
+ </xsl:if>
+ <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:
3em;</xsl:attribute>
+ <xsl:attribute name="value">Add</xsl:attribute>
+ <xsl:attribute
name="onClick">javascript:addScriptInclude('<xsl:value-of
select="@esb_med_pos"/>');return false;
+ </xsl:attribute>
+ </xsl:element>
+ <label style='margin-left: 20px;'>Add include key</label>
+ <br/>
+ </div>
+
+
</xsl:if>
</div>
- </xsl:template>
+ </xsl:template>
+
+ <xsl:template name="script_includes_template">
+ <xsl:param name="value"/>
+ <xsl:param name="limit"/>
+ <xsl:if test="$value != 0">
+ <xsl:call-template name="script_include_template">
+ <xsl:with-param name="index" select="($limit +1) - $value"/>
+ </xsl:call-template>
+ <xsl:call-template name="script_includes_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="script_include_template"
xmlns:syn="http://ws.apache.org/ns/synapse">
+ <xsl:param name="index"/>
+ <tr>
+ <xsl:if test="self::node()//syn:include[$index]/@key">
+ <td>
+ <xsl:text>Key</xsl:text>
+ </td>
+ <td>
+ <input type="text" size="40" name="include_key"
+ class="esb-edit_disabled">
+ <xsl:attribute name="id"><xsl:value-of
select="concat('include_key',$index)"/></xsl:attribute>
+ <xsl:attribute name="value">
+ <xsl:value-of
select="self::node()//syn:include[$index]/@key"/>
+ </xsl:attribute>
+ <xsl:attribute name="DISABLED"/>
+ </input>
+ </td>
+ <td>
+ <xsl:element name="img">
+ <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:includeKeyFromRegistry('<xsl:value-of
select="$index"/>','<xsl:value-of select="@esb_med_pos"/>');return false;
+ </xsl:attribute>
+ </xsl:element>
+ <xsl:element name="img">
+ <xsl:attribute name="src">
+ extensions/core/images/delete.gif</xsl:attribute>
+ <xsl:attribute name="title">Delete include
key</xsl:attribute>
+ <xsl:attribute name="onClick">
+ javascript:includeKeyDelete('<xsl:value-of
select="$index"/>','<xsl:value-of select="@esb_med_pos"/>');return false;
+ </xsl:attribute>
+ </xsl:element>
+ </td>
+ </xsl:if>
+ </tr>
+ </xsl:template>
</xsl:stylesheet>
\ No newline at end of file
Modified:
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_view.xsl
==============================================================================
---
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_view.xsl
(original)
+++
trunk/esb/java/modules/distribution/src/main/www/extensions/core/xslt/mediators/script_view.xsl
Wed Dec 12 20:26:27 2007
@@ -72,7 +72,13 @@
</td>
</tr>
</xsl:variable>
-
+
+ <xsl:variable name="include_header">
+ <tr>
+ <th>Include</th>
+ </tr>
+ </xsl:variable>
+
<xsl:if test="@language">
<xsl:if test="@key">
<div id="common_table_content">
@@ -88,6 +94,18 @@
</xsl:if>
</tbody>
</table>
+
+ <table border="0" cellpadding="0" cellspacing="0">
+ <tbody>
+ <xsl:copy-of select="$include_header"/>
+ <xsl:for-each select="syn:include">
+ <tr>
+ <td><xsl:value-of select="@key"/></td>
+ </tr>
+ </xsl:for-each>
+ </tbody>
+ </table>
+
</div>
</xsl:if>
_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev