Search in sources :

Example 1 with IOutputAnnotationProvider

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider in project tracecompass by tracecompass.

the class TmfTreeCompositeDataProvider method fetchAnnotations.

@Override
public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    boolean isComplete = true;
    AnnotationModel model = new AnnotationModel(Collections.emptyMap());
    for (P dataProvider : getProviders()) {
        if (dataProvider instanceof IOutputAnnotationProvider) {
            TmfModelResponse<AnnotationModel> response = ((IOutputAnnotationProvider) dataProvider).fetchAnnotations(fetchParameters, monitor);
            isComplete &= response.getStatus() == ITmfResponse.Status.COMPLETED;
            model = AnnotationModel.of(model, response.getModel());
            if (monitor != null && monitor.isCanceled()) {
                return new TmfModelResponse<>(null, ITmfResponse.Status.CANCELLED, CommonStatusMessage.TASK_CANCELLED);
            }
        }
    }
    if (isComplete) {
        return new TmfModelResponse<>(model, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    return new TmfModelResponse<>(model, ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
}
Also used : AnnotationModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)

Example 2 with IOutputAnnotationProvider

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testCategories.

/**
 * Test fetching the annotation categories
 */
@Test
public void testCategories() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null);
    TmfModelResponse<@NonNull AnnotationCategoriesModel> response = provider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor());
    assertEquals(Status.COMPLETED, response.getStatus());
    AnnotationCategoriesModel model = response.getModel();
    assertNotNull(model);
    assertEquals(Arrays.asList(CATEGORY), model.getAnnotationCategories());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) AnnotationCategoriesModel(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) Test(org.junit.Test)

Example 3 with IOutputAnnotationProvider

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testNextPreviousIncluded.

/**
 * Test that previous and next annotations are always included.
 */
@Test
public void testNextPreviousIncluded() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-100L, 0L, -1, "-1", COLOR_STYLE), new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(100L, 0L, -1, "1", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(300L, 0L, -1, "3", COLOR_STYLE), new Annotation(400L, 0L, -1, "4", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 300L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 4 with IOutputAnnotationProvider

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testAlternateShadingAnnotationSource.

/**
 * Test a periodic annotation provider with alternate shading at every period.
 */
@Test
public void testAlternateShadingAnnotationSource() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, EVEN_COLOR, ODD_COLOR);
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(-100L, 100L, -1, "-1", ODD_COLOR_STYLE), new Annotation(0L, 100L, -1, "0", EVEN_COLOR_STYLE), new Annotation(100L, 100L, -1, "1", ODD_COLOR_STYLE), new Annotation(200L, 100L, -1, "2", EVEN_COLOR_STYLE), new Annotation(300L, 100L, -1, "3", ODD_COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(50L, 250L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Example 5 with IOutputAnnotationProvider

use of org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider in project tracecompass by tracecompass.

the class PeriodicAnnotationProviderTest method testIsApplicable.

/**
 * Test a periodic annotation provider with a filtering implementation.
 */
@Test
public void testIsApplicable() {
    IOutputAnnotationProvider provider = new PeriodicAnnotationProvider(CATEGORY, ITimeReference.ZERO, 100L, 0, COLOR, null) {

        @Override
        public boolean isApplicable(long index) {
            return (index % 2 == 0);
        }
    };
    Map<String, List<Annotation>> expected = ImmutableMap.of(CATEGORY, Arrays.asList(new Annotation(0L, 0L, -1, "0", COLOR_STYLE), new Annotation(200L, 0L, -1, "2", COLOR_STYLE), new Annotation(400L, 0L, -1, "4", COLOR_STYLE), new Annotation(600L, 0L, -1, "6", COLOR_STYLE), new Annotation(800L, 0L, -1, "8", COLOR_STYLE), new Annotation(1000L, 0L, -1, "10", COLOR_STYLE)));
    Map<String, Object> fetchParameters = ImmutableMap.of(DataProviderParameterUtils.REQUESTED_TIME_KEY, StateSystemUtils.getTimes(0L, 1000L, 1));
    assertAnnotationModelResponse(expected, provider.fetchAnnotations(fetchParameters, new NullProgressMonitor()));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicAnnotationProvider(org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider) IOutputAnnotationProvider(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider) ArrayList(java.util.ArrayList) List(java.util.List) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Aggregations

IOutputAnnotationProvider (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.IOutputAnnotationProvider)14 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)12 ArrayList (java.util.ArrayList)10 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)10 PeriodicAnnotationProvider (org.eclipse.tracecompass.internal.tmf.core.annotations.PeriodicAnnotationProvider)10 Test (org.junit.Test)10 List (java.util.List)9 AnnotationCategoriesModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationCategoriesModel)3 NonNull (org.eclipse.jdt.annotation.NonNull)2 AnnotationModel (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.AnnotationModel)2 ITimeGraphDataProvider (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider)2 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)2 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)2 Collection (java.util.Collection)1 ITimeReference (org.eclipse.tracecompass.tmf.core.markers.ITimeReference)1 TimeReference (org.eclipse.tracecompass.tmf.core.markers.TimeReference)1 IMarkerEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)1 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)1 MarkerEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent)1 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)1