import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
import org.eclipse.tracecompass.internal.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
import org.eclipse.tracecompass.tmf.ui.viewers.tree.TmfTreeViewerEntry;
/**
- * An abstract tree viewer implementation for displaying segment store statistics
+ * An abstract tree viewer implementation for displaying segment store
+ * statistics
*
* @author Bernd Hufmann
*
private static final Format FORMATTER = new SubSecondTimeWithUnitFormat();
- @Nullable private TmfAbstractAnalysisModule fModule;
+ @Nullable
+ private TmfAbstractAnalysisModule fModule;
private static final String[] COLUMN_NAMES = new String[] {
checkNotNull(Messages.SegmentStoreStatistics_LevelLabel),
checkNotNull(Messages.SegmentStoreStatistics_Statistics_MinLabel),
checkNotNull(Messages.SegmentStoreStatistics_MaxLabel),
- checkNotNull(Messages.SegmentStoreStatistics_AverageLabel)
+ checkNotNull(Messages.SegmentStoreStatistics_AverageLabel),
+ checkNotNull(Messages.SegmentStoreStatisticsViewer_StandardDeviation)
};
/**
@Override
public String getColumnText(@Nullable Object element, int columnIndex) {
- String value = ""; //$NON-NLS-1$
+ String value = ""; //$NON-NLS-1$
if (element instanceof HiddenTreeViewerEntry) {
if (columnIndex == 0) {
value = ((HiddenTreeViewerEntry) element).getName();
value = String.valueOf(toFormattedString(entry.getEntry().getMax()));
} else if (columnIndex == 3) {
value = String.valueOf(toFormattedString(entry.getEntry().getAverage()));
+ } else if (columnIndex == 4) {
+ value = String.valueOf(toFormattedString(entry.getEntry().getStdDev()));
}
}
}
*
* @return the statistics analysis module
*/
- @Nullable protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
+ @Nullable
+ protected abstract TmfAbstractAnalysisModule createStatisticsAnalysiModule();
/**
* Gets the statistics analysis module
+ *
* @return the statistics analysis module
*/
- @Nullable public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
+ @Nullable
+ public TmfAbstractAnalysisModule getStatisticsAnalysisModule() {
return fModule;
}
/* All columns are sortable */
List<@Nullable TmfTreeColumnData> columns = new ArrayList<>();
TmfTreeColumnData column = new TmfTreeColumnData(COLUMN_NAMES[0]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[1]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[2]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
});
columns.add(column);
column = new TmfTreeColumnData(COLUMN_NAMES[3]);
+ column.setAlignment(SWT.RIGHT);
column.setComparator(new ViewerComparator() {
@Override
public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
}
});
columns.add(column);
+ column = new TmfTreeColumnData(COLUMN_NAMES[4]);
+ column.setAlignment(SWT.RIGHT);
+ column.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(@Nullable Viewer viewer, @Nullable Object e1, @Nullable Object e2) {
+ if ((e1 == null) || (e2 == null)) {
+ return 0;
+ }
+
+ SegmentStoreStatisticsEntry n1 = (SegmentStoreStatisticsEntry) e1;
+ SegmentStoreStatisticsEntry n2 = (SegmentStoreStatisticsEntry) e2;
+ return Double.compare(n1.getEntry().getStdDev(), n2.getEntry().getStdDev());
+
+ }
+ });
+ columns.add(column);
+ column = new TmfTreeColumnData(""); //$NON-NLS-1$
+ columns.add(column);
return columns;
}
};
}
-
@Override
public void initializeDataSource() {
/* Should not be called while trace is still null */
* @return formatted value
*/
protected static String toFormattedString(double value) {
- // The cast to long is needed because the formatter cannot truncate the number.
+ // The cast to long is needed because the formatter cannot truncate the
+ // number.
String percentageString = checkNotNull(String.format("%s", FORMATTER.format(value))); //$NON-NLS-1$
return percentageString;
}