aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2013-11-15 09:27:48 (EST)
committerJeff Johnston2013-11-26 15:12:49 (EST)
commitfa6613e3b0bd4f8039b10ba9eaf9bfc329c9df1d (patch)
treefd9cc445923ddf584fb75dbba0f3e4811645460b
parent96ac93c89a32bc653c3683a1b651fa37213bdefc (diff)
downloadorg.eclipse.linuxtools-fa6613e3b0bd4f8039b10ba9eaf9bfc329c9df1d.zip
org.eclipse.linuxtools-fa6613e3b0bd4f8039b10ba9eaf9bfc329c9df1d.tar.gz
org.eclipse.linuxtools-fa6613e3b0bd4f8039b10ba9eaf9bfc329c9df1d.tar.bz2
Systemtap: autosave scripts before run.refs/changes/01/18901/2
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/18901 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-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 0d625ab..20532da 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 d6d391e..c630cc1 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 2899a8a..3915d68 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 {