FileDocCategorySizeDatePackage
ProfileProvider.javaAPI DocAndroid 1.5 API13579Wed May 06 22:41:10 BST 2009com.android.traceview

ProfileProvider

public class ProfileProvider extends Object implements org.eclipse.jface.viewers.ITreeContentProvider

Fields Summary
private MethodData[]
mRoots
private org.eclipse.swt.events.SelectionAdapter
mListener
private org.eclipse.jface.viewers.TreeViewer
mTreeViewer
private TraceReader
mReader
private org.eclipse.swt.graphics.Image
mSortUp
private org.eclipse.swt.graphics.Image
mSortDown
private String[]
mColumnNames
private int[]
mColumnWidths
private int[]
mColumnAlignments
private static final int
COL_NAME
private static final int
COL_INCLUSIVE_PER
private static final int
COL_INCLUSIVE
private static final int
COL_EXCLUSIVE_PER
private static final int
COL_EXCLUSIVE
private static final int
COL_CALLS
private static final int
COL_TIME_PER_CALL
private long
mTotalTime
private Pattern
mUppercase
private int
mPrevMatchIndex
Constructors Summary
public ProfileProvider(TraceReader reader)


       
        mRoots = reader.getMethods();
        mReader = reader;
        mTotalTime = reader.getEndTime();
        Display display = Display.getCurrent();
        InputStream in = getClass().getClassLoader().getResourceAsStream(
                "icons/sort_up.png");
        mSortUp = new Image(display, in);
        in = getClass().getClassLoader().getResourceAsStream(
                "icons/sort_down.png");
        mSortDown = new Image(display, in);
        mUppercase = Pattern.compile("[A-Z]");
    
Methods Summary
public voiddispose()

    
private MethodDatadoMatchName(java.lang.String name, int startIndex)

        // Check if the given "name" has any uppercase letters
        boolean hasUpper = mUppercase.matcher(name).matches();
        for (int ii = startIndex; ii < mRoots.length; ++ii) {
            MethodData md = mRoots[ii];
            String fullName = md.getName();
            // If there were no upper case letters in the given name,
            // then ignore case when matching.
            if (!hasUpper)
                fullName = fullName.toLowerCase();
            if (fullName.indexOf(name) != -1) {
                mPrevMatchIndex = ii;
                return md;
            }
        }
        mPrevMatchIndex = -1;
        return null;
    
public MethodDatafindMatchingName(java.lang.String name)

        return doMatchName(name, 0);
    
public MethodDatafindMatchingTreeItem(org.eclipse.swt.widgets.TreeItem item)

        if (item == null)
            return null;
        String text = item.getText();
        if (Character.isDigit(text.charAt(0)) == false)
            return null;
        int spaceIndex = text.indexOf(' ");
        String numstr = text.substring(0, spaceIndex);
        int rank = Integer.valueOf(numstr);
        for (MethodData md : mRoots) {
            if (md.getRank() == rank)
                return md;
        }
        return null;
    
public MethodDatafindNextMatchingName(java.lang.String name)

        return doMatchName(name, mPrevMatchIndex + 1);
    
public java.lang.Object[]getChildren(java.lang.Object element)

        if (element instanceof MethodData) {
            MethodData md = (MethodData) element;
            return md.getProfileNodes();
        }
        if (element instanceof ProfileNode) {
            ProfileNode pn = (ProfileNode) element;
            return pn.getChildren();
        }
        return new Object[0];
    
public int[]getColumnAlignments()

        return mColumnAlignments;
    
public org.eclipse.swt.events.SelectionAdaptergetColumnListener()

        if (mListener == null)
            mListener = new ColumnListener();
        return mListener;
    
public java.lang.String[]getColumnNames()

        return mColumnNames;
    
public int[]getColumnWidths()

        return mColumnWidths;
    
public java.lang.Object[]getElements(java.lang.Object element)

        return mRoots;
    
public org.eclipse.jface.viewers.LabelProvidergetLabelProvider()

        return new ProfileLabelProvider();
    
public java.lang.ObjectgetParent(java.lang.Object element)

        return null;
    
public java.lang.ObjectgetRoot()

        return "root";
    
public booleanhasChildren(java.lang.Object element)

        if (element instanceof MethodData)
            return true;
        if (element instanceof ProfileNode)
            return true;
        return false;
    
public voidinputChanged(org.eclipse.jface.viewers.Viewer arg0, java.lang.Object arg1, java.lang.Object arg2)

    
public voidsetTreeViewer(org.eclipse.jface.viewers.TreeViewer treeViewer)

        mTreeViewer = treeViewer;