Fixed FELIX-3476 Make package admin to use SimpleWebConsolePlugin
https://issues.apache.org/jira/browse/FELIX-3476
Fixed FELIX-3474 Make package admin work with J9 and other embedded VMs
https://issues.apache.org/jira/browse/FELIX-3474
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1330237 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/packageadmin/src/main/resources/res/plugin.css b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.css
new file mode 100644
index 0000000..474a443
--- /dev/null
+++ b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.css
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+td.mvn { white-space: pre-wrap }
+#findField { width: 50% }
diff --git a/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html
new file mode 100644
index 0000000..d4fbae3
--- /dev/null
+++ b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.html
@@ -0,0 +1,63 @@
+<script type="text/javascript" src="${pluginRoot}/res/plugin.js"></script>
+<script type="text/javascript">
+// <![CDATA[
+var i18n = {
+ statusFind : '${status.find}',
+ statusDups : '${status.dups}'
+}
+// ]]>
+</script>
+
+<!-- status line -->
+<p class="statline">${status.initial}</p>
+
+<!-- table caption -->
+<form method="post" action="${pluginRoot}">
+ <div class="ui-widget-header ui-corner-top buttonGroup">
+ <span>${find.label}</span>
+ <input type="text" id="findField" title="${find.tip}" />
+ <button id="findButton">${find.btn}</button>
+ <button id="findDups">${find.dups}</button>
+ </div>
+</form>
+
+<!-- table find results -->
+<table class="tablesorter nicetable noauto" id="findTable">
+ <thead>
+ <tr>
+ <th>${header.package.name}</th>
+ <th>${header.package.ver}</th>
+ <th>${header.exporting.bundle}</th>
+ <th>${header.maven.deps}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="pkg"> </td>
+ <td class="ver">-</td>
+ <td class="bnd">${no.exporters.found}</td>
+ <td class="mvn">${no.maven.found}</td>
+ </tr>
+ </tbody>
+</table>
+
+<!-- duplicates -->
+<table class="nicetable noauto ui-helper-hidden" id="dupsTable">
+ <thead>
+ <tr>
+ <th>${header.package.name}</th>
+ <th>${header.package.ver}</th>
+ <th>${header.exporting.bundle}</th>
+ <th>${header.importing.bundle}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td class="pkg">-</td>
+ <td class="ver">-</td>
+ <td class="exp">-</td>
+ <td class="imp"> </td>
+ </tr>
+ </tbody>
+</table>
+
diff --git a/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js
new file mode 100644
index 0000000..8468103
--- /dev/null
+++ b/webconsole-plugins/packageadmin/src/main/resources/res/plugin.js
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+var findField = false;
+var findButton = false;
+var findTable = false;
+var findTableBody = false;
+var findTableTemplate = false;
+var dupsTable = false;
+var dupsTableBody = false;
+var dupsTableTemplate = false;
+var statline = false;
+
+function linkBundle(bnd) { return '<a href="{0}/bundles/{1}">{2} ({3})</a>'.msgFormat(appRoot, bnd.bid, bnd.bsn, bnd.bid) }
+
+$(function() {
+ findField = $('#findField');
+ statline = $('.statline');
+
+ findTable = $('#findTable').tablesorter({
+ headers:{
+ 1:{sorter: false},
+ 3:{sorter: false}
+ },
+ textExtraction:mixedLinksExtraction
+ });
+ findTableBody = findTable.find('tbody');
+ findTableTemplate = findTableBody.find('tr').clone();
+ findTableBody.empty();
+
+ dupsTable = $('#dupsTable');
+ dupsTableBody = dupsTable.find('tbody');
+ dupsTableTemplate = dupsTableBody.find('tr').clone();
+
+ $('#findButton').click(function() {
+ if(!findField.val()) {
+ findField.addClass('ui-state-error');
+ } else {
+ findField.removeClass('ui-state-error');
+
+ $.post(pluginRoot, { 'action': 'deps', 'plugin.find' : findField.val() }, function(response) {
+ dupsTable.addClass('ui-helper-hidden')
+ findTable.removeClass('ui-helper-hidden');
+ findTableBody.empty();
+ if (response.packages) for(var i in response.packages) {
+ var pkg = response.packages[i];
+ if (pkg.exporters) for(var i in pkg.exporters) {
+ var exp = pkg.exporters[i];
+ var tr = findTableTemplate.clone()
+ .find('td.pkg').text(pkg.name).end()
+ .find('td.ver').text(exp.version).end()
+ .find('td.bnd').html(linkBundle(exp)).end()
+ .appendTo(findTableBody);
+ if (response.maven && response.maven[exp.bid]) {
+ var mvn = response.maven[exp.bid];
+ mvn['scope'] = 'provided';
+ var txt = ''; for (var p in mvn) {
+ txt += '\t<' + p + '>' + mvn[p] + '</' + p + '>\n';
+ }
+ tr.find('td.mvn').text('<dependency>\n' + txt + '</dependency>');
+ }
+ } else {
+ var tr = findTableTemplate.clone()
+ .find('td.pkg').text(pkg.name).end()
+ .appendTo(findTableBody);
+ }
+ }
+ statline.text(i18n.statusFind.msgFormat(response.packages ? response.packages.length : 0));
+ findTable.trigger('update').trigger('applyWidgets')
+ }, 'json');
+ }
+ return false;
+ });
+
+ $('#findDups').click(function() {
+ $.post(pluginRoot, { 'action': 'dups' }, function(response) {
+ findTable.addClass('ui-helper-hidden');
+ dupsTable.removeClass('ui-helper-hidden')
+ dupsTableBody.empty();
+ if (response) for(var i in response) {
+ var pkg = response[i];
+ if (pkg.entries) for (var i in pkg.entries) {
+ var exp = pkg.entries[i];
+ var td = dupsTableTemplate.clone()
+ .find('td.pkg').text(pkg.name).end()
+ .find('td.ver').text(exp.version).end()
+ .find('td.exp').html(linkBundle(exp)).end();
+ if (exp.importers) {
+ var txt = ''; for(var j in exp.importers) txt += linkBundle(exp.importers[j]) + '<br/>';
+ td.find('td.imp').html( txt );
+ }
+ if (i==0) {
+ td.find('td.pkg').attr('rowspan', pkg.entries.length);
+ } else {
+ td.find('td.pkg').remove();
+ }
+ td.appendTo(dupsTableBody);
+ }
+ }
+ statline.text(i18n.statusDups.msgFormat(response ? response.length : 0));
+ }, 'json');
+
+ return false;
+ });
+
+})