Search in sources :

Example 1 with ErrorHandler

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

the class ComponentGraphAction method doOpenGraphForProject.

/**
 * @param project the project whose graph is to be displayed
 */
private void doOpenGraphForProject(final IProject project) {
    try {
        // looking for a file inside the selected
        // project
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IFile input = null;
        IResource[] members = project.members();
        for (final IResource res : members) {
            if (res.getType() == IResource.FILE) {
                input = (IFile) res;
                break;
            }
            if (res.getType() == IResource.FOLDER) {
                members = ((IFolder) res).members();
            }
        }
        final IEditorPart editor = page.findEditor(new FileEditorInput(input));
        if (editor instanceof ComponentGraphEditor) {
            ((ComponentGraphEditor) editor).refreshGraph();
        } else {
            page.openEditor(new FileEditorInput(input), ComponentGraphEditor.ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
        }
    } catch (Exception exc) {
        final ErrorHandler errorHandler = new GUIErrorHandler();
        errorHandler.reportException("Error while parsing the project", exc);
    }
}
Also used : GUIErrorHandler(org.eclipse.titanium.error.GUIErrorHandler) ErrorHandler(org.eclipse.titanium.error.ErrorHandler) IFile(org.eclipse.core.resources.IFile) GUIErrorHandler(org.eclipse.titanium.error.GUIErrorHandler) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ComponentGraphEditor(org.eclipse.titanium.graph.gui.windows.ComponentGraphEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IResource(org.eclipse.core.resources.IResource) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 2 with ErrorHandler

use of org.eclipse.titanium.error.ErrorHandler 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 ErrorHandler

use of org.eclipse.titanium.error.ErrorHandler 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 ErrorHandler

use of org.eclipse.titanium.error.ErrorHandler 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)

Example 5 with ErrorHandler

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

the class SaveModuleNet 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() + ".net";
        GraphHandler.saveGraphToPajek(graph, fileName);
        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)

Aggregations

ErrorHandler (org.eclipse.titanium.error.ErrorHandler)7 ConsoleErrorHandler (org.eclipse.titanium.error.ConsoleErrorHandler)6 ComponentGraphGenerator (org.eclipse.titanium.graph.generators.ComponentGraphGenerator)4 ModuleGraphGenerator (org.eclipse.titanium.graph.generators.ModuleGraphGenerator)4 File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 JAXBException (javax.xml.bind.JAXBException)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 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 GUIErrorHandler (org.eclipse.titanium.error.GUIErrorHandler)1 ComponentGraphEditor (org.eclipse.titanium.graph.gui.windows.ComponentGraphEditor)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1