Modify the pom to include 'res'
Add the factories template
Add the instances template
Add the ipojo,js retrieving the instance list
Add the factories.js retrieving the factory list
Modify the IPOJOPlugin to support the factories and
instances template as well as the JSON messages
to retrives the lists.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@963381 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/webconsole-plugin/src/main/resources/res/factories.html b/ipojo/webconsole-plugin/src/main/resources/res/factories.html
new file mode 100644
index 0000000..16a186a
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/factories.html
@@ -0,0 +1,43 @@
+<script type="text/javascript" src="${pluginRoot}/res/ui/factory.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">Factory Name</th>
+			<th class="col_Factory">Bundle</th>
+			<th class="col_State">State</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr><!-- template -->
+			<td class="name">&nbsp;	</td>
+			<td class="bundle">&nbsp;</td><!-- factory -->
+			<td class="state">&nbsp;</td><!-- state -->
+		</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/instances.html b/ipojo/webconsole-plugin/src/main/resources/res/instances.html
new file mode 100644
index 0000000..42c3cc0
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/instances.html
@@ -0,0 +1,42 @@
+<script type="text/javascript" src="${pluginRoot}/res/ui/ipojo.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">Instance Name</th>
+			<th class="col_Factory">Factory</th>
+			<th class="col_State">State</th>
+		</tr>
+	</thead>
+	<tbody>
+		<tr><!-- template -->
+			<td class="name">&nbsp;	</td>
+			<td class="factory">&nbsp;</td><!-- factory -->
+			<td class="state">&nbsp;</td><!-- state -->
+		</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
new file mode 100644
index 0000000..67f03e6
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/ui/factory.js
@@ -0,0 +1,88 @@
+/*
+ * 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 renderFactoriesData(factories)  {
+    $(".statline").html(getFactoriesStatLine(factories));
+    tableBody.empty();
+    for ( var idx in factories.data ) {
+        factoriesEntry( factories.data[idx] );
+    }
+    $("#plugin_table").trigger("update");
+}
+
+function getFactoriesStatLine(factories) {
+    return factories.count + " factories in total, "
+        + factories.valid_count + " valid factories, "
+        + factories.invalid_count + " invalid factories.";
+}
+
+function factoriesEntry(factory) {
+    var name = factory.name;
+    var state = factory.state;
+    var bundle = factory.bundle;
+
+    console.log("Create entry : " + factory);
+
+    var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'factory-' + factory.name);
+
+    _.find('td.name').html('<a href="' + window.location.pathname + '/factories/' + name + '">' + name + '</a>');
+    _.find('td.bundle').text(bundle);
+    _.find('td.state').text(state);
+}
+
+
+function loadFactoriesData() {
+    console.log("Load factories data");
+	$.get(pluginRoot + "/factories.json", null, function(data) {
+		renderFactoriesData(data);
+	}, "json");	
+}
+
+function loadInstancesData() {
+    console.log("Go to instances"); 
+    window.location=window.location.pathname + "?view=instances"
+}
+
+function loadHandlersData() {
+    console.log("Load handlers data"); 
+}
+
+var tableBody = false;
+var tableEntryTemplate = false;
+
+$(document).ready(function(){
+	tableBody = $('#plugin_table tbody');
+	tableEntryTemplate = tableBody.find('tr').clone();
+
+    loadFactoriesData();
+	
+    $(".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
new file mode 100644
index 0000000..6504308
--- /dev/null
+++ b/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.js
@@ -0,0 +1,85 @@
+/*
+ * 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 renderInstancesData(instances)  {
+    $(".statline").html(getInstancesStatLine(instances));
+    tableBody.empty();
+    for ( var idx in instances.data ) {
+        instancesEntry( instances.data[idx] );
+    }
+    $("#plugin_table").trigger("update");
+}
+
+function getInstancesStatLine(instances) {
+    return instances.count + " instances in total, "
+        + instances.valid_count + " valid instances, "
+        + instances.invalid_count + " invalid instances.";
+}
+
+function instancesEntry(instance) {
+    var name = instance.name;
+    var state = instance.state;
+    var factory = instance.factory;
+
+    var _ = tableEntryTemplate.clone().appendTo(tableBody).attr('id', 'instance-' + instance.name);
+
+    _.find('td.name').html('<a href="' + window.location.pathname + '/instance/' + name + '">' + name + '</a>');
+    _.find('td.factory').html('<a href="' + window.location.pathname + '/factory/' + factory + '">' + factory + '</a>');;
+    _.find('td.state').text(state);
+}
+
+
+function loadInstancesData() {
+	$.get(pluginRoot + "/instances.json", null, function(data) {
+		renderInstancesData(data);
+	}, "json");	
+}
+
+function loadFactoriesData() {
+    console.log("Go to factories data");
+    window.location=window.location.pathname + '?view=factories'; 
+}
+
+function loadHandlersData() {
+    console.log("Load handlers data"); 
+}
+
+var tableBody = false;
+var tableEntryTemplate = false;
+
+$(document).ready(function(){
+	tableBody = $('#plugin_table tbody');
+	tableEntryTemplate = tableBody.find('tr').clone();
+
+    loadInstancesData();
+	
+    $(".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
+	});
+});
+