geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject svn commit: r675910 - /geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js
Date Fri, 11 Jul 2008 10:38:46 GMT
Author: shivahr
Date: Fri Jul 11 03:38:45 2008
New Revision: 675910

URL: http://svn.apache.org/viewvc?rev=675910&view=rev
Log:
GERONIMO-4192 Do syntax highlighting of the generated plan in EAR PlanCreator. Thanks to Shrey
for the patch.

Modified:
    geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js

Modified: geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js?rev=675910&r1=675909&r2=675910&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js
(original)
+++ geronimo/server/trunk/plugins/plancreator/plancreator-portlets/src/main/webapp/js/enterpriseApp.js
Fri Jul 11 03:38:45 2008
@@ -40,6 +40,45 @@
     });
 }
 
+function _formatElements(planHtml, expr, className, prefix, suffix, beg, end) {
+    var values = planHtml.match(expr);
+    if(values != null) {
+        beg = prefix.length;
+        end = suffix.length;
+        dojo.forEach(values, function(v) {
+            planHtml = planHtml.replace(v, prefix + '<span class="' + className + '">'
+ v.substring(beg,v.length-end) + '</span>' + suffix);
+        }, this);
+    }
+    return planHtml;
+}
+
+function _formatPlan(planHtml) {
+    planHTML = planHtml.replace(/\r/g, '');
+    planHTML = planHtml.replace(/\n/g, '<br/>');
+
+    // strings
+    planHtml = _formatElements(planHtml, /(=(\")(\S)+(\"))+/g, 'string', '=', '');
+    planHtml = _formatElements(planHtml, /(=(\')(\S)+(\'))+/g, 'string', "=", "");
+
+    // values
+    planHtml = _formatElements(planHtml, /&gt;(.)*?&lt;/g, 'value', "&gt;", "&lt;");
   
+    
+    // opening tags
+    values = planHtml.match(/&lt;(\S)+/g);
+    if(values) {
+        dojo.forEach(values, function(v) {
+            var end = v.indexOf('&gt;');
+            if(end != -1)
+                v = v.substring(0,end);
+            planHtml = planHtml.replace(v, '&lt;<span class="tag">' + v.substring(4)
+ '</span>');
+        }, this);
+    }
+
+    // closing tags
+    planHtml = _formatElements(planHtml, /&lt;\/(\S)+/g, 'tag', "&lt;", "&gt;");
+    return planHtml;
+}
+
 function refreshGeneratedPlan() {
     EARHelper.getGeneratedPlan(function(plan) {
         var elem = dojo.byId('generatedPlanDisplayer');
@@ -48,6 +87,7 @@
         } else {
             elem.innerText = plan;
         }
+        elem.innerHTML = _formatPlan(elem.innerHTML);
     });
 }
 
@@ -645,7 +685,7 @@
         case 'environment': saveEnvironment(); break;
         case 'references': /* saveReferences() */; break;
         case 'security': saveSecurity(); break;
-        case 'generatedPlan': saveGeneratedPlan(); break;
+        case 'generatedPlan': /* saveGeneratedPlan(); */ break;
     }
     this.currentTab = page.id;
     switch(this.currentTab) {



Mime
View raw message