Skip to content

Commit c20d8a4

Browse files
committed
tmf: Add generic object data provider
Add IObjectDataProvider interface that returns an ObjectModel with a generic object, and optional next and previous navigation parameters. Add DATA provider type. Add selectionRange to IDataProviderCapabilities. Signed-off-by: Patrick Tasse <[email protected]>
1 parent 5aed12b commit c20d8a4

File tree

7 files changed

+175
-3
lines changed

7 files changed

+175
-3
lines changed

tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.model,
109109
org.eclipse.tracecompass.tmf.core.model.annotations,
110110
org.eclipse.tracecompass.tmf.core.model.filters,
111111
org.eclipse.tracecompass.tmf.core.model.genericxy,
112+
org.eclipse.tracecompass.tmf.core.model.object,
112113
org.eclipse.tracecompass.tmf.core.model.timegraph,
113114
org.eclipse.tracecompass.tmf.core.model.tree,
114115
org.eclipse.tracecompass.tmf.core.model.xy,

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/dataprovider/IDataProviderCapabilities.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515
/**
1616
* Interface to implement to indicate capabilities of a data provider, such as
1717
* "canCreate" and "canDelete" capability.
18-
*
18+
* <p>
1919
* "canCreate" indicates that a given data provider can create a derived data
2020
* provider. "canDelete" indicates that a given data provider can be deleted.
21-
*
21+
* <p>
2222
* Call method {@link IDataProviderFactory#getAdapter(Class)} with class
2323
* {@link ITmfDataProviderConfigurator} to obtain an instance of
2424
* {@link ITmfDataProviderConfigurator}, which implements the "canCreate" and
2525
* "canDelete" capabilities.
26+
* <p>
27+
* "selectionRange" indicates that a given data provider can use the selection
28+
* range to compute its data. Clients should include the selection range in
29+
* query parameters and refresh the data when the selection range changes.
2630
*
2731
* @since 9.6
2832
* @author Bernd Hufmann
@@ -43,4 +47,15 @@ public interface IDataProviderCapabilities {
4347
* {@code false}
4448
*/
4549
boolean canDelete();
50+
51+
/**
52+
* Whether the data provider uses the selection range.
53+
*
54+
* @return {@code true} if this data provider uses the selection range, else
55+
* {@code false}
56+
* @since 10.2
57+
*/
58+
default boolean selectionRange() {
59+
return false;
60+
}
4661
}

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/dataprovider/IDataProviderDescriptor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ public enum ProviderType {
7878
* A provider for generic xy charts with a time-less x-axis
7979
* @since 10.1
8080
*/
81-
TREE_GENERIC_XY
81+
TREE_GENERIC_XY,
82+
/**
83+
* A provider of generic data objects
84+
* @since 10.2
85+
*/
86+
DATA
8287
}
8388

8489
/**

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/model/DataProviderCapabilities.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class DataProviderCapabilities implements IDataProviderCapabilities {
2929

3030
private final boolean canCreate;
3131
private final boolean canDelete;
32+
private final boolean selectionRange;
3233

3334
/**
3435
* Constructor
@@ -39,6 +40,7 @@ public class DataProviderCapabilities implements IDataProviderCapabilities {
3940
public DataProviderCapabilities(Builder builder) {
4041
canCreate = builder.canCreate;
4142
canDelete = builder.canDelete;
43+
selectionRange = builder.selectionRange;
4244
}
4345

4446
@Override
@@ -51,6 +53,11 @@ public boolean canDelete() {
5153
return canDelete;
5254
}
5355

56+
@Override
57+
public boolean selectionRange() {
58+
return selectionRange;
59+
}
60+
5461
@Override
5562
@SuppressWarnings("nls")
5663
public String toString() {
@@ -84,6 +91,7 @@ public boolean equals(@Nullable Object obj) {
8491
public static class Builder {
8592
private boolean canCreate = false;
8693
private boolean canDelete = false;
94+
private boolean selectionRange = false;
8795

8896
/**
8997
* Sets canCreate flag
@@ -111,6 +119,20 @@ public Builder setCanDelete(boolean canDelete) {
111119
return this;
112120
}
113121

122+
/**
123+
* Sets selectionRange flag
124+
*
125+
* @param selectionRange
126+
* {@code true} if this data provider uses the selection
127+
* range, else {@code false}
128+
* @return the builder instance.
129+
* @since 10.2
130+
*/
131+
public Builder setSelectionRange(boolean selectionRange) {
132+
this.selectionRange = selectionRange;
133+
return this;
134+
}
135+
114136
/**
115137
* The method to construct an instance of
116138
* {@link IDataProviderCapabilities}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.eclipse.tracecompass.tmf.core.model.object;
2+
3+
import java.util.Map;
4+
5+
import org.eclipse.core.runtime.IProgressMonitor;
6+
import org.eclipse.jdt.annotation.Nullable;
7+
import org.eclipse.tracecompass.tmf.core.model.ITmfDataProvider;
8+
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
9+
10+
/**
11+
* Interface for a data provider that returns a generic object as model
12+
*
13+
* @since 10.2
14+
*/
15+
public interface IObjectDataProvider extends ITmfDataProvider {
16+
17+
/**
18+
* This method computes a generic object model. Then, it returns a
19+
* {@link TmfModelResponse} that contains the model.
20+
*
21+
* @param fetchParameters
22+
* Map of parameters that can be used to compute result object
23+
* @param monitor
24+
* A ProgressMonitor to cancel task
25+
* @return A {@link TmfModelResponse} instance
26+
*/
27+
public TmfModelResponse<ObjectModel> fetchData(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor);
28+
29+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**********************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
**********************************************************************/
11+
12+
package org.eclipse.tracecompass.tmf.core.model.object;
13+
14+
import org.eclipse.jdt.annotation.Nullable;
15+
16+
/**
17+
* Represents a generic object with optional navigation parameters.
18+
* <p>
19+
* If the object is a partial subdivision of the full object, then the optional
20+
* next and previous navigation parameter objects can be set, and later returned
21+
* as query parameters to get the following or preceding subdivision.
22+
*
23+
* @since 10.2
24+
*/
25+
public class ObjectModel {
26+
27+
private final Object fObject;
28+
private @Nullable Object fNext;
29+
private @Nullable Object fPrevious;
30+
31+
/**
32+
* Constructor
33+
*
34+
* @param object
35+
* the generic object represented by this model
36+
*/
37+
public ObjectModel(Object object) {
38+
fObject = object;
39+
}
40+
41+
/**
42+
* Get the generic object represented by this model
43+
*
44+
* @return the object
45+
*/
46+
public Object getObject() {
47+
return fObject;
48+
}
49+
50+
/**
51+
* Get the next navigation parameter object
52+
*
53+
* @return the next navigation parameter object
54+
*/
55+
public @Nullable Object getNext() {
56+
return fNext;
57+
}
58+
59+
/**
60+
* Get the previous navigation parameter object
61+
*
62+
* @return the previous navigation parameter object
63+
*/
64+
public @Nullable Object getPrevious() {
65+
return fPrevious;
66+
}
67+
68+
/**
69+
* Set the next navigation parameter object
70+
*
71+
* @param next
72+
* the next navigation parameter object
73+
*/
74+
public void setNext(Object next) {
75+
fNext = next;
76+
}
77+
78+
/**
79+
* Set the previous navigation parameter object
80+
*
81+
* @param previous
82+
* the previous navigation parameter object
83+
*/
84+
public void setPrevious(Object previous) {
85+
fPrevious = previous;
86+
}
87+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
12+
@org.eclipse.jdt.annotation.NonNullByDefault
13+
package org.eclipse.tracecompass.tmf.core.model.object;

0 commit comments

Comments
 (0)