| author | François Rajotte | 2013-02-28 11:12:35 (EST) |
|---|---|---|
| committer | Patrick Tasse | 2013-02-28 14:07:18 (EST) |
| commit | 7f08fa6ac161f95fe1d9f2564476e3ec2f168a4d (patch) (side-by-side diff) | |
| tree | e723cdb0cdc59cbfb6b22ea7d0782f8e656a2158 | |
| parent | 54c535689a8500baeb47535fe60b138b3fc21530 (diff) | |
| download | org.eclipse.linuxtools-7f08fa6ac161f95fe1d9f2564476e3ec2f168a4d.zip org.eclipse.linuxtools-7f08fa6ac161f95fe1d9f2564476e3ec2f168a4d.tar.gz org.eclipse.linuxtools-7f08fa6ac161f95fe1d9f2564476e3ec2f168a4d.tar.bz2 | |
Change the TimeGraphCombo's filter to a blacklist rather than a whitelistrefs/changes/40/10740/5
This should better support views that modify the list of entries dynamically.
Change-Id: I1a5e324d49a58e8444d4767542815c1e00836c64
Signed-off-by: François Rajotte <francois.rajotte@polymtl.ca>
Reviewed-on: https://git.eclipse.org/r/10740
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
| -rw-r--r-- | lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java index c21ac3a..cb753cc 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Ericsson + * Copyright (c) 2012, 2013 Ericsson, others * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -8,6 +8,7 @@ * * Contributors: * Patrick Tasse - Initial API and implementation + * François Rajotte - Filter implementation *******************************************************************************/ package org.eclipse.linuxtools.tmf.ui.widgets.timegraph; @@ -288,28 +289,28 @@ public class TimeGraphCombo extends Composite { } /** - * This filter simply keeps a list of elements that should be shown. - * All the other elements will be filtered. + * This filter simply keeps a list of elements that should be filtered out. + * All the other elements will be shown. * By default and when the list is set to null, all elements are shown. */ private class RawViewerFilter extends ViewerFilter { - private List<Object> fNonFiltered = null; + private List<Object> fFiltered = null; - public void setNonFiltered(List<Object> objects) { - fNonFiltered = objects; + public void setFiltered(List<Object> objects) { + fFiltered = objects; } - public List<Object> getNonFiltered() { - return fNonFiltered; + public List<Object> getFiltered() { + return fFiltered; } @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - if (fNonFiltered == null) { + if (fFiltered == null) { return true; } - return fNonFiltered.contains(element); + return !fFiltered.contains(element); } } @@ -634,8 +635,10 @@ public class TimeGraphCombo extends Composite { fFilterDialog.setTitle(Messages.TmfTimeFilterDialog_WINDOW_TITLE); fFilterDialog.setMessage(Messages.TmfTimeFilterDialog_MESSAGE); fFilterDialog.setExpandedElements(allElements.toArray()); - if (fFilter.getNonFiltered() != null) { - fFilterDialog.setInitialElementSelections(fFilter.getNonFiltered()); + if (fFilter.getFiltered() != null) { + ArrayList<? extends ITimeGraphEntry> nonFilteredElements = new ArrayList<ITimeGraphEntry>(allElements); + nonFilteredElements.removeAll(fFilter.getFiltered()); + fFilterDialog.setInitialElementSelections(nonFilteredElements); } else { fFilterDialog.setInitialElementSelections(allElements); } @@ -645,9 +648,11 @@ public class TimeGraphCombo extends Composite { if (fFilterDialog.getResult() != null) { fInhibitTreeSelection = true; if (fFilterDialog.getResult().length != allElements.size()) { - fFilter.setNonFiltered(new ArrayList<Object>(Arrays.asList(fFilterDialog.getResult()))); + ArrayList<Object> filteredElements = new ArrayList<Object>(allElements); + filteredElements.removeAll(Arrays.asList(fFilterDialog.getResult())); + fFilter.setFiltered(filteredElements); } else { - fFilter.setNonFiltered(null); + fFilter.setFiltered(null); } fTreeViewer.refresh(); fTreeViewer.expandAll(); @@ -781,7 +786,7 @@ public class TimeGraphCombo extends Composite { */ public void setInput(ITimeGraphEntry[] input) { fTopInput = new ArrayList<ITimeGraphEntry>(Arrays.asList(input)); - fFilter.setNonFiltered(null); + fFilter.setFiltered(null); fInhibitTreeSelection = true; fTreeViewer.setInput(input); for (SelectionListenerWrapper listenerWrapper : fSelectionListenerMap.values()) { |

