Search in sources :

Example 1 with MetricGroup

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

the class GraphMetricsPage method createContents.

@Override
protected Control createContents(final Composite parent) {
    final Composite page = new Composite(parent, 0);
    final GridLayout l = new GridLayout();
    l.numColumns = 2;
    page.setLayout(l);
    for (final MetricGroup type : new MetricGroup[] { MetricGroup.MODULE, MetricGroup.FUNCTION, MetricGroup.TESTCASE, MetricGroup.ALTSTEP }) {
        final Label header = new Label(page, 0);
        header.setText(type.getGroupName() + " metrics");
        final GridData headerData = new GridData();
        headerData.horizontalSpan = 2;
        header.setLayoutData(headerData);
        final Composite padding = new Composite(page, 0);
        padding.setLayoutData(new GridData(25, 0));
        final Composite inner = new Composite(page, 0);
        for (final IMetricEnum metric : type.getMetrics()) {
            final BooleanFieldEditor editor = new BooleanFieldEditor(PreferenceConstants.nameMetricGraph(metric.id()), metric.getName(), inner);
            editor.getDescriptionControl(inner).setToolTipText(metric.getHint());
            editor.setPage(this);
            editor.setPreferenceStore(this.getPreferenceStore());
            editor.load();
            editors.add(editor);
        }
    }
    return page;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IMetricEnum(org.eclipse.titanium.metrics.IMetricEnum) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor)

Example 2 with MetricGroup

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

the class MetricsLimitPreferencePage method createContents.

@Override
protected Control createContents(final Composite parent) {
    final Composite page = new Composite(parent, 0);
    final GridLayout l = new GridLayout();
    l.numColumns = 2;
    page.setLayout(l);
    for (final MetricGroup type : MetricGroup.values()) {
        final Label header = new Label(page, 0);
        header.setText(type.getGroupName() + " metrics");
        final GridData headerData = new GridData();
        headerData.horizontalSpan = 2;
        header.setLayoutData(headerData);
        final Composite padding = new Composite(page, 0);
        padding.setLayoutData(new GridData(25, 0));
        final Composite inner = new Composite(page, 0);
        final GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        inner.setLayout(layout);
        final IRiskEditorListener listener = new IRiskEditorListener() {

            @Override
            public void editorChanged() {
                inner.layout();
                page.layout();
            }
        };
        final IRiskEditorPropertyListener propertyListener = new IRiskEditorPropertyListener() {

            @Override
            public void propertyChange(final boolean valid) {
                if (!valid) {
                    setValid(false);
                    updateApplyButton();
                } else if (!isValid()) {
                    checkState();
                }
            }
        };
        for (final IMetricEnum metric : type.getMetrics()) {
            final Label name = new Label(inner, 0);
            name.setText(metric.getName());
            name.setToolTipText(metric.getHint());
            final IRiskFieldEditor editor = getRiskEditor(inner, metric);
            editor.addRiskEditorListener(listener);
            editor.setPropListener(propertyListener);
            editor.load();
            editors.add(editor);
        }
    }
    checkState();
    return page;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IRiskFieldEditor(org.eclipse.titanium.metrics.preferences.IRiskFieldEditor) IRiskEditorPropertyListener(org.eclipse.titanium.metrics.preferences.IRiskEditorPropertyListener) IMetricEnum(org.eclipse.titanium.metrics.IMetricEnum) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) IRiskEditorListener(org.eclipse.titanium.metrics.preferences.IRiskEditorListener)

Example 3 with MetricGroup

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

the class MetricsViewPreferencePage method createContents.

@Override
protected Control createContents(final Composite parent) {
    final Composite page = new Composite(parent, 0);
    final GridLayout l = new GridLayout();
    l.numColumns = 2;
    page.setLayout(l);
    for (final MetricGroup type : MetricGroup.values()) {
        final Label header = new Label(page, 0);
        header.setText(type.getGroupName() + " metrics");
        final GridData headerData = new GridData();
        headerData.horizontalSpan = 2;
        header.setLayoutData(headerData);
        final Composite padding = new Composite(page, 0);
        padding.setLayoutData(new GridData(25, 0));
        final Composite inner = new Composite(page, 0);
        for (final IMetricEnum metric : type.getMetrics()) {
            final BooleanFieldEditor editor = new BooleanFieldEditor(PreferenceConstants.nameMetricEnabled(metric.id()), metric.getName(), inner);
            editor.getDescriptionControl(inner).setToolTipText(metric.getHint());
            editor.setPage(this);
            editor.setPreferenceStore(this.getPreferenceStore());
            editor.load();
            editors.add(editor);
        }
    }
    return page;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) IMetricEnum(org.eclipse.titanium.metrics.IMetricEnum) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor)

Example 4 with MetricGroup

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

the class ContentProvider method getElements.

@Override
public Object[] getElements(final Object inputElement) {
    if (!(inputElement instanceof MetricData)) {
        throw new IllegalArgumentException();
    }
    data = (MetricData) inputElement;
    final List<? super INode> children = new ArrayList<INode>();
    for (final MetricGroup t : MetricGroup.values()) {
        final RootNode n = new RootNode(t);
        if (n.hasChildren(data)) {
            children.add(n);
        }
    }
    return children.toArray();
}
Also used : ArrayList(java.util.ArrayList) MetricGroup(org.eclipse.titanium.metrics.MetricGroup) MetricData(org.eclipse.titanium.metrics.MetricData)

Example 5 with MetricGroup

use of org.eclipse.titanium.metrics.MetricGroup 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)

Aggregations

MetricGroup (org.eclipse.titanium.metrics.MetricGroup)6 IMetricEnum (org.eclipse.titanium.metrics.IMetricEnum)5 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)2 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 MetricData (org.eclipse.titanium.metrics.MetricData)1 StatColumn (org.eclipse.titanium.metrics.StatColumn)1 Statistics (org.eclipse.titanium.metrics.Statistics)1 IRiskEditorListener (org.eclipse.titanium.metrics.preferences.IRiskEditorListener)1 IRiskEditorPropertyListener (org.eclipse.titanium.metrics.preferences.IRiskEditorPropertyListener)1 IRiskFieldEditor (org.eclipse.titanium.metrics.preferences.IRiskFieldEditor)1