Search in sources :

Example 1 with RiskLevel

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

the class MeasureableGraphHandler method calculateColour.

/**
 * This method calculates the colour of a given node according to a given
 * metric.
 *
 * @param node
 *            : The node that you want to colour
 * @param metric
 *            : The given metric type (currently it handles <font
 *            color="red">ONLY</font> one metric)
 * @return The calculated node colour
 */
public Color calculateColour(final NodeDescriptor node, final IMetricEnum metric) {
    chosenColouringMetric = metric;
    if (node.isMissing()) {
        node.setNodeColour(NodeColours.MISSING_COLOUR);
        return NodeColours.MISSING_COLOUR;
    }
    Color actColor;
    final ModuleMetricsWrapper actProvider = WrapperStore.getWrapper(node.getProject());
    final RiskLevel rColor = actProvider.getRisk(metric, node.getName());
    switch(rColor) {
        case NO:
            actColor = NodeColours.DARK_GREEN;
            break;
        case LOW:
            actColor = NodeColours.DARK_YELLOW;
            break;
        case HIGH:
            actColor = NodeColours.DARK_RED;
            break;
        default:
            actColor = NodeColours.NO_VALUE_COLOUR;
            break;
    }
    node.setNodeColour(actColor);
    return actColor;
}
Also used : Color(java.awt.Color) ModuleMetricsWrapper(org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper) RiskLevel(org.eclipse.titanium.metrics.utils.RiskLevel)

Example 2 with RiskLevel

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

the class ExportAllMetrics method exportInformationForProject.

@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
    final MetricData data = MetricData.measure(project);
    final RiskLevel r = RiskLevel.NO;
    final String fn = args[0] + project.getName() + ".xls";
    final File file = new File(fn);
    final XLSExporter xlsWriter = new XLSExporter(data);
    xlsWriter.setFile(file);
    xlsWriter.write(r);
}
Also used : XLSExporter(org.eclipse.titanium.metrics.view.XLSExporter) RiskLevel(org.eclipse.titanium.metrics.utils.RiskLevel) File(java.io.File) MetricData(org.eclipse.titanium.metrics.MetricData)

Example 3 with RiskLevel

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

the class MetricsView method createExportToXlsButton.

private void createExportToXlsButton(final Composite head) {
    export = new Button(head, SWT.NONE);
    export.setImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "resources/icons/metrics_export_csv.gif").createImage());
    export.setToolTipText(EXPORT_TOOLTIP);
    export.setEnabled(false);
    export.setLayoutData(new GridData(SWT.DEFAULT, 25));
    export.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent event) {
            // choose the set of metrics to export
            final RiskLevel r = new ExportSetDialog(parent.getDisplay()).open();
            if (r == null) {
                return;
            }
            final FileDialog d = new FileDialog(parent.getShell(), SWT.SAVE);
            d.setText("Export metric results to xls");
            d.setFilterExtensions(new String[] { "*.xls" });
            final Calendar now = Calendar.getInstance();
            d.setFileName(projectSelector.getText() + "--" + now.get(Calendar.YEAR) + "-" + (1 + now.get(Calendar.MONTH)) + "-" + now.get(Calendar.DAY_OF_MONTH));
            final String fn = d.open();
            if (fn == null) {
                return;
            }
            final File file = new File(fn);
            final XLSExporter xlsWriter = new XLSExporter(data);
            xlsWriter.setFile(file);
            xlsWriter.write(r);
        }
    });
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Calendar(java.util.Calendar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RiskLevel(org.eclipse.titanium.metrics.utils.RiskLevel) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Aggregations

RiskLevel (org.eclipse.titanium.metrics.utils.RiskLevel)3 File (java.io.File)2 Color (java.awt.Color)1 Calendar (java.util.Calendar)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Button (org.eclipse.swt.widgets.Button)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 MetricData (org.eclipse.titanium.metrics.MetricData)1 ModuleMetricsWrapper (org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper)1 XLSExporter (org.eclipse.titanium.metrics.view.XLSExporter)1