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:
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs112
1 files changed, 69 insertions, 43 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
index e07e8dd7e3..9b36617840 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
@@ -341,10 +341,16 @@ namespace MonoDevelop.Components.MainToolbar
bool SelectActiveRuntime (ref bool selected, ref ExecutionTarget defaultTarget, ref int defaultIter)
{
var runtimes = ToolbarView.RuntimeModel.Cast<RuntimeModel> ().ToList ();
+ string lastRuntimeForProject = currentStartupProject != null ? currentStartupProject.UserProperties.GetValue<string> ("PreferredExecutionTarget", defaultValue: null) : null;
+ var activeTarget = IdeApp.Workspace.ActiveExecutionTarget;
+ var activeTargetId = activeTarget != null ? activeTarget.Id : null;
+
for (int iter = 0; iter < runtimes.Count; ++iter) {
var item = runtimes [iter];
- if (!item.Enabled)
- continue;
+ using (var model = item.GetMutableModel ()) {
+ if (!model.Enabled)
+ continue;
+ }
var target = item.ExecutionTarget;
if (target == null || !target.Enabled)
@@ -354,12 +360,12 @@ namespace MonoDevelop.Components.MainToolbar
if (item.HasChildren)
continue;
- if (defaultTarget == null) {
+ if (defaultTarget == null || lastRuntimeForProject == target.Id) {
defaultTarget = target;
defaultIter = iter;
}
- if (target.Id == IdeApp.Workspace.PreferredActiveExecutionTarget) {
+ if (target.Id == activeTargetId) {
IdeApp.Workspace.ActiveExecutionTarget = target;
ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt (iter);
UpdateBuildConfiguration ();
@@ -367,7 +373,7 @@ namespace MonoDevelop.Components.MainToolbar
return true;
}
- if (target.Equals (IdeApp.Workspace.ActiveExecutionTarget)) {
+ if (target.Equals (activeTarget)) {
ToolbarView.ActiveRuntime = ToolbarView.RuntimeModel.ElementAt (iter);
UpdateBuildConfiguration ();
selected = true;
@@ -395,7 +401,6 @@ namespace MonoDevelop.Components.MainToolbar
UpdateBuildConfiguration ();
}
}
-
} finally {
ignoreRuntimeChangedCount--;
}
@@ -438,6 +443,9 @@ namespace MonoDevelop.Components.MainToolbar
void TrackStartupProject ()
{
if (currentStartupProject != null && ((currentSolution != null && currentStartupProject != currentSolution.StartupItem) || currentSolution == null)) {
+ var runtime = (RuntimeModel)ToolbarView.ActiveRuntime;
+ if (runtime != null && runtime.Command == null)
+ currentStartupProject.UserProperties.SetValue<string> ("PreferredExecutionTarget", runtime.TargetId);
currentStartupProject.ExecutionTargetsChanged -= executionTargetsChanged;
currentStartupProject.Saved -= HandleUpdateCombos;
}
@@ -762,8 +770,6 @@ namespace MonoDevelop.Components.MainToolbar
public RuntimeModel (MainToolbarController controller, ExecutionTarget target) : this (controller)
{
ExecutionTarget = target;
- Enabled = !(ExecutionTarget is ExecutionTargetGroup);
- Visible = true;
}
public RuntimeModel (MainToolbarController controller, ExecutionTarget target, RuntimeModel parent) : this (controller, target)
@@ -785,6 +791,7 @@ namespace MonoDevelop.Components.MainToolbar
public IEnumerable<IRuntimeModel> Children {
get { return children; }
}
+
public bool Notable {
get { return ExecutionTarget != null && ExecutionTarget.Notable; }
}
@@ -799,16 +806,6 @@ namespace MonoDevelop.Components.MainToolbar
set;
}
- public bool Visible {
- get;
- private set;
- }
-
- public bool Enabled {
- get;
- private set;
- }
-
public bool IsSeparator {
get { return Command == null && ExecutionTarget == null; }
}
@@ -818,43 +815,72 @@ namespace MonoDevelop.Components.MainToolbar
set;
}
- public string DisplayString {
- get {
- if (Command != null) {
- var ci = IdeApp.CommandService.GetCommandInfo (Command, new CommandTargetRoute (Controller.lastCommandTarget));
- Visible = ci.Visible;
- Enabled = ci.Enabled;
- return RemoveUnderline (ci.Text);
- }
+ public bool NotifyActivated ()
+ {
+ if (Command != null && IdeApp.CommandService.DispatchCommand (Command, CommandSource.ContextMenu))
+ return true;
+ return false;
+ }
+ internal string TargetId {
+ get {
if (ExecutionTarget == null)
return "";
-
- return !HasParent ? ExecutionTarget.FullName : ExecutionTarget.Name;
+ return ExecutionTarget.Id;
}
}
- public string FullDisplayString {
- get {
- if (Command != null) {
- var ci = IdeApp.CommandService.GetCommandInfo (Command, new CommandTargetRoute (Controller.lastCommandTarget));
- Visible = ci.Visible;
- Enabled = ci.Enabled;
- return RemoveUnderline (ci.Text);
- }
+ public IRuntimeMutableModel GetMutableModel ()
+ {
+ return Command != null ? new RuntimeMutableModel (Controller, Command) : new RuntimeMutableModel (ExecutionTarget, HasParent);
+ }
+ }
- if (ExecutionTarget == null)
- return "";
+ class RuntimeMutableModel : IRuntimeMutableModel
+ {
+ public RuntimeMutableModel (MainToolbarController controller, object command)
+ {
+ var ci = IdeApp.CommandService.GetCommandInfo (command, new CommandTargetRoute (controller.lastCommandTarget));
+ Visible = ci.Visible;
+ Enabled = ci.Enabled;
+ DisplayString = FullDisplayString = RemoveUnderline (ci.Text);
+ }
- return ExecutionTarget.FullName;
+ public RuntimeMutableModel (ExecutionTarget target, bool hasParent)
+ {
+ Enabled = !(target is ExecutionTargetGroup);
+ Visible = true;
+ if (target == null)
+ DisplayString = FullDisplayString = string.Empty;
+ else {
+ FullDisplayString = target.FullName;
+ DisplayString = !hasParent ? target.FullName : target.Name;
}
}
- public bool NotifyActivated ()
+ // Marker so it won't be reused.
+ public void Dispose ()
{
- if (Command != null && IdeApp.CommandService.DispatchCommand (Command, CommandSource.ContextMenu))
- return true;
- return false;
+ }
+
+ public bool Visible {
+ get;
+ private set;
+ }
+
+ public bool Enabled {
+ get;
+ private set;
+ }
+
+ public string DisplayString {
+ get;
+ private set;
+ }
+
+ public string FullDisplayString {
+ get;
+ private set;
}
static string RemoveUnderline (string s)