Search in sources :

Example 1 with ComponentGraphEditor

use of org.eclipse.titanium.graph.gui.windows.ComponentGraphEditor 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)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 ErrorHandler (org.eclipse.titanium.error.ErrorHandler)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