diff options
author | Raphael Moll <ralf@android.com> | 2012-11-26 15:04:41 -0800 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-11-26 15:04:42 -0800 |
commit | e34bfe70f739bc0640c0bd955527007b8be9ce92 (patch) | |
tree | 6f33b06e80c8a0328c5a1be70428530021b3b1a8 /sdkmanager/libs | |
parent | f1e120d3a173d80023fd8f001bbf0960dbc01a3b (diff) | |
parent | 3fae5f5a94d6b8ef9a6126bfc3e45823696b0542 (diff) | |
download | sdk-e34bfe70f739bc0640c0bd955527007b8be9ce92.zip sdk-e34bfe70f739bc0640c0bd955527007b8be9ce92.tar.gz sdk-e34bfe70f739bc0640c0bd955527007b8be9ce92.tar.bz2 |
Merge "SDK Manager: fix to auto-select top platfrom at startup."
Diffstat (limited to 'sdkmanager/libs')
3 files changed, 44 insertions, 25 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPage.java index d1fc6af..d9a1102 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPage.java @@ -150,6 +150,12 @@ public final class PackagesPage extends Composite implements ISdkChangeListener mGroupPackages.getDisplay().syncExec(runnable); } }; + + @Override + protected void syncViewerSelection() { + PackagesPage.this.syncViewerSelection(); + } + @Override protected void refreshViewerInput() { PackagesPage.this.refreshViewerInput(); @@ -478,7 +484,6 @@ public final class PackagesPage extends Composite implements ISdkChangeListener mTreeViewer.setInput(null); refreshViewerInput(); syncViewerSelection(); - updateButtonsState(); break; case TOGGLE_SHOW_INSTALLED_PKG: button = mCheckFilterInstalled; @@ -882,10 +887,9 @@ public final class PackagesPage extends Composite implements ISdkChangeListener * for initial run. */ private void onSelectNewUpdates(boolean selectNew, boolean selectUpdates, boolean selectTop) { - // This does not update the tree itself, syncViewerSelection does it below. + // This will update the tree's "selected" state and then invoke syncViewerSelection() + // which will in turn update tree. mImpl.onSelectNewUpdates(selectNew, selectUpdates, selectTop); - syncViewerSelection(); - updateButtonsState(); } /** @@ -895,7 +899,6 @@ public final class PackagesPage extends Composite implements ISdkChangeListener // This does not update the tree itself, syncViewerSelection does it below. mImpl.onDeselectAll(); syncViewerSelection(); - updateButtonsState(); } /** @@ -935,33 +938,38 @@ public final class PackagesPage extends Composite implements ISdkChangeListener ITreeContentProvider provider = (ITreeContentProvider) mTreeViewer.getContentProvider(); Object input = mTreeViewer.getInput(); - if (input == null) { - return; - } - for (Object cat : provider.getElements(input)) { - Object[] children = provider.getElements(cat); - boolean allChecked = children.length > 0; - for (Object child : children) { - if (child instanceof PkgItem) { - PkgItem item = (PkgItem) child; - boolean checked = item.isChecked(); - allChecked &= checked; - - if (checked != mTreeViewer.getChecked(item)) { - if (checked) { - if (!mTreeViewer.getExpandedState(cat)) { - mTreeViewer.setExpandedState(cat, true); + if (input != null) { + for (Object cat : provider.getElements(input)) { + Object[] children = provider.getElements(cat); + boolean allChecked = children.length > 0; + for (Object child : children) { + if (child instanceof PkgItem) { + PkgItem item = (PkgItem) child; + boolean checked = item.isChecked(); + allChecked &= checked; + + if (checked != mTreeViewer.getChecked(item)) { + if (checked) { + if (!mTreeViewer.getExpandedState(cat)) { + mTreeViewer.setExpandedState(cat, true); + } } + checkAndExpandItem( + item, + checked, + true/*fixChildren*/, + false/*fixParent*/); } - checkAndExpandItem(item, checked, true/*fixChildren*/, false/*fixParent*/); } } - } - if (allChecked != mTreeViewer.getChecked(cat)) { - mTreeViewer.setChecked(cat, allChecked); + if (allChecked != mTreeViewer.getChecked(cat)) { + mTreeViewer.setChecked(cat, allChecked); + } } } + + updateButtonsState(); } /** diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPageImpl.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPageImpl.java index 3ca0ee3..96d9db2 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPageImpl.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/ui/PackagesPageImpl.java @@ -82,6 +82,11 @@ abstract class PackagesPageImpl { */ abstract protected void syncExec(Runnable runnable); + /** + * Synchronizes the 'checked' state of PkgItems in the tree with their internal isChecked state. + */ + abstract protected void syncViewerSelection(); + void performFirstLoad() { // First a package loader is created that only checks // the local cache xml files. It populates the package @@ -310,6 +315,7 @@ abstract class PackagesPageImpl { selectUpdates, selectTop, SdkConstants.CURRENT_PLATFORM); + syncViewerSelection(); } /** diff --git a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/ui/MockPackagesPageImpl.java b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/ui/MockPackagesPageImpl.java index 9ab36c1..04b3027 100755 --- a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/ui/MockPackagesPageImpl.java +++ b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/ui/MockPackagesPageImpl.java @@ -49,6 +49,11 @@ public class MockPackagesPageImpl extends PackagesPageImpl { runnable.run(); } + @Override + protected void syncViewerSelection() { + // No-op. There is no real tree viewer to synchronize. + } + private MockTreeViewer mTreeViewer; @Override |