Skip to content

Commit

Permalink
server: Return table column data type
Browse files Browse the repository at this point in the history
When requesting the table columns, the server will now return the type of each column.
The types are derived from DataType enum, such as STRING, NUMBER, TIMESTAMP, DURATION, etc.

[Added] Accessing data type of table columns (i.e., headers)

Signed-off-by: Kaveh Shahedi <[email protected]>
  • Loading branch information
kavehshahedi authored and bhufmann committed Sep 30, 2024
1 parent f5f4b6b commit 8599114
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.tmf.core.dataprovider.DataType;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;

/**
Expand All @@ -27,7 +28,7 @@ public class TableColumnHeader {
private final long fId;
private final String fName;
private final @Nullable String fDescription;
private final @Nullable String fType;
private final DataType fType;

/**
* Constructor
Expand All @@ -40,7 +41,7 @@ public TableColumnHeader(ITmfTreeDataModel dataModel) {
List<@NonNull String> labels = dataModel.getLabels();
fName = dataModel.getLabels().get(0);
fDescription = labels.size() >= 2 ? dataModel.getLabels().get(1) : null;
fType = null;
fType = dataModel.getDataType();
}

/**
Expand Down Expand Up @@ -75,7 +76,7 @@ public String getDescription() {
*
* @return The type of the column
*/
public String getType() {
public DataType getType() {
return fType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.tmf.core.dataprovider.DataType;
import org.eclipse.tracecompass.tmf.core.model.ITableColumnDescriptor;
import org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel;
Expand All @@ -40,7 +39,7 @@ public class TreeModelWrapper {
public static class TreeColumnHeader {
private final String fName;
private final String fTooltip;
private final @Nullable String fDataType;
private final DataType fDataType;

/**
* Constructor with only the name
Expand All @@ -55,12 +54,7 @@ public static class TreeColumnHeader {
public TreeColumnHeader(String name, String tooltip, DataType dataType) {
fName = name;
fTooltip = tooltip;
if (dataType.equals(DataType.STRING)) {
// Default case
fDataType = null;
} else {
fDataType = dataType.name();
}
fDataType = dataType;
}

/**
Expand All @@ -85,7 +79,7 @@ public String getTooltip() {
*
* @return data type.
*/
public @Nullable String getDataType() {
public DataType getDataType() {
return fDataType;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void serialize(TreeColumnHeader value, JsonGenerator gen, SerializerProvi
gen.writeStringField("name", value.getName()); //$NON-NLS-1$
gen.writeStringField("tooltip", value.getTooltip()); //$NON-NLS-1$
if (value.getDataType() != null) {
gen.writeStringField("dataType", value.getDataType()); //$NON-NLS-1$
gen.writeStringField("dataType", value.getDataType().name()); //$NON-NLS-1$
}
gen.writeEndObject();
}
Expand Down

0 comments on commit 8599114

Please sign in to comment.