writer.write(String.format("0x%04x\n", i));
}
} finally {
- writer.close();
+ if (writer != null) {
+ writer.close();
+ }
}
}
\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
\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
* 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
}\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
\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
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
\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
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
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
try {\r
mAvdManager.reloadAvds();\r
} catch (AndroidLocationException e) {\r
- // FIXME\r
+ mSdkLog.error(e, null);\r
}\r
}\r
}\r
try {\r
listener.onSdkChange();\r
} catch (Throwable t) {\r
- // TODO: log error\r
+ mSdkLog.error(t, null);\r
}\r
}\r
}\r
* 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
}\r
\r
// Load user sources\r
- sources.loadUserSources();\r
+ sources.loadUserSources(mUpdaterData.getSdkLog());\r
\r
mRemotePackagesPage.onSdkChange();\r
}\r