geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1128213 - in /geronimo/server/trunk/plugins/console/console-base-portlets/src/main: java/org/apache/geronimo/console/bundlemanager/ webapp/WEB-INF/view/bundlemanager/
Date Fri, 27 May 2011 09:35:12 GMT
Author: rwonly
Date: Fri May 27 09:35:11 2011
New Revision: 1128213

URL: http://svn.apache.org/viewvc?rev=1128213&view=rev
Log:
GERONIMO-5978 show exporters and importers in one table

Modified:
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/FindPackages.jsp

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java?rev=1128213&r1=1128212&r2=1128213&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
Fri May 27 09:35:11 2011
@@ -148,11 +148,9 @@ public class BundleManagerPortlet extend
             
         } else if (FIND_PACKAGES_PAGE.equals(page)) {
             String packageString = actionRequest.getParameter("packageString");
-            String packageType = actionRequest.getParameter("packageType");
             //set render params
             actionResponse.setRenderParameter("page", FIND_PACKAGES_PAGE);
             actionResponse.setRenderParameter("packageStringValue", packageString);
-            actionResponse.setRenderParameter("packageTypeValue", packageType);
             
         } else { //main page
             
@@ -263,56 +261,60 @@ public class BundleManagerPortlet extend
                 
                 
                 String packageString = renderRequest.getParameter("packageStringValue");
-                String packageType = renderRequest.getParameter("packageTypeValue");
                  
-                Map<PackageInfo,List<BundleInfo>> pbs = new HashMap<PackageInfo,List<BundleInfo>>();
-
+               
+                Map<PackageInfo,List<BundleInfo>> packageExportBundles = new
HashMap<PackageInfo,List<BundleInfo>>();
+                Map<PackageInfo,List<BundleInfo>> packageImportBundles = new
HashMap<PackageInfo,List<BundleInfo>>();
+                
+                
                 for (Bundle bundle : bundleContext.getBundles()) {
-                    if (packageType.equals("export")){ //export pakcages
-                        BundleDescription description = new BundleDescription(bundle.getHeaders());
-                        List<BundleDescription.ExportPackage> exports = description.getExportPackage();
-                        for (BundleDescription.ExportPackage exportPkg :exports){
-                            if (exportPkg.getName().indexOf(packageString)!= -1){
-                                PackageInfo packageInfo = new PackageInfo(exportPkg.getName(),
exportPkg.getVersion().toString());
-                                BundleInfo bundleInfo = new SimpleBundleInfo(bundle);
-                                fillPackageBundlesMap(pbs, packageInfo, bundleInfo);
+                    ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(bundle);
+                    if (exportedPackages != null) {
+                        
+                        // construct the export bundle info
+                        BundleInfo exportBundleInfo = new SimpleBundleInfo(bundle);
+                        
+                        for (ExportedPackage exportedPackage : exportedPackages) {
+                            if (exportedPackage.getName().toLowerCase().indexOf(packageString.trim().toLowerCase())!=
-1) { // filter by keyword and ignore case 
                                 
-                            }
-                        }
-                    } else {    //import packages, we get this by travel all exported packages
-                        ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(bundle);
-                        if (exportedPackages != null) {
-                            for (ExportedPackage exportedPackage : exportedPackages) {
-                                if (exportedPackage.getName().indexOf(packageString)!= -1)
{
-                                    Bundle[] importingBundles = exportedPackage.getImportingBundles();
-                                    if (importingBundles != null) {
+                                // construct the package info
+                                // fill in its export bundle
+                                PackageInfo packageInfo = new PackageInfo(exportedPackage.getName(),
exportedPackage.getVersion().toString());
+                                fillPackageBundlesMap(packageExportBundles, packageInfo,
exportBundleInfo);
+                                
+                                Bundle[] importingBundles = exportedPackage.getImportingBundles();
+                                if (importingBundles != null) {                         
          
+                                    for (Bundle importingBundle : importingBundles) {
                                         
-                                        PackageInfo packageInfo = new PackageInfo(exportedPackage.getName(),
exportedPackage.getVersion().toString());
-                                        for (Bundle importingBundle : importingBundles) {
-                                            BundleInfo bundleInfo = new SimpleBundleInfo(importingBundle);
-                                            fillPackageBundlesMap(pbs, packageInfo, bundleInfo);
-                                        } 
+                                        // construct the import bundle info
+                                        // fill in its import bundle
+                                        BundleInfo importBundleInfo = new SimpleBundleInfo(importingBundle);
+                                        fillPackageBundlesMap(packageImportBundles, packageInfo,
importBundleInfo);
                                         
-                                    }
+                                    } 
+                                    
                                 }
                             }
                         }
                     }
                 }
                 
-                List<PackagePerspective> packagePerspectives = new ArrayList<PackagePerspective>();
+                
+                List<PackageWiredBundles> packageWiredBundlesList = new ArrayList<PackageWiredBundles>();
                 BundleSymbolicComparator bsc = new BundleSymbolicComparator();
-                for(Entry<PackageInfo,List<BundleInfo>> entry : pbs.entrySet()){
-                    PackagePerspective pp = new PackagePerspective(entry.getKey(),entry.getValue());
-                    pp.sortBundleInfos(bsc);
-                    packagePerspectives.add(pp);
+                for(Entry<PackageInfo,List<BundleInfo>> entry : packageExportBundles.entrySet()){
+                    PackageInfo pkg = entry.getKey();
+                    List<BundleInfo> exportBundles = entry.getValue();
+                    List<BundleInfo> importBundles = packageImportBundles.get(pkg)
== null? new ArrayList<BundleInfo>():packageImportBundles.get(pkg);
+                    
+                    PackageWiredBundles pwb = new PackageWiredBundles(pkg, exportBundles,
importBundles);
+                    pwb.sortBundleInfos(bsc);
+                    packageWiredBundlesList.add(pwb);
                 }
                 
-                Collections.sort(packagePerspectives);
+                Collections.sort(packageWiredBundlesList);
                 
-                renderRequest.setAttribute("packagePerspectives", packagePerspectives);
-                
-                renderRequest.setAttribute("packageTypeValue", packageType);
+                renderRequest.setAttribute("packageWiredBundlesList", packageWiredBundlesList);
                 renderRequest.setAttribute("packageStringValue", packageString);
                 findPackagesView.include(renderRequest, renderResponse);
                 
@@ -1212,4 +1214,62 @@ public class BundleManagerPortlet extend
         return registeredServicePerspectives;
     }
     
+    
+    /*************************************************************
+     * definitions for find packages page
+     *************************************************************/
+    public static class PackageWiredBundles implements Comparable<PackageWiredBundles>{
+
+        private PackageInfo packageInfo;
+        private List<BundleInfo> importBundleInfos = new ArrayList<BundleInfo>();
+        private List<BundleInfo> exportBundleInfos = new ArrayList<BundleInfo>();
+                
+        public PackageWiredBundles(String packageName, String packageVersion) {
+            this.packageInfo = new PackageInfo(packageName, packageVersion);
+        }
+        
+        public PackageWiredBundles(PackageInfo packageInfo) {
+            this.packageInfo = packageInfo;
+        }
+        
+        public PackageWiredBundles(PackageInfo packageInfo, List<BundleInfo> exportBundleInfos,
List<BundleInfo> importBundleInfos) {
+            this.packageInfo = packageInfo;
+            this.importBundleInfos = importBundleInfos;
+            this.exportBundleInfos = exportBundleInfos;
+        }
+        
+        @Override
+        public int compareTo(PackageWiredBundles another) {
+            if (another != null) {
+                return packageInfo.compareTo(another.packageInfo);
+            } else {
+                return -1;
+            } 
+        }
+        
+        public PackageInfo getPackageInfo() {
+            return packageInfo;
+        }
+
+        public List<BundleInfo> getImportBundleInfos() {
+            return importBundleInfos;
+        }
+        
+        public void addImportBundleInfo(BundleInfo info){
+            this.importBundleInfos.add(info);
+        }
+        
+        public List<BundleInfo> getExportBundleInfos() {
+            return exportBundleInfos;
+        }
+        
+        public void addExportBundleInfo(BundleInfo info){
+            this.exportBundleInfos.add(info);
+        }
+        
+        public void sortBundleInfos(Comparator<BundleInfo> comparator){
+            Collections.sort(importBundleInfos, comparator);
+            Collections.sort(exportBundleInfos, comparator);
+        }
+    }
 }

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp?rev=1128213&r1=1128212&r2=1128213&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp
Fri May 27 09:35:11 2011
@@ -92,11 +92,7 @@ function refreshPrompt(target, bundleId,
         </td>
         <td align="right">
             <form id="packageForm" method="POST" action="<portlet:actionURL><portlet:param
name='page' value='find_packages'/></portlet:actionURL>">
-                Find (
-                <input type="radio" name="packageType" value="import" />Import
-                /
-                <input type="radio" name="packageType" value="export" checked="true" />Export
-                ) Packages:
+                Find Packages:
                 <input type="text" id="packageString" name="packageString" value=""/>&nbsp;
                 <input type="submit" value="Go" />
             </form>
@@ -181,8 +177,8 @@ function refreshPrompt(target, bundleId,
             theTr.style.backgroundColor = oldcolor;
         }
     </script> 
-      <c:set var="backgroundClass" value='MediumBackground'/>
-      <c:forEach var="bundleInfo" items="${extendedBundleInfos}">
+    <c:set var="backgroundClass" value='MediumBackground'/>
+    <c:forEach var="bundleInfo" items="${extendedBundleInfos}">
       <c:choose>
           <c:when test="${backgroundClass == 'MediumBackground'}" >
               <c:set var="backgroundClass" value='LightBackground'/>
@@ -277,7 +273,7 @@ function refreshPrompt(target, bundleId,
         </td>
 
       </tr>
-      </c:forEach>
+    </c:forEach>
 </table>
 
 

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/FindPackages.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/FindPackages.jsp?rev=1128213&r1=1128212&r2=1128213&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/FindPackages.jsp
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/FindPackages.jsp
Fri May 27 09:35:11 2011
@@ -23,18 +23,14 @@
 
 <a href="<portlet:actionURL/>" >OSGi Manager</a> > Find Packages 
 <br/><br/>
-<table width="100%" class="TableLine" summary="OSGi install">
+<table width="100%" class="TableLine" summary="Find Packages">
     <tr>
         <td>
-            The <b>${packageTypeValue}</b> packages with keyword "<b>${packageStringValue}</b>"
+            The Packages with Keyword: "<b>${packageStringValue}</b>"
         </td>
         <form id="packageForm" method="POST" action="<portlet:actionURL><portlet:param
name='page' value='find_packages'/></portlet:actionURL>">
         <td align="right">
-                Find (
-                <input type="radio" name="packageType" value="import" />Import
-                /
-                <input type="radio" name="packageType" value="export" checked="true" />Export
-                ) Packages:
+                Find Packages:
                 <input type="text" id="packageString" name="packageString" value=""/>&nbsp;
                 <input type="submit" value="Go" />
         </td>
@@ -42,19 +38,32 @@
     </tr>
 </table>
 <br/>
-<table width="100%" class="TableLine" summary="Wired Bundles">
+<script language="javascript">
+function showHideById(id) {
+    document.getElementById(id).style.display = (document.getElementById(id).style.display=='none')?'block':'none';
+}
+
+function showHideTr(num) {
+    showHideById("exportTr-"+num);
+    showHideById("importTr-"+num);
+}      
+</script>
+<script language="javascript"> 
+var oldcolor;
+function highlightTr(theTr){
+    oldcolor = theTr.style.backgroundColor;
+    theTr.style.backgroundColor = '#e2ebfe';
+}
+function recoverTr(theTr){
+    theTr.style.backgroundColor = oldcolor;
+}
+</script> 
+<table width="100%" class="TableLine" cellpadding="3" cellspacing="0" summary="Find Packages
Result">
     <tr class="DarkBackground">
-        <c:if test="${packageTypeValue == 'import'}" >          
-            <th scope="col" width="40%">Import Packages</th>   
-            <th scope="col" width="60%">Imported by Bundles</th> 
-        </c:if>
-        <c:if test="${packageTypeValue == 'export'}" >   
-            <th scope="col" width="40%">Export Packages</th>   
-            <th scope="col" width="60%">Exported by Bundles</th> 
-        </c:if>
+        <th scope="col" colspan="2">Search Result (Click to see package's exporter
and importer)</th>   
     </tr>
     <c:set var="backgroundClass" value='MediumBackground'/>
-    <c:forEach var="pp" items="${packagePerspectives}">
+    <c:forEach var="pwb" items="${packageWiredBundlesList}" varStatus="status">
         <c:choose>
             <c:when test="${backgroundClass == 'MediumBackground'}" >
                 <c:set var="backgroundClass" value='LightBackground'/>
@@ -63,12 +72,31 @@
                 <c:set var="backgroundClass" value='MediumBackground'/>
             </c:otherwise>
         </c:choose>
-        <tr>
-            <td class="${backgroundClass}">
-                ${pp.packageInfo.packageName} (version=${pp.packageInfo.packageVersion})
+        <tr class="${backgroundClass}" style="cursor:pointer" onmouseover="highlightTr(this)"
onmouseout="recoverTr(this)">
+            <td colspan="2" onclick="showHideTr(${status.index})">
+                ${pwb.packageInfo.packageName} (version=${pwb.packageInfo.packageVersion})
+            </td>
+        </tr>
+        <tr class="${backgroundClass}" id="exportTr-${status.index}" style="display:none">
+            <td valign="top">
+                - exporting by bundles:
             </td>
-            <td class="${backgroundClass}">
-                <c:forEach var="info" items="${pp.bundleInfos}">
+            <td>
+                <c:forEach var="info" items="${pwb.exportBundleInfos}">
+                    ${info.symbolicName} (id=${info.bundleId}) (version=${info.bundleVersion})
+                    <a href="<portlet:renderURL><portlet:param name='page' value='view_manifest'/><portlet:param
name='bundleId' value='${info.bundleId}'/></portlet:renderURL>"><img border="0"
src="<%=request.getContextPath()%>/images/icon_mf.png" alt="icon_mf.png" title="View
Manifest" style="vertical-align:middle"/></a>
+                    <a href="<portlet:renderURL><portlet:param name='page' value='view_wired_bundles'/><portlet:param
name='bundleId' value='${info.bundleId}'/></portlet:renderURL>"><img border="0"
src="<%=request.getContextPath()%>/images/icon_wb.png" alt="icon_wb.png" title="View
Wired Bundles" style="vertical-align:middle"/></a>
+                    <a href="<portlet:renderURL><portlet:param name='page' value='view_services'/><portlet:param
name='bundleId' value='${info.bundleId}'/></portlet:renderURL>"><img border="0"
src="<%=request.getContextPath()%>/images/icon_serv.png" alt="icon_serv.png" title="View
Services" style="vertical-align:middle"/></a>
+                    <br/>
+                </c:forEach>
+            </td>
+        </tr>
+        <tr class="${backgroundClass}" id="importTr-${status.index}" style="display:none">
+            <td valign="top">
+                - importing by bundles:
+            </td>
+            <td>
+                <c:forEach var="info" items="${pwb.importBundleInfos}">
                     ${info.symbolicName} (id=${info.bundleId}) (version=${info.bundleVersion})
                     <a href="<portlet:renderURL><portlet:param name='page' value='view_manifest'/><portlet:param
name='bundleId' value='${info.bundleId}'/></portlet:renderURL>"><img border="0"
src="<%=request.getContextPath()%>/images/icon_mf.png" alt="icon_mf.png" title="View
Manifest" style="vertical-align:middle"/></a>
                     <a href="<portlet:renderURL><portlet:param name='page' value='view_wired_bundles'/><portlet:param
name='bundleId' value='${info.bundleId}'/></portlet:renderURL>"><img border="0"
src="<%=request.getContextPath()%>/images/icon_wb.png" alt="icon_wb.png" title="View
Wired Bundles" style="vertical-align:middle"/></a>
@@ -78,4 +106,4 @@
             </td>
         </tr>
     </c:forEach>
-</table>
\ No newline at end of file
+</table>



Mime
View raw message