FELIX-3111 : Separate OBR Plugin
FELIX-3107 : Separate Shell Plugin
FELIX-3099 : Separate Deployment Admin plugin
FELIX-3100 : Separate SCR plugin

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1169777 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..1a0f302
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,40 @@
+#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.

+

+#

+# Web Console strings for reference all strings here are commented.

+# This file may be used to produce a translation of the strings

+#

+# Note that properties files are ISO-8859-1 encoded. To provide translations

+# for languages requiring different character encodings, you may use the

+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/

+# to translate the natively encoded files to ISO-8859-1 during bundle build

+#

+# Translations requiring non-ISO-8859-1 encoding are placed in the

+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said

+# plugin while building the bundle

+#

+

+# Deployment Admin plugin

+deppack.pluginTitle=Deployment Packages

+deppack.status.no_data=No deployment packages installed!

+deppack.status.no_service=Deployment Admin is not installed/running!

+deppack.status.ok=Deployment Admin service is running

+deppack.details=Details

+deppack.actions=Actions

+deppack.install_update=Install or Update

+deppack.package.name=Package Name

+deppack.bundles=Bundles

+deppack.uninstall=Uninstall

diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.css b/webconsole-plugins/deppack/src/main/resources/res/plugin.css
new file mode 100644
index 0000000..c767846
--- /dev/null
+++ b/webconsole-plugins/deppack/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.

+ */

+

+.pkgname { cursor:pointer }

+.pkgname span { float:left }

diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.html b/webconsole-plugins/deppack/src/main/resources/res/plugin.html
new file mode 100644
index 0000000..ba16fcd
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/res/plugin.html
@@ -0,0 +1,55 @@
+<script type="text/javascript" src="${pluginRoot}/res/plugin.js"></script>

+<script type="text/javascript">

+// <![CDATA[

+var i18n = {

+	status_no_data : "${deppack.status.no_data}",

+	status_no_serv : "${deppack.status.no_service}",

+	status_ok      : "${deppack.status.ok}",

+	package_name   : "${deppack.package.name}",

+	version        : "${version}",

+	bundles        : "${deppack.bundles}",

+	uninstall      : "${deppack.uninstall}"

+}

+var packageListData = ${__data__};

+// ]]>

+</script>

+

+<p class="statline">&nbsp;</p>

+

+<div id="dps1"> <!-- will be hidden if no DP service available -->

+<!-- top header -->

+<form method="post" enctype="multipart/form-data" action="${pluginRoot}">

+	<div class="ui-widget-header ui-corner-top buttonGroup" style="text-align: right">

+		<input name="action"  type="hidden" value="deploydp" />

+		<input name="pckfile" type="file" size="50" />

+		<input type="submit" value="${deppack.install_update}" />

+	</div>

+</form>

+

+<div id="dps2"> <!-- will be hidden if no data available -->

+	<table id="plugin_table" class="nicetable">

+	<thead>

+		<tr>

+			<th>${id}</th>

+			<th style="width:100%">${deppack.details}</th>

+			<th>${version}</th>

+			<th colspan="1">${deppack.actions}</th>

+		</tr>

+	</thead>

+	<tbody>

+		<tr>

+			<td colspan="5">&nbsp;</td>

+		</tr>

+	</tbody>

+	</table>

+

+	<!-- bottom header -->

+	<form method="post" enctype="multipart/form-data" action="${pluginRoot}">

+		<div class="ui-widget-header ui-corner-bottom buttonGroup" style="text-align: right">

+			<input name="action"  type="hidden" value="deploydp" />

+			<input name="pckfile" type="file" size="50" />

+			<input type="submit" value="${deppack.install_update}" />

+		</div>

+	</form>

+</div><!--dps2-->

+</div><!--dps1-->

diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.js b/webconsole-plugins/deppack/src/main/resources/res/plugin.js
new file mode 100644
index 0000000..149590e
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/res/plugin.js
@@ -0,0 +1,172 @@
+/*

+ * 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 fixId(id) { return id.replace('.', '_'); }

+

+function data( /* Array of Object */ dataArray ) { // render components

+	plugin_table.find('tbody').empty();

+	if (dataArray.length == 1) {

+		entry( dataArray[0], true );

+	} else {

+		for ( var idx in dataArray ) {

+			entry( dataArray[idx] );

+		}

+	}

+}

+

+function entry( /* Object */ dataEntry, /* boolean */ singleEntry ) {

+	var id = fixId(dataEntry.id);

+	var trElement = tr( 'ui-state-active', { 'id': 'entry' + id });

+

+	// entry brief

+	entryInternal( trElement,  dataEntry, singleEntry );

+	plugin_table.append(trElement);

+

+	// dataEntry detailed properties

+	trElement = tr( 'ui-helper-hidden', { 

+		'id'   : 'entry' + id + '_details'

+	});

+	if (dataEntry.props) {

+		getDataEntryDetails( trElement, dataEntry.props );

+	}

+	plugin_table.append(trElement);

+}

+

+function entryInternal( /* Element */ parent, /* Object */ dataEntry, /* boolean */ singleEntry ) {

+	var id = dataEntry.id;

+	var _id = fixId(id);

+

+	parent.appendChild( td( null, null, [ text( id ) ] ) );

+	parent.appendChild( td( null, 

+			{

+				'onclick': 'toggleDetails("#entry' + _id + '")',

+				'class': 'pkgname'

+			}, 

+			[

+				createElement( 'span', 'ui-icon ui-icon-triangle-1-e', { id: 'entry' + _id + '_icon'} ),

+				text(dataEntry.name)

+			]

+		)

+	);

+	parent.appendChild( td( null, null, [ text( dataEntry.state ) ] ) );

+

+	for ( var aidx in dataEntry.actions ) {

+		var action = dataEntry.actions[aidx];

+		parent.appendChild( actionButton( action.enabled, id, action.link, action.name ) );

+	}

+}

+

+

+/* Element */ function actionButton( /* boolean */ enabled, /* long */ id, /* String */ op, /* String */ opLabel ) {

+	var buttonTd = td( "content", { align: "right" } );

+	if ( op ) {

+		switch (opLabel) {

+			case "Uninstall" : opLabel = i18n.uninstall; break;

+		}

+		var input = createElement( "input", null, {

+				type: 'button',

+				value: opLabel,

+				onclick: 'changeDataEntryState("' + id + '", "' + op + '");'

+			});

+		if (!enabled) {

+			input.setAttribute( "disabled", true );

+			$(input).addClass('ui-state-disabled');

+		}

+		buttonTd.appendChild( input );

+	} else {

+		addText( buttonTd, "\u00a0" );

+	}

+	return buttonTd;

+}

+

+

+function getDataEntryDetails( /* Element */ parent, /* Array of Object */ details )

+{

+	parent.appendChild( addText( td( "content"), "\u00a0" ) );

+	

+	var tdEl = td( null, { colspan: 4 } );

+	parent.appendChild( tdEl );

+	

+	var tableEl = createElement( "table", null, { border: 0 } );

+	tdEl.appendChild( tableEl );

+	

+	var tbody = createElement( "tbody" );

+	tableEl.appendChild( tbody );

+	for (var idx in details) {

+		var prop = details[idx];

+		var trEl = tr();

+		var key = prop.key;

+		switch (key) {

+			case 'Package Name': key = i18n.package_name; break;

+			case 'Version'     : key = i18n.version; break;

+			case 'Bundles'     : key = i18n.bundles; break;

+		}

+		trEl.appendChild( addText( td( null, { noWrap: true } ), key ) );

+

+		var proptd = td();

+		trEl.appendChild( proptd );

+		$(proptd).html( prop.value ? prop.value : "\u00a0");

+

+		tbody.appendChild( trEl );

+	}

+ }

+

+

+function changeDataEntryState(/* long */ id, /* String */ action) {

+	var parm = pluginRoot + "/" + id + "?action=" + action;

+	$.post(parm, null, function() { // always reload

+		document.location.reload();

+	}, "text");

+}

+

+

+function toggleDetails(name) {

+	var icon = $(name + '_icon');

+	var details = $(name + '_details');

+	var show = icon.attr('show');

+	if (typeof show == 'undefined') show = '';

+	icon.attr('show', show ? '' : 'true');

+

+	if (show == 'true') {

+		icon.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');

+		details.addClass('ui-helper-hidden');

+	} else {

+		icon.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');

+		details.removeClass('ui-helper-hidden');

+	}

+}

+

+var plugin_table = false;

+$(document).ready(function() {

+	plugin_table = $('#plugin_table');

+	var /* Array of Data Objects */ bundleData = packageListData;

+	if (bundleData.error) {

+		$('.statline').text(i18n.status_no_serv);

+		$('#dps1').addClass('ui-helper-hidden');

+	} else if (!bundleData.data || bundleData.data.length == 0) {

+		$('.statline').text(i18n.status_no_data);

+		$('#dps1').removeClass('ui-helper-hidden');

+		$('#dps2').addClass('ui-helper-hidden');

+	} else {

+		data( bundleData.data );

+		$('.statline').text(i18n.status_ok);

+		$('#dps1').removeClass('ui-helper-hidden');

+		$('#dps2').removeClass('ui-helper-hidden');

+		initStaticWidgets(plugin_table);

+	}

+});

+