aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marchi2013-03-22 11:16:04 (EDT)
committerAlexandre Montplaisir2013-04-12 11:50:23 (EDT)
commitdb55844a3ef6cc363d6d73c1e40fdfd379885588 (patch)
treea15c508da65304c91e0bed49ba0577cb2f1c5df9
parentd01ca0ae8db629dd970a8c416a9c51a83f285509 (diff)
downloadorg.eclipse.linuxtools-db55844a3ef6cc363d6d73c1e40fdfd379885588.zip
org.eclipse.linuxtools-db55844a3ef6cc363d6d73c1e40fdfd379885588.tar.gz
org.eclipse.linuxtools-db55844a3ef6cc363d6d73c1e40fdfd379885588.tar.bz2
Add "check subtree" feature to TimeGraphFilterDialogrefs/changes/90/11390/6
Change-Id: Ib3d9a4c634d506c58524af704f903be685aaf3d1 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/11390 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TimeGraphFilterDialog.java110
3 files changed, 90 insertions, 24 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 059a487..a859a84 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
@@ -105,6 +105,8 @@ public class Messages extends NLS {
public static String TmfTimeFilterDialog_UNCHECK_ALL;
public static String TmfTimeFilterDialog_CHECK_SELECTED;
public static String TmfTimeFilterDialog_UNCHECK_SELECTED;
+ public static String TmfTimeFilterDialog_CHECK_SUBTREE;
+ public static String TmfTimeFilterDialog_UNCHECK_SUBTREE;
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 db97d10..e2aac10 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
@@ -88,6 +88,8 @@ TmfTimeFilterDialog_CHECK_ALL=Check all
TmfTimeFilterDialog_UNCHECK_ALL=Uncheck all
TmfTimeFilterDialog_CHECK_SELECTED=Check selected
TmfTimeFilterDialog_UNCHECK_SELECTED=Uncheck selected
+TmfTimeFilterDialog_CHECK_SUBTREE=Check subtree
+TmfTimeFilterDialog_UNCHECK_SUBTREE=Uncheck subtree
# 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 c8956ed..b4f3bb4 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
@@ -61,6 +61,11 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog;
* @author François Rajotte
*/
public class TimeGraphFilterDialog extends SelectionStatusDialog {
+ private final static int BUTTON_CHECK_SELECTED_ID = IDialogConstants.CLIENT_ID;
+ private final static int BUTTON_UNCHECK_SELECTED_ID = IDialogConstants.CLIENT_ID + 1;
+ private final static int BUTTON_CHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 2;
+ private final static int BUTTON_UNCHECK_SUBTREE_ID = IDialogConstants.CLIENT_ID + 3;
+
private CheckboxTreeViewer fViewer;
@@ -353,7 +358,6 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
protected Composite createSelectionButtons(Composite composite) {
Composite buttonComposite = new Composite(composite, SWT.RIGHT);
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
layout.marginWidth = 0;
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
buttonComposite.setLayout(layout);
@@ -364,62 +368,86 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
buttonComposite.setLayoutData(data);
/* Create the buttons in the good order to place them as we want */
+ Button checkSelectedButton = createButton(buttonComposite,
+ BUTTON_CHECK_SELECTED_ID, Messages.TmfTimeFilterDialog_CHECK_SELECTED,
+ false);
+ Button checkSubtreeButton = createButton(buttonComposite,
+ BUTTON_CHECK_SUBTREE_ID, Messages.TmfTimeFilterDialog_CHECK_SUBTREE,
+ false);
Button checkAllButton = createButton(buttonComposite,
IDialogConstants.SELECT_ALL_ID, Messages.TmfTimeFilterDialog_CHECK_ALL,
false);
- Button checkSelectedButton = createButton(buttonComposite,
- IDialogConstants.CLIENT_ID, Messages.TmfTimeFilterDialog_CHECK_SELECTED,
+
+ Button uncheckSelectedButton = createButton(buttonComposite,
+ BUTTON_UNCHECK_SELECTED_ID, Messages.TmfTimeFilterDialog_UNCHECK_SELECTED,
+ false);
+ Button uncheckSubtreeButton = createButton(buttonComposite,
+ BUTTON_UNCHECK_SUBTREE_ID, Messages.TmfTimeFilterDialog_UNCHECK_SUBTREE,
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);
+
/*
* Apply the layout again after creating the buttons to override
* createButton messing with the columns
*/
- layout.numColumns = 2;
+ layout.numColumns = 3;
buttonComposite.setLayout(layout);
/* Add a listener to each button */
- checkAllButton.addSelectionListener(new SelectionAdapter() {
+ checkSelectedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Object[] viewerElements = fContentProvider.getElements(fInput);
+ TreeSelection selection = (TreeSelection) fViewer.getSelection();
- for (int i = 0; i < viewerElements.length; i++) {
- fViewer.setSubtreeChecked(viewerElements[i], true);
+ for (Object element : selection.toArray()) {
+ checkElement(element);
}
updateOKStatus();
}
});
- uncheckAllButton.addSelectionListener(new SelectionAdapter() {
+ checkSubtreeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- fViewer.setCheckedElements(new Object[0]);
+ TreeSelection selection = (TreeSelection) fViewer.getSelection();
+
+ for (Object element : selection.toArray()) {
+ checkElementAndSubtree(element);
+ }
+ }
+ });
+
+ checkAllButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Object[] viewerElements = fContentProvider.getElements(fInput);
+
+ for (int i = 0; i < viewerElements.length; i++) {
+ fViewer.setSubtreeChecked(viewerElements[i], true);
+ }
+
updateOKStatus();
}
});
- checkSelectedButton.addSelectionListener(new SelectionAdapter() {
+ uncheckSelectedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeSelection selection = (TreeSelection) fViewer.getSelection();
for (Object element : selection.toArray()) {
- checkElement(element);
+ uncheckElement(element);
}
updateOKStatus();
}
});
- uncheckSelectedButton.addSelectionListener(new SelectionAdapter() {
+ uncheckSubtreeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeSelection selection = (TreeSelection) fViewer.getSelection();
@@ -432,23 +460,57 @@ public class TimeGraphFilterDialog extends SelectionStatusDialog {
}
});
+ uncheckAllButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ fViewer.setCheckedElements(new Object[0]);
+ updateOKStatus();
+ }
+ });
+
return buttonComposite;
}
+ /**
+ * Check an element and all its parents.
+ *
+ * @param element
+ * The element to check.
+ */
private void checkElement(Object element) {
- Object e = element;
- while (e != null) {
- fViewer.setChecked(e, true);
- e = fContentProvider.getParent(e);
+ fViewer.setChecked(element, true);
+
+ Object parent = fContentProvider.getParent(element);
+
+ if (parent != null) {
+ checkElement(parent);
}
}
- private void uncheckElement(Object element) {
- Object e = element;
+ /**
+ * Check an element, all its parents and all its children.
+ *
+ * @param element
+ * The element to check.
+ */
+ private void checkElementAndSubtree(Object element) {
+ checkElement(element);
+
+ for (Object child : fContentProvider.getChildren(element)) {
+ checkElementAndSubtree(child);
+ }
+ }
- fViewer.setChecked(e, false);
+ /**
+ * Uncheck an element and all its children.
+ *
+ * @param element
+ * The element to uncheck.
+ */
+ private void uncheckElement(Object element) {
+ fViewer.setChecked(element, false);
- for (Object child : fContentProvider.getChildren(e)) {
+ for (Object child : fContentProvider.getChildren(element)) {
uncheckElement(child);
}
}