Search in sources :

Example 1 with StatColumn

use of org.eclipse.titanium.metrics.StatColumn in project titan.EclipsePlug-ins by eclipse.

the class ProjectStatNode method getColumnText.

@Override
public String getColumnText(final MetricData data, final int i) {
    if (i == 0) {
        return metric.getName();
    } else {
        StatColumn c = null;
        switch(i) {
            case 1:
                c = StatColumn.TOTAL;
                break;
            case 2:
                c = StatColumn.MAX;
                break;
            case 3:
                c = StatColumn.MEAN;
                break;
            case 4:
                c = StatColumn.DEV;
                break;
            default:
                return null;
        }
        Statistics s;
        if (metric instanceof AltstepMetric) {
            s = data.getStatistics((AltstepMetric) metric);
        } else if (metric instanceof FunctionMetric) {
            s = data.getStatistics((FunctionMetric) metric);
        } else if (metric instanceof TestcaseMetric) {
            s = data.getStatistics((TestcaseMetric) metric);
        } else if (metric instanceof ModuleMetric) {
            s = data.getStatistics((ModuleMetric) metric);
        } else {
            throw new IllegalArgumentException(metric.getName() + " is not a subproject metric");
        }
        final Number n = s.get(c);
        return n == null ? null : n.toString();
    }
}
Also used : StatColumn(org.eclipse.titanium.metrics.StatColumn) TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) ModuleMetric(org.eclipse.titanium.metrics.ModuleMetric) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) Statistics(org.eclipse.titanium.metrics.Statistics)

Example 2 with StatColumn

use of org.eclipse.titanium.metrics.StatColumn in project titan.EclipsePlug-ins by eclipse.

the class InfoWindow method createContents.

/**
 * Fills the table with metrics data, and shows the InfoWindow
 *
 * @param node
 *            : The module to show info about.
 */
private void createContents(final NodeDescriptor node) {
    if (node.isMissing()) {
        errorHandler.reportErrorMessage("The module \"" + node.getDisplayName() + "\" cannot be found on the disk!");
        return;
    }
    final String shownName = node.getDisplayName();
    List<String> actRow = null;
    addRow(new ArrayList<String>(Arrays.asList("General Information")), Color.lightGray);
    addRow(new ArrayList<String>(Arrays.asList("Module name", shownName)), Color.white);
    for (final MetricGroup type : new MetricGroup[] { MetricGroup.MODULE }) {
        addRow(new ArrayList<String>(Arrays.asList(type.getGroupName() + " metrics")), Color.lightGray);
        for (final IMetricEnum metric : type.getMetrics()) {
            if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
                continue;
            }
            actRow = new ArrayList<String>();
            actRow.add(metric.getName());
            String val = null;
            final Number tempVal = metricsProvider.getValue(metric, module.getName());
            if (tempVal != null) {
                val = tempVal.toString();
            }
            actRow.add(val);
            if (chosenMetric.equals(metric)) {
                addRow(actRow, node.getColor());
            } else {
                addRow(actRow, Color.white);
            }
        }
    }
    for (final MetricGroup type : new MetricGroup[] { MetricGroup.ALTSTEP, MetricGroup.FUNCTION, MetricGroup.TESTCASE }) {
        addRow(new ArrayList<String>(Arrays.asList(type.getGroupName())), Color.lightGray);
        for (final IMetricEnum metric : type.getMetrics()) {
            if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
                continue;
            }
            actRow = new ArrayList<String>();
            actRow.add(metric.getName());
            final Statistics stat = metricsProvider.getStats(metric, module.getName());
            for (final StatColumn actCol : StatColumn.values()) {
                final Number val = stat == null ? null : stat.get(actCol);
                actRow.add(val == null ? "-" : val.toString());
            }
            if (chosenMetric.equals(metric)) {
                addRow(actRow, node.getColor());
            } else {
                addRow(actRow, Color.white);
            }
        }
    }
}
Also used : StatColumn(org.eclipse.titanium.metrics.StatColumn) IMetricEnum(org.eclipse.titanium.metrics.IMetricEnum) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) Statistics(org.eclipse.titanium.metrics.Statistics)

Example 3 with StatColumn

use of org.eclipse.titanium.metrics.StatColumn in project titan.EclipsePlug-ins by eclipse.

the class MetricsView method createTree.

private void createTree(final Tree inner) {
    final GridData gd = new GridData();
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    inner.setLayoutData(gd);
    inner.setHeaderVisible(true);
    inner.setLinesVisible(true);
    final Map<StatColumn, TreeColumn> columns = new EnumMap<StatColumn, TreeColumn>(StatColumn.class);
    final TreeColumn names = new TreeColumn(inner, SWT.LEFT);
    names.setAlignment(SWT.LEFT);
    names.setText(COLUMN_HEADER_1);
    names.setWidth(250);
    for (final StatColumn col : StatColumn.values()) {
        final TreeColumn c = new TreeColumn(inner, SWT.RIGHT);
        c.setAlignment(ALIGNMENTS.get(col));
        c.setText(col.getName());
        c.setWidth(100);
        columns.put(col, c);
    }
}
Also used : StatColumn(org.eclipse.titanium.metrics.StatColumn) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) EnumMap(java.util.EnumMap)

Example 4 with StatColumn

use of org.eclipse.titanium.metrics.StatColumn in project titan.EclipsePlug-ins by eclipse.

the class ModuleStatNode method getColumnText.

@Override
public String getColumnText(final MetricData data, final int i) {
    if (i == 0) {
        return module.getName();
    } else {
        StatColumn c = null;
        switch(i) {
            case 1:
                c = StatColumn.TOTAL;
                break;
            case 2:
                c = StatColumn.MAX;
                break;
            case 3:
                c = StatColumn.MEAN;
                break;
            case 4:
                c = StatColumn.DEV;
                break;
            default:
                return null;
        }
        Statistics stat;
        if (metric instanceof AltstepMetric) {
            stat = data.getStatistics((AltstepMetric) metric, module);
        } else if (metric instanceof FunctionMetric) {
            stat = data.getStatistics((FunctionMetric) metric, module);
        } else if (metric instanceof TestcaseMetric) {
            stat = data.getStatistics((TestcaseMetric) metric, module);
        } else {
            throw new AssertionError("ModuleStatNode should have a subModule-metric");
        }
        final Number n = stat.get(c);
        return n == null ? null : n.toString();
    }
}
Also used : StatColumn(org.eclipse.titanium.metrics.StatColumn) TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) Statistics(org.eclipse.titanium.metrics.Statistics)

Aggregations

StatColumn (org.eclipse.titanium.metrics.StatColumn)4 Statistics (org.eclipse.titanium.metrics.Statistics)3 AltstepMetric (org.eclipse.titanium.metrics.AltstepMetric)2 FunctionMetric (org.eclipse.titanium.metrics.FunctionMetric)2 TestcaseMetric (org.eclipse.titanium.metrics.TestcaseMetric)2 EnumMap (java.util.EnumMap)1 GridData (org.eclipse.swt.layout.GridData)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 IMetricEnum (org.eclipse.titanium.metrics.IMetricEnum)1 MetricGroup (org.eclipse.titanium.metrics.MetricGroup)1 ModuleMetric (org.eclipse.titanium.metrics.ModuleMetric)1