am 093fff99: Merge change 20808 into donut
Merge commit '093fff996e834dae50df6c6713e6ffcf4e7a3667' * commit '093fff996e834dae50df6c6713e6ffcf4e7a3667': BUG 2039245 : Need to show something in the source if there are no available package
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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,7 +169,21 @@ public class RepoSourcesAdapter {
|
||||
return mUpdaterData.getSources().getSources();
|
||||
|
||||
} else if (parentElement instanceof RepoSource) {
|
||||
final RepoSource source = (RepoSource) parentElement;
|
||||
return getRepoSourceChildren((RepoSource) parentElement);
|
||||
|
||||
} else if (parentElement instanceof Package) {
|
||||
return getPackageChildren((Package) parentElement);
|
||||
}
|
||||
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
if (packages == null && source.getFetchError() == null) {
|
||||
@@ -151,19 +197,36 @@ public class RepoSourcesAdapter {
|
||||
|
||||
packages = source.getPackages();
|
||||
}
|
||||
if (packages != null) {
|
||||
|
||||
boolean wasEmptyBeforeFilter = (packages == null || packages.length == 0);
|
||||
|
||||
// filter out only the packages that are new/upgrade.
|
||||
if (mUpdaterData.getSettingsController().getShowUpdateOnly()) {
|
||||
return filteredPackages(packages);
|
||||
if (packages != null && mUpdaterData.getSettingsController().getShowUpdateOnly()) {
|
||||
packages = filteredPackages(packages);
|
||||
}
|
||||
return packages;
|
||||
} else if (source.getFetchError() != null) {
|
||||
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) };
|
||||
}
|
||||
|
||||
} else if (parentElement instanceof Package) {
|
||||
Archive[] archives = ((Package) parentElement).getArchives();
|
||||
// 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
|
||||
@@ -178,9 +241,6 @@ public class RepoSourcesAdapter {
|
||||
return archives;
|
||||
}
|
||||
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent of a given element.
|
||||
* The input {@link RepoSourcesAdapter} is the parent of all {@link RepoSource} elements.
|
||||
@@ -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()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 397 B |
Reference in New Issue
Block a user