1 package com.stateofflow.eclipse.metrics.preferences.builder;
2
3 import java.util.Collection;
4
5 import org.eclipse.jface.preference.FieldEditor;
6 import org.eclipse.jface.preference.IPreferenceStore;
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.swt.widgets.Group;
9 import org.eclipse.swt.widgets.TabFolder;
10
11 import com.stateofflow.eclipse.metrics.calculators.complexity.CyclomaticComplexityCalculator;
12 import com.stateofflow.eclipse.metrics.metric.MetricPropertyKey;
13
14 public final class CyclomaticComplexityTabBuilder extends TabBuilder {
15 public CyclomaticComplexityTabBuilder(final Collection<FieldEditor> fieldEditors, final IPreferenceStore preferenceStore) {
16 super(fieldEditors, preferenceStore);
17 }
18
19 @Override
20 public void create(final TabFolder folder) {
21 final Composite root = createCompositeForTabItem(folder, "Complexity", "McCabe's Cyclomatic Complexity and Related Metrics");
22 addUpperBoundsGroup(root);
23 addOptionsGroup(root);
24 }
25
26 private void addOptionsGroup(final Composite root) {
27 final Group group = createGroup(root, "Options", 1);
28 addCyclomaticComplexityBooleanEditor(group, CyclomaticComplexityCalculator.COUNT_CASE_STATEMENTS_KEY, "Include 'case' and 'default' statements");
29 addCyclomaticComplexityBooleanEditor(group, CyclomaticComplexityCalculator.COUNT_CATCH_CLAUSES_KEY, "Include 'catch' clauses");
30 addCyclomaticComplexityBooleanEditor(group, CyclomaticComplexityCalculator.COUNT_TERNARY_OPERATORS_KEY, "Include ternary operator");
31 }
32
33 private void addUpperBoundsGroup(final Composite root) {
34 final Group group = createGroupForPreferredUpperBounds(root);
35 addEnableMetricFields(group, CyclomaticComplexityCalculator.METHOD_METRIC_ID, "Cyclomatic Complexity");
36 addEnableMetricFields(group, CyclomaticComplexityCalculator.WEIGHTED_METHODS_PER_CLASS_METRIC_ID, "Weighted Methods Per Class");
37 }
38
39 private void addCyclomaticComplexityBooleanEditor(final Group group, final MetricPropertyKey key, final String label) {
40 addBooleanEditor(group, key, label);
41 }
42 }
43