|
65 | 65 | import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects; |
66 | 66 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; |
67 | 67 | import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider; |
| 68 | +import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; |
68 | 69 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; |
69 | 70 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
70 | 71 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; |
@@ -218,19 +219,9 @@ public void initTrace(final IResource resource, final String path, final Class<? |
218 | 219 |
|
219 | 220 | try { |
220 | 221 | this.fTrace = new CTFTrace(path); |
221 | | - CtfTmfContext ctx; |
222 | 222 | /* Set the start and (current) end times for this trace */ |
223 | | - ctx = (CtfTmfContext) seekEvent(0L); |
224 | | - CtfTmfEvent event = getNext(ctx); |
225 | | - if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { |
226 | | - /* Handle the case where the trace is empty */ |
227 | | - this.setStartTime(TmfTimestamp.BIG_BANG); |
228 | | - } else { |
229 | | - final ITmfTimestamp curTime = event.getTimestamp(); |
230 | | - this.setStartTime(curTime); |
231 | | - long endTime = Math.max(curTime.getValue(), fTrace.getCurrentEndTime()); |
232 | | - this.setEndTime(TmfTimestamp.fromNanos(endTime)); |
233 | | - } |
| 223 | + CtfTmfContext ctx = resetTimes(); |
| 224 | + |
234 | 225 | /* |
235 | 226 | * Register every event type. When you call getType, it will register a trace to |
236 | 227 | * that type in the TmfEventTypeManager |
@@ -913,4 +904,28 @@ public Path trim(@NonNull TmfTimeRange range, @NonNull Path destinationPath, @No |
913 | 904 | return null; |
914 | 905 | } |
915 | 906 |
|
| 907 | + @Override |
| 908 | + public void setTimestampTransform(final ITmfTimestampTransform tt) { |
| 909 | + super.setTimestampTransform(tt); |
| 910 | + resetTimes(); |
| 911 | + } |
| 912 | + |
| 913 | + private CtfTmfContext resetTimes() { |
| 914 | + CtfTmfContext ctx; |
| 915 | + /* Set the start and (current) end times for this trace */ |
| 916 | + ctx = (CtfTmfContext) seekEvent(0L); |
| 917 | + CtfTmfEvent event = getNext(ctx); |
| 918 | + if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { |
| 919 | + /* Handle the case where the trace is empty */ |
| 920 | + this.setStartTime(TmfTimestamp.BIG_BANG); |
| 921 | + } else { |
| 922 | + final ITmfTimestamp curTime = event.getTimestamp(); |
| 923 | + this.setStartTime(curTime); |
| 924 | + long endTime = createTimestamp(fTrace.getCurrentEndTime()).getValue(); |
| 925 | + endTime = Math.max(curTime.getValue(), endTime); |
| 926 | + this.setEndTime(TmfTimestamp.fromNanos(endTime)); |
| 927 | + } |
| 928 | + return ctx; |
| 929 | + } |
| 930 | + |
916 | 931 | } |
0 commit comments