Add the handler list support.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@963383 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/webconsole-plugin/src/main/resources/res/handlers.html b/ipojo/webconsole-plugin/src/main/resources/res/handlers.html
new file mode 100644
index 0000000..b93da53
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/handlers.html
@@ -0,0 +1,47 @@
+<script type="text/javascript" src="${pluginRoot}/res/ui/handler.js"></script>
+
+
+<!-- status line -->
+<p class="statline">&nbsp;</p>
+
+<!-- top header -->
+<form method="post" enctype="multipart/form-data" action="">
+	<div class="ui-widget-header ui-corner-top buttonGroup">
+		<button class="instancesButton" type="button">Instances</button>
+		<button class="factoriesButton" type="button">Factories</button>
+		<button class="handlersButton" type="button">Handlers</button>
+	</div>
+</form>
+
+<table id="plugin_table" class="tablesorter nicetable noauto">
+	<thead>
+		<tr>
+			<th class="col_Name">Handler Name</th>
+            <th class="col_Type">Handler Type</th>
+			<th class="col_Bundle">Bundle</th>
+			<th class="col_State">State</th>
+            <th class="col_Missing">Missing Handlers</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr><!-- template -->
+			<td class="name">&nbsp;	</td>
+            <td class="type">&nbsp; </td>
+			<td class="bundle">&nbsp;</td>
+			<td class="state">&nbsp;</td>
+            <td class="missing">&nbsp; </td>
+		</tr>
+	</tbody>
+</table>
+
+<!-- bottom header -->
+<form method="post" enctype="multipart/form-data" action="">
+    <div class="ui-widget-header ui-corner-bottom buttonGroup">
+        <button class="instancesButton" type="button">Instances</button>
+        <button class="factoriesButton" type="button">Factories</button>
+        <button class="handlersButton" type="button">Handlers</button>
+    </div>
+</form>
+
+<!-- status line -->
+<p class="statline">&nbsp;</p>
diff --git a/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js b/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
index 67f03e6..50b8ba3 100644
--- a/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
+++ b/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
@@ -57,7 +57,7 @@
 }
 
 function loadHandlersData() {
-    console.log("Load handlers data"); 
+    window.location=window.location.pathname + "?view=handlers"
 }
 
 var tableBody = false;
diff --git a/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js b/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js
new file mode 100644
index 0000000..cddbd60
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/ui/handler.js
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *	  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+function renderHandlersData(handlers)  {
+    $(".statline").html(getHandlersStatLine(handlers));
+    tableBody.empty();
+    for ( var idx in handlers.data ) {
+        handlersEntry( handlers.data[idx] );
+    }
+    $("#plugin_table").trigger("update");
+}
+
+function getHandlersStatLine(handlers) {
+    return handlers.count + " handlers in total, "
+        + handlers.valid_count + " valid handlers, "
+        + handlers.invalid_count + " invalid handlers.";
+}
+
+function handlersEntry(handler) {
+    var name = handler.name;
+    var state = handler.state;
+    var bundle = handler.bundle;
+    var type = handler.type;
+
+    console.log("Create entry : " + handler);
+
+    var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'handler-' + handler.name);
+
+    _.find('td.name').text(name);
+    _.find('td.type').text(type);
+    _.find('td.bundle').text(bundle);
+    _.find('td.state').text(state);
+    if (handler.missing) {
+        _.find('td.missing').html(handler.missing);    
+    } else {
+        _.find('td.missing').html('<i>No missing handlers</i>');
+    }
+    
+}
+
+
+function loadHandlersData() {
+    console.log("Load handlers data");
+	$.get(pluginRoot + "/handlers.json", null, function(data) {
+		renderHandlersData(data);
+	}, "json");	
+}
+
+function loadInstancesData() {
+    window.location=window.location.pathname + "?view=instances"
+}
+
+function loadFactoriesData() {
+    window.location=window.location.pathname + "?view=factories"
+}
+
+var tableBody = false;
+var tableEntryTemplate = false;
+
+$(document).ready(function(){
+	tableBody = $('#plugin_table tbody');
+	tableEntryTemplate = tableBody.find('tr').clone();
+
+    loadHandlersData();
+	
+    $(".instancesButton").click(loadInstancesData);
+    $(".factoriesButton").click(loadFactoriesData);
+    $(".handlersButton").click(loadHandlersData);
+
+	var extractMethod = function(node) {
+		var link = node.getElementsByTagName("a");
+		if ( link && link.length == 1 ) {
+			return link[0].innerHTML;
+		}
+		return node.innerHTML;
+	};
+	$("#plugin_table").tablesorter({
+		sortList: [[1,0]],
+		textExtraction:extractMethod
+	});
+});
+
diff --git a/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js b/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
index 6504308..0fea36e 100644
--- a/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
+++ b/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
@@ -54,7 +54,7 @@
 }
 
 function loadHandlersData() {
-    console.log("Load handlers data"); 
+    window.location=window.location.pathname + "?view=handlers"
 }
 
 var tableBody = false;