SDK Updater: Better handling of fetch errors.
The remote page now shows fetch errors in the tree. Using refresh tries to reload error sources.
This commit is contained in:
@@ -36,10 +36,28 @@ import org.eclipse.swt.graphics.Image;
|
||||
*
|
||||
* This implementation is UI dependent.
|
||||
*/
|
||||
class RepoSourcesAdapter {
|
||||
public class RepoSourcesAdapter {
|
||||
|
||||
private final UpdaterData mUpdaterData;
|
||||
|
||||
public static class RepoSourceError implements IDescription {
|
||||
|
||||
private final RepoSource mSource;
|
||||
|
||||
public RepoSourceError(RepoSource source) {
|
||||
mSource = source;
|
||||
}
|
||||
|
||||
public String getLongDescription() {
|
||||
return mSource.getLongDescription();
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return mSource.getFetchError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RepoSourcesAdapter(UpdaterData updaterData) {
|
||||
mUpdaterData = updaterData;
|
||||
}
|
||||
@@ -55,7 +73,7 @@ class RepoSourcesAdapter {
|
||||
|
||||
// ------------
|
||||
|
||||
public class ViewerLabelProvider extends LabelProvider {
|
||||
private class ViewerLabelProvider extends LabelProvider {
|
||||
|
||||
/** Returns an image appropriate for this element. */
|
||||
@Override
|
||||
@@ -119,8 +137,7 @@ class RepoSourcesAdapter {
|
||||
final RepoSource source = (RepoSource) parentElement;
|
||||
Package[] packages = source.getPackages();
|
||||
|
||||
if (packages == null) {
|
||||
|
||||
if (packages == null && source.getFetchError() == null) {
|
||||
final boolean forceHttp = mUpdaterData.getSettingsController().getForceHttp();
|
||||
|
||||
mUpdaterData.getTaskFactory().start("Loading Source", new ITask() {
|
||||
@@ -133,6 +150,9 @@ class RepoSourcesAdapter {
|
||||
}
|
||||
if (packages != null) {
|
||||
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) {
|
||||
|
||||
@@ -359,7 +359,9 @@ class UpdaterData {
|
||||
RepoSource[] sources = mSources.getSources();
|
||||
monitor.setProgressMax(sources.length);
|
||||
for (RepoSource source : sources) {
|
||||
if (forceFetching || source.getPackages() != null) {
|
||||
if (forceFetching ||
|
||||
source.getPackages() != null ||
|
||||
source.getFetchError() != null) {
|
||||
source.load(monitor.createSubMonitor(1), forceHttp);
|
||||
}
|
||||
monitor.incProgress(1);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.android.sdklib.internal.repository.Package;
|
||||
import com.android.sdklib.internal.repository.PlatformPackage;
|
||||
import com.android.sdklib.internal.repository.RepoSource;
|
||||
import com.android.sdklib.internal.repository.ToolPackage;
|
||||
import com.android.sdkuilib.internal.repository.RepoSourcesAdapter;
|
||||
|
||||
import org.eclipse.swt.SWTException;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
@@ -92,6 +93,9 @@ public class ImageFactory {
|
||||
if (object instanceof RepoSource) {
|
||||
return getImageByName("source_icon16.png");
|
||||
|
||||
} else if (object instanceof RepoSourcesAdapter.RepoSourceError) {
|
||||
return getImageByName("error_icon16.png");
|
||||
|
||||
} else if (object instanceof PlatformPackage) {
|
||||
return getImageByName("android_icon_16.png");
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 626 B |
Reference in New Issue
Block a user