Search in sources :

Example 91 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class ChartEditor method showView.

/**
 * Shows the Valgrind view in the active page and gives it focus.
 */
private void showView() {
    Display.getDefault().syncExec(() -> {
        try {
            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            activePage.showView(IValgrindToolView.VIEW_ID);
        } catch (PartInitException e) {
            e.printStackTrace();
        }
    });
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 92 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class SpecfileFormEditor method addPages.

@Override
protected void addPages() {
    try {
        int index = addPage(editor, getEditorInput());
        setPageText(index, Messages.SpecfileFormEditor_0);
        Specfile specfile = editor.getSpecfile();
        FormPage mainPackage = new MainPackagePage(this, specfile);
        addPage(0, mainPackage);
        addPage(1, new RpmSectionPage(this, specfile, RpmSections.PREP_SECTION));
        addPage(2, new RpmSectionPage(this, specfile, RpmSections.BUILD_SECTION));
        addPage(3, new RpmSectionPage(this, specfile, RpmSections.INSTALL_SECTION));
    } catch (PartInitException e) {
    // 
    }
}
Also used : Specfile(org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile) FormPage(org.eclipse.ui.forms.editor.FormPage) PartInitException(org.eclipse.ui.PartInitException)

Example 93 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class SourcesFileHyperlink method open.

/**
 * Tries to open the given file name looking for it in the current directory
 * and in ../SOURCES.
 *
 * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
 */
@Override
public void open() {
    IContainer container = original.getParent();
    IResource resourceToOpen = container.findMember(fileName);
    if (resourceToOpen == null) {
        IResource sourcesFolder = container.getParent().findMember(// $NON-NLS-1$
        "SOURCES");
        resourceToOpen = ((IFolder) sourcesFolder).getFile(fileName);
    }
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        if (resourceToOpen.getType() == IResource.FILE) {
            IDE.openEditor(page, (IFile) resourceToOpen);
        }
    } catch (PartInitException e) {
        SpecfileLog.logError(e);
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 94 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class CovView method displayCovResults.

public static void displayCovResults(String binaryPath, String gcda) {
    try {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IFile binary = root.getFileForLocation(new Path(binaryPath));
        IProject project = null;
        if (binary != null) {
            project = binary.getProject();
        }
        // parse and process coverage data
        CovManager cvrgeMnger = new CovManager(binaryPath, project);
        List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
        cvrgeMnger.processCovFiles(gcdaPaths, gcda);
        // generate model for view
        cvrgeMnger.fillGcovView();
        // load an Eclipse view
        Date date = new Date(0);
        Date dateCandidate;
        for (String file : gcdaPaths) {
            dateCandidate = new Date(new File(file).lastModified());
            if (dateCandidate.after(date)) {
                date = dateCandidate;
            }
        }
        String timestamp = DateFormat.getInstance().format(date);
        PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
            try {
                displayCovResults(cvrgeMnger, timestamp);
            } catch (PartInitException e) {
                reportError(e);
            }
        });
    } catch (InterruptedException | IOException | CoreException e) {
        reportError(e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) Date(java.util.Date) CovManager(org.eclipse.linuxtools.internal.gcov.parser.CovManager) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) SourceFile(org.eclipse.linuxtools.internal.gcov.parser.SourceFile)

Example 95 with PartInitException

use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.

the class OpenSourceFileAction method openAnnotatedSourceFile.

public static void openAnnotatedSourceFile(IProject project, IFile binary, SourceFile sourceFile, IPath realLocation, int lineNumber) {
    PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
        IWorkbenchPage page = CUIPlugin.getActivePage();
        if (page != null) {
            IFileStore fs = getFileStore(project, realLocation);
            if (fs == null && !realLocation.isAbsolute() && binary != null) {
                IPath p = binary.getProjectRelativePath().removeLastSegments(1);
                fs = getFileStore(project, p.append(realLocation));
            }
            if (fs == null) {
                try {
                    page.openEditor(new STAnnotatedSourceNotFoundEditorInput(project, sourceFile, realLocation, lineNumber), STAnnotatedSourceNotFoundEditor.ID, true);
                } catch (PartInitException e) {
                    Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.OpenSourceFileAction_open_error, e);
                    Activator.getDefault().getLog().log(s);
                }
            } else {
                try {
                    IEditorPart editor = IDE.openEditorOnFileStore(page, fs);
                    if (lineNumber > 0 && editor instanceof ITextEditor) {
                        IDocumentProvider provider = ((ITextEditor) editor).getDocumentProvider();
                        IDocument document = provider.getDocument(editor.getEditorInput());
                        try {
                            int start = document.getLineOffset(lineNumber - 1);
                            ((ITextEditor) editor).selectAndReveal(start, 0);
                        } catch (BadLocationException e) {
                        // ignore
                        }
                        IWorkbenchPage p = editor.getSite().getPage();
                        p.activate(editor);
                    }
                } catch (PartInitException e) {
                    Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.OpenSourceFileAction_open_error, e);
                    Activator.getDefault().getLog().log(s);
                }
            }
        }
    });
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IPath(org.eclipse.core.runtime.IPath) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException) IEditorPart(org.eclipse.ui.IEditorPart) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39