diff options
author | Xavier Ducrohet <xav@android.com> | 2011-02-01 19:47:41 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-02-01 21:44:00 -0800 |
commit | 0aea2e8d8ebd3b014322c3031893c4f9179be584 (patch) | |
tree | 8b8b246b95d79df2da45202e84605b05b806d3cc /traceview/src | |
parent | c8596f7a4719c2f6aac3e0aec86676da0cd6bbaa (diff) | |
download | sdk-0aea2e8d8ebd3b014322c3031893c4f9179be584.zip sdk-0aea2e8d8ebd3b014322c3031893c4f9179be584.tar.gz sdk-0aea2e8d8ebd3b014322c3031893c4f9179be584.tar.bz2 |
Add support for CTRL+click on the method in Traceview.
This will open the method declaration in an editor.
Change-Id: I79e160bf565ac563e423132e010b7e51ab531673
Diffstat (limited to 'traceview/src')
-rw-r--r-- | traceview/src/com/android/traceview/MethodData.java | 24 | ||||
-rw-r--r-- | traceview/src/com/android/traceview/ProfileView.java | 21 |
2 files changed, 31 insertions, 14 deletions
diff --git a/traceview/src/com/android/traceview/MethodData.java b/traceview/src/com/android/traceview/MethodData.java index 0bc9853..d54b72b 100644 --- a/traceview/src/com/android/traceview/MethodData.java +++ b/traceview/src/com/android/traceview/MethodData.java @@ -46,10 +46,10 @@ public class MethodData { private Image mFadedImage; private HashMap<Integer, ProfileData> mParents; private HashMap<Integer, ProfileData> mChildren; - + // The parents of this method when this method was in a recursive call private HashMap<Integer, ProfileData> mRecursiveParents; - + // The children of this method when this method was in a recursive call private HashMap<Integer, ProfileData> mRecursiveChildren; @@ -150,7 +150,7 @@ public class MethodData { mParents); } } - + private HashMap<Integer, ProfileData> updateInclusive(long time, MethodData contextMethod, MethodData elementMethod, boolean elementIsParent, HashMap<Integer, ProfileData> map) { @@ -178,15 +178,15 @@ public class MethodData { ProfileData[] sortedChildren; ProfileData[] sortedRecursiveParents; ProfileData[] sortedRecursiveChildren; - + sortedParents = sortProfileData(mParents); sortedChildren = sortProfileData(mChildren); sortedRecursiveParents = sortProfileData(mRecursiveParents); sortedRecursiveChildren = sortProfileData(mRecursiveChildren); - + // Add "self" time to the top of the sorted children sortedChildren = addSelf(sortedChildren); - + // Create the ProfileNode objects that we need ArrayList<ProfileNode> nodes = new ArrayList<ProfileNode>(); ProfileNode profileNode; @@ -212,7 +212,7 @@ public class MethodData { } mProfileNodes = nodes.toArray(new ProfileNode[nodes.size()]); } - + // Create and return a ProfileData[] array that is a sorted copy // of the given HashMap values. private ProfileData[] sortProfileData(HashMap<Integer, ProfileData> map) { @@ -222,12 +222,12 @@ public class MethodData { // Convert the hash values to an array of ProfileData Collection<ProfileData> values = map.values(); ProfileData[] sorted = values.toArray(new ProfileData[values.size()]); - + // Sort the array by elapsed inclusive time Arrays.sort(sorted, mByElapsedInclusive); return sorted; } - + private ProfileData[] addSelf(ProfileData[] children) { ProfileData[] pdata; if (children == null) { @@ -283,12 +283,16 @@ public class MethodData { return mProfileName; } + public String getSignature() { + return mSignature; + } + public void computeProfileName() { if (mRank == -1) { mProfileName = mName; return; } - + StringBuilder sb = new StringBuilder(); sb.append(mRank); sb.append(" "); //$NON-NLS-1$ diff --git a/traceview/src/com/android/traceview/ProfileView.java b/traceview/src/com/android/traceview/ProfileView.java index 71dedfd..506efca 100644 --- a/traceview/src/com/android/traceview/ProfileView.java +++ b/traceview/src/com/android/traceview/ProfileView.java @@ -16,10 +16,6 @@ package com.android.traceview; -import java.util.ArrayList; -import java.util.Observable; -import java.util.Observer; - import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; @@ -48,6 +44,10 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; +import java.util.ArrayList; +import java.util.Observable; +import java.util.Observer; + public class ProfileView extends Composite implements Observer { private TreeViewer mTreeViewer; @@ -57,6 +57,11 @@ public class ProfileView extends Composite implements Observer { private Color mColorNoMatch; private Color mColorMatch; private MethodData mCurrentHighlightedMethod; + private MethodHandler mMethodHandler; + + public interface MethodHandler { + void handleMethod(MethodData method); + } public ProfileView(Composite parent, TraceReader reader, SelectionController selectController) { @@ -224,10 +229,18 @@ public class ProfileView extends Composite implements Observer { ArrayList<Selection> selections = new ArrayList<Selection>(); selections.add(Selection.highlight("MethodData", md)); mSelectionController.change(selections, "ProfileView"); + + if (mMethodHandler != null && (event.stateMask & SWT.MOD1) != 0) { + mMethodHandler.handleMethod(md); + } } }); } + public void setMethodHandler(MethodHandler handler) { + mMethodHandler = handler; + } + private void findName(String query) { MethodData md = mProfileProvider.findMatchingName(query); selectMethod(md); |