FELIX-757 : Add bundle status message

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@704914 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
index fcd415b..cc382ab 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
@@ -26,7 +26,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.felix.bundlerepository.*;
-import org.apache.felix.shell.impl.UpdateCommandImpl;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
 import org.apache.felix.webconsole.internal.obr.DeployerThread;
@@ -286,10 +285,20 @@
         return null;
     }
 
+    private void renderBundleInfoCount(final PrintWriter pw, String msg, int count)
+    throws IOException {
+        pw.print("<td class='content'>" );
+        pw.print(msg);pw.print(" : ");pw.print(count);
+        pw.print(" Bundle"); if ( count != 1) pw.print('s');
+        pw.println("</td>");
+    }
 
     protected void renderContent( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
         IOException
     {
+        Bundle bundle = getBundle( request.getPathInfo() );
+        Bundle[] bundles = ( bundle != null ) ? new Bundle[]
+            { bundle } : this.getBundles();
 
         PrintWriter pw = response.getWriter();
 
@@ -297,6 +306,24 @@
         pw.println( "<script src='" + appRoot + "/res/ui/datatable.js' language='JavaScript'></script>" );
         pw.println( "<script src='" + appRoot + "/res/ui/bundles.js' language='JavaScript'></script>" );
 
+        if ( bundles != null ) {
+            pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'><tbody>" );
+            pw.println("<tr class='content'>" );
+            renderBundleInfoCount(pw, "Available", bundles.length);
+            int active = 0, installed = 0, resolved = 0;
+            for(int i=0; i<bundles.length; i++) {
+                switch ( bundles[i].getState() ) {
+                    case Bundle.ACTIVE: active++; break;
+                    case Bundle.INSTALLED: installed++;break;
+                    case Bundle.RESOLVED: resolved++;break;
+                }
+            }
+            renderBundleInfoCount(pw, "Active", active);
+            renderBundleInfoCount(pw, "Resolved", resolved);
+            renderBundleInfoCount(pw, "Installed", installed);
+            pw.println("</tr></tbody></table>");
+        }
+
         Util.startScript( pw );
         pw.println( "var bundleListData = " );
         JSONWriter jw = new JSONWriter( pw );
@@ -310,9 +337,6 @@
             jw.key( "numActions" );
             jw.value( 4 );
 
-            Bundle bundle = getBundle( request.getPathInfo() );
-            Bundle[] bundles = ( bundle != null ) ? new Bundle[]
-                { bundle } : this.getBundles();
             boolean details = ( bundle != null );
 
             if ( bundles != null && bundles.length > 0 )
@@ -526,9 +550,9 @@
         keyVal( jw, "Description", headers.get( Constants.BUNDLE_DESCRIPTION ) );
 
         keyVal( jw, "Start Level", getStartLevel( bundle ) );
-        
+
         keyVal( jw, "Bundle Classpath", headers.get( Constants.BUNDLE_CLASSPATH ) );
-        
+
         if ( bundle.getState() == Bundle.INSTALLED )
         {
             listImportExportsUnresolved( jw, bundle );
@@ -889,7 +913,7 @@
         else
         {
             val.append( " -- Cannot be resolved" );
-            
+
             if ( optional )
             {
                 val.append( " but is not required" );
@@ -905,7 +929,7 @@
         {
             val.append( "</span>" );
         }
-        
+
         val.append( "<br />" );
     }