use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry in project tracecompass by tracecompass.
the class TmfFilteredXYChartViewer method handleCheckStateChangedEvent.
/**
* Update the chart depending on the selected entries.
*
* @param entries
* Counters to display on the chart
*/
@Override
public void handleCheckStateChangedEvent(Collection<ITmfTreeViewerEntry> entries) {
cancelUpdate();
Iterable<TmfGenericTreeEntry> counterEntries = Iterables.filter(entries, TmfGenericTreeEntry.class);
Collection<@NonNull Long> selectedIds = Sets.newHashSet(Iterables.transform(counterEntries, e -> e.getModel().getId()));
if (!selectedIds.containsAll(fSelectedIds)) {
clearContent();
}
fSelectedIds = selectedIds;
// Update the styles as well
BaseXYPresentationProvider presProvider = getPresentationProvider();
for (ITmfTreeViewerEntry entry : entries) {
if (entry instanceof TmfGenericTreeEntry) {
TmfGenericTreeEntry<TmfTreeDataModel> genericEntry = (TmfGenericTreeEntry<TmfTreeDataModel>) entry;
TmfTreeDataModel model = genericEntry.getModel();
OutputElementStyle style = model.getStyle();
if (style != null) {
presProvider.setStyle(model.getId(), style);
}
}
}
updateContent();
}
use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry in project tracecompass by tracecompass.
the class AbstractSegmentsStatisticsViewer method modelToTree.
/**
* Algorithm to convert a model (List of {@link SegmentStoreStatisticsModel}) to
* the tree.
*
* @param trace
* trace / experiment.
* @param model
* model to convert
* @return the resulting {@link TmfTreeViewerEntry}.
*/
@Nullable
private TmfTreeViewerEntry modelToTree(ITmfTrace trace, List<SegmentStoreStatisticsModel> model) {
TmfTreeViewerEntry root = getRoot(trace);
if (root == null) {
return null;
}
synchronized (root) {
root.getChildren().clear();
Map<Long, TmfTreeViewerEntry> map = new HashMap<>();
map.put(-1L, root);
for (TmfTreeDataModel entry : model) {
TmfTreeViewerEntry viewerEntry = new TmfGenericTreeEntry<>(entry);
map.put(entry.getId(), viewerEntry);
TmfTreeViewerEntry parent = map.get(entry.getParentId());
if (parent != null && !parent.getChildren().contains(viewerEntry)) {
parent.addChild(viewerEntry);
}
}
}
return root;
}
use of org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfGenericTreeEntry in project tracecompass by tracecompass.
the class AbstractSegmentsStatisticsViewer method appendToTablePopupMenu.
/**
* Method to add commands to the context sensitive menu.
*
* @param manager
* the menu manager
* @param sel
* the current selection
*/
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
Object element = sel.getFirstElement();
if (element instanceof TmfGenericTreeEntry) {
IAction gotoStartTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMinAction) {
@Override
public void run() {
long start;
long end;
if (element instanceof TmfGenericTreeEntry) {
SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
start = model.getMinStart();
end = model.getMinEnd();
} else {
return;
}
broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
updateContent(start, end, true);
}
};
IAction gotoEndTime = new Action(Messages.SegmentStoreStatisticsViewer_GotoMaxAction) {
@Override
public void run() {
long start;
long end;
if (element instanceof TmfGenericTreeEntry) {
SegmentStoreStatisticsModel model = ((TmfGenericTreeEntry<SegmentStoreStatisticsModel>) element).getModel();
start = model.getMaxStart();
end = model.getMaxEnd();
} else {
return;
}
broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentsStatisticsViewer.this, TmfTimestamp.fromNanos(start), TmfTimestamp.fromNanos(end), getTrace()));
updateContent(start, end, true);
}
};
manager.add(gotoStartTime);
manager.add(gotoEndTime);
}
}
Aggregations