diff options
author | Susan Franklin | 2010-04-25 19:59:51 +0000 |
---|---|---|
committer | Susan Franklin | 2010-04-25 19:59:51 +0000 |
commit | e0a22aa70c8cef209c84aa20046b3b251d92f136 (patch) | |
tree | 368aa0585b32fc80c877c7e989e30f855519db8d /bundles/org.eclipse.equinox.p2.ui | |
parent | 57c28d728824552e9acde7e927dcc48306f71a45 (diff) | |
download | rt.equinox.p2-e0a22aa70c8cef209c84aa20046b3b251d92f136.tar.gz rt.equinox.p2-e0a22aa70c8cef209c84aa20046b3b251d92f136.tar.xz rt.equinox.p2-e0a22aa70c8cef209c84aa20046b3b251d92f136.zip |
Bug 278189 - [ui] Install new software dialog should have selection buttons
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui')
2 files changed, 37 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java index c4fcd9c1e..aab30eb38 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java @@ -440,9 +440,12 @@ public class AvailableIUGroup extends StructuredIUGroup { */ public void setChecked(Object[] selections) { filteredTree.getCheckboxTreeViewer().setCheckedElements(selections); - // Relying on knowledge that DelayedFilterCheckbox doesn't care which element is in the listener - Object element = selections.length > 0 ? selections[0] : new Object(); - filteredTree.getCheckboxTreeViewer().fireCheckStateChanged(element, true); + // TODO HACK ALERT! + // Since We don't have API for setAllChecked(boolean), clients have to use this method. + // We need to signal DelayedFilterCheckboxTree when everything needs to be deselected since + // we aren't firing an event for each item. + Object element = selections.length == 0 ? DelayedFilterCheckboxTree.ALL_ITEMS_HACK : selections[0]; + filteredTree.getCheckboxTreeViewer().fireCheckStateChanged(element, selections.length > 0); } public void setRepositoryFilter(int filterFlag, URI repoLocation) { diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java index 25c222924..296faa04d 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java @@ -36,6 +36,8 @@ public class DelayedFilterCheckboxTree extends FilteredTree { private static final long FILTER_DELAY = 400; + public static final Object ALL_ITEMS_HACK = new Object(); + ToolBar toolBar; Display display; PatternFilter patternFilter; @@ -64,35 +66,39 @@ public class DelayedFilterCheckboxTree extends FilteredTree { // We use an additive check state cache so we need to remove // previously checked items if the user unchecked them. if (!event.getChecked() && checkState != null) { - ArrayList<Object> toRemove = new ArrayList<Object>(1); - // See bug 258117. Ideally we would get check state changes - // for children when the parent state changed, but we aren't, so - // we need to remove all children from the additive check state - // cache. - if (contentProvider.hasChildren(event.getElement())) { - Set<Object> unchecked = new HashSet<Object>(); - Object[] children = contentProvider.getChildren(event.getElement()); - for (int i = 0; i < children.length; i++) { - unchecked.add(children[i]); - } - Iterator<Object> iter = checkState.iterator(); - while (iter.hasNext()) { - Object current = iter.next(); - if (current != null && unchecked.contains(current)) { - toRemove.add(current); + if (event.getElement() == ALL_ITEMS_HACK) + clearCheckStateCache(); + else { + ArrayList<Object> toRemove = new ArrayList<Object>(1); + // See bug 258117. Ideally we would get check state changes + // for children when the parent state changed, but we aren't, so + // we need to remove all children from the additive check state + // cache. + if (contentProvider.hasChildren(event.getElement())) { + Set<Object> unchecked = new HashSet<Object>(); + Object[] children = contentProvider.getChildren(event.getElement()); + for (int i = 0; i < children.length; i++) { + unchecked.add(children[i]); } - } - } else { - for (Object element : checkState) { - if (checkboxViewer.getComparer().equals(element, event.getElement())) { - toRemove.add(element); - // Do not break out of the loop. We may have duplicate equal - // elements in the cache. Since the cache is additive, we want - // to be sure we've gotten everything. + Iterator<Object> iter = checkState.iterator(); + while (iter.hasNext()) { + Object current = iter.next(); + if (current != null && unchecked.contains(current)) { + toRemove.add(current); + } + } + } else { + for (Object element : checkState) { + if (checkboxViewer.getComparer().equals(element, event.getElement())) { + toRemove.add(element); + // Do not break out of the loop. We may have duplicate equal + // elements in the cache. Since the cache is additive, we want + // to be sure we've gotten everything. + } } } + checkState.removeAll(toRemove); } - checkState.removeAll(toRemove); } else if (event.getChecked()) { rememberLeafCheckState(); } |