diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-11 15:44:37 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-11 15:44:37 -0700 |
commit | 59c906cc302695ccfdbea5f57f100dbb65519a23 (patch) | |
tree | cc15817ecc10d1afc417f808837e63ad83966a8e | |
parent | 0d1a6d1a7bc9e4d1d3b6ca9bafb24fe6f9cc984f (diff) | |
parent | 91b8a2ab33121bccb37b439eb8974ccfefa0d9a0 (diff) | |
download | sdk-59c906cc302695ccfdbea5f57f100dbb65519a23.zip sdk-59c906cc302695ccfdbea5f57f100dbb65519a23.tar.gz sdk-59c906cc302695ccfdbea5f57f100dbb65519a23.tar.bz2 |
Merge change 20808 into donut
* changes:
BUG 2039245 : Need to show something in the source if there are no available package
4 files changed, 119 insertions, 59 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java index a7c1a83..6ea040c 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java @@ -62,7 +62,6 @@ public class RemotePackagesPage extends Composite implements ISdkListener { private Group mDescriptionContainer;
private Button mAddSiteButton;
private Button mDeleteSiteButton;
- private Label mPlaceholder3;
private Button mRefreshButton;
private Button mInstallSelectedButton;
private Label mDescriptionLabel;
@@ -118,16 +117,6 @@ public class RemotePackagesPage extends Composite implements ISdkListener { spacer.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
gd.heightHint = 0;
- mUpdateOnlyCheckBox = new Button(composite, SWT.CHECK);
- mUpdateOnlyCheckBox.setText("Display updates only");
- mUpdateOnlyCheckBox.setSelection(mUpdaterData.getSettingsController().getShowUpdateOnly());
- mUpdateOnlyCheckBox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- onShowUpdateOnly(); //$hide$
- }
- });
-
mDescriptionContainer = new Group(parent, SWT.NONE);
mDescriptionContainer.setLayout(new GridLayout(1, false));
mDescriptionContainer.setText("Description");
@@ -155,8 +144,16 @@ public class RemotePackagesPage extends Composite implements ISdkListener { });
mDeleteSiteButton.setText("Delete Site...");
- mPlaceholder3 = new Label(parent, SWT.NONE);
- mPlaceholder3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
+ mUpdateOnlyCheckBox = new Button(parent, SWT.CHECK);
+ mUpdateOnlyCheckBox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
+ mUpdateOnlyCheckBox.setText("Display updates only");
+ mUpdateOnlyCheckBox.setSelection(mUpdaterData.getSettingsController().getShowUpdateOnly());
+ mUpdateOnlyCheckBox.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ onShowUpdateOnly(); //$hide$
+ }
+ });
mRefreshButton = new Button(parent, SWT.NONE);
mRefreshButton.addSelectionListener(new SelectionAdapter() {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java index dbf46f5..de12666 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java @@ -43,6 +43,11 @@ public class RepoSourcesAdapter { private final UpdaterData mUpdaterData;
+ /**
+ * A dummy RepoSource entry returned for sources which had load errors.
+ * It displays a summary of the error as its short description or
+ * it displays the source's long description.
+ */
public static class RepoSourceError implements IDescription {
private final RepoSource mSource;
@@ -60,6 +65,33 @@ public class RepoSourcesAdapter { }
}
+ /**
+ * A dummy RepoSource entry returned for sources with no packages.
+ * We need that to force the SWT tree to display an open/close triangle
+ * even for empty sources.
+ */
+ public static class RepoSourceEmpty implements IDescription {
+
+ private final RepoSource mSource;
+ private final boolean mEmptyBecauseOfUpdateOnly;
+
+ public RepoSourceEmpty(RepoSource source, boolean emptyBecauseOfUpdateOnly) {
+ mSource = source;
+ mEmptyBecauseOfUpdateOnly = emptyBecauseOfUpdateOnly;
+ }
+
+ public String getLongDescription() {
+ return mSource.getLongDescription();
+ }
+
+ public String getShortDescription() {
+ if (mEmptyBecauseOfUpdateOnly) {
+ return "Some packages were found but are not compatible updates.";
+ } else {
+ return "No packages found";
+ }
+ }
+ }
public RepoSourcesAdapter(UpdaterData updaterData) {
mUpdaterData = updaterData;
@@ -137,48 +169,76 @@ public class RepoSourcesAdapter { return mUpdaterData.getSources().getSources();
} else if (parentElement instanceof RepoSource) {
- final RepoSource source = (RepoSource) parentElement;
- Package[] packages = source.getPackages();
+ return getRepoSourceChildren((RepoSource) parentElement);
+
+ } else if (parentElement instanceof Package) {
+ return getPackageChildren((Package) parentElement);
+ }
+
+ return new Object[0];
+ }
- if (packages == null && source.getFetchError() == null) {
- final boolean forceHttp = mUpdaterData.getSettingsController().getForceHttp();
+ /**
+ * Returns the list of packages for this repo source, eventually filtered to display
+ * only update packages. If the list is empty, returns a specific empty node. If there's
+ * an error, returns a specific error node.
+ */
+ private Object[] getRepoSourceChildren(final RepoSource source) {
+ Package[] packages = source.getPackages();
- mUpdaterData.getTaskFactory().start("Loading Source", new ITask() {
- public void run(ITaskMonitor monitor) {
- source.load(monitor, forceHttp);
- }
- });
+ if (packages == null && source.getFetchError() == null) {
+ final boolean forceHttp = mUpdaterData.getSettingsController().getForceHttp();
- packages = source.getPackages();
- }
- if (packages != null) {
- // filter out only the packages that are new/upgrade.
- if (mUpdaterData.getSettingsController().getShowUpdateOnly()) {
- return filteredPackages(packages);
+ mUpdaterData.getTaskFactory().start("Loading Source", new ITask() {
+ public void run(ITaskMonitor monitor) {
+ source.load(monitor, forceHttp);
}
- return packages;
- } else if (source.getFetchError() != null) {
- // Return a dummy entry to display the fetch error
- return new Object[] { new RepoSourceError(source) };
- }
+ });
- } else if (parentElement instanceof Package) {
- Archive[] archives = ((Package) parentElement).getArchives();
- if (mUpdaterData.getSettingsController().getShowUpdateOnly()) {
- for (Archive archive : archives) {
- // if we only want the compatible archives, then we just take the first
- // one. it's unlikely there are 2 compatible archives for the same
- // package
- if (archive.isCompatible()) {
- return new Object[] { archive };
- }
+ packages = source.getPackages();
+ }
+
+ boolean wasEmptyBeforeFilter = (packages == null || packages.length == 0);
+
+ // filter out only the packages that are new/upgrade.
+ if (packages != null && mUpdaterData.getSettingsController().getShowUpdateOnly()) {
+ packages = filteredPackages(packages);
+ }
+ if (packages != null && packages.length == 0) {
+ packages = null;
+ }
+
+ if (packages != null && source.getFetchError() != null) {
+ // Return a dummy entry to display the fetch error
+ return new Object[] { new RepoSourceError(source) };
+ }
+
+ // Either return a non-null package list or create a new empty node
+ if (packages != null) {
+ return packages;
+ } else {
+ return new Object[] { new RepoSourceEmpty(source, !wasEmptyBeforeFilter) } ;
+ }
+ }
+
+ /**
+ * Returns the list of archives for the given package, eventually filtering it
+ * to only show the compatible archives.
+ */
+ private Object[] getPackageChildren(Package pkg) {
+ Archive[] archives = pkg.getArchives();
+ if (mUpdaterData.getSettingsController().getShowUpdateOnly()) {
+ for (Archive archive : archives) {
+ // if we only want the compatible archives, then we just take the first
+ // one. it's unlikely there are 2 compatible archives for the same
+ // package
+ if (archive.isCompatible()) {
+ return new Object[] { archive };
}
}
-
- return archives;
}
- return new Object[0];
+ return archives;
}
/**
@@ -213,7 +273,7 @@ public class RepoSourcesAdapter { * @param remotePackages the list of packages to filter.
* @return a non null (but maybe empty) list of new or update packages.
*/
- private Object[] filteredPackages(Package[] remotePackages) {
+ private Package[] filteredPackages(Package[] remotePackages) {
// get the installed packages
Package[] installedPackages = mUpdaterData.getInstalledPackage();
@@ -233,10 +293,10 @@ public class RepoSourcesAdapter { if (info == UpdateInfo.UPDATE) {
filteredList.add(remotePkg);
newPkg = false;
- break; // there shouldn't be 2 revision of the same package
+ break; // there shouldn't be 2 revisions of the same package
} else if (info != UpdateInfo.INCOMPATIBLE) {
newPkg = false;
- break; // there shouldn't be 2 revision of the same package
+ break; // there shouldn't be 2 revisions of the same package
}
}
@@ -247,6 +307,6 @@ public class RepoSourcesAdapter { }
}
- return filteredList.toArray();
+ return filteredList.toArray(new Package[filteredList.size()]);
}
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/ImageFactory.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/ImageFactory.java index bd39c5e..cbd846e 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/ImageFactory.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/ImageFactory.java @@ -91,31 +91,34 @@ public class ImageFactory { */
public Image getImageForObject(Object object) {
if (object instanceof RepoSource) {
- return getImageByName("source_icon16.png");
+ return getImageByName("source_icon16.png"); //$NON-NLS-1$
} else if (object instanceof RepoSourcesAdapter.RepoSourceError) {
- return getImageByName("error_icon16.png");
+ return getImageByName("error_icon16.png"); //$NON-NLS-1$
+
+ } else if (object instanceof RepoSourcesAdapter.RepoSourceEmpty) {
+ return getImageByName("nopkg_icon16.png"); //$NON-NLS-1$
} else if (object instanceof PlatformPackage) {
- return getImageByName("android_icon_16.png");
+ return getImageByName("android_icon_16.png"); //$NON-NLS-1$
} else if (object instanceof AddonPackage) {
- return getImageByName("addon_icon16.png");
+ return getImageByName("addon_icon16.png"); //$NON-NLS-1$
} else if (object instanceof ToolPackage) {
- return getImageByName("tool_icon16.png");
+ return getImageByName("tool_icon16.png"); //$NON-NLS-1$
} else if (object instanceof DocPackage) {
- return getImageByName("doc_icon16.png");
+ return getImageByName("doc_icon16.png"); //$NON-NLS-1$
} else if (object instanceof ExtraPackage) {
- return getImageByName("extra_icon16.png");
+ return getImageByName("extra_icon16.png"); //$NON-NLS-1$
} else if (object instanceof Archive) {
if (((Archive) object).isCompatible()) {
- return getImageByName("archive_icon16.png");
+ return getImageByName("archive_icon16.png"); //$NON-NLS-1$
} else {
- return getImageByName("incompat_icon16.png");
+ return getImageByName("incompat_icon16.png"); //$NON-NLS-1$
}
}
return null;
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/nopkg_icon16.png b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/nopkg_icon16.png Binary files differnew file mode 100755 index 0000000..147837f --- /dev/null +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/nopkg_icon16.png |