summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSimon Marchi2013-03-14 14:53:05 (EDT)
committer Alexandre Montplaisir2013-03-18 15:46:40 (EDT)
commitf16f88579e461dc603aeeb9c4d9b70d4c81a8069 (patch)
treeecadfca3129f2f9948db6891ac90f91b3888dac8
parent29fb2e77d18a54f03cc889fb44eb51a99d9a01a4 (diff)
downloadorg.eclipse.linuxtools-f16f88579e461dc603aeeb9c4d9b70d4c81a8069.zip
org.eclipse.linuxtools-f16f88579e461dc603aeeb9c4d9b70d4c81a8069.tar.gz
org.eclipse.linuxtools-f16f88579e461dc603aeeb9c4d9b70d4c81a8069.tar.bz2
Add multiple selection in the time graph filter dialogrefs/changes/70/11170/9
* Add "(un)check selected" buttons * Change "(de)select all" to "(un)check all" * Remove container mode option Change-Id: Id002dc2f93589f2e8c209c87598476ba3f4006c0 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Signed-off-by: Fran├žois Rajotte <francois.rajotte@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/11170 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Hudson CI IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java145
3 files changed, 92 insertions, 65 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
index 8251105..059a487 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
@@ -101,8 +101,10 @@ public class Messages extends NLS {
public static String TmfTimeLegend_StateTypeName;
public static String TmfTimeFilterDialog_WINDOW_TITLE;
public static String TmfTimeFilterDialog_MESSAGE;
- public static String TmfTimeFilterDialog_SELECT_ALL;
- public static String TmfTimeFilterDialog_DESELECT_ALL;
+ public static String TmfTimeFilterDialog_CHECK_ALL;
+ public static String TmfTimeFilterDialog_UNCHECK_ALL;
+ public static String TmfTimeFilterDialog_CHECK_SELECTED;
+ public static String TmfTimeFilterDialog_UNCHECK_SELECTED;
public static String TmfTimeTipHandler_DURATION;
public static String TmfTimeTipHandler_TRACE_DATE;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
index c85d0a0..db97d10 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
@@ -84,8 +84,10 @@ TmfTimeLegend_WINDOW_TITLE=Trace Visualizer's Legend
TmfTimeLegend_StateTypeName=States
TmfTimeFilterDialog_WINDOW_TITLE=Filter
TmfTimeFilterDialog_MESSAGE=Check the entries to show
-TmfTimeFilterDialog_SELECT_ALL=Select all
-TmfTimeFilterDialog_DESELECT_ALL=Deselect all
+TmfTimeFilterDialog_CHECK_ALL=Check all
+TmfTimeFilterDialog_UNCHECK_ALL=Uncheck all
+TmfTimeFilterDialog_CHECK_SELECTED=Check selected
+TmfTimeFilterDialog_UNCHECK_SELECTED=Uncheck selected
# org.eclipse.linuxtools.tmf.ui.viewers.timegraph.widgets
TmfTimeTipHandler_DURATION=Duration
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
index c8d50e2..c8956ed 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java
@@ -29,6 +29,7 @@ import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.linuxtools.internal.tmf.ui.Messages;
@@ -37,7 +38,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -48,7 +48,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
@@ -90,8 +89,6 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
private int fHeight = 18;
- private boolean fContainerMode;
-
private Object[] fExpandedElements;
/**
@@ -105,22 +102,10 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
setResult(new ArrayList<Object>(0));
setStatusLineAboveButtons(true);
setHelpAvailable(false);
- fContainerMode = false;
fExpandedElements = null;
}
/**
- * If set, the checked /gray state of containers (inner nodes) is derived
- * from the checked state of its leaf nodes.
- *
- * @param containerMode
- * The containerMode to set
- */
- public void setContainerMode(boolean containerMode) {
- fContainerMode = containerMode;
- }
-
- /**
* Sets the initial selection. Convenience method.
*
* @param selection
@@ -315,11 +300,7 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
* @return the tree viewer
*/
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
- if (fContainerMode) {
- fViewer = new ContainerCheckedTreeViewer(parent, SWT.BORDER);
- } else {
- fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
- }
+ fViewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI);
Tree tree = fViewer.getTree();
tree.setHeaderVisible(true);
@@ -372,7 +353,7 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
protected Composite createSelectionButtons(Composite composite) {
Composite buttonComposite = new Composite(composite, SWT.RIGHT);
GridLayout layout = new GridLayout();
- layout.numColumns = 0;
+ layout.numColumns = 2;
layout.marginWidth = 0;
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
buttonComposite.setLayout(layout);
@@ -381,38 +362,97 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
| GridData.GRAB_HORIZONTAL);
data.grabExcessHorizontalSpace = true;
buttonComposite.setLayoutData(data);
- Button selectButton = createButton(buttonComposite,
- IDialogConstants.SELECT_ALL_ID, Messages.TmfTimeFilterDialog_SELECT_ALL,
+
+ /* Create the buttons in the good order to place them as we want */
+ Button checkAllButton = createButton(buttonComposite,
+ IDialogConstants.SELECT_ALL_ID, Messages.TmfTimeFilterDialog_CHECK_ALL,
+ false);
+ Button checkSelectedButton = createButton(buttonComposite,
+ IDialogConstants.CLIENT_ID, Messages.TmfTimeFilterDialog_CHECK_SELECTED,
+ false);
+ Button uncheckAllButton = createButton(buttonComposite,
+ IDialogConstants.DESELECT_ALL_ID, Messages.TmfTimeFilterDialog_UNCHECK_ALL,
+ false);
+ Button uncheckSelectedButton = createButton(buttonComposite,
+ IDialogConstants.CLIENT_ID + 1, Messages.TmfTimeFilterDialog_UNCHECK_SELECTED,
false);
- SelectionListener listener = new SelectionAdapter() {
+
+ /*
+ * Apply the layout again after creating the buttons to override
+ * createButton messing with the columns
+ */
+ layout.numColumns = 2;
+ buttonComposite.setLayout(layout);
+
+ /* Add a listener to each button */
+ checkAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] viewerElements = fContentProvider.getElements(fInput);
- if (fContainerMode) {
- fViewer.setCheckedElements(viewerElements);
- } else {
- for (int i = 0; i < viewerElements.length; i++) {
- fViewer.setSubtreeChecked(viewerElements[i], true);
- }
+
+ for (int i = 0; i < viewerElements.length; i++) {
+ fViewer.setSubtreeChecked(viewerElements[i], true);
}
+
updateOKStatus();
}
- };
- selectButton.addSelectionListener(listener);
- Button deselectButton = createButton(buttonComposite,
- IDialogConstants.DESELECT_ALL_ID, Messages.TmfTimeFilterDialog_DESELECT_ALL,
- false);
- listener = new SelectionAdapter() {
+ });
+
+ uncheckAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fViewer.setCheckedElements(new Object[0]);
updateOKStatus();
}
- };
- deselectButton.addSelectionListener(listener);
+ });
+
+ checkSelectedButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TreeSelection selection = (TreeSelection) fViewer.getSelection();
+
+ for (Object element : selection.toArray()) {
+ checkElement(element);
+ }
+
+ updateOKStatus();
+ }
+ });
+
+ uncheckSelectedButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TreeSelection selection = (TreeSelection) fViewer.getSelection();
+
+ for (Object element : selection.toArray()) {
+ uncheckElement(element);
+ }
+
+ updateOKStatus();
+ }
+ });
+
return buttonComposite;
}
+ private void checkElement(Object element) {
+ Object e = element;
+ while (e != null) {
+ fViewer.setChecked(e, true);
+ e = fContentProvider.getParent(e);
+ }
+ }
+
+ private void uncheckElement(Object element) {
+ Object e = element;
+
+ fViewer.setChecked(e, false);
+
+ for (Object child : fContentProvider.getChildren(e)) {
+ uncheckElement(child);
+ }
+ }
+
private boolean evaluateIfTreeEmpty(Object input) {
Object[] elements = fContentProvider.getElements(input);
if (elements.length > 0) {
@@ -434,37 +474,20 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
CheckStateListener() {
}
+
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
try {
ITimeGraphEntry entry = (ITimeGraphEntry) event.getElement();
boolean checked = event.getChecked();
- if (!checked) {
- uncheckChildren(entry);
- }
- else
- {
- checkParent(entry);
+ if (checked) {
+ checkElement(entry);
+ } else {
+ uncheckElement(entry);
}
} catch (ClassCastException e) {
return;
}
}
-
- private void uncheckChildren(ITimeGraphEntry entry) {
-
- for (ITimeGraphEntry child : entry.getChildren()) {
- getTreeViewer().setChecked(child, false);
- uncheckChildren(child);
- }
- }
-
- private void checkParent(ITimeGraphEntry entry) {
-
- if (entry.getParent() != null) {
- getTreeViewer().setChecked(entry.getParent(), true);
- checkParent(entry.getParent());
- }
- }
}
}