Search in sources :

Example 1 with AltstepMetric

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

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

the class ProjectStatNode method getChildren.

@Override
public Object[] getChildren(final MetricData data) {
    if (initialized) {
        return children;
    }
    final List<? super IContentNode> c = new ArrayList<IContentNode>();
    if (metric instanceof FunctionMetric || metric instanceof AltstepMetric || metric instanceof TestcaseMetric) {
        for (final Module m : data.getModules()) {
            final IContentNode n = new ModuleStatNode(metric, m);
            if (n.hasChildren(data)) {
                c.add(n);
            }
        }
    } else if (metric instanceof ModuleMetric) {
        for (final Module m : data.getModules()) {
            c.add(new ModuleNode((ModuleMetric) metric, m));
        }
    } else {
        throw new AssertionError("ProjectStatNode should have a subProject-metric");
    }
    children = c.toArray();
    initialized = true;
    return children;
}
Also used : TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) ModuleMetric(org.eclipse.titanium.metrics.ModuleMetric) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) ArrayList(java.util.ArrayList) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) Module(org.eclipse.titan.designer.AST.Module)

Example 3 with AltstepMetric

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

the class ModuleGraphEditor method initWindow.

@Override
protected void initWindow() {
    super.initWindow();
    isom.addActionListener(layoutListener);
    layoutGroup.add(isom);
    layoutMenu.add(isom);
    kk.addActionListener(layoutListener);
    layoutGroup.add(kk);
    layoutMenu.add(kk);
    fr.addActionListener(layoutListener);
    layoutGroup.add(fr);
    layoutMenu.add(fr);
    spring.addActionListener(layoutListener);
    layoutMenu.add(spring);
    layoutGroup.add(spring);
    circle.addActionListener(layoutListener);
    layoutMenu.add(circle);
    layoutGroup.add(circle);
    final JMenu dagMenu = new JMenu("Directed layouts");
    layoutMenu.add(dagMenu);
    tdag.setSelected(true);
    tdag.addActionListener(layoutListener);
    dagMenu.add(tdag);
    layoutGroup.add(tdag);
    rtdag.addActionListener(layoutListener);
    dagMenu.add(rtdag);
    layoutGroup.add(rtdag);
    layoutMenu.add(metricLayoutMenu);
    final ActionListener changeMetrics = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            MetricsEntry metric = (MetricsEntry) e.getSource();
            chosenMetric = metric;
            for (NodeDescriptor node : graph.getVertices()) {
                ((MeasureableGraphHandler) handler).calculateColour(node, chosenMetric.getMetric());
            }
            drawArea.repaint();
            if (satView != null) {
                satView.repaint();
            }
        }
    };
    boolean isFirst = true;
    // Creating the metric-selection menu:
    JMenu actMenu = new JMenu(ModuleMetric.GROUP_NAME);
    JMenu actLayoutMenu = new JMenu(ModuleMetric.GROUP_NAME);
    metricsMenu.add(actMenu);
    metricLayoutMenu.add(actLayoutMenu);
    for (final ModuleMetric metric : ModuleMetric.values()) {
        if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
            continue;
        }
        final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
        if (isFirst) {
            item.setSelected(true);
            chosenMetric = item;
            isFirst = false;
        }
        item.addActionListener(changeMetrics);
        metricsGroup.add(item);
        actMenu.add(item);
        final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
        layoutItem.addActionListener(layoutListener);
        layoutGroup.add(layoutItem);
        actLayoutMenu.add(layoutItem);
    }
    actMenu = new JMenu(AltstepMetric.GROUP_NAME);
    actLayoutMenu = new JMenu(AltstepMetric.GROUP_NAME);
    metricsMenu.add(actMenu);
    metricLayoutMenu.add(actLayoutMenu);
    for (final AltstepMetric metric : AltstepMetric.values()) {
        if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
            continue;
        }
        final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
        item.addActionListener(changeMetrics);
        metricsGroup.add(item);
        actMenu.add(item);
        final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
        layoutItem.addActionListener(layoutListener);
        layoutGroup.add(layoutItem);
        actLayoutMenu.add(layoutItem);
    }
    actMenu = new JMenu(FunctionMetric.GROUP_NAME);
    actLayoutMenu = new JMenu(FunctionMetric.GROUP_NAME);
    metricLayoutMenu.add(actLayoutMenu);
    metricsMenu.add(actMenu);
    for (final FunctionMetric metric : FunctionMetric.values()) {
        if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
            continue;
        }
        final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
        item.addActionListener(changeMetrics);
        metricsGroup.add(item);
        actMenu.add(item);
        final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
        layoutItem.addActionListener(layoutListener);
        layoutGroup.add(layoutItem);
        actLayoutMenu.add(layoutItem);
    }
    actMenu = new JMenu(TestcaseMetric.GROUP_NAME);
    actLayoutMenu = new JMenu(TestcaseMetric.GROUP_NAME);
    metricLayoutMenu.add(actLayoutMenu);
    metricsMenu.add(actMenu);
    for (final TestcaseMetric metric : TestcaseMetric.values()) {
        if (!PreferenceManager.isEnabledOnModuleGraph(metric)) {
            continue;
        }
        final MetricsEntry item = new MetricsEntry(metric.getName(), metric);
        item.addActionListener(changeMetrics);
        metricsGroup.add(item);
        actMenu.add(item);
        final MetricsLayoutEntry layoutItem = new MetricsLayoutEntry(metric);
        layoutItem.addActionListener(layoutListener);
        layoutGroup.add(layoutItem);
        actLayoutMenu.add(layoutItem);
    }
    final JMenuItem recalcItem = new JMenuItem("Recalculate metrics");
    recalcItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            WrapperStore.clearStore();
            GlobalParser.reAnalyzeSemantically();
            recolour(graph.getVertices());
            if (chosenLayout instanceof MetricsLayoutEntry) {
                chosenLayout.doClick();
            }
        }
    });
    metricsMenu.add(recalcItem);
    folderKnotCluster.addActionListener(new ClusteringAction("foldername", true));
    knotClusteringMenu.add(folderKnotCluster);
    folderGraphCluster.addActionListener(new ClusteringAction("foldername", false));
    graphClusteringMenu.add(folderGraphCluster);
    linkedKnotCluster.addActionListener(new ClusteringAction("linkedlocation", true));
    knotClusteringMenu.add(linkedKnotCluster);
    linkedGraphCluster.addActionListener(new ClusteringAction("linkedlocation", false));
    graphClusteringMenu.add(linkedGraphCluster);
    locationKnotCluster.addActionListener(new ClusteringAction("modulelocation", true));
    knotClusteringMenu.add(locationKnotCluster);
    locationGraphCluster.addActionListener(new ClusteringAction("modulelocation", false));
    graphClusteringMenu.add(locationGraphCluster);
    regKnotCluster.addActionListener(new ClusteringAction("regularexpression", true));
    knotClusteringMenu.add(regKnotCluster);
    regGraphCluster.addActionListener(new ClusteringAction("regularexpression", false));
    graphClusteringMenu.add(regGraphCluster);
    nameKnotCluster.addActionListener(new ClusteringAction("modulename", true));
    knotClusteringMenu.add(nameKnotCluster);
    nameGraphCluster.addActionListener(new ClusteringAction("modulename", false));
    nameClusteringMenu.add(nameGraphCluster);
    fullNameGraphCluster.addActionListener(new ClusteringAction("fullmodulenametree", false, (LayoutEntry) tdag));
    nameClusteringMenu.add(fullNameGraphCluster);
    sparseNameGraphCluster.addActionListener(new ClusteringAction("sparsemodulenametree", false, (LayoutEntry) tdag));
    nameClusteringMenu.add(sparseNameGraphCluster);
    autoKnotCluster.addActionListener(new ClusteringAction("automatic", true));
    knotClusteringMenu.add(autoKnotCluster);
    closeGraphClusters.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            chosenLayout.setSelected(false);
            tdag.setSelected(true);
            chosenLayout = (LayoutEntry) tdag;
            enableModuleMenus(true);
            setGraph(originalGraph);
        }
    });
    closeGraphClusters.setEnabled(false);
    menuBar.add(metricsMenu);
    clusteringMenu.add(knotClusteringMenu);
    graphClusteringMenu.add(nameClusteringMenu);
    clusteringMenu.add(graphClusteringMenu);
    clusteringMenu.add(closeGraphClusters);
    menuBar.add(clusteringMenu);
}
Also used : MeasureableGraphHandler(org.eclipse.titanium.graph.visualization.MeasureableGraphHandler) MetricsEntry(org.eclipse.titanium.graph.gui.utils.MetricsEntry) ActionEvent(java.awt.event.ActionEvent) MetricsLayoutEntry(org.eclipse.titanium.graph.gui.utils.MetricsLayoutEntry) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) ModuleMetric(org.eclipse.titanium.metrics.ModuleMetric) ActionListener(java.awt.event.ActionListener) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) MetricsLayoutEntry(org.eclipse.titanium.graph.gui.utils.MetricsLayoutEntry) LayoutEntry(org.eclipse.titanium.graph.gui.utils.LayoutEntry) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 4 with AltstepMetric

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

Example 5 with AltstepMetric

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

the class ModuleStatNode method getChildren.

@Override
public Object[] getChildren(final MetricData data) {
    if (initialized) {
        return children;
    }
    final List<? super IContentNode> c = new ArrayList<IContentNode>();
    if (metric instanceof FunctionMetric) {
        for (final Def_Function f : data.getFunctions().get(module)) {
            c.add(new FunctionNode((FunctionMetric) metric, f));
        }
    } else if (metric instanceof TestcaseMetric) {
        for (final Def_Testcase t : data.getTestcases().get(module)) {
            c.add(new TestcaseNode((TestcaseMetric) metric, t));
        }
    } else if (metric instanceof AltstepMetric) {
        for (final Def_Altstep a : data.getAltsteps().get(module)) {
            c.add(new AltstepNode((AltstepMetric) metric, a));
        }
    } else {
        throw new AssertionError("ModuleStatNode should have a subModule-metric");
    }
    children = c.toArray();
    initialized = true;
    return children;
}
Also used : TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) ArrayList(java.util.ArrayList) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Aggregations

AltstepMetric (org.eclipse.titanium.metrics.AltstepMetric)5 FunctionMetric (org.eclipse.titanium.metrics.FunctionMetric)5 TestcaseMetric (org.eclipse.titanium.metrics.TestcaseMetric)5 ModuleMetric (org.eclipse.titanium.metrics.ModuleMetric)3 ArrayList (java.util.ArrayList)2 StatColumn (org.eclipse.titanium.metrics.StatColumn)2 Statistics (org.eclipse.titanium.metrics.Statistics)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 Module (org.eclipse.titan.designer.AST.Module)1 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)1 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1 NodeDescriptor (org.eclipse.titanium.graph.components.NodeDescriptor)1 LayoutEntry (org.eclipse.titanium.graph.gui.utils.LayoutEntry)1 MetricsEntry (org.eclipse.titanium.graph.gui.utils.MetricsEntry)1 MetricsLayoutEntry (org.eclipse.titanium.graph.gui.utils.MetricsLayoutEntry)1 MeasureableGraphHandler (org.eclipse.titanium.graph.visualization.MeasureableGraphHandler)1