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
path: root/main
diff options
context:
space:
mode:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2015-09-11 17:19:22 +0300
committerMarius Ungureanu <marius.ungureanu@xamarin.com>2015-09-11 17:19:22 +0300
commite81bf6a82eb4c479b16099f127030d185110fe93 (patch)
tree646477f0d7337cf652e517801db2cebf9a575ab9 /main
parentc775cb73a5de2c081f0d1bd594e3b9906c6e2e44 (diff)
parent8b161da94f0c78a191564688059d0f7bc383b919 (diff)
Merge branch 'master' into roslyn
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/MacPlatform/MainToolbar/SelectorView.cs69
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs15
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs29
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs96
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarModels.cs57
5 files changed, 160 insertions, 106 deletions
diff --git a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
index 0420ca00f6..a2f3cd79cc 100644
--- a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
+++ b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs
@@ -101,14 +101,21 @@ namespace MonoDevelop.MacIntegration.MainToolbar
void CreateMenuItem (NSMenu menu, IRuntimeModel runtime)
{
- var menuItem = new NSMenuItem {
- IndentationLevel = runtime.IsIndented ? 2 : 1,
- AttributedTitle = new NSAttributedString (runtime.DisplayString, new NSStringAttributes {
- Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font,
- }),
- Enabled = runtime.Enabled,
- Hidden = !runtime.Visible,
- };
+ NSMenuItem menuItem;
+ string runtimeFullDisplayString;
+
+ using (var mutableModel = runtime.GetMutableModel ()) {
+ runtimeFullDisplayString = mutableModel.FullDisplayString;
+
+ menuItem = new NSMenuItem {
+ IndentationLevel = runtime.IsIndented ? 2 : 1,
+ AttributedTitle = new NSAttributedString (mutableModel.DisplayString, new NSStringAttributes {
+ Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font,
+ }),
+ Enabled = mutableModel.Enabled,
+ Hidden = !mutableModel.Visible,
+ };
+ }
var subMenu = CreateSubMenuForRuntime (runtime);
if (subMenu != null) {
@@ -116,8 +123,14 @@ namespace MonoDevelop.MacIntegration.MainToolbar
menuItem.Enabled = true;
} else {
menuItem.Activated += (o2, e2) => {
- string old = ActiveRuntime.FullDisplayString;
- IRuntimeModel newRuntime = runtimeModel.FirstOrDefault (r => r.FullDisplayString == runtime.FullDisplayString);
+ string old;
+ using (var activeMutableModel = ActiveRuntime.GetMutableModel ())
+ old = activeMutableModel.FullDisplayString;
+
+ IRuntimeModel newRuntime = runtimeModel.FirstOrDefault (r => {
+ using (var newRuntimeMutableModel = r.GetMutableModel ())
+ return newRuntimeMutableModel.FullDisplayString == runtimeFullDisplayString;
+ });
if (newRuntime == null)
return;
@@ -127,7 +140,10 @@ namespace MonoDevelop.MacIntegration.MainToolbar
RuntimeChanged (o2, ea);
if (ea.Handled)
- ActiveRuntime = runtimeModel.First (r => r.FullDisplayString == old);
+ ActiveRuntime = runtimeModel.First (r => {
+ using (var newRuntimeMutableModel = r.GetMutableModel ())
+ return newRuntimeMutableModel.FullDisplayString == old;
+ });
};
}
menu.AddItem (menuItem);
@@ -185,18 +201,22 @@ namespace MonoDevelop.MacIntegration.MainToolbar
++i;
}
} else if (object.ReferenceEquals (ClickedPathComponentCell, PathComponentCells [RuntimeIdx])) {
- foreach (var runtime in RuntimeModel) {
- if (idx == -1 && runtime.DisplayString == ActiveRuntime.DisplayString)
- idx = i;
-
- if (runtime.HasParent)
- continue;
-
- if (runtime.IsSeparator)
- menu.AddItem (NSMenuItem.SeparatorItem);
- else
- CreateMenuItem (menu, runtime);
- ++i;
+ using (var activeMutableModel = ActiveRuntime.GetMutableModel ()) {
+ foreach (var runtime in RuntimeModel) {
+ using (var mutableModel = runtime.GetMutableModel ()) {
+ if (idx == -1 && mutableModel.DisplayString == activeMutableModel.DisplayString)
+ idx = i;
+ }
+
+ if (runtime.HasParent)
+ continue;
+
+ if (runtime.IsSeparator)
+ menu.AddItem (NSMenuItem.SeparatorItem);
+ else
+ CreateMenuItem (menu, runtime);
+ ++i;
+ }
}
} else
throw new NotSupportedException ();
@@ -255,7 +275,8 @@ namespace MonoDevelop.MacIntegration.MainToolbar
get { return activeRuntime; }
set {
activeRuntime = value;
- UpdatePathText (RuntimeIdx, value.FullDisplayString);
+ using (var mutableModel = value.GetMutableModel ())
+ UpdatePathText (RuntimeIdx, mutableModel.FullDisplayString);
}
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
index b162335415..10f352b26a 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
@@ -1395,6 +1395,9 @@ namespace MonoDevelop.VersionControl.Git
protected override void OnMoveFile (FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
{
+ var srcRepo = GetRepository (localSrcPath);
+ var dstRepo = GetRepository (localDestPath);
+
VersionInfo vi = GetVersionInfo (localSrcPath, VersionInfoQueryFlags.IgnoreCache);
if (vi == null || !vi.IsVersioned) {
base.OnMoveFile (localSrcPath, localDestPath, force, monitor);
@@ -1403,10 +1406,16 @@ namespace MonoDevelop.VersionControl.Git
vi = GetVersionInfo (localDestPath, VersionInfoQueryFlags.IgnoreCache);
if (vi != null && ((vi.Status & (VersionStatus.ScheduledDelete | VersionStatus.ScheduledReplace)) != VersionStatus.Unversioned))
- RootRepository.Unstage (localDestPath);
+ dstRepo.Unstage (localDestPath);
- RootRepository.Move (localSrcPath, localDestPath);
- ClearCachedVersionInfo (localSrcPath, localDestPath);
+ if (srcRepo == dstRepo) {
+ srcRepo.Move (localSrcPath, localDestPath);
+ ClearCachedVersionInfo (localSrcPath, localDestPath);
+ } else {
+ File.Copy (localSrcPath, localDestPath);
+ srcRepo.Remove (localSrcPath, true);
+ dstRepo.Stage (localDestPath);
+ }
}
protected override void OnMoveDirectory (FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
index bad71a8f9c..a4c434995e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbar.cs
@@ -106,19 +106,22 @@ namespace MonoDevelop.Components.MainToolbar
return;
}
- renderer.Visible = runtime.Visible;
- renderer.Sensitive = runtime.Enabled;
- renderer.Xpad = (uint)(runtime.IsIndented ? 18 : 3);
-
- if (!runtimeCombo.PopupShown) {
- // no need to ident text when the combo dropdown is not showing
- if (Platform.IsWindows)
- renderer.Xpad = 3;
- renderer.Text = runtime.FullDisplayString;
- renderer.Attributes = normalAttributes;
- } else {
- renderer.Text = runtime.DisplayString;
- renderer.Attributes = runtime.Notable ? boldAttributes : normalAttributes;
+ using (var mutableModel = runtime.GetMutableModel ()) {
+ renderer.Visible = mutableModel.Visible;
+ renderer.Sensitive = mutableModel.Enabled;
+ renderer.Xpad = (uint)(runtime.IsIndented ? 18 : 3);
+
+ if (!runtimeCombo.PopupShown) {
+ // no need to ident text when the combo dropdown is not showing
+ if (Platform.IsWindows)
+ renderer.Xpad = 3;
+ renderer.Text = mutableModel.FullDisplayString;
+ renderer.Attributes = normalAttributes;
+ } else {
+ renderer.Text = mutableModel.DisplayString;
+ renderer.Attributes = runtime.Notable ? boldAttributes : normalAttributes;
+ }
+
}
}
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 8bbee5894d..9e65d4e43c 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs
@@ -347,8 +347,10 @@ namespace MonoDevelop.Components.MainToolbar
var runtimes = ToolbarView.RuntimeModel.Cast<RuntimeModel> ().ToList ();
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)
@@ -776,8 +778,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)
@@ -799,6 +799,7 @@ namespace MonoDevelop.Components.MainToolbar
public IEnumerable<IRuntimeModel> Children {
get { return children; }
}
+
public bool Notable {
get { return ExecutionTarget != null && ExecutionTarget.Notable; }
}
@@ -813,16 +814,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; }
}
@@ -832,43 +823,64 @@ 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;
+ }
- if (ExecutionTarget == null)
- return "";
+ public IRuntimeMutableModel GetMutableModel ()
+ {
+ return Command != null ? new RuntimeMutableModel (Controller, Command) : new RuntimeMutableModel (ExecutionTarget, HasParent);
+ }
+ }
+
+ 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 !HasParent ? ExecutionTarget.FullName : ExecutionTarget.Name;
+ 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 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);
- }
+ // Marker so it won't be reused.
+ public void Dispose ()
+ {
+ }
- if (ExecutionTarget == null)
- return "";
+ public bool Visible {
+ get;
+ private set;
+ }
- return ExecutionTarget.FullName;
- }
+ public bool Enabled {
+ get;
+ private set;
}
- public bool NotifyActivated ()
- {
- if (Command != null && IdeApp.CommandService.DispatchCommand (Command, CommandSource.ContextMenu))
- return true;
- return false;
+ public string DisplayString {
+ get;
+ private set;
+ }
+
+ public string FullDisplayString {
+ get;
+ private set;
}
static string RemoveUnderline (string s)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarModels.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarModels.cs
index bdd0036f0d..eb814b067b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarModels.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarModels.cs
@@ -51,30 +51,6 @@ namespace MonoDevelop.Components.MainToolbar
IEnumerable<IRuntimeModel> Children { get; }
/// <summary>
- /// Gets the display string to be used inside a context menu.
- /// </summary>
- /// <value>The display string.</value>
- string DisplayString { get; }
-
- /// <summary>
- /// Gets the display string to be for selected items.
- /// </summary>
- /// <value>The full display string.</value>
- string FullDisplayString { get; }
-
- /// <summary>
- /// Gets whether the menu item is visible.
- /// </summary>
- /// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
- bool Visible { get; }
-
- /// <summary>
- /// Gets whether the menu item is enabled.
- /// </summary>
- /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
- bool Enabled { get; }
-
- /// <summary>
/// Gets whether the menu item is a separator.
/// </summary>
/// <value><c>true</c> if this instance is separator; otherwise, <c>false</c>.</value>
@@ -100,6 +76,39 @@ namespace MonoDevelop.Components.MainToolbar
/// </remarks>
/// <value><c>true</c> if this instance has a parent; otherwise, <c>false</c>.</value>
bool HasParent { get; }
+
+ /// <summary>
+ /// Gets the runtime combo item model.
+ /// </summary>
+ /// <value>The runtime combo item.</value>
+ IRuntimeMutableModel GetMutableModel();
+ }
+
+ public interface IRuntimeMutableModel : IDisposable
+ {
+ /// <summary>
+ /// Gets the display string to be used inside a context menu.
+ /// </summary>
+ /// <value>The display string.</value>
+ string DisplayString { get; }
+
+ /// <summary>
+ /// Gets the display string to be for selected items.
+ /// </summary>
+ /// <value>The full display string.</value>
+ string FullDisplayString { get; }
+
+ /// <summary>
+ /// Gets whether the menu item is visible.
+ /// </summary>
+ /// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
+ bool Visible { get; }
+
+ /// <summary>
+ /// Gets whether the menu item is enabled.
+ /// </summary>
+ /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
+ bool Enabled { get; }
}
public interface ISearchMenuModel