Search in sources :

Example 1 with ConsoleErrorHandler

use of org.eclipse.titanium.error.ConsoleErrorHandler in project titan.EclipsePlug-ins by eclipse.

the class SonarDataExporter method exportMetrics.

private void exportMetrics(final URI exportDir) throws IOException {
    final URI filePath = URIUtil.append(exportDir, "metrics.xml");
    final File file = new File(filePath);
    FileUtils.delete(file);
    final SonarMetricsExporter exporter = new SonarMetricsExporter();
    try {
        exporter.export(MetricData.measure(project), file);
    } catch (JAXBException e) {
        new ConsoleErrorHandler().reportException("Error while exporting the project metrics", e);
    }
}
Also used : SonarMetricsExporter(org.eclipse.titanium.sonar.metrics.SonarMetricsExporter) JAXBException(javax.xml.bind.JAXBException) ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) URI(java.net.URI) File(java.io.File)

Example 2 with ConsoleErrorHandler

use of org.eclipse.titanium.error.ConsoleErrorHandler in project titan.EclipsePlug-ins by eclipse.

the class SaveComponentNet method exportInformationForProject.

@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
    final ErrorHandler errorHandler = new ConsoleErrorHandler();
    final ComponentGraphGenerator generator = new ComponentGraphGenerator(project, errorHandler);
    try {
        generator.generateGraph();
        GraphHandler.saveGraphToPajek(generator.getGraph(), args[0] + project.getName() + ".net");
    } catch (Exception e) {
        errorHandler.reportException("Error while exporting", e);
    }
}
Also used : ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) ErrorHandler(org.eclipse.titanium.error.ErrorHandler) ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) ComponentGraphGenerator(org.eclipse.titanium.graph.generators.ComponentGraphGenerator)

Example 3 with ConsoleErrorHandler

use of org.eclipse.titanium.error.ConsoleErrorHandler in project titan.EclipsePlug-ins by eclipse.

the class SaveModuleDot method exportInformationForProject.

@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
    final ErrorHandler errorHandler = new ConsoleErrorHandler();
    final ModuleGraphGenerator generator = new ModuleGraphGenerator(project, errorHandler);
    try {
        generator.generateGraph();
        String clusterName = "";
        for (int i = 1; i < args.length; ++i) {
            if (args[i].startsWith("-c")) {
                clusterName = args[i].substring(2);
            }
        }
        if (clusterName.isEmpty()) {
            graph = generator.getGraph();
        } else {
            final BaseCluster clusterer = new ClustererBuilder().setAlgorithm(clusterName).setGraph(generator.getGraph()).setProject(project).build();
            clusterer.run(monitor, false);
            graph = clusterer.getGraph();
        }
        final String fileName = args[0] + project.getName() + ".dot";
        GraphHandler.saveGraphToDot(graph, fileName, project.getName());
        errorHandler.reportInformation("The graphs have been successfully saved. See results at " + new File(fileName).getAbsolutePath());
    } catch (Exception e) {
        errorHandler.reportException("Error while exporting", e);
    }
}
Also used : ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) ErrorHandler(org.eclipse.titanium.error.ErrorHandler) ModuleGraphGenerator(org.eclipse.titanium.graph.generators.ModuleGraphGenerator) ClustererBuilder(org.eclipse.titanium.graph.clustering.ClustererBuilder) BaseCluster(org.eclipse.titanium.graph.clustering.BaseCluster) ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) File(java.io.File)

Example 4 with ConsoleErrorHandler

use of org.eclipse.titanium.error.ConsoleErrorHandler in project titan.EclipsePlug-ins by eclipse.

the class ClustererBuilder method build.

/**
 * This method builds up the convenient clusterer object
 * @return The built object
 * @throws IllegalArgumentException If some needed parameters are not already set
 */
public BaseCluster build() throws IllegalArgumentException {
    if (originalGraph == null) {
        throw new IllegalArgumentException("The graph parameter wasn't set for the builder");
    }
    final ConsoleErrorHandler errorHandler = new ConsoleErrorHandler();
    BaseCluster clusterer = null;
    if ("modulelocation".equalsIgnoreCase(clusterName)) {
        clusterer = new ModuleLocationCluster(originalGraph, project);
    } else if ("foldername".equalsIgnoreCase(clusterName)) {
        clusterer = new FolderNameCluster(originalGraph, project);
    } else if ("linkedlocation".equalsIgnoreCase(clusterName)) {
        clusterer = new LinkedFileCluster(originalGraph, project);
    } else if ("regularexpression".equalsIgnoreCase(clusterName)) {
        clusterer = new RegexpCluster(originalGraph);
    } else if ("modulename".equalsIgnoreCase(clusterName)) {
        clusterer = new ModuleNameCluster(originalGraph);
    } else if ("fullmodulenametree".equalsIgnoreCase(clusterName)) {
        clusterer = new FullModuleNameCluster(originalGraph);
    } else if ("sparsemodulenametree".equalsIgnoreCase(clusterName)) {
        clusterer = new SparseModuleNameCluster(originalGraph);
    } else if ("automatic".equalsIgnoreCase(clusterName)) {
        clusterer = new AutomaticCluster(originalGraph, project);
    } else {
        errorHandler.reportInformation("Usage: <output path> [-c<clustering algorithm name>]");
        errorHandler.reportInformation("The possible clustering algorithms are: ");
        errorHandler.reportInformation("\tModuleLocation\n\tFolderName\n\tLinkedLocation\n\tRegularExpression\n\tModuleName\n" + "\tFullModuleNameTree\n\tSparseModuleNameTree");
        throw new IllegalArgumentException("The algorithm doesn't exist!");
    }
    return clusterer;
}
Also used : ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler)

Example 5 with ConsoleErrorHandler

use of org.eclipse.titanium.error.ConsoleErrorHandler in project titan.EclipsePlug-ins by eclipse.

the class SaveComponentDot method exportInformationForProject.

@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
    final ErrorHandler errorHandler = new ConsoleErrorHandler();
    final ComponentGraphGenerator generator = new ComponentGraphGenerator(project, errorHandler);
    try {
        generator.generateGraph();
        GraphHandler.saveGraphToDot(generator.getGraph(), args[0] + project.getName() + ".dot", project.getName());
    } catch (Exception e) {
        errorHandler.reportException("Error while exporting", e);
    }
}
Also used : ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) ErrorHandler(org.eclipse.titanium.error.ErrorHandler) ConsoleErrorHandler(org.eclipse.titanium.error.ConsoleErrorHandler) ComponentGraphGenerator(org.eclipse.titanium.graph.generators.ComponentGraphGenerator)

Aggregations

ConsoleErrorHandler (org.eclipse.titanium.error.ConsoleErrorHandler)8 ErrorHandler (org.eclipse.titanium.error.ErrorHandler)6 ComponentGraphGenerator (org.eclipse.titanium.graph.generators.ComponentGraphGenerator)4 ModuleGraphGenerator (org.eclipse.titanium.graph.generators.ModuleGraphGenerator)4 File (java.io.File)3 URI (java.net.URI)3 JAXBException (javax.xml.bind.JAXBException)3 IOException (java.io.IOException)2 BaseCluster (org.eclipse.titanium.graph.clustering.BaseCluster)2 ClustererBuilder (org.eclipse.titanium.graph.clustering.ClustererBuilder)2 GraphGenerator (org.eclipse.titanium.graph.generators.GraphGenerator)2 SonarMetricsExporter (org.eclipse.titanium.sonar.metrics.SonarMetricsExporter)1