FELIX-569 Apply config-name_column-sorting.patch by Valentin Valchev (thanks)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@922580 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
index fea1f37..493ff99 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
@@ -124,7 +124,20 @@
                     final String[] idList = idGetter.getIds( mti );
                     for ( int j = 0; idList != null && j < idList.length; j++ )
                     {
-                        ObjectClassDefinition ocd = mti.getObjectClassDefinition( idList[j], locale );
+                        // After getting the list of PIDs, a configuration  might be 
+                        // removed. So the getObjectClassDefinition will throw
+                        // an exception, and this will prevent ALL configuration from
+                        // being displayed. By catching it, the configurations will be
+                        // visible
+                        ObjectClassDefinition ocd = null;
+                        try 
+                        {
+                            ocd = mti.getObjectClassDefinition( idList[j], locale );
+                        }
+                        catch (IllegalArgumentException ignore)
+                        {
+                            // ignore - just don't show this configuration
+                        }
                         if ( ocd != null )
                         {
                             objectClasses.add( ocd );
@@ -189,7 +202,15 @@
                 MetaTypeInformation mti = mts.getMetaTypeInformation( bundle );
                 if ( mti != null )
                 {
-                    return mti.getObjectClassDefinition( pid, locale );
+                    // see #getObjectClasses( final IdGetter idGetter, final String locale )
+                    try
+                    {
+                        return mti.getObjectClassDefinition( pid, locale );
+                    }
+                    catch (IllegalArgumentException e)
+                    {
+                        // ignore - return null
+                    }
                 }
             }
         }
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
index 7e96f45..c282eb8 100644
--- a/webconsole/src/main/resources/res/ui/config.js
+++ b/webconsole/src/main/resources/res/ui/config.js
@@ -426,8 +426,8 @@
 
 function addConfig(conf) {
 	var tr = configRow.clone().appendTo(configBody);
-	tr.find('td:eq(0)').text(conf.fpid ? conf.fpid : '-'); // fpid
-	tr.find('td:eq(1)').text(conf.name).click(function() { // name & edit
+	tr.find('td:eq(1)').text(conf.fpid ? conf.fpid : '-'); // fpid
+	tr.find('td:eq(0)').text(conf.name).click(function() { // name & edit
 		configure(conf.id);
 	});
 	tr.find('td:eq(2)').html(conf.bundle ? '<a href="' + pluginRoot + '/../bundles/' + conf.bundle + '">' + conf.bundle_name + '</a>' : '-'); // binding
@@ -454,8 +454,8 @@
 
 function addFactoryConfig(conf) {
 	var tr = factoryRow.clone().appendTo(factoryBody);
-	tr.find('td:eq(0)').text(conf.id); // fpid
-	tr.find('td:eq(1)').text(conf.name).click(function() { // name & edit
+	tr.find('td:eq(1)').text(conf.id); // fpid
+	tr.find('td:eq(0)').text(conf.name).click(function() { // name & edit
 		configure(conf.id, true);
 	});
 	// buttons
@@ -480,7 +480,7 @@
 	});
 	factoryBody   = factoryTable.find('tbody');
 	factoryRow    = factoryBody.find('tr').clone();
-	
+
 	// setup button - cannot inline in dialog option because of i18n
 	var _buttons = {};
 	_buttons[i18n.abort] = function() {
@@ -511,6 +511,11 @@
 		for(var i in configData.pids) addConfig(configData.pids[i]);
 		for(var i in configData.fpids) addFactoryConfig(configData.fpids[i]);
 		initStaticWidgets(configContent);
+
+		// initial sorting orger by name
+		var sorting = [[0,0]]; 
+		configTable.trigger('sorton', [sorting]);
+		factoryTable.trigger('sorton', [sorting]);
 	} else {
 		configContent.addClass('ui-helper-hidden');
 	}
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
index 34629c5..4a3d7f1 100644
--- a/webconsole/src/main/resources/templates/config.html
+++ b/webconsole/src/main/resources/templates/config.html
@@ -39,17 +39,17 @@
 	<table class="tablesorter nicetable noauto">
 		<thead>
 			<tr>
-				<th class="col_FPID">Factory PID</th>
 				<th class="col_Name">Name</th>
+				<th class="col_FPID">Factory PID</th>
 				<th class="col_Binding">Bundle</th>
 				<th class="col_Actions" style="width: 7em">Actions</th>
 			</tr>
 		</thead>
 		<tbody>
 			<tr>
-				<td>&nbsp;</td>
 				<td class="pointer">&nbsp;</td>
 				<td>&nbsp;</td>
+				<td>&nbsp;</td>
 				<td>
 					<ul class="icons">
 						<li class="dynhover" title="${config.edit.tip}"><span class="ui-icon ui-icon-pencil">&nbsp;</span></li>
@@ -67,15 +67,15 @@
 	<table class="tablesorter nicetable noauto">
 		<thead>
 			<tr>
-				<th class="col_FPID">Factory PID</th>
 				<th class="col_Name">Name</th>
+				<th class="col_FPID">Factory PID</th>
 				<th class="col_Actions" style="width: 7em">Actions</th>
 			</tr>
 		</thead>
 		<tbody>
 			<tr>
-				<td>&nbsp;</td>
 				<td class="pointer">&nbsp;</td>
+				<td>&nbsp;</td>
 				<td>
 					<ul class="icons">
 						<li class="dynhover" title="${config.create.tip}"><span class="ui-icon ui-icon-plusthick">&nbsp;</span></li>