aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeneroso Pagano2014-07-18 08:34:33 (EDT)
committerPatrick Tasse2014-07-24 14:56:58 (EDT)
commit8be17f28d3f50247725b70b1dad20c5aad090bb0 (patch)
tree3113f2a6a7c1e17f2b166c703df95e75ed5082a3
parent68d6d2c489667df89bb8f7358fd31cda1f98150b (diff)
downloadorg.eclipse.linuxtools-8be17f28d3f50247725b70b1dad20c5aad090bb0.zip
org.eclipse.linuxtools-8be17f28d3f50247725b70b1dad20c5aad090bb0.tar.gz
org.eclipse.linuxtools-8be17f28d3f50247725b70b1dad20c5aad090bb0.tar.bz2
TMF: Support for drag selection listeners in TimeGraphControlrefs/changes/24/30124/5
The TimeGraphControl can send a TimeGraphTimeEvent to the attached ITimeGraphTimeListener(s) to notify the time interval currently being selected while the user is moving the mouse (drag selection). Change-Id: I340e4749861123febd268fb3e1969bcf809470b4 Signed-off-by: Generoso Pagano <generoso.pagano@gmail.com> Reviewed-on: https://git.eclipse.org/r/30124 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
index 85036aa..9a2ecb0 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
@@ -15,6 +15,7 @@
* provide base classes for time graph view
* Add display of links between items
* Xavier Raynaud, Kalray - Code optimization
+ * Generoso Pagano, Inria - Support for drag selection listeners
*****************************************************************************/
package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
@@ -40,8 +41,10 @@ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampDelta;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphColorListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTreeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTreeExpansionEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ILinkEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
@@ -139,6 +142,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
private ITimeGraphPresentationProvider fTimeGraphProvider = null;
private ItemData fItemData = null;
private List<SelectionListener> fSelectionListeners;
+ private List<ITimeGraphTimeListener> fDragSelectionListeners;
private final List<ISelectionChangedListener> fSelectionChangedListeners = new ArrayList<>();
private final List<ITimeGraphTreeListener> fTreeListeners = new ArrayList<>();
private final List<MenuDetectListener> fTimeGraphEntryMenuListeners = new ArrayList<>();
@@ -360,6 +364,65 @@ public class TimeGraphControl extends TimeGraphBaseControl
}
/**
+ * Add a drag selection listener
+ *
+ * @param listener
+ * The listener to add
+ * @since 3.1
+ */
+ public void addDragSelectionListener(ITimeGraphTimeListener listener) {
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (null == fDragSelectionListeners) {
+ fDragSelectionListeners = new ArrayList<>();
+ }
+ fDragSelectionListeners.add(listener);
+ }
+
+ /**
+ * Remove a drag selection listener
+ *
+ * @param listener
+ * The listener to remove
+ * @since 3.1
+ */
+ public void removeDragSelectionListener(ITimeGraphTimeListener listener) {
+ if (null != fDragSelectionListeners) {
+ fDragSelectionListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Drag Selection changed callback
+ *
+ * @param start
+ * Time interval start
+ * @param end
+ * Time interval end
+ * @since 3.1
+ */
+ public void fireDragSelectionChanged(long start, long end) {
+ // check for backward intervals
+ long beginTime, endTime;
+ if (start > end) {
+ beginTime = end;
+ endTime = start;
+ } else {
+ beginTime = start;
+ endTime = end;
+ }
+ // call the listeners
+ if (null != fDragSelectionListeners) {
+ Iterator<ITimeGraphTimeListener> it = fDragSelectionListeners.iterator();
+ while (it.hasNext()) {
+ ITimeGraphTimeListener listener = it.next();
+ listener.timeSelected(new TimeGraphTimeEvent(this, beginTime, endTime));
+ }
+ }
+ }
+
+ /**
* Get the traces in the model
*
* @return The array of traces
@@ -2015,6 +2078,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
redraw();
fTimeGraphScale.setDragRange(fDragX0, fDragX);
+ fireDragSelectionChanged(getTimeAtX(fDragX0), getTimeAtX(fDragX));
} else if (DRAG_ZOOM == fDragState) {
fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
redraw();