felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r963389 - in /felix/trunk/ipojo/webconsole-plugin/src/main: java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java resources/res/ui/bundles.css resources/res/ui/factory_detail.js resources/res/ui/ipojo.css
Date Mon, 12 Jul 2010 17:42:47 GMT
Author: clement
Date: Mon Jul 12 17:42:47 2010
New Revision: 963389

URL: http://svn.apache.org/viewvc?rev=963389&view=rev
Log:
Add factory details in the webconsole plugin.

Added:
    felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/bundles.css
    felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory_detail.js
    felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.css
Modified:
    felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java

Modified: felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java?rev=963389&r1=963388&r2=963389&view=diff
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
(original)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/java/org/apache/felix/ipojo/webconsole/IPOJOPlugin.java
Mon Jul 12 17:42:47 2010
@@ -22,6 +22,7 @@ import org.apache.felix.ipojo.annotation
 import org.apache.felix.ipojo.annotations.Requires;
 import org.apache.felix.ipojo.annotations.ServiceProperty;
 import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.PropertyDescription;
 import org.apache.felix.webconsole.AbstractWebConsolePlugin;
 import org.apache.felix.webconsole.DefaultVariableResolver;
 import org.apache.felix.webconsole.WebConsoleUtil;
@@ -277,6 +278,23 @@ public class IPOJOPlugin extends Abstrac
                 data.put("services", services);
             }
             
+            PropertyDescription[] props = factory.getComponentDescription().getProperties();
+            if (props != null  && props.length != 0) {
+                JSONArray properties = new JSONArray();
+                for (int i = 0; i < props.length; i++) {
+                    JSONObject prop = new JSONObject();
+                    prop.put("name", props[i].getName());
+                    prop.put("type", props[i].getType());
+                    prop.put("mandatory", props[i].isMandatory());
+                    prop.put("immutable", props[i].isImmutable());
+                    if (props[i].getValue() != null) {
+                        prop.put("value", props[i].getValue());
+                    }
+                    properties.put(prop);
+                }
+                data.put("properties", properties);
+            }
+            
             if (! factory.getRequiredHandlers().isEmpty()) {
                 JSONArray req = new JSONArray
                     (factory.getRequiredHandlers());

Added: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/bundles.css
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/bundles.css?rev=963389&view=auto
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/bundles.css (added)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/bundles.css Mon Jul 12 17:42:47
2010
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#optionalData {
+	margin: 0;
+	padding: 0;
+}
+
+th.col_Symbolic_Name { width: 9em }
+th.col_Version,
+th.col_Status   { width: 7em }
+th.col_Actions { width: 121px }
+.filterBox      { float: left; margin-left: 1em }
+.symName                 { font-style: italic }
+.symName:before { content: " (" }
+.symName:after   { content: ")"  }
+.filterClear        { display: inline-block; vertical-align: middle }
+.bIcon, .bName   { display: inline-block }
+.bIcon { float: left }
\ No newline at end of file

Added: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory_detail.js
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory_detail.js?rev=963389&view=auto
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory_detail.js (added)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/factory_detail.js Mon Jul
12 17:42:47 2010
@@ -0,0 +1,160 @@
+/*
+ * 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 renderFactoryDetails(data)  {
+    $(".statline").html(getFactoriesStatLine(data));
+    createDetail( data.data );
+    //$("#plugin_table").trigger("update");
+}
+
+function getFactoriesStatLine(factories) {
+    return factories.count + " factories in total, "
+        + factories.valid_count + " valid factories, "
+        + factories.invalid_count + " invalid factories.";
+}
+
+function createDetail(factory) {
+    console.log("Create details");
+    var name = factory.name;
+    var state = factory.state;
+    var bundle = factory.bundle;
+    var service = "No provided services"
+    
+    console.log("Create entry : " + factory);
+
+    var _ = tableBody;
+    
+    // Set the name
+    _.find('td.Vname').html(factory.name);
+    // Set the bundle //TODO we can create a link here ?
+    _.find('td.Vbundle').text(factory.bundle);
+    // Set the state
+    _.find('td.Vstate').text(factory.state);
+    
+    // Set the services
+    // If define, use a list
+    if (factory.services) {
+        var list = $('<ul>');
+        for (var s in factory.services) {
+            list.append($('<li>').append(factory.services[s]));
+        }
+        _.find('td.Vservices').html(list);
+    } else { // Undefined
+        _.find('td.Vservices').html('<i>No provided service specifications</i>');
+    }
+    
+    // Set the properties
+    $(tablePropBody).empty();
+    if (factory.properties) {
+        for (var s in factory.properties) {
+            var prop = factory.properties[s];
+            // For each properties clone the template
+            var entry = propEntryTemplate.clone().appendTo(tablePropBody).attr('id', 'property-'
+ prop.name);
+            entry.find('td.name').text(prop.name);
+            entry.find('td.type').text(prop.type);
+            entry.find('td.mandatory').text(prop.mandatory);
+            entry.find('td.immutable').text(prop.immutable);
+            if (prop.value) {
+                entry.find('td.value').text(prop.value);
+            } else {
+                entry.find('td.value').html('<i>No default value</i>');
+            }
+        }
+    } else {
+        // Hide the table
+        $('table.properties').hide();
+    }
+        
+    // Set the required handlers.
+    if (factory.requiredHandlers) {
+        var list = $('<ul>');
+        for (var s in factory.requiredHandlers) {
+            list.append($('<li>').append(factory.requiredHandlers[s]));
+        }
+        _.find('td.VrequiredHandlers').html(list);
+    } else { // Undefined
+        _.find('td.VrequiredHandlers').html('<i>No required handlers</i>');
+    }
+    
+    // Set the missing handlers.
+    if (factory.missingHandlers) {
+        var list = $('<ul>');
+        for (var s in factory.missingHandlers) {
+            list.append($('<li>').append(factory.missingHandlers[s]));
+        }
+        _.find('td.VmissingHandlers').html(list);
+    } else { // Undefined
+        _.find('td.VmissingHandlers').html('<i>No missing handlers</i>');
+    }
+    
+    // Set the created instances.
+    if (factory.instances) {
+        var list = $('<ul>');
+        for (var s in factory.instances) {
+            list.append($('<li>').append(factory.instances[s]));
+        }
+        _.find('td.VcreatedInstances').html(list);
+    } else { // Undefined
+        _.find('td.VcreatedInstances').html('<i>No created instances</i>');
+    }
+
+    _.find('pre.architecture_content').text(factory.architecture);
+}
+
+function retrieveDetails() {
+    $.get(pluginRoot + '/factories/' + factory_name + '.json', null, function(data) {
+        renderFactoryDetails(data);
+    }, "json");
+}
+
+function loadFactoriesData() {
+    window.location = factories_url;	
+}
+
+function loadInstancesData() {
+    window.location = instances_url;
+}
+
+function loadHandlersData() {
+    window.location = handlers_url;
+}
+
+var tableBody = false;
+var tablePropBody = false;
+var propEntryTemplate = false;
+
+$(document).ready(function(){
+	tableBody = $('#plugin_table tbody');
+    
+    tablePropBody = $('.properties tbody');
+    propEntryTemplate = tablePropBody.find('tr').clone();
+    
+    retrieveDetails();
+	
+    $(".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;
+	};
+	
+});
+

Added: felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.css
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.css?rev=963389&view=auto
==============================================================================
--- felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.css (added)
+++ felix/trunk/ipojo/webconsole-plugin/src/main/resources/res/ui/ipojo.css Mon Jul 12 17:42:47
2010
@@ -0,0 +1,17 @@
+td.lheader {
+    width: 20em;
+    font-weight: bold;
+}
+
+div.architecture {
+    border-color: #CCC;
+    border-width: 1px;
+    border-style: solid;
+    border-spacing: 5px;
+    font-family: Courier;
+    margin: 5px;
+    background: #CCC;
+    width: 80em;
+    overflow: auto;
+    padding: 8px;
+}



Mime
View raw message