Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2019-06-19 14:35:38 -0400
committerMatthew Khouzam2019-07-04 15:03:16 -0400
commit1edbecf2c3f1c7ce25cdd392a8c7a65b09dac147 (patch)
treebd6a33c4b55e8366c737eba331a1d4381e1893bd
parent3f31d0c32c48433c49fe727dc4ff35e4f2293b08 (diff)
downloadorg.eclipse.tracecompass-1edbecf2c3f1c7ce25cdd392a8c7a65b09dac147.tar.gz
org.eclipse.tracecompass-1edbecf2c3f1c7ce25cdd392a8c7a65b09dac147.tar.xz
org.eclipse.tracecompass-1edbecf2c3f1c7ce25cdd392a8c7a65b09dac147.zip
tmf.ui: support multiple callsites menu option
Open a list of items if there are multiple callsites Change-Id: Ib13ae6bbc11626376281a3456d5726b32fe11da2 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/144394 Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: CI Bot
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/actions/OpenSourceCodeAction.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/actions/OpenSourceCodeAction.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/actions/OpenSourceCodeAction.java
index 4a316472ef..8210afab28 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/actions/OpenSourceCodeAction.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/actions/OpenSourceCodeAction.java
@@ -12,6 +12,8 @@ package org.eclipse.tracecompass.tmf.ui.actions;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
@@ -26,6 +28,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -53,7 +56,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
public class OpenSourceCodeAction extends Action {
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private final ITmfSourceLookup fSourceLookup;
+ private final ITmfCallsite fCallsite;
private final Shell fShell;
/**
@@ -69,27 +72,35 @@ public class OpenSourceCodeAction extends Action {
* @return an contribution item to open a callsite or null if invalid
*/
public static IContributionItem create(String actionText, ITmfSourceLookup sourceLookup, Shell shell) {
- ITmfCallsite cs = sourceLookup.getCallsite();
+ List<ITmfCallsite> cs = sourceLookup.getCallsites();
if (cs == null) {
return null;
}
- Long lineNo = cs.getLineNo();
- if (lineNo == null) {
+ List<ITmfCallsite> callsites = cs.stream().filter(callstack -> callstack.getLineNo() != null).collect(Collectors.toList());
+ if (callsites.isEmpty()) {
/* Not enough information to provide a full callsite */
return null;
}
- return new ActionContributionItem(new OpenSourceCodeAction(actionText, sourceLookup, shell));
+ if (callsites.size() == 1) {
+ return new ActionContributionItem(new OpenSourceCodeAction(actionText, callsites.get(0), shell));
+ }
+
+ MenuManager mgr = new MenuManager(actionText);
+ for (ITmfCallsite callsite : callsites) {
+ mgr.add(new OpenSourceCodeAction(callsite.toString(), callsite, shell));
+ }
+ return mgr;
}
- private OpenSourceCodeAction(String text, ITmfSourceLookup sourceLookup, Shell shell) {
+ private OpenSourceCodeAction(String text, ITmfCallsite callsite, Shell shell) {
super(text);
- fSourceLookup = sourceLookup;
+ fCallsite = callsite;
fShell = shell;
}
@Override
public void run() {
- ITmfCallsite cs = fSourceLookup.getCallsite();
+ ITmfCallsite cs = fCallsite;
if (cs == null) {
return;
}

Back to the top