Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-03-25 20:47:30 +0000
committerAndrew Ferrazzutti2014-04-24 20:16:43 +0000
commit8bafa137f246e165c600310b587be2b4363cb705 (patch)
tree46691fa5788ff2b1a71ba5f09e076ebf0346122c /systemtap
parent3a727a995c3205650af794fb0c141893e8e4cefd (diff)
downloadorg.eclipse.linuxtools-8bafa137f246e165c600310b587be2b4363cb705.tar.gz
org.eclipse.linuxtools-8bafa137f246e165c600310b587be2b4363cb705.tar.xz
org.eclipse.linuxtools-8bafa137f246e165c600310b587be2b4363cb705.zip
Systemtap: Improve function/C probe addition.
-Make general improvements to the way functions and probes are added to scripts with their respective views. -Migrate plugin implementation of inline-probing C files from Actions to Commands. -When inline-probing C files, ask user for the .stp script to add the probe to. Change-Id: Ice5fc1945eeb7edbe579a2fc05b20f4f0da7176e Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/23946 Tested-by: Hudson CI
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java20
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java5
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties7
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml45
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDESessionSettings.java142
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/AddStapProbe.java158
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/BrowserViewAction.java4
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/FunctionBrowserAction.java37
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/KernelSourceAction.java31
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ProbeAliasAction.java123
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/AddStapProbeHandler.java131
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/Messages.java31
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/messages.properties15
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties15
15 files changed, 377 insertions, 391 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java
index ae08f95f52..ae55177f6f 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/SimpleEditor.java
@@ -79,9 +79,9 @@ public class SimpleEditor extends TextEditor {
IRegion reg = finder.find(0, search, true, !regExSearch, false, regExSearch);
int offset = reg.getOffset();
line = doc.getLineOfOffset(offset);
- } catch(BadLocationException ble) {
+ } catch (BadLocationException ble) {
// Pass
- } catch(NullPointerException npe) {
+ } catch (NullPointerException npe) {
line = -1;
}
@@ -99,7 +99,7 @@ public class SimpleEditor extends TextEditor {
try {
int offset = doc.getLineOffset(line-1) + character;
this.getSelectionProvider().setSelection(new TextSelection(doc, offset, 0));
- } catch(BadLocationException boe) {
+ } catch (BadLocationException boe) {
// Pass
}
}
@@ -113,7 +113,7 @@ public class SimpleEditor extends TextEditor {
try {
this.getSelectionProvider().setSelection(new TextSelection(doc, doc.getLineOffset(line-1), doc.getLineLength(line-1)-1));
- } catch(BadLocationException boe) {
+ } catch (BadLocationException boe) {
// Pass
}
}
@@ -124,7 +124,7 @@ public class SimpleEditor extends TextEditor {
@Override
public void doSaveAs() {
File file = queryFile();
- if(file == null) {
+ if (file == null) {
return;
}
@@ -137,7 +137,7 @@ public class SimpleEditor extends TextEditor {
PrintStream ps = new PrintStream(fos)){
ps.print(s);
ps.close();
- } catch(IOException fnfe) {
+ } catch (IOException fnfe) {
// Pass
}
@@ -166,7 +166,7 @@ public class SimpleEditor extends TextEditor {
int offset = s.length();
s += text;
doc.set(s);
- this.setHighlightRange(offset,0,true);
+ this.setHighlightRange(offset, 0, true);
}
/**
@@ -177,13 +177,13 @@ public class SimpleEditor extends TextEditor {
ISelection selection = this.getSelectionProvider().getSelection();
IDocument doc = getSourceViewer().getDocument();
- if(selection instanceof ITextSelection) {
+ if (selection instanceof ITextSelection) {
ITextSelection s = (ITextSelection) selection;
- StringBuffer sb = new StringBuffer(doc.get().substring(0,s.getOffset()));
+ StringBuffer sb = new StringBuffer(doc.get().substring(0, s.getOffset()));
sb.append(text.trim());
sb.append(doc.get().substring(s.getOffset() + s.getLength(), doc.get().length()));
doc.set(sb.toString());
- this.setHighlightRange(s.getOffset() + text.trim().length(),0,true);
+ this.setHighlightRange(s.getOffset() + text.trim().length(), 0, true);
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java
index 53b46f0960..f1b91706c9 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/src/org/eclipse/linuxtools/systemtap/ui/editor/actions/file/OpenFileAction.java
@@ -120,10 +120,10 @@ public class OpenFileAction extends Action implements IWorkbenchWindowActionDele
* @return the File object associated to the selected file.
*/
protected File queryFile() {
- FileDialog dialog= new FileDialog(window.getShell(), SWT.OPEN);
+ FileDialog dialog = new FileDialog(window.getShell(), dialogStyle());
dialog.setFilterExtensions(new String[]{"*.stp"}); //$NON-NLS-1$
dialog.setText(dialogName());
- String path= dialog.open();
+ String path = dialog.open();
if (path != null && path.length() > 0) {
return new File(path);
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
index d9477b171a..10fb24e143 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
@@ -480,8 +480,9 @@ public class TestCreateSystemtapScript {
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Untitled Text File"));
bot.button("Finish").click();
+ String probeDialogTitle = "Select Script";
items[1].doubleClick();
- shell = bot.shell("Add Probe To Script");
+ shell = bot.shell(probeDialogTitle);
shell.setFocus();
bot.button("Yes").click();
bot.waitUntil(Conditions.shellCloses(shell));
@@ -508,7 +509,7 @@ public class TestCreateSystemtapScript {
editor = bot.editorByTitle("Untitled 1").toTextEditor();
editor.show();
items[3].doubleClick();
- shell = bot.shell("Add Probe To Script");
+ shell = bot.shell(probeDialogTitle);
shell.setFocus();
SWTBotTable table = bot.table();
assertTrue(table.containsItem(scriptName));
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
index 6591d89b81..d4905469a1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
@@ -45,6 +45,8 @@ category.data.name=Data
category.data.desc=Graph data management
category.tapset.name=Tapset
category.tapset.desc=Tapset content actions
+category.cfiles.name=C Actions
+category.cfiles.desc=Actions applied to C/C++ files
toolbar.actions.name=SystemTap Actions
@@ -78,8 +80,6 @@ action.dataImport.desc=Import previously-saved graph contents
category.name=SystemTap
wizard.name=SystemTap Script
-action.addStapProbe.label = Add SystemTap probe
-
command.runChart.name=Run w/C&hart
command.runChart.desc=Run the Script w/Chart
command.toggleComment.name=Toggle Comment
@@ -88,6 +88,9 @@ command.toggleComment.mne=Tog&gle Comment
command.indent.name=Correct Indentation
command.indent.desc=Correct Indentation of SystemTap File Lines
command.indent.mne=Correct &Indentation
+command.addStapProbe.name=Add SystemTap Probe
+command.addStapProbe.desc=Probe the current C file at the designated line.
+command.addStapProbe.mne=Add SystemTap &Probe
editor.context.name=SystemTap Editor
editor.context.desc=Editor for SystemTap Scripts
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
index ebada20893..133dee4fd2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
@@ -152,9 +152,9 @@
<menuContribution
allPopups="true"
- locationURI="popup:org.eclipse.ui.popup.any">
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
- commandId="org.eclipse.linuxtools.systemtap.ui.ide.handlers.definitionMenu"
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.definitionMenu"
style="push">
<visibleWhen>
<with
@@ -171,6 +171,16 @@
</visibleWhen>
</command>
</menuContribution>
+
+ <menuContribution
+ locationURI="popup:#CEditorRulerContext?after=additions">
+ <command
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.addStapProbe"
+ label="%command.addStapProbe.name"
+ mnemonic="%command.addStapProbe.mne"
+ style="push">
+ </command>
+ </menuContribution>
</extension>
<extension
@@ -333,7 +343,20 @@
name="%action.viewDefinition.name"
description="%action.viewDefinition.desc"
categoryId="org.eclipse.linuxtools.systemtap.ui.ide.category.tapset"
- id="org.eclipse.linuxtools.systemtap.ui.ide.handlers.definitionMenu">
+ id="org.eclipse.linuxtools.systemtap.ui.ide.definitionMenu">
+ </command>
+
+ <category
+ name="%category.cfiles.name"
+ description="%category.cfiles.desc"
+ id="org.eclipse.linuxtools.systemtap.ui.ide.category.cfiles">
+ </category>
+ <command
+ name="%command.addStapProbe.name"
+ description="%command.addStapProbe.desc"
+ categoryId="org.eclipse.linuxtools.systemtap.ui.ide.category.cfiles"
+ id="org.eclipse.linuxtools.systemtap.ui.ide.addStapProbe"
+ defaultHandler="org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.AddStapProbeHandler">
</command>
</extension>
@@ -341,7 +364,7 @@
point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.DefinitionHandler"
- commandId="org.eclipse.linuxtools.systemtap.ui.ide.handlers.definitionMenu">
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.definitionMenu">
<enabledWhen>
<with
variable="activeMenuSelection">
@@ -370,20 +393,6 @@
</extension>
<extension
- point="org.eclipse.ui.popupMenus">
- <viewerContribution
- targetID="#CEditorRulerContext"
- id="org.eclipse.linuxtools.systemtap.ui.ide.actions">
- <action
- label="%action.addStapProbe.label"
- class="org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.AddStapProbe"
- menubarPath="additions"
- id="org.eclipse.linuxtools.systemtap.ui.ide.AddStapProbe">
- </action>
- </viewerContribution>
- </extension>
-
- <extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.linuxtools.systemtap.ui.ide.IDEPerspective">
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDESessionSettings.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDESessionSettings.java
index 5b5fe8bbd0..6c790f19b2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDESessionSettings.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/IDESessionSettings.java
@@ -11,14 +11,26 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
+import org.eclipse.linuxtools.systemtap.ui.editor.actions.file.NewFileAction;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ListDialog;
/**
* A simple class that contains information about the current session of the IDE, such as
- * the path to the tapset libraries, the active SystemTap Script Editor, and if the user
- * chooses, the user's account password.
+ * the path to the tapset libraries, and the active SystemTap Script Editor.
* @author Ryan Morse
*/
public class IDESessionSettings {
@@ -38,20 +50,21 @@ public class IDESessionSettings {
* @since 1.2
*/
public static STPEditor getActiveSTPEditor() {
- if (activeSTPEditor == null){
- // If the active editor is not set and there is only one
- // stap script editor open set that to be the active editor.
+ if (activeSTPEditor == null) {
+ // If no active editor is et and there is only one
+ // opened stap script editor, set it to be the active editor.
IEditorReference[] editors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
- int count = 0;
- for(IEditorReference editor: editors){
- if (editor.getId().equals(STPEditor.ID)){
- activeSTPEditor = (STPEditor) editor.getEditor(true);
- count++;
+ STPEditor stpEditor = null;
+ for (IEditorReference editor: editors) {
+ if (editor.getId().equals(STPEditor.ID)) {
+ if (stpEditor == null) {
+ stpEditor = (STPEditor) editor.getEditor(true);
+ } else {
+ return null;
+ }
}
}
- if (count > 1){
- activeSTPEditor = null;
- }
+ activeSTPEditor = stpEditor;
}
return activeSTPEditor;
}
@@ -61,7 +74,108 @@ public class IDESessionSettings {
* @param editor the active editor.
* @since 1.2
*/
- public static void setActiveSTPEditor (STPEditor editor){
+ public static void setActiveSTPEditor(STPEditor editor) {
activeSTPEditor = editor;
}
+
+ /**
+ * Restore and return an STPEditor based on the user's choice.
+ * @param checkCurrent Set to <code>true</code> if the currently active editor may be returned
+ * if it is an {@link STPEditor}.
+ * @return
+ */
+ public static STPEditor getOrAskForActiveSTPEditor(boolean checkCurrent) {
+ STPEditor stpEditor;
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ if (checkCurrent) {
+ IEditorPart editor = page.getActiveEditor();
+ stpEditor = editor instanceof STPEditor ? (STPEditor) editor : askForSTPEditor(window);
+ } else {
+ stpEditor = askForSTPEditor(window);
+ }
+ if (stpEditor != null) {
+ page.activate(stpEditor);
+ }
+ return stpEditor;
+ }
+
+ private static STPEditor askForSTPEditor(IWorkbenchWindow window) {
+ final List<STPEditor> allEditors = new LinkedList<>();
+ for (IEditorReference editor : window.getActivePage().getEditorReferences()) {
+ if (editor.getId().equals(STPEditor.ID)) {
+ allEditors.add((STPEditor) editor.getEditor(true));
+ }
+ }
+
+ switch (allEditors.size()) {
+ // If only one file is found, open it. Give user the option to open another file.
+ case 1:
+ MessageDialog messageDialog = new MessageDialog(window.getShell(),
+ Localization.getString("GetEditorAction.DialogTitle"), null, //$NON-NLS-1$
+ MessageFormat.format(Localization.getString("GetEditorAction.AskBeforeOpenMessage"), //$NON-NLS-1$
+ allEditors.get(0).getEditorInput().getName() ),
+ MessageDialog.QUESTION,
+ new String[]{Localization.getString("GetEditorAction.AskBeforeOpenCancel"), //$NON-NLS-1$
+ Localization.getString("GetEditorAction.AskBeforeOpenAnother"), //$NON-NLS-1$
+ Localization.getString("GetEditorAction.AskBeforeOpenYes")}, 2); //$NON-NLS-1$
+
+ switch (messageDialog.open()) {
+ case 2:
+ return allEditors.get(0);
+
+ case 1:
+ return openNewFile(window);
+
+ default:
+ return null;
+ }
+
+ // If no files found, prompt user to open a new file
+ case 0:
+ return openNewFile(window);
+
+ // If multiple files found, prompt user to select one of them
+ default:
+ return openNewFileFromMultiple(window, allEditors);
+ }
+ }
+
+ private static STPEditor openNewFileFromMultiple(IWorkbenchWindow window, final List<STPEditor> allEditors) {
+ ListDialog listDialog = new ListDialog(window.getShell());
+ listDialog.setTitle(Localization.getString("GetEditorAction.DialogTitle")); //$NON-NLS-1$
+ listDialog.setContentProvider(new ArrayContentProvider());
+
+ listDialog.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ int i = (Integer) element;
+ return i != -1 ? allEditors.get(i).getEditorInput().getName()
+ : Localization.getString("GetEditorAction.OtherFile"); //$NON-NLS-1$
+ }
+ });
+
+ Integer[] editorIndexes = new Integer[allEditors.size() + 1];
+ for (int i = 0; i < editorIndexes.length - 1; i++) {
+ editorIndexes[i] = i;
+ }
+ editorIndexes[editorIndexes.length - 1] = -1;
+ listDialog.setInput(editorIndexes);
+ listDialog.setMessage(Localization.getString("GetEditorAction.SelectEditor")); //$NON-NLS-1$
+ if (listDialog.open() == Window.OK) {
+ int result = (Integer) listDialog.getResult()[0];
+ return result != -1 ? allEditors.get(result) : openNewFile(window);
+ }
+ // Abort if user cancels
+ return null;
+ }
+
+ private static STPEditor openNewFile(IWorkbenchWindow window) {
+ NewFileAction action = new NewFileAction();
+ action.run();
+ if (action.isSuccessful()) {
+ return (STPEditor) window.getActivePage().getActiveEditor();
+ }
+ return null;
+ }
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/AddStapProbe.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/AddStapProbe.java
deleted file mode 100644
index 47f43890ce..0000000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/AddStapProbe.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Red Hat Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat Inc. - Initial API and implementation.
- *******************************************************************************/
-package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDESessionSettings;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
-import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
-import org.eclipse.linuxtools.systemtap.ui.editor.actions.file.NewFileAction;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.FileStoreEditorInput;
-import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class AddStapProbe extends AbstractRulerActionDelegate {
-
- @Override
- protected IAction createAction(final ITextEditor editor,
- final IVerticalRulerInfo rulerInfo) {
- return new Action() {
-
- @Override
- public void runWithEvent(Event event) {
- Shell shell = editor.getSite().getShell();
- shell.setCursor(shell.getDisplay().getSystemCursor(
- SWT.CURSOR_WAIT));
- int lineno = rulerInfo.getLineOfLastMouseButtonActivity();
- IDocument document = editor.getDocumentProvider().getDocument(
- editor.getEditorInput());
-
- String s = document.get();
- String[] lines = s.split("\n"); //$NON-NLS-1$
- String line = lines[lineno].trim();
- boolean die = false;
- if (line.isEmpty()) {//eat blank lines
- die = true;
- }
- if (line.startsWith("#")) {//eat preprocessor directives //$NON-NLS-1$
- die = true;
- }
- if (line.startsWith("//")) {//eat C99 comments //$NON-NLS-1$
- die = true;
- }
- if (line.startsWith("/*") && !line.contains("*/") && !line.endsWith("*/")) {//try to eat single-line C comments //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- die = true;
- }
-
- // gogo find comment segments
- try {
- ArrayList<Integer> commentChunks = new ArrayList<>();
- char[] chars = s.toCharArray();
- int needle = 1;
- int offset = document.getLineOffset(lineno);
- while (needle < chars.length) {
- if (chars[needle - 1] == '/' && chars[needle] == '*') {
- commentChunks.add(needle);
- while (needle < chars.length) {
- if (chars[needle - 1] == '*'
- && chars[needle] == '/') {
- commentChunks.add(needle);
- needle++;
- break;
- }
- needle++;
- }
- }
- needle++;
- }
- for (int i = 0, pair, start, end; i < commentChunks.size(); i++) {
- if (!(commentChunks.get(i).intValue() < offset)) {
- pair = i - i % 2;
- start = commentChunks.get(pair).intValue();
- end = commentChunks.get(pair + 1).intValue();
- if (offset >= start && offset <= end) {
- die = true;
- }
- }
- }
- } catch (BadLocationException excp) {
- ExceptionErrorDialog.openError(Localization.getString("AddStapProbe.UnableToInsertProbe"), excp); //$NON-NLS-1$
- }
- if (die) {
- MessageDialog
- .openError(
- PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getShell(),
- Localization
- .getString("CEditor.ProbeInsertFailed"), Localization.getString("CEditor.CanNotProbeLine")); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- IEditorInput in = editor.getEditorInput();
- if (in instanceof FileStoreEditorInput) {
- FileStoreEditorInput input = (FileStoreEditorInput) in;
-
- IPreferenceStore p = IDEPlugin.getDefault()
- .getPreferenceStore();
- String kernroot = p
- .getString(IDEPreferenceConstants.P_KERNEL_SOURCE);
-
- String filepath = input.getURI().getPath();
- String kernrelative = filepath.substring(
- kernroot.length() + 1, filepath.length());
- StringBuffer sb = new StringBuffer();
-
- sb.append("probe kernel.statement(\"*@" + kernrelative + ":" + (lineno + 1) + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- sb.append("\n{\n\t\n}\n"); //$NON-NLS-1$
- STPEditor activeSTPEditor = IDESessionSettings
- .getActiveSTPEditor();
- if (null == activeSTPEditor) {
- NewFileAction action = new NewFileAction();
- action.run();
- IEditorPart ed = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage()
- .getActiveEditor();
- if (ed instanceof STPEditor) {
- IDESessionSettings
- .setActiveSTPEditor((STPEditor) ed);
- }
- }
-
- if (null != activeSTPEditor) {
- activeSTPEditor.insertText(sb.toString());
- }
- }
- }
- shell.setCursor(null); // Return the cursor to normal
-
- }
-
- };
- }
-
-}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/BrowserViewAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/BrowserViewAction.java
index 098f110d9b..aba71c915c 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/BrowserViewAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/BrowserViewAction.java
@@ -67,10 +67,6 @@ public abstract class BrowserViewAction extends Action implements ISelectionList
run();
}
- protected IWorkbenchWindow getWindow() {
- return window;
- }
-
protected Object getSelectedElement() {
return ((IStructuredSelection) viewer.getViewer().getSelection()).getFirstElement();
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/FunctionBrowserAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/FunctionBrowserAction.java
index 256b91dcf5..ceeec32046 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/FunctionBrowserAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/FunctionBrowserAction.java
@@ -11,17 +11,12 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDESessionSettings;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.views.FunctionBrowserView;
-import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
-import org.eclipse.linuxtools.systemtap.ui.editor.actions.file.NewFileAction;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
@@ -59,35 +54,13 @@ public class FunctionBrowserAction extends BrowserViewAction {
*/
@Override
public void run() {
- IWorkbenchPage page = getWindow().getActivePage();
Object o = getSelectedElement();
if (o instanceof TreeNode) {
TreeNode t = (TreeNode) o;
- if(t.isClickable()) {
- IEditorInput input;
- IEditorPart ed = page.getActiveEditor();
- if(ed == null) {
- NewFileAction action = new NewFileAction();
- action.run();
- if (action.isSuccessful())
- ed = page.getWorkbenchWindow().getActivePage().getActiveEditor();
- else
- return;
- }
- input = ed.getEditorInput();
- IEditorPart editor;
- try {
- editor = page.openEditor(input, STPEditor.ID);
-
- if(editor instanceof STPEditor) {
- STPEditor stpeditor = (STPEditor)editor;
- //build the string
- String s = t.toString() + "\n"; //$NON-NLS-1$
- stpeditor.insertTextAtCurrent(s);
-
- }
- } catch (PartInitException e) {
- ExceptionErrorDialog.openError(Localization.getString("FunctionBrowserAction.UnableToInsertFunction"), e); //$NON-NLS-1$
+ if (t.isClickable()) {
+ STPEditor stpeditor = IDESessionSettings.getOrAskForActiveSTPEditor(true);
+ if (stpeditor != null) {
+ stpeditor.insertTextAtCurrent(t.toString() + "\n"); //$NON-NLS-1$
}
} else {
runExpandAction();
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/KernelSourceAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/KernelSourceAction.java
index 144ea758d9..6256a016c4 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/KernelSourceAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/KernelSourceAction.java
@@ -12,14 +12,11 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions;
import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDESessionSettings;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.views.KernelBrowserView;
import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
@@ -57,16 +54,6 @@ public class KernelSourceAction extends BrowserViewAction {
}
/**
- * Creates a <code>PathEditorInput</code> for the file specified.
- * @param file The <code>File</code> to create an input for.
- * @return A <code>PathEditorInput</code> that represents the requested file.
- */
- private IEditorInput createEditorInput(IFileStore fs) {
- FileStoreEditorInput input= new FileStoreEditorInput(fs);
- return input;
- }
-
- /**
* The main code body for this action. Causes one of the following to occur:
* <ul>
* <li>If the selected node is clickable, as specified in <code>TreeNode.isClickable</code>
@@ -83,25 +70,19 @@ public class KernelSourceAction extends BrowserViewAction {
public void run() {
IWorkbench wb = PlatformUI.getWorkbench();
Object o = getSelectedElement();
- if(o instanceof TreeNode) {
- TreeNode t = (TreeNode)o;
- if(t.isClickable()) {
-
- IFileStore fs = (IFileStore)t.getData();
+ if (o instanceof TreeNode) {
+ TreeNode t = (TreeNode) o;
+ if (t.isClickable()) {
+ IFileStore fs = (IFileStore) t.getData();
if (fs != null) {
- IEditorInput input= createEditorInput(fs);
+ IEditorInput input = new FileStoreEditorInput(fs);
try {
- IEditorPart editor = wb.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(editor instanceof STPEditor)
- IDESessionSettings.setActiveSTPEditor((STPEditor)editor);
wb.getActiveWorkbenchWindow().getActivePage().openEditor(input, CDT_EDITOR_ID);
} catch (PartInitException e) {
ExceptionErrorDialog.openError(Messages.ScriptRunAction_errorDialogTitle, e);
}
-
}
- }
- else {
+ } else {
runExpandAction();
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ProbeAliasAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ProbeAliasAction.java
index 6b8489893f..7de9559ac3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ProbeAliasAction.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ProbeAliasAction.java
@@ -11,27 +11,14 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions;
-import java.text.MessageFormat;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDESessionSettings;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ProbeNodeData;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.ProbevarNodeData;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.views.ProbeAliasBrowserView;
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
-import org.eclipse.linuxtools.systemtap.ui.editor.actions.file.NewFileAction;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.dialogs.ListDialog;
@@ -64,27 +51,21 @@ public class ProbeAliasAction extends BrowserViewAction {
*/
@Override
public void run() {
- IWorkbenchPage page = getWindow().getActivePage();
Object o = getSelectedElement();
if (o instanceof TreeNode) {
TreeNode t = (TreeNode) o;
if (t.isClickable()) {
- IEditorPart editor = page.getActiveEditor();
- if (!(editor instanceof STPEditor)) {
- editor = findEditor();
- if (null == editor) {
- return;
- }
+ STPEditor stpeditor = IDESessionSettings.getOrAskForActiveSTPEditor(true);
+ if (stpeditor != null) {
+ stpeditor.insertText(buildString((TreeNode) o));
}
- page.activate(editor);
- buildString((STPEditor) editor, (TreeNode) o);
} else {
runExpandAction();
}
}
}
- private void buildString(STPEditor stpeditor, TreeNode t) {
+ private String buildString(TreeNode t) {
//build the string
StringBuilder s = new StringBuilder("\nprobe " + t.toString()); //$NON-NLS-1$
if (t.getChildCount() > 0 && t.getChildAt(0).getData() instanceof ProbeNodeData) {
@@ -108,99 +89,7 @@ public class ProbeAliasAction extends BrowserViewAction {
s.append("\n\t */\n"); //$NON-NLS-1$
}
s.append("\n}\n"); //$NON-NLS-1$
- stpeditor.insertText(s.toString());
- }
-
- private IEditorPart getRestoredEditor(final IEditorReference ref) {
- if (ref.getEditor(false) == null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ref.getEditor(true);
- }
- });
- }
- return ref.getEditor(false);
- }
-
- private STPEditor findEditor() {
- final List<STPEditor> allEditors = new LinkedList<>();
- for (IEditorReference ref : getWindow().getActivePage().getEditorReferences()) {
- IEditorPart editor = getRestoredEditor(ref);
- if (editor instanceof STPEditor) {
- allEditors.add((STPEditor) editor);
- }
- }
-
- switch (allEditors.size()) {
- // If only one file is found, open it. Give user the option to open another file.
- case 1:
- MessageDialog messageDialog = new MessageDialog(getWindow().getShell(),
- Localization.getString("ProbeAliasAction.DialogTitle"), null, //$NON-NLS-1$
- MessageFormat.format(Localization.getString("ProbeAliasAction.AskBeforeAddMessage"), //$NON-NLS-1$
- allEditors.get(0).getEditorInput().getName() ),
- MessageDialog.QUESTION,
- new String[]{Localization.getString("ProbeAliasAction.AskBeforeAddCancel"), //$NON-NLS-1$
- Localization.getString("ProbeAliasAction.AskBeforeAddAnother"), //$NON-NLS-1$
- Localization.getString("ProbeAliasAction.AskBeforeAddYes")}, 2); //$NON-NLS-1$
-
- switch (messageDialog.open()) {
- case 2:
- return allEditors.get(0);
-
- case 1:
- return openNewFile();
-
- default:
- return null;
- }
-
- // If no files found, prompt user to open a new file
- case 0:
- return openNewFile();
-
- // If multiple files found, prompt user to select one of them
- default:
- return openNewFileFromMultiple(allEditors);
- }
- }
-
- private STPEditor openNewFileFromMultiple(final List<STPEditor> allEditors) {
- ListDialog listDialog = new ListDialog(getWindow().getShell());
- listDialog.setTitle(Localization.getString("ProbeAliasAction.DialogTitle")); //$NON-NLS-1$
- listDialog.setContentProvider(new ArrayContentProvider());
-
- listDialog.setLabelProvider(new LabelProvider() {
- @Override
- public String getText(Object element) {
- int i = (Integer) element;
- return i != -1 ? allEditors.get(i).getEditorInput().getName()
- : Localization.getString("ProbeAliasAction.OtherFile"); //$NON-NLS-1$
- }
- });
-
- Integer[] editorIndexes = new Integer[allEditors.size() + 1];
- for (int i = 0; i < editorIndexes.length - 1; i++) {
- editorIndexes[i] = i;
- }
- editorIndexes[editorIndexes.length - 1] = -1;
- listDialog.setInput(editorIndexes);
- listDialog.setMessage(Localization.getString("ProbeAliasAction.SelectEditor")); //$NON-NLS-1$
- if (listDialog.open() == Window.OK) {
- int result = (Integer) listDialog.getResult()[0];
- return result != -1 ? allEditors.get(result) : openNewFile();
- }
- // Abort if user cancels
- return null;
- }
-
- private STPEditor openNewFile() {
- NewFileAction action = new NewFileAction();
- action.run();
- if (action.isSuccessful()) {
- return (STPEditor) getWindow().getActivePage().getActiveEditor();
- }
- return null;
+ return s.toString();
}
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/AddStapProbeHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/AddStapProbeHandler.java
new file mode 100644
index 0000000000..d4af4ae9fd
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/AddStapProbeHandler.java
@@ -0,0 +1,131 @@
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDESessionSettings;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
+import org.eclipse.linuxtools.systemtap.graphing.ui.widgets.ExceptionErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class AddStapProbeHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ITextEditor editor;
+ try {
+ editor = (ITextEditor) HandlerUtil.getActiveEditor(event);
+ } catch (ClassCastException e) {
+ throw new ExecutionException(Messages.AddStapProbe_editorError, e);
+ }
+ IVerticalRulerInfo rulerInfo = (IVerticalRulerInfo) editor.getAdapter(IVerticalRulerInfo.class);
+
+ Shell shell = editor.getSite().getShell();
+ shell.setCursor(shell.getDisplay().getSystemCursor(
+ SWT.CURSOR_WAIT));
+ int lineno = rulerInfo.getLineOfLastMouseButtonActivity();
+ IDocument document = editor.getDocumentProvider().getDocument(
+ editor.getEditorInput());
+
+ String s = document.get();
+ String[] lines = s.split("\n"); //$NON-NLS-1$
+ String line = lines[lineno].trim();
+ boolean die = false;
+ if (line.isEmpty()) {//eat blank lines
+ die = true;
+ }
+ if (line.startsWith("#")) {//eat preprocessor directives //$NON-NLS-1$
+ die = true;
+ }
+ if (line.startsWith("//")) {//eat C99 comments //$NON-NLS-1$
+ die = true;
+ }
+ if (line.startsWith("/*") && !line.contains("*/") && !line.endsWith("*/")) {//try to eat single-line C comments //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ die = true;
+ }
+
+ // gogo find comment segments
+ try {
+ ArrayList<Integer> commentChunks = new ArrayList<>();
+ char[] chars = s.toCharArray();
+ int needle = 1;
+ int offset = document.getLineOffset(lineno);
+ while (needle < chars.length) {
+ if (chars[needle - 1] == '/' && chars[needle] == '*') {
+ commentChunks.add(needle);
+ while (needle < chars.length) {
+ if (chars[needle - 1] == '*'
+ && chars[needle] == '/') {
+ commentChunks.add(needle);
+ needle++;
+ break;
+ }
+ needle++;
+ }
+ }
+ needle++;
+ }
+ for (int i = 0, pair, start, end; i < commentChunks.size(); i++) {
+ if (!(commentChunks.get(i).intValue() < offset)) {
+ pair = i - i % 2;
+ start = commentChunks.get(pair).intValue();
+ end = commentChunks.get(pair + 1).intValue();
+ if (offset >= start && offset <= end) {
+ die = true;
+ }
+ }
+ }
+ } catch (BadLocationException excp) {
+ ExceptionErrorDialog.openError(Messages.AddStapProbe_unableToInsertProbe, excp);
+ }
+ if (die) {
+ MessageDialog
+ .openError(
+ PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(),
+ Messages.CEditor_probeInsertFailed, Messages.CEditor_canNotProbeLine);
+ } else {
+ IEditorInput in = editor.getEditorInput();
+ if (in instanceof FileStoreEditorInput) {
+ FileStoreEditorInput input = (FileStoreEditorInput) in;
+
+ IPreferenceStore p = IDEPlugin.getDefault()
+ .getPreferenceStore();
+ String kernroot = p
+ .getString(IDEPreferenceConstants.P_KERNEL_SOURCE);
+
+ String filepath = input.getURI().getPath();
+ String kernrelative = filepath.substring(
+ kernroot.length() + 1, filepath.length());
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("probe kernel.statement(\"*@" + kernrelative + ":" + (lineno + 1) + "\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ sb.append("\n{\n\t\n}\n"); //$NON-NLS-1$
+ STPEditor activeSTPEditor = IDESessionSettings.getOrAskForActiveSTPEditor(false);
+ if (null != activeSTPEditor) {
+ activeSTPEditor.insertText(sb.toString());
+ }
+ }
+ }
+ shell.setCursor(null); // Return the cursor to normal
+ return null;
+ }
+
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/Messages.java
new file mode 100644
index 0000000000..92c22977ec
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/Messages.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 2.0
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.messages"; //$NON-NLS-1$
+ public static String AddStapProbe_editorError;
+ public static String AddStapProbe_unableToInsertProbe;
+ public static String CEditor_probeInsertFailed;
+ public static String CEditor_canNotProbeLine;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/messages.properties
new file mode 100644
index 0000000000..76e97e6adc
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/handlers/messages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2012-2013 Red Hat, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Red Hat - initial API and implementation
+###############################################################################
+
+AddStapProbe_editorError=Invalid editor type for probe addition.
+AddStapProbe_unableToInsertProbe=Unable to Insert Probe
+CEditor_probeInsertFailed=Probe Insertion Failure
+CEditor_canNotProbeLine=Stap cannot insert a probe on this line of code. \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
index dab8258343..dcece1c435 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
@@ -15,18 +15,19 @@ KernelSourceAction.InsertSelectedFunction=Insert the Selected Function
ProbeAliasAction.Insert=&Insert
ProbeAliasAction.InsertSelectedProbe=Insert the Selected Probe
ProbeAliasAction.AvailableVariables=available variables on this probe:
-ProbeAliasAction.SelectEditor=Choose which script the selected probe will be added to.
-ProbeAliasAction.DialogTitle=Add Probe To Script
-ProbeAliasAction.AskBeforeAddMessage=The selected probe will be added to "{0}". Continue?
-ProbeAliasAction.AskBeforeAddYes=Yes
-ProbeAliasAction.AskBeforeAddCancel=Cancel
-ProbeAliasAction.AskBeforeAddAnother=Choose another file
-ProbeAliasAction.OtherFile=<Other File...>
FunctionBrowserAction.Insert=&Insert
FunctionBrowserAction.InsertFunction=Insert the Selected Function
FunctionBrowserAction.UnableToInsertFunction=Unable To Insert Function
+GetEditorAction.SelectEditor=Choose which script to open.
+GetEditorAction.DialogTitle=Select Script
+GetEditorAction.AskBeforeOpenMessage=Opening "{0}". Continue?
+GetEditorAction.AskBeforeOpenYes=Yes
+GetEditorAction.AskBeforeOpenCancel=Cancel
+GetEditorAction.AskBeforeOpenAnother=Choose another file
+GetEditorAction.OtherFile=<Other File...>
+
DefinitionHandler.FileIOErrorTitle=File Error
DefinitionHandler.FileIOErrorMessage=Unable to open definition file.

Back to the top