*
* Contributors:
* Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
+ * Bernd Hufmann - Bug fixes
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.common;
import java.util.Arrays;
-import org.eclipse.linuxtools.lttng.LttngConstants;
-import org.eclipse.linuxtools.lttng.control.LttngCoreProviderFactory;
-import org.eclipse.linuxtools.lttng.control.LttngSyntheticEventProvider;
-import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent;
-import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
-import org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest;
-import org.eclipse.linuxtools.lttng.request.IRequestStatusListener;
-import org.eclipse.linuxtools.lttng.request.LttngSyntEventRequest;
-import org.eclipse.linuxtools.lttng.request.RequestCompletedSignal;
-import org.eclipse.linuxtools.lttng.request.RequestStartedSignal;
-import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor;
+import org.eclipse.linuxtools.lttng.core.LttngConstants;
+import org.eclipse.linuxtools.lttng.core.control.LttngCoreProviderFactory;
+import org.eclipse.linuxtools.lttng.core.control.LttngSyntheticEventProvider;
+import org.eclipse.linuxtools.lttng.core.event.LttngSyntheticEvent;
+import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.core.request.ILttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.request.IRequestStatusListener;
+import org.eclipse.linuxtools.lttng.core.request.LttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.request.RequestCompletedSignal;
+import org.eclipse.linuxtools.lttng.core.request.RequestStartedSignal;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.ITransEventProcessor;
import org.eclipse.linuxtools.lttng.ui.TraceDebug;
import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
* Number of events before a GUI refresh
*/
protected static final Long INPUT_CHANGED_REFRESH = 75000L;
- private static final long DEFAULT_OFFSET = 0L;
+ private static final long DEFAULT_OFFSET = 0;
protected boolean synch = true; // time synchronization, used to be an option
protected ITimeAnalysisViewer tsfviewer = null;
return INPUT_CHANGED_REFRESH;
}
+ /**
+ * Cancel the ongoing request if another experiment is being selected
+ * @param experimentDisposedSignal
+ */
+ @TmfSignalHandler
+ public void experimentDisposed(TmfExperimentDisposedSignal<? extends TmfEvent> experimentDisposedSignal) {
+ fProvider.conditionallyCancelRequests();
+ }
+
/*
* (non-Javadoc)
*
if (synch) {
Object source = signal.getSource();
if (signal != null && source != null && source != this) {
- // Internal value is expected in nano seconds.
- long selectedTime = signal.getCurrentTime().getValue();
- if (tsfviewer != null) {
- tsfviewer.setSelectedTime(selectedTime, true, source);
-
- ParamsUpdater paramUpdater = getParamsUpdater();
- Long savedSelTime = paramUpdater.getSelectedTime();
- if ((savedSelTime == null) || (savedSelTime != selectedTime)) {
- // Update the parameter updater to save the selected time
- paramUpdater.setSelectedTime(selectedTime);
- }
+
+ if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
+
+ // Check for GUI thread
+ if (Display.getCurrent() != null) {
+ // GUI thread - execute update right away.
+
+ // Internal value is expected in nano seconds.
+ long selectedTime = signal.getCurrentTime().getValue();
+ if (tsfviewer != null) {
+ tsfviewer.setSelectedTime(selectedTime, true, source);
+
+ ParamsUpdater paramUpdater = getParamsUpdater();
+ Long savedSelTime = paramUpdater.getSelectedTime();
+ if ((savedSelTime == null) || (savedSelTime != selectedTime)) {
+ // Update the parameter updater to save the selected time
+ paramUpdater.setSelectedTime(selectedTime);
+ }
+ }
+ } else {
+ // Perform the updates on the UI thread
+
+ // We need to clone the timestamp in the signal so that it won't be overwritten duo to multipe thread access
+ final TmfTimeSynchSignal savedSignal = new TmfTimeSynchSignal(signal.getSource(), signal.getCurrentTime().clone());
+ tsfviewer.getControl().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if ((tsfviewer != null) && (!tsfviewer.getControl().isDisposed())) {
+ synchToTime(savedSignal);
+ }
+ }
+ });
+ }
}
}
}
}
// Clearing of process data is configurable
- dataRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.FOREGROUND);
+ eventRequest(trange, experiment.getTimeRange(), clearingData, ExecutionType.FOREGROUND);
}
}
}
/**
* @param zoomedTRange
* @param experimentTRange
+ * @param clearingData
* @param execType
*/
- public void dataRequest(TmfTimeRange zoomedTRange,
- TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
+ public void eventRequest(TmfTimeRange zoomedTRange, TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
// timeRange is the Experiment time range
- boolean sent = processDataRequest(zoomedTRange, experimentTRange, clearingData, execType);
+ boolean sent = processDataRequest(zoomedTRange, experimentTRange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA, clearingData, execType);
+
+ if (sent) {
+ waitCursor(true);
+ }
+ }
+
+ /**
+ * @param offset
+ * @param nbRequested
+ * @param startTime
+ * @param clearingData
+ * @param execType
+ */
+ public void eventRequest(long offset, TmfTimeRange range, boolean clearingData, ExecutionType execType) {
+
+ // timeRange is the Experiment time range
+ boolean sent = processDataRequest(range, null, offset, TmfDataRequest.ALL_DATA, clearingData, execType);
if (sent) {
waitCursor(true);
* @return
*/
private boolean processDataRequest(TmfTimeRange requestTrange,
- TmfTimeRange experimentTRange, boolean clearingData, ExecutionType execType) {
+ TmfTimeRange experimentTRange, long offset, int nbRequested, boolean clearingData, ExecutionType execType) {
// Validate input
- if (requestTrange == null || experimentTRange == null) {
+ if (requestTrange == null) {
TraceDebug.debug("Invalid input"); //$NON-NLS-1$
return false;
}
// Cancel the currently executing request before starting a new one
fProvider.conditionallyCancelRequests();
-
fCurrentRequest = new LttngSyntEventRequest(
- requestTrange, DEFAULT_OFFSET, TmfDataRequest.ALL_DATA,
+ requestTrange, offset, nbRequested,
LttngConstants.DEFAULT_BLOCK_SIZE, this, experimentTRange, getEventProcessor(),
TmfExperiment.getCurrentExperiment().getName(), execType) {
* @param complete
* true: yes, false: partial update
*/
+ @SuppressWarnings("deprecation")
protected void modelInputChanged(ILttngSyntEventRequest request, boolean complete) {
long experimentStartTime = -1;
long experimentEndTime = -1;