Author: paperwing
Date: 2012-07-26 13:16:25 -0700 (Thu, 26 Jul 2012)
New Revision: 30001

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/AppManager.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
Log:
Now only shows 3.0-compatible apps from app store. However, some apps uploaded 
to app store were submitted before recent decisions regarding OSGi metadata, so 
may not work perfectly. Eventually, some test apps will be added.

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-07-26 20:01:53 UTC (rev 30000)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
 2012-07-26 20:16:25 UTC (rev 30001)
@@ -462,7 +462,8 @@
        
        /**
         * Uses heuristics to check if another App represents the same 
Cytoscape app as this App, 
-        * ignoring filename differences.
+        * ignoring filename differences. Specifically, it returns true only if 
the app names
+        * and app versions are equal.
         * 
         * @param other The app to compare against.
         * @return <code>true</code> if the apps are suspected to be the same 
Cytoscape app,
@@ -478,6 +479,22 @@
                
                return false;
        }
+
+       /**
+        * Returns true only if the argument is an {@link App} with the same 
app name and version.
+        */
+       @Override
+       public boolean equals(Object other) {
+               if (other == null) {
+                       return false;
+               }
+               
+               if (other instanceof App) {
+                       return (this.heuristicEquals((App) other));
+               }
+               
+               return false;
+       }
        
        public String getAppName() {
                return appName;
@@ -599,14 +616,14 @@
     {  
         if( ! f.exists() )  
         {  
-            System.err.println( "Cannont delete, file does not exist: " + 
f.getPath() );  
+            System.err.println( "Cannot delete, file does not exist: " + 
f.getPath() );  
             return false;  
         }  
         f.setReadable( true );  
         f.setWritable( true );  
         if( ! f.canWrite() )  
         {  
-            System.err.println( "Cannont delete, file is read-only: " + 
f.getPath() );  
+            System.err.println( "Cannot delete, file is read-only: " + 
f.getPath() );  
             return false;  
         }  
   
@@ -616,7 +633,7 @@
         parent.setWritable( true );  
         if( ! parent.canWrite() )  
         {  
-            System.err.println( "Cannont delete, parent folder read-only: " + 
parent.getPath() );  
+            System.err.println( "Cannot delete, parent folder read-only: " + 
parent.getPath() );  
             return false;  
         }  
   
@@ -675,11 +692,11 @@
                if (!targetDirectory.equals(parentPath)) {
                        if (moveDirectories.contains(parentPath)) {
                                FileUtils.moveFile(this.getAppFile(), 
targetFile);
-                               System.out.println("Moving: " + 
this.getAppFile() + " -> " + targetFile);
+                               //System.out.println("Moving: " + 
this.getAppFile() + " -> " + targetFile);
                                this.setAppFile(targetFile);
                        } else {
                                FileUtils.copyFile(this.getAppFile(), 
targetFile);
-                               System.out.println("Copying: " + 
this.getAppFile() + " -> " + targetFile);
+                               //System.out.println("Copying: " + 
this.getAppFile() + " -> " + targetFile);
                                this.setAppFile(targetFile);
                        }
                }

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
  2012-07-26 20:01:53 UTC (rev 30000)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
  2012-07-26 20:16:25 UTC (rev 30001)
@@ -144,8 +144,15 @@
                Set<App> installedFolderApps = obtainAppsFromDirectory(new 
File(getInstalledAppsPath()), false);
                for (App app: installedFolderApps) {
                        try {
-                               app.install(this);
-                               apps.add(app);
+                               boolean appRegistered = false;
+                               for (App regApp : apps) {
+                                       if (regApp.heuristicEquals(app))
+                                               appRegistered = true;
+                               }
+                               if (!appRegistered) {
+                                       app.install(this);
+                                       apps.add(app);
+                               }
                        } catch (AppInstallException e) {
                        }
                }
@@ -153,8 +160,15 @@
                Set<App> disabledFolderApps = obtainAppsFromDirectory(new 
File(getDisabledAppsPath()), false);
                for (App app: disabledFolderApps) {
                        try {
-                               app.disable(this);
-                               apps.add(app);
+                               boolean appRegistered = false;
+                               for (App regApp : apps) {
+                                       if (regApp.heuristicEquals(app))
+                                               appRegistered = true;
+                               }
+                               if (!appRegistered) {
+                                       app.disable(this);
+                                       apps.add(app);
+                               }                               
                        } catch (AppDisableException e) {
                        }
                }
@@ -162,8 +176,15 @@
                Set<App> uninstalledFolderApps = obtainAppsFromDirectory(new 
File(getUninstalledAppsPath()), false);
                for (App app: uninstalledFolderApps) {
                        try {
-                               app.uninstall(this);
-                               apps.add(app);
+                               boolean appRegistered = false;
+                               for (App regApp : apps) {
+                                       if (regApp.heuristicEquals(app))
+                                               appRegistered = true;
+                               }
+                               if (!appRegistered) {
+                                       app.uninstall(this);
+                                       apps.add(app);
+                               }
                        } catch (AppUninstallException e) {
                        }
                }

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-07-26 20:01:53 UTC (rev 30000)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
      2012-07-26 20:16:25 UTC (rev 30001)
@@ -33,7 +33,7 @@
  */
 public class WebQuerier {
        
-       private static final String APP_STORE_URL = 
"http://apps.cytoscape.org/";;
+       private static final String APP_STORE_URL = "http://apps3.nrnb.org/";;
        
        private static final String REQUEST_JSON_HEADER_KEY = 
"X-Requested-With";
        private static final String REQUEST_JSON_HEADER_VALUE = 
"XMLHttpRequest";
@@ -242,7 +242,7 @@
                                List<WebApp.Release> compatibleReleases = 
getCompatibleReleases(webApp);
                                
                                // Only add this app if it has compatible 
releases
-                               if (compatibleReleases.size() > -1) {
+                               if (compatibleReleases.size() > 0) {
                                        // Obtain tags associated with this app
                                        processAppTags(webApp, jsonObject);
        

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-07-26 20:01:53 UTC (rev 30000)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
      2012-07-26 20:16:25 UTC (rev 30001)
@@ -313,7 +313,7 @@
     private void updateLabels() {
        int installedCount = appManager.getApps().size();
        
-       appsInstalledLabel.setText(installedCount + installedCount == 1 ? " App 
installed." : " Apps installed.");
+       appsInstalledLabel.setText(installedCount + (installedCount == 1 ? " 
App installed." : " Apps installed."));
     }
     
     /**

-- 
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