Search in sources :

Example 6 with TreeElement

use of org.eclipse.linuxtools.internal.gcov.model.TreeElement in project linuxtools by eclipse.

the class CovViewer method handleOpenEvent.

@Override
protected void handleOpenEvent(OpenEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    TreeElement element = (TreeElement) selection.getFirstElement();
    if (element != null) {
        if (element.getParent() != null) {
            // $NON-NLS-1$
            String sourceLoc = "";
            long lineNumber = 0;
            if (element.getClass() == CovFileTreeElement.class) {
                sourceLoc = element.getName();
            } else if (element.getClass() == CovFunctionTreeElement.class) {
                sourceLoc = ((CovFunctionTreeElement) element).getSourceFilePath();
                lineNumber = ((CovFunctionTreeElement) element).getFirstLnNmbr();
            }
            CovManager cvm = (CovManager) this.getInput();
            SourceFile sourceFile = cvm.getSourceFile(sourceLoc);
            if (sourceFile != null) {
                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
                String binaryLoc = cvm.getBinaryPath();
                IPath binaryPath = new Path(binaryLoc);
                IFile binary = root.getFileForLocation(binaryPath);
                IProject project = null;
                if (binary != null) {
                    project = binary.getProject();
                }
                OpenSourceFileAction.openAnnotatedSourceFile(project, binary, sourceFile, (int) lineNumber);
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) CovFunctionTreeElement(org.eclipse.linuxtools.internal.gcov.model.CovFunctionTreeElement) CovManager(org.eclipse.linuxtools.internal.gcov.parser.CovManager) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SourceFile(org.eclipse.linuxtools.internal.gcov.parser.SourceFile) IProject(org.eclipse.core.resources.IProject) CovFileTreeElement(org.eclipse.linuxtools.internal.gcov.model.CovFileTreeElement) CovFunctionTreeElement(org.eclipse.linuxtools.internal.gcov.model.CovFunctionTreeElement) TreeElement(org.eclipse.linuxtools.internal.gcov.model.TreeElement)

Example 7 with TreeElement

use of org.eclipse.linuxtools.internal.gcov.model.TreeElement in project linuxtools by eclipse.

the class FieldCoveragePercentage method getToolTipText.

@Override
public String getToolTipText(Object element) {
    TreeElement e = (TreeElement) element;
    String s = NLS.bind(Messages.FieldCoveragePercentage_column_tooltip, Integer.toString((int) e.getCoveragePercentage()));
    return s;
}
Also used : CovRootTreeElement(org.eclipse.linuxtools.internal.gcov.model.CovRootTreeElement) TreeElement(org.eclipse.linuxtools.internal.gcov.model.TreeElement)

Example 8 with TreeElement

use of org.eclipse.linuxtools.internal.gcov.model.TreeElement in project linuxtools by eclipse.

the class FieldCoveragePercentage method getNumber.

@Override
public Number getNumber(Object obj) {
    TreeElement e = (TreeElement) obj;
    float f = getPercentage(obj);
    if (e.getClass() == CovRootTreeElement.class)
        return 0;
    else {
        if (f < 0) {
            f = 0.0f;
        }
        return f;
    }
}
Also used : CovRootTreeElement(org.eclipse.linuxtools.internal.gcov.model.CovRootTreeElement) TreeElement(org.eclipse.linuxtools.internal.gcov.model.TreeElement)

Aggregations

TreeElement (org.eclipse.linuxtools.internal.gcov.model.TreeElement)8 CovRootTreeElement (org.eclipse.linuxtools.internal.gcov.model.CovRootTreeElement)5 LinkedList (java.util.LinkedList)2 CovFileTreeElement (org.eclipse.linuxtools.internal.gcov.model.CovFileTreeElement)2 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 CovFolderTreeElement (org.eclipse.linuxtools.internal.gcov.model.CovFolderTreeElement)1 CovFunctionTreeElement (org.eclipse.linuxtools.internal.gcov.model.CovFunctionTreeElement)1 CovManager (org.eclipse.linuxtools.internal.gcov.parser.CovManager)1 SourceFile (org.eclipse.linuxtools.internal.gcov.parser.SourceFile)1