Author: slotia
Date: 2012-07-11 09:50:24 -0700 (Wed, 11 Jul 2012)
New Revision: 29831

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/manager/BundleApp.java
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
Log:
Fixed issue where App Manager was attempting to load apps from a non-existent 
directory

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-11 16:39:09 UTC (rev 29830)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
 2012-07-11 16:50:24 UTC (rev 29831)
@@ -78,8 +78,9 @@
         */
        public enum AppStatus{
                INSTALLED("Installed"),
-               TO_BE_UNINSTALLED("Uninstall-on-restart"),
-               UNINSTALLED("Uninstalled");
+               TO_BE_UNINSTALLED("Will be uninstalled after restart"),
+               TO_BE_DISABLED("Will be disabled after restart"),
+               DISABLED("Disabled");
                
                String readableStatus;
                
@@ -102,7 +103,7 @@
                
                appValidated = false;
                officialNameObtained = false;
-               this.status = AppStatus.UNINSTALLED;
+               this.status = null;
        }
        
        /**
@@ -229,7 +230,7 @@
                                                if 
(appFile.getParentFile().getCanonicalPath().equals(uninstalledAppsPath)) {
                                                        
                                                // Forgive collision if other 
app is not installed
-                                               } else if 
(conflictingApp.getStatus() == AppStatus.UNINSTALLED) {
+                                               } else if 
(conflictingApp.getStatus() != AppStatus.INSTALLED) {
                                                
                                                // Ignore collisions with self
                                                // } else if 
(conflictingApp.getAppFile().equals(appFile)) {

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-11 16:39:09 UTC (rev 29830)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
  2012-07-11 16:50:24 UTC (rev 29831)
@@ -398,6 +398,12 @@
                // Let the listeners know that an app has been uninstalled
                fireAppsChangedEvent();
        }
+
+    public void disableApp(App app) {
+               
+               // Let the listeners know that an app has been disabled
+               fireAppsChangedEvent();
+    }
        
        private void fireAppsChangedEvent() {
                AppsChangedEvent appEvent = new AppsChangedEvent(this);
@@ -616,6 +622,11 @@
        }
        
        private void installAppsInDirectory(File directory, boolean 
ignoreDuplicateBundleApps) {
+        // Temporary fix to get the App Manager working--this should be 
removed later (Samad)
+        if (!directory.exists()) {
+            logger.error("Attempting to load from a directory that does not 
exist: " + directory.getAbsolutePath());
+            return;
+        }
 
                // Parse App objects from the given directory
                Set<App> parsedApps = obtainAppsFromDirectory(directory, 
ignoreDuplicateBundleApps);

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
   2012-07-11 16:39:09 UTC (rev 29830)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
   2012-07-11 16:50:24 UTC (rev 29831)
@@ -167,10 +167,6 @@
                // to the uninstalled apps directory
                // defaultUninstall(appManager);
                
-               if (this.getStatus() == AppStatus.UNINSTALLED) {
-                       return;
-               }
-               
                try {
                        File uninstallDirectoryTargetFile = new 
File(appManager.getUninstalledAppsPath() + File.separator + 
getAppFile().getName());
                        
@@ -193,7 +189,7 @@
                
                this.getAppTemporaryInstallFile().delete();
                
-               this.setStatus(AppStatus.UNINSTALLED);
+               this.setStatus(AppStatus.TO_BE_UNINSTALLED);
        }
 
        /**

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-11 16:39:09 UTC (rev 29830)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
      2012-07-11 16:50:24 UTC (rev 29831)
@@ -32,8 +32,9 @@
     private javax.swing.JLabel descriptionLabel;
     private javax.swing.JScrollPane descriptionScrollPane;
     private javax.swing.JTextArea descriptionTextArea;
+    private javax.swing.JButton enableSelectedButton;
     private javax.swing.JButton disableSelectedButton;
-    private javax.swing.JButton enableSelectedButton;;
+    private javax.swing.JButton uninstallSelectedButton;
        
     private AppManager appManager;
     private AppsChangedListener appListener;
@@ -55,6 +56,7 @@
         appsInstalledLabel = new javax.swing.JLabel();
         enableSelectedButton = new javax.swing.JButton();
         disableSelectedButton = new javax.swing.JButton();
+        uninstallSelectedButton = new javax.swing.JButton();
         descriptionLabel = new javax.swing.JLabel();
         descriptionScrollPane = new javax.swing.JScrollPane();
         descriptionTextArea = new javax.swing.JTextArea();
@@ -65,14 +67,14 @@
 
             },
             new String [] {
-                "App", "Name", "Author", "Version", "Status"
+                "App", "Name", "Version", "Status"
             }
         ) {
 
                        private static final long serialVersionUID = 
919039586559362963L;
                        
                        boolean[] canEdit = new boolean [] {
-                false, false, false, false, false
+                false, false, false, false
             };
 
             public boolean isCellEditable(int rowIndex, int columnIndex) {
@@ -101,6 +103,14 @@
             }
         });
 
+        uninstallSelectedButton.setText("Uninstall");
+        uninstallSelectedButton.setEnabled(false);
+        uninstallSelectedButton.addActionListener(new 
java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                uninstallSelectedButtonActionPerformed(evt);
+            }
+        });
+
         descriptionLabel.setText("App Information:");
 
         descriptionTextArea.setEditable(false);
@@ -120,6 +130,8 @@
                         
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                             .add(descriptionLabel)
                             .add(layout.createSequentialGroup()
+                                .add(uninstallSelectedButton)
+                                
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                 .add(disableSelectedButton)
                                 
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                 .add(enableSelectedButton))
@@ -141,12 +153,12 @@
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                 
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(enableSelectedButton)
-                    .add(disableSelectedButton))
+                    .add(disableSelectedButton)
+                    .add(uninstallSelectedButton))
                 .addContainerGap())
         );
     }
         
-        
     private void 
enableSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // Obtain App objects corresponding to currently selected table entries
         Set<App> selectedApps = getSelectedApps();
@@ -165,10 +177,33 @@
         
         enableSelectedButton.setEnabled(false);
         disableSelectedButton.setEnabled(true);
+        uninstallSelectedButton.setEnabled(true);
     }
 
     private void 
disableSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // Obtain App objects corresponding to currently selected table entries
+        Set<App> selectedApps = getSelectedApps();
+        
+        for (App app : selectedApps) {
+               if (app.getStatus().equals(AppStatus.DISABLED))
+                continue;
+            /*
+            try {
+            } catch (AppInstallException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            */
+        }
+        
+        disableSelectedButton.setEnabled(false);
+        enableSelectedButton.setEnabled(true);
+        uninstallSelectedButton.setEnabled(true);
+    }
+
+
+    private void 
uninstallSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+       // Obtain App objects corresponding to currently selected table entries
        Set<App> selectedApps = getSelectedApps();
         
         for (App app : selectedApps) {
@@ -183,7 +218,8 @@
                }
         }
         
-        disableSelectedButton.setEnabled(false);
+        uninstallSelectedButton.setEnabled(false);
+        disableSelectedButton.setEnabled(true);
         enableSelectedButton.setEnabled(true);
     }
 
@@ -261,7 +297,6 @@
                tableModel.addRow(new Object[]{
                                        app,
                                        app.getAppFile() != null ? 
app.getAppName() : app.getAppName() + " (File moved)",
-                                       app.getAuthors(),
                                        app.getVersion(),
                                        app.getStatus()
                        });
@@ -274,16 +309,8 @@
      * Update the labels that display the number of currently installed and 
available apps.
      */
     private void updateLabels() {
-       int installedCount = 0;
+       int installedCount = appManager.getApps().size();
        
-       for (App app : appManager.getApps()) {
-               // Simple apps require a restart to be completely uninstalled; 
count them as installed
-               // until the restart
-               if (app.getStatus() != AppStatus.UNINSTALLED) {
-                       installedCount++;
-               }
-       }
-       
        appsInstalledLabel.setText(installedCount + " Apps installed.");
     }
     
@@ -311,7 +338,7 @@
                
                // Disable buttons
                enableSelectedButton.setEnabled(false);
-               disableSelectedButton.setEnabled(false);
+               uninstallSelectedButton.setEnabled(false);
                
        // If a single app is selected, show its app description
        } else if (numSelected == 1){
@@ -323,10 +350,10 @@
                // Enable/disable the appropriate button
                if (selectedApp.getStatus() == AppStatus.INSTALLED) {
                        enableSelectedButton.setEnabled(false);
-                       disableSelectedButton.setEnabled(true);
+                       uninstallSelectedButton.setEnabled(true);
                } else {
                        enableSelectedButton.setEnabled(true);
-                       disableSelectedButton.setEnabled(false);
+                       uninstallSelectedButton.setEnabled(false);
                }
        } else {
                descriptionTextArea.setText(numSelected + " apps selected.");
@@ -347,15 +374,15 @@
                
                if (allInstalled) {
                        enableSelectedButton.setEnabled(false);
-                       disableSelectedButton.setEnabled(true);
+                       uninstallSelectedButton.setEnabled(true);
                } else if (allUninstalled) {
                        enableSelectedButton.setEnabled(true);
-                       disableSelectedButton.setEnabled(false);
+                       uninstallSelectedButton.setEnabled(false);
                } else {
                        // If some of the selected apps are installed and some 
are uninstalled,
                        // enable both buttons
                        enableSelectedButton.setEnabled(true);
-                       disableSelectedButton.setEnabled(true);
+                       uninstallSelectedButton.setEnabled(true);
                }
        }
     }

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