Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2013-11-15 14:27:48 +0000
committerAndrew Ferrazzutti2013-11-28 14:51:11 +0000
commit154026ee2a278c8491d6b78a017182426192f15f (patch)
treee890f116e9d46971e72d3f0ba09324124d6b335f
parent43e1ab2fac42f029638f935cf9f0399759d2749b (diff)
downloadorg.eclipse.linuxtools-154026ee2a278c8491d6b78a017182426192f15f.tar.gz
org.eclipse.linuxtools-154026ee2a278c8491d6b78a017182426192f15f.tar.xz
org.eclipse.linuxtools-154026ee2a278c8491d6b78a017182426192f15f.zip
Systemtap: autosave scripts before run.
Also allow the "Run As->Systemtap" option appear in the script editor's context menu while it contains a .stp file from outside the workspace. Change-Id: Iaf03d298c5f9567d855c80d00a8fbae17e504970 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/19012 Tested-by: Hudson CI
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.editor/META-INF/MANIFEST.MF3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml17
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java36
3 files changed, 41 insertions, 15 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/META-INF/MANIFEST.MF
index 0d625ab20c..20532daed7 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/META-INF/MANIFEST.MF
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.editor/META-INF/MANIFEST.MF
@@ -15,4 +15,5 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.eclipse.ui.ide
+Import-Package: org.eclipse.core.filesystem.provider,
+ org.eclipse.ui.ide
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
index d6d391e9d1..c630cc1ac2 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
@@ -327,17 +327,12 @@
value="*.stp">
</test>
</and>
- <and>
- <instanceof
- value="org.eclipse.ui.IFileEditorInput">
- </instanceof>
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor">
- </equals>
- </with>
- </and>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPEditor">
+ </equals>
+ </with>
</or>
</iterate>
</with>
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
index 2899a8a2b9..3915d68b81 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptLaunchConfigurationDelegate.java
@@ -14,12 +14,16 @@ package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher;
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.RunScriptChartHandler;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.RunScriptHandler;
@@ -30,11 +34,37 @@ import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.GraphData;
import org.eclipse.linuxtools.systemtap.ui.consolelog.internal.ConsoleLogPlugin;
import org.eclipse.linuxtools.systemtap.ui.consolelog.preferences.ConsoleLogPreferenceConstants;
-public class SystemTapScriptLaunchConfigurationDelegate implements
- ILaunchConfigurationDelegate {
+public class SystemTapScriptLaunchConfigurationDelegate extends
+ LaunchConfigurationDelegate {
static final String CONFIGURATION_TYPE = "org.eclipse.linuxtools.systemtap.ui.ide.SystemTapLaunchConfigurationType"; //$NON-NLS-1$
+ private IProject[] scriptProject = new IProject[1];
+
+ /**
+ * Keep a reference to the target running script's parent project, so only that project
+ * will be saved when the script is run.
+ */
+ @Override
+ protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) {
+ return scriptProject;
+ }
+
+ @Override
+ public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ // Find the parent project of the target script.
+ IPath path = Path.fromOSString(configuration.getAttribute(SystemTapScriptLaunchConfigurationTab.SCRIPT_PATH_ATTR, (String)null));
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ IProject project = file == null ? null : file.getProject();
+
+ // Only save the target script's project if a project is found.
+ if (project != null) {
+ scriptProject[0] = project;
+ return super.preLaunchCheck(configuration, mode, monitor);
+ }
+ return true;
+ }
+
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {

Back to the top