Author: paperwing
Date: 2012-08-20 16:07:23 -0700 (Mon, 20 Aug 2012)
New Revision: 30238

Modified:
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
Log:
refs #1361 Currently installed apps tab should now obtain and display app 
descriptions from available app stores. App descriptions are not stored in the 
jar or locally at the moment, so they are obtained from the app store.

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
 2012-08-20 23:02:59 UTC (rev 30237)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
 2012-08-20 23:07:23 UTC (rev 30238)
@@ -105,7 +105,7 @@
                this.appName = "";
                this.version = "";
                this.authors = "";
-               this.description = "";
+               this.description = null;
                this.appFile = null;
                
                appValidated = false;

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
      2012-08-20 23:02:59 UTC (rev 30237)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
      2012-08-20 23:07:23 UTC (rev 30238)
@@ -17,6 +17,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeSet;
 
 import javax.swing.ImageIcon;
 
@@ -565,6 +566,11 @@
        
        public void checkWebAppInstallStatus(Set<WebApp> webApps, AppManager 
appManager) {
                
+               // This method contains a nest structure with 3 for loops. 
However,
+               // there isn't much other way to check every hash of every 
WebApp with every
+               // installed app. Runtime performance is
+               // (num_installed_apps * num_web_apps * releases_per_web_app)
+               
                for (App app : appManager.getApps()) {
                        
                        if (app.getSha512Checksum() == null) {
@@ -738,23 +744,55 @@
                return 0;
        }
        
-       public String findAppDescriptions(Set<App> apps) {
-                
-               //String appChecksum = app.getSha512Checksum().toLowerCase();
+       public void findAppDescriptions(Set<App> apps) {
+               // TODO: Perhaps modify this method to do the check with a 
given app store
+               // as a parameter, instead of all app stores
                
                
+               // Find the set of all available apps
+               Set<WebApp> allWebApps = new HashSet<WebApp>(
+                               appsByUrl.get(DEFAULT_APP_STORE_URL).size());
+               
                for (String url : appsByUrl.keySet()) {
                        
                        Set<WebApp> urlApps = appsByUrl.get(url);
                        for (WebApp webApp : urlApps) {
                                
-                               List<Release> releases = webApp.getReleases();
-                               for (Release release : releases) {
+                               allWebApps.add(webApp);
+                       }
+               }
+               
+               // Find set of all app releases
+               Map<Release, WebApp> allReleases = new HashMap<Release, WebApp>(
+                               appsByUrl.get(DEFAULT_APP_STORE_URL).size());
+               
+               List<Release> appReleases = null;
+               for (WebApp webApp : allWebApps) {
+                       
+                       appReleases = webApp.getReleases();
+                       
+                       for (Release appRelease : appReleases) {
+                               allReleases.put(appRelease, webApp);
+                       }
+               }
+               
+               // Find matching app hashes
+               for (Release release : allReleases.keySet()) {
+                       
+                       for (App app : apps) {
+                               String checksum = 
app.getSha512Checksum().toLowerCase();
+                               
+                               // TODO: Currently, this will give the app the 
description from the
+                               // first app store providing the matching hash. 
Perhaps
+                               // we could give the default app store the 
priority in providing the description,
+                               // in cases where multiple stores give the same 
hash.
+                               if 
(checksum.indexOf(release.getSha512Checksum().toLowerCase()) != -1
+                                               && app.getDescription() == 
null) {
                                        
+                                       System.out.println("Found description: 
" + allReleases.get(release).getDescription());
+                                       
app.setDescription(allReleases.get(release).getDescription());
                                }
                        }
                }
-               
-               return null;
        }
 }

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
      2012-08-20 23:02:59 UTC (rev 30237)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
      2012-08-20 23:07:23 UTC (rev 30238)
@@ -1,5 +1,7 @@
 package org.cytoscape.app.internal.ui;
 
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -158,6 +160,15 @@
                     .add(uninstallSelectedButton))
                 .addContainerGap())
         );
+        
+        // Add listener to obtain descriptions for available apps
+        this.addComponentListener(new ComponentAdapter() {
+               
+               @Override
+               public void componentShown(ComponentEvent e) {
+                       
appManager.getWebQuerier().findAppDescriptions(appManager.getApps());
+               }
+        });
     }
         
     private void 
enableSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
@@ -347,9 +358,12 @@
        } else if (numSelected == 1){
                App selectedApp = selectedApps.iterator().next();
                
-               String text = "App description not found.";
+               String text = selectedApp.getDescription() == null ? 
+                       "App description not found." : 
selectedApp.getDescription();
                descriptionTextArea.setText(text);
                
+               
+               
                // Enable/disable the appropriate button
                if (selectedApp.getStatus() == AppStatus.INSTALLED) {
                        enableSelectedButton.setEnabled(false);

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
    2012-08-20 23:02:59 UTC (rev 30237)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
    2012-08-20 23:07:23 UTC (rev 30238)
@@ -127,9 +127,6 @@
                        
                        @Override
                        public void appsChanged(AppsChangedEvent event) {
-                               // System.out.println("apps changed, updating 
box");
-                               resultsTree.getSelectionPath();
-
                                TreePath[] selectionPaths = 
resultsTree.getSelectionPaths();
 
                                updateDescriptionBox();

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to