Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hutchinson <m.j.hutchinson@gmail.com>2015-01-12 22:11:22 +0300
committerMichael Hutchinson <m.j.hutchinson@gmail.com>2015-01-12 22:11:22 +0300
commit8cdf2e2bd61e6788fdb93d82c090474651af9d1d (patch)
treeda2499cbbe5c28504532465b1a98da02cfacdff5 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution
parentc68b96d4cc9425f384569093decf9c6705e9f11e (diff)
[Ide] Add Run->With commands for all execution targets
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs25
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/TargetedExecutionHandler.cs52
2 files changed, 77 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
index a8a2955615..de62f8902e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/ExecutionModeCommandService.cs
@@ -88,11 +88,36 @@ namespace MonoDevelop.Ide.Execution
if (info.Count > 0)
info.AddSeparator ();
}
+
+ var targets = new List<ExecutionTarget> ();
+ FlattenExecutionTargets (targets, project.GetExecutionTargets (IdeApp.Workspace.ActiveConfiguration));
+
+ if (targets.Count > 1) {
+ foreach (var t in targets) {
+ var h = new TargetedExecutionHandler (Runtime.ProcessService.DefaultExecutionHandler, t);
+ CommandInfo ci = info.Add (t.FullName, new CommandItem (ctx, new ExecutionMode (t.Id, t.FullName, h)));
+ ci.Description = GettextCatalog.GetString ("Run With: {0}", ci.Text);
+ }
+ info.AddSeparator ();
+ }
+
if (supportsParameterization) {
info.AddSeparator ();
info.Add (GettextCatalog.GetString ("Edit Custom Modes..."), new CommandItem (ctx, null));
}
}
+
+ static void FlattenExecutionTargets (List<ExecutionTarget> addToList, IEnumerable<ExecutionTarget> targets)
+ {
+ foreach (var t in targets) {
+ var group = t as ExecutionTargetGroup;
+ if (group != null) {
+ FlattenExecutionTargets (addToList, group);
+ } else {
+ addToList.Add (t);
+ }
+ }
+ }
public static IExecutionHandler GetExecutionModeForCommand (object data)
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/TargetedExecutionHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/TargetedExecutionHandler.cs
new file mode 100644
index 0000000000..63ba2161d0
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Execution/TargetedExecutionHandler.cs
@@ -0,0 +1,52 @@
+//
+// TargetedExecutionHandler.cs
+//
+// Author:
+// Michael Hutchinson <m.j.hutchinson@gmail.com>
+//
+// Copyright (c) 2015 Xamarin Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using MonoDevelop.Core.Execution;
+
+namespace MonoDevelop.Ide.Execution
+{
+ class TargetedExecutionHandler : ITargetedExecutionHandler
+ {
+ public ExecutionTarget Target { get; set; }
+ public IExecutionHandler Handler { get; set; }
+
+ public TargetedExecutionHandler (IExecutionHandler handler, ExecutionTarget target)
+ {
+ Target = target;
+ Handler = handler;
+ }
+
+ public bool CanExecute (ExecutionCommand command)
+ {
+ return Handler.CanExecute (command);
+ }
+
+ public IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console)
+ {
+ return Handler.Execute (command, console);
+ }
+ }
+} \ No newline at end of file