Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2015-01-26 21:56:02 +0000
committerPatrick Tasse2015-01-28 15:25:04 +0000
commit5328e7e5693e65c60cdbd80b9cfa5e514675dd03 (patch)
tree52be9cb9a1cc6d7e14dabc0ba569fd5ac1d17d26
parent599920a5802bfa078c242959dfe84c25bc566155 (diff)
downloadorg.eclipse.linuxtools-5328e7e5693e65c60cdbd80b9cfa5e514675dd03.tar.gz
org.eclipse.linuxtools-5328e7e5693e65c60cdbd80b9cfa5e514675dd03.tar.xz
org.eclipse.linuxtools-5328e7e5693e65c60cdbd80b9cfa5e514675dd03.zip
tmf: Bug 457109: Throttle time graph listener notifications
Change-Id: Ib37d6ecfe6a54629d3eb1fadc285b9090bf7d1aa Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/40405 Tested-by: Hudson CI Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java113
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java49
2 files changed, 104 insertions, 58 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
index d4396b342b..8fdedb830c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphViewer.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2007, 2014 Intel Corporation, Ericsson, others
+ * Copyright (c) 2007, 2015 Intel Corporation, 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 accompanies this distribution, and is available at
@@ -57,6 +57,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
@@ -136,6 +137,66 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
private Action fFollowArrowFwdAction;
private Action fFollowArrowBwdAction;
+ private ListenerNotifier fListenerNotifier;
+ private final Object fListenerNotifierLock = new Object();
+
+ private class ListenerNotifier extends Thread {
+ private static final long DELAY = 400L;
+ private static final long POLLING_INTERVAL = 10L;
+ private long fLastUpdateTime = Long.MAX_VALUE;
+ private boolean fSelectionChanged = false;
+ private boolean fTimeRangeUpdated = false;
+ private boolean fTimeSelected = false;
+
+ @Override
+ public void run() {
+ while ((System.currentTimeMillis() - fLastUpdateTime) < DELAY) {
+ try {
+ Thread.sleep(POLLING_INTERVAL);
+ } catch (Exception e) {
+ return;
+ }
+ }
+ synchronized (fListenerNotifierLock) {
+ fListenerNotifier = null;
+ }
+ if (!isInterrupted()) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (fDataViewer.isDisposed()) {
+ return;
+ }
+ if (fSelectionChanged) {
+ fireSelectionChanged(fSelectedEntry);
+ }
+ if (fTimeRangeUpdated) {
+ fireTimeRangeUpdated(fTime0, fTime1);
+ }
+ if (fTimeSelected) {
+ fireTimeSelected(fSelectionBegin, fSelectionEnd);
+ }
+ }
+ });
+ }
+ }
+
+ public void selectionChanged() {
+ fSelectionChanged = true;
+ fLastUpdateTime = System.currentTimeMillis();
+ }
+
+ public void timeRangeUpdated() {
+ fTimeRangeUpdated = true;
+ fLastUpdateTime = System.currentTimeMillis();
+ }
+
+ public void timeSelected() {
+ fTimeSelected = true;
+ fLastUpdateTime = System.currentTimeMillis();
+ }
+ }
+
/**
* Standard constructor.
* <p>
@@ -703,12 +764,12 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
@Override
public void setStartFinishTimeNotify(long time0, long time1) {
setStartFinishTime(time0, time1);
- notifyRangeListeners(fTime0, fTime1);
+ notifyRangeListeners();
}
@Override
public void notifyStartFinishTime() {
- notifyRangeListeners(fTime0, fTime1);
+ notifyRangeListeners();
}
@Override
@@ -786,7 +847,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
fTimeGraphCtrl.redraw();
fTimeScaleCtrl.redraw();
if (changed) {
- notifyTimeListeners(fSelectionBegin, fSelectionEnd);
+ notifyTimeListeners();
}
}
@@ -836,11 +897,11 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
fSelectionEnd = time;
if (doNotify && ((time0 != fTime0) || (time1 != fTime1))) {
- notifyRangeListeners(fTime0, fTime1);
+ notifyRangeListeners();
}
if (doNotify && notifySelectedTime) {
- notifyTimeListeners(fSelectionBegin, fSelectionEnd);
+ notifyTimeListeners();
}
}
@@ -848,7 +909,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
public void widgetDefaultSelected(SelectionEvent e) {
if (fSelectedEntry != getSelection()) {
fSelectedEntry = getSelection();
- notifySelectionListeners(fSelectedEntry);
+ notifySelectionListeners();
}
}
@@ -856,7 +917,7 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
public void widgetSelected(SelectionEvent e) {
if (fSelectedEntry != getSelection()) {
fSelectedEntry = getSelection();
- notifySelectionListeners(fSelectedEntry);
+ notifySelectionListeners();
}
}
@@ -941,7 +1002,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
fSelectionListeners.remove(listener);
}
- private void notifySelectionListeners(ITimeGraphEntry selection) {
+ private void notifySelectionListeners() {
+ synchronized (fListenerNotifierLock) {
+ if (fListenerNotifier == null) {
+ fListenerNotifier = new ListenerNotifier();
+ fListenerNotifier.start();
+ }
+ fListenerNotifier.selectionChanged();
+ }
+ }
+
+ private void fireSelectionChanged(ITimeGraphEntry selection) {
TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection);
for (ITimeGraphSelectionListener listener : fSelectionListeners) {
@@ -969,7 +1040,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
fTimeListeners.remove(listener);
}
- private void notifyTimeListeners(long startTime, long endTime) {
+ private void notifyTimeListeners() {
+ synchronized (fListenerNotifierLock) {
+ if (fListenerNotifier == null) {
+ fListenerNotifier = new ListenerNotifier();
+ fListenerNotifier.start();
+ }
+ fListenerNotifier.timeSelected();
+ }
+ }
+
+ private void fireTimeSelected(long startTime, long endTime) {
TimeGraphTimeEvent event = new TimeGraphTimeEvent(this, startTime, endTime);
for (ITimeGraphTimeListener listener : fTimeListeners) {
@@ -997,7 +1078,17 @@ public class TimeGraphViewer implements ITimeDataProvider, SelectionListener {
fRangeListeners.remove(listener);
}
- private void notifyRangeListeners(long startTime, long endTime) {
+ private void notifyRangeListeners() {
+ synchronized (fListenerNotifierLock) {
+ if (fListenerNotifier == null) {
+ fListenerNotifier = new ListenerNotifier();
+ fListenerNotifier.start();
+ }
+ fListenerNotifier.timeRangeUpdated();
+ }
+ }
+
+ private void fireTimeRangeUpdated(long startTime, long endTime) {
// Check if the time has actually changed from last notification
if (startTime != fTime0ExtSynch || endTime != fTime1ExtSynch) {
// Notify Time Scale Selection Listeners
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 5d988950ab..b05e907f4a 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2007, 2014 Intel Corporation and others
+ * Copyright (c) 2007, 2015 Intel Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -160,44 +160,6 @@ public class TimeGraphControl extends TimeGraphBaseControl
private int fBorderWidth = 0;
private int fHeaderHeight = 0;
- private MouseScrollNotifier fMouseScrollNotifier;
- private final Object fMouseScrollNotifierLock = new Object();
-
- private class MouseScrollNotifier extends Thread {
- private static final long DELAY = 400L;
- private static final long POLLING_INTERVAL = 10L;
- private long fLastScrollTime = Long.MAX_VALUE;
-
- @Override
- public void run() {
- while ((System.currentTimeMillis() - fLastScrollTime) < DELAY) {
- try {
- Thread.sleep(POLLING_INTERVAL);
- } catch (Exception e) {
- return;
- }
- }
- if (!isInterrupted()) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (isDisposed()) {
- return;
- }
- fTimeProvider.notifyStartFinishTime();
- }
- });
- }
- synchronized (fMouseScrollNotifierLock) {
- fMouseScrollNotifier = null;
- }
- }
-
- public void mouseScrolled() {
- fLastScrollTime = System.currentTimeMillis();
- }
- }
-
/**
* Standard constructor
*
@@ -920,14 +882,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));
long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);
long newTime1 = newTime0 + newInterval;
- fTimeProvider.setStartFinishTime(newTime0, newTime1);
- synchronized (fMouseScrollNotifierLock) {
- if (fMouseScrollNotifier == null) {
- fMouseScrollNotifier = new MouseScrollNotifier();
- fMouseScrollNotifier.start();
- }
- fMouseScrollNotifier.mouseScrolled();
- }
+ fTimeProvider.setStartFinishTimeNotify(newTime0, newTime1);
}
/**

Back to the top