OSDN Git Service

SDK Updater: Cleanup a bunch of todos
authorRaphael <raphael@google.com>
Fri, 26 Jun 2009 03:00:05 +0000 (20:00 -0700)
committerRaphael <raphael@google.com>
Fri, 26 Jun 2009 03:00:05 +0000 (20:00 -0700)
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSources.java
tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
tools/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterWindowImpl.java

index b9c3da2..85160a3 100644 (file)
@@ -180,7 +180,9 @@ public final class SdkManager {
                 writer.write(String.format("0x%04x\n", i));
             }
         } finally {
-            writer.close();
+            if (writer != null) {
+                writer.close();
+            }
         }
     }
 
index 622a6f2..85dbbd0 100755 (executable)
@@ -122,7 +122,7 @@ public class PlatformPackage extends Package {
 \r
         File platforms = new File(osSdkRoot, SdkConstants.FD_PLATFORMS);\r
         File folder = new File(platforms, String.format("android-%s", getVersion())); //$NON-NLS-1$\r
-        // TODO find similar existing platform in platforms folder\r
+\r
         return folder;\r
     }\r
 \r
index 7a024c4..a15014d 100755 (executable)
@@ -18,6 +18,7 @@ package com.android.sdklib.internal.repository;
 \r
 import com.android.prefs.AndroidLocation;\r
 import com.android.prefs.AndroidLocation.AndroidLocationException;\r
+import com.android.sdklib.ISdkLog;\r
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
@@ -68,7 +69,7 @@ public class RepoSources {
      * Loads all user sources. This <em>replaces</em> all existing user sources\r
      * by the ones from the property file.\r
      */\r
-    public void loadUserSources() {\r
+    public void loadUserSources(ISdkLog log) {\r
 \r
         // Remove all existing user sources\r
         for (Iterator<RepoSource> it = mSources.iterator(); it.hasNext(); ) {\r
@@ -100,14 +101,14 @@ public class RepoSources {
             }\r
 \r
         } catch (NumberFormatException e) {\r
-            // TODO print to log\r
-            e.printStackTrace();\r
+            log.error(e, null);\r
+\r
         } catch (AndroidLocationException e) {\r
-            // TODO print to log\r
-            e.printStackTrace();\r
+            log.error(e, null);\r
+\r
         } catch (IOException e) {\r
-            // TODO print to log\r
-            e.printStackTrace();\r
+            log.error(e, null);\r
+\r
         } finally {\r
             if (fis != null) {\r
                 try {\r
@@ -121,8 +122,9 @@ public class RepoSources {
 \r
     /**\r
      * Saves all the user sources.\r
+     * @param log\r
      */\r
-    public void saveUserSources() {\r
+    public void saveUserSources(ISdkLog log) {\r
         FileOutputStream fos = null;\r
         try {\r
             String folder = AndroidLocation.getFolder();\r
@@ -144,11 +146,11 @@ public class RepoSources {
             props.store( fos, "## User Sources for Android tool");  //$NON-NLS-1$\r
 \r
         } catch (AndroidLocationException e) {\r
-            // TODO print to log\r
-            e.printStackTrace();\r
+            log.error(e, null);\r
+\r
         } catch (IOException e) {\r
-            // TODO print to log\r
-            e.printStackTrace();\r
+            log.error(e, null);\r
+\r
         } finally {\r
             if (fos != null) {\r
                 try {\r
index 5e32c5a..f5b28ea 100755 (executable)
@@ -47,11 +47,6 @@ import org.eclipse.swt.widgets.TreeColumn;
 \r
 import java.util.ArrayList;\r
 \r
-/*\r
- * TODO list\r
- * - load add-on sites from pref\r
- * - delete site callback, update pref\r
- */\r
 \r
 public class RemotePackagesPage extends Composite implements ISdkListener {\r
 \r
@@ -260,18 +255,12 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
         mTreeViewerSources.setExpandedState(pkg, true);\r
         for (Object archive : provider.getChildren(pkg)) {\r
             if (archive instanceof Archive) {\r
-                if (((Archive) archive).isCompatible()) {\r
-                    mTreeViewerSources.setChecked(archive, true);\r
-                } else {\r
-                    mTreeViewerSources.setChecked(archive, false);\r
-                    // TODO change the item image to mark it incompatible\r
-                }\r
+                mTreeViewerSources.setChecked(archive, ((Archive) archive).isCompatible());\r
             }\r
         }\r
     }\r
 \r
     private void onInstallSelectedArchives() {\r
-\r
         ArrayList<Archive> archives = new ArrayList<Archive>();\r
         for (Object element : mTreeViewerSources.getCheckedElements()) {\r
             if (element instanceof Archive) {\r
@@ -292,7 +281,7 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
         boolean changed = false;\r
 \r
         ISelection sel = mTreeViewerSources.getSelection();\r
-        if (sel instanceof ITreeSelection) {\r
+        if (mUpdaterData != null && sel instanceof ITreeSelection) {\r
             for (Object c : ((ITreeSelection) sel).toList()) {\r
                 if (c instanceof RepoSource && ((RepoSource) c).isUserSource()) {\r
                     RepoSource source = (RepoSource) c;\r
index a0b591e..109000b 100755 (executable)
@@ -219,7 +219,7 @@ class UpdaterData {
             try {\r
                 mAvdManager.reloadAvds();\r
             } catch (AndroidLocationException e) {\r
-                // FIXME\r
+                mSdkLog.error(e, null);\r
             }\r
         }\r
     }\r
@@ -236,7 +236,7 @@ class UpdaterData {
                         try {\r
                             listener.onSdkChange();\r
                         } catch (Throwable t) {\r
-                            // TODO: log error\r
+                            mSdkLog.error(t, null);\r
                         }\r
                     }\r
                 }\r
index 8534b96..2605410 100755 (executable)
@@ -227,7 +227,7 @@ public class UpdaterWindowImpl {
      * Called by the main loop when the window has been disposed.\r
      */\r
     private void dispose() {\r
-        mUpdaterData.getSources().saveUserSources();\r
+        mUpdaterData.getSources().saveUserSources(mUpdaterData.getSdkLog());\r
     }\r
 \r
     // --- page switching ---\r
@@ -325,7 +325,7 @@ public class UpdaterWindowImpl {
         }\r
 \r
         // Load user sources\r
-        sources.loadUserSources();\r
+        sources.loadUserSources(mUpdaterData.getSdkLog());\r
 \r
         mRemotePackagesPage.onSdkChange();\r
     }\r