diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui')
10 files changed, 176 insertions, 165 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs index 4fa2e70f60..25aac3297a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs @@ -33,7 +33,7 @@ using Gtk; namespace MonoDevelop.Ide.Gui { - class BackgroundProgressMonitor: SimpleProgressMonitor + class BackgroundProgressMonitor: ProgressMonitor { string title; StatusBarIcon icon; @@ -56,10 +56,10 @@ namespace MonoDevelop.Ide.Gui if (icon == null) return; string tip; - if (Tracker.UnknownWork) - tip = string.Format ("{0}\n{1}", title, Tracker.CurrentTask); + if (ProgressIsUnknown) + tip = string.Format ("{0}\n{1}", title, CurrentTaskName); else - tip = string.Format ("{0} ({1}%)\n{2}", title, (int)(Tracker.GlobalWork * 100), Tracker.CurrentTask); + tip = string.Format ("{0} ({1}%)\n{2}", title, (int)(Progress * 100), CurrentTaskName); Application.Invoke (delegate { if (icon != null) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index aaf11e4ef7..ede3dfd33b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -451,8 +451,6 @@ namespace MonoDevelop.Ide.Gui return; } - RegisterPad (content); - if (item != null) { if (show) item.Visible = true; @@ -1292,6 +1290,8 @@ namespace MonoDevelop.Ide.Gui void AddPad (PadCodon padCodon, string placement, DockItemStatus defaultStatus) { + RegisterPad (padCodon); + PadWindow window = new PadWindow (this, padCodon); window.Icon = padCodon.Icon; padWindows [padCodon] = window; @@ -1331,9 +1331,6 @@ namespace MonoDevelop.Ide.Gui else window.NotifyContentHidden (); }; - - if (!padContentCollection.Contains (padCodon)) - padContentCollection.Add (padCodon); } void UpdatePad (object source, EventArgs args) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs index 1efcf2e3c7..a8e41c92ed 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs @@ -75,7 +75,7 @@ namespace MonoDevelop.Ide.Gui { Widget w = CreateWidget (entry); if (w is Button) { - buttons.Add (new ToolButtonStatus (entry.CommandId, (Gtk.Button) w)); + buttons.Add (new ToolButtonStatus (entry.CommandId, (Gtk.Button)w, entry.DispayType)); ((Gtk.Button) w).Clicked += delegate { IdeApp.CommandService.DispatchCommand (entry.CommandId, null, initialTarget, CommandSource.MainToolbar); }; @@ -141,11 +141,16 @@ namespace MonoDevelop.Ide.Gui string stockId; Button button; object cmdId; + CommandEntryDisplayType displayType; - public ToolButtonStatus (object cmdId, Button button) + public ToolButtonStatus (object cmdId, Button button, CommandEntryDisplayType displayType = CommandEntryDisplayType.Default) { this.cmdId = cmdId; this.button = button; + if (displayType == CommandEntryDisplayType.Default)//Simplefies code in rest of class + this.displayType = CommandEntryDisplayType.IconHasPriority; + else + this.displayType = displayType; } public void Update (CommandTargetRoute targetRoute) @@ -155,10 +160,12 @@ namespace MonoDevelop.Ide.Gui bool hasAccel = string.IsNullOrEmpty (cmdInfo.AccelKey); bool hasIcon = !cmdInfo.Icon.IsNull; string desc = cmdInfo.Description; - + bool displayText = !(displayType == CommandEntryDisplayType.IconHasPriority && hasIcon) && + displayType != CommandEntryDisplayType.IconOnly; + //If the button only has an icon it's not always clear what it does. In such cases, use the label as a //fallback tooltip. Also do this if there's an accelerator, so the user can see what it is. - if (string.IsNullOrEmpty (desc) && (hasIcon || hasAccel)) + if (string.IsNullOrEmpty (desc) && (!displayText || hasAccel)) desc = cmdInfo.Text; if (lastDesc != desc) { @@ -172,10 +179,11 @@ namespace MonoDevelop.Ide.Gui lastDesc = desc; } - if (!hasIcon && button.Label != cmdInfo.Text) + if (displayText && button.Label != cmdInfo.Text) { button.Label = cmdInfo.Text; - - if (cmdInfo.Icon != stockId) { + } + + if (displayType != CommandEntryDisplayType.TextOnly && cmdInfo.Icon != stockId) { stockId = cmdInfo.Icon; button.Image = new Gtk.Image (cmdInfo.Icon, Gtk.IconSize.Menu); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs index b7e118ea1d..dd0f91da87 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs @@ -462,53 +462,6 @@ namespace MonoDevelop.Ide.Gui UpdateParseDocument (); } - public bool IsBuildTarget - { - get - { - if (this.IsViewOnly) - return false; - if (Window.ViewContent.ContentName != null) - return Services.ProjectService.CanCreateSingleFileProject(Window.ViewContent.ContentName); - - return false; - } - } - - public IAsyncOperation Build () - { - return IdeApp.ProjectOperations.BuildFile (Window.ViewContent.ContentName); - } - - public IAsyncOperation Rebuild () - { - return Build (); - } - - public void Clean () - { - } - - public IAsyncOperation Run () - { - return Run (Runtime.ProcessService.DefaultExecutionHandler); - } - - public IAsyncOperation Run (IExecutionHandler handler) - { - return IdeApp.ProjectOperations.ExecuteFile (Window.ViewContent.ContentName, handler); - } - - public bool CanRun () - { - return CanRun (Runtime.ProcessService.DefaultExecutionHandler); - } - - public bool CanRun (IExecutionHandler handler) - { - return IsBuildTarget && Window.ViewContent.ContentName != null && IdeApp.ProjectOperations.CanExecuteFile (Window.ViewContent.ContentName, handler); - } - public bool Close () { return ((SdiWorkspaceWindow)Window).CloseWindow (false, true); @@ -740,7 +693,7 @@ namespace MonoDevelop.Ide.Gui TypeSystemService.ProjectContentWrapper currentWrapper; internal void SetProject (Project project) { - if (Window.ViewContent.Project == project) + if (Window == null || Window.ViewContent == null || Window.ViewContent.Project == project) return; DetachExtensionChain (); ISupportsProjectReload pr = GetContent<ISupportsProjectReload> (); @@ -768,9 +721,7 @@ namespace MonoDevelop.Ide.Gui var wrapper = TypeSystemService.GetProjectContentWrapper (project); wrapper.Loaded += HandleInLoadChanged; currentWrapper = wrapper; - RunWhenLoaded (delegate { - currentWrapper.RequestLoad (); - }); + currentWrapper.RequestLoad (); } StartReparseThread (); } @@ -825,7 +776,7 @@ namespace MonoDevelop.Ide.Gui get { if (currentWrapper == null) return false; - return !currentWrapper.IsLoaded || !currentWrapper.ReferencesConnected; + return !currentWrapper.IsLoaded; } } @@ -845,42 +796,49 @@ namespace MonoDevelop.Ide.Gui } uint parseTimeout = 0; + object reparseLock = new object(); internal void StartReparseThread () { - // Don't directly parse the document because doing it at every key press is - // very inefficient. Do it after a small delay instead, so several changes can - // be parsed at the same time. - string currentParseFile = FileName; - if (string.IsNullOrEmpty (currentParseFile)) - return; - CancelParseTimeout (); - if (IsProjectContextInUpdate) - return; - parseTimeout = GLib.Timeout.Add (ParseDelay, delegate { - var editor = Editor; - if (editor == null || IsProjectContextInUpdate) { - parseTimeout = 0; - return false; + lock (reparseLock) { + if (currentWrapper != null) + currentWrapper.EnsureReferencesAreLoaded (); + + // Don't directly parse the document because doing it at every key press is + // very inefficient. Do it after a small delay instead, so several changes can + // be parsed at the same time. + string currentParseFile = FileName; + if (string.IsNullOrEmpty (currentParseFile)) + return; + CancelParseTimeout (); + if (IsProjectContextInUpdate) { + return; } - string currentParseText = editor.Text; - string mimeType = editor.Document.MimeType; - ThreadPool.QueueUserWorkItem (delegate { - if (IsProjectContextInUpdate) - return; - TypeSystemService.AddSkippedFile (currentParseFile); - var currentParsedDocument = TypeSystemService.ParseFile (Project, currentParseFile, mimeType, currentParseText); - Application.Invoke (delegate { - // this may be called after the document has closed, in that case the OnDocumentParsed event shouldn't be invoked. - if (isClosed) + parseTimeout = GLib.Timeout.Add (ParseDelay, delegate { + var editor = Editor; + if (editor == null || IsProjectContextInUpdate) { + parseTimeout = 0; + return false; + } + string currentParseText = editor.Text; + string mimeType = editor.Document.MimeType; + ThreadPool.QueueUserWorkItem (delegate { + if (IsProjectContextInUpdate) { return; - - this.parsedDocument = currentParsedDocument; - OnDocumentParsed (EventArgs.Empty); + } + TypeSystemService.AddSkippedFile (currentParseFile); + var currentParsedDocument = TypeSystemService.ParseFile (Project, currentParseFile, mimeType, currentParseText); + Application.Invoke (delegate { + // this may be called after the document has closed, in that case the OnDocumentParsed event shouldn't be invoked. + if (isClosed) + return; + this.parsedDocument = currentParsedDocument; + OnDocumentParsed (EventArgs.Empty); + }); }); + parseTimeout = 0; + return false; }); - parseTimeout = 0; - return false; - }); + } } /// <summary> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs index 6f4aa11a6d..566581443b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs @@ -37,6 +37,7 @@ using MonoDevelop.Core.Execution; using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Ide.FindInFiles; using MonoDevelop.Components.Docking; +using System.Threading; namespace MonoDevelop.Ide.Gui { @@ -51,22 +52,22 @@ namespace MonoDevelop.Ide.Gui { } - public IProgressMonitor GetBuildProgressMonitor () + public ProgressMonitor GetBuildProgressMonitor () { return GetBuildProgressMonitor (GettextCatalog.GetString ("Building...")); } - public IProgressMonitor GetCleanProgressMonitor () + public ProgressMonitor GetCleanProgressMonitor () { return GetBuildProgressMonitor (GettextCatalog.GetString ("Cleaning...")); } - public IProgressMonitor GetRebuildProgressMonitor () + public ProgressMonitor GetRebuildProgressMonitor () { return GetBuildProgressMonitor (GettextCatalog.GetString ("Rebuilding...")); } - private IProgressMonitor GetBuildProgressMonitor (string statusText) + private ProgressMonitor GetBuildProgressMonitor (string statusText) { Pad pad = IdeApp.Workbench.GetPad<ErrorListPad> (); ErrorListPad errorPad = (ErrorListPad) pad.Content; @@ -75,27 +76,27 @@ namespace MonoDevelop.Ide.Gui return mon; } - public IProgressMonitor GetRunProgressMonitor () + public ProgressMonitor GetRunProgressMonitor () { return GetOutputProgressMonitor ("MonoDevelop.Ide.ApplicationOutput", GettextCatalog.GetString ("Application Output"), Stock.RunProgramIcon, true, true); } - public IProgressMonitor GetToolOutputProgressMonitor (bool bringToFront) + public ProgressMonitor GetToolOutputProgressMonitor (bool bringToFront, CancellationTokenSource cs = null) { return GetOutputProgressMonitor ("MonoDevelop.Ide.ToolOutput", GettextCatalog.GetString ("Tool Output"), Stock.RunProgramIcon, bringToFront, true); } - public IProgressMonitor GetLoadProgressMonitor (bool lockGui) + public ProgressMonitor GetLoadProgressMonitor (bool lockGui) { return GetStatusProgressMonitor (GettextCatalog.GetString ("Loading..."), Stock.StatusSolutionOperation, true, false, lockGui); } - public IProgressMonitor GetProjectLoadProgressMonitor (bool lockGui) + public ProgressMonitor GetProjectLoadProgressMonitor (bool lockGui) { return new GtkProjectLoadProgressMonitor (GetLoadProgressMonitor (lockGui)); } - public IProgressMonitor GetSaveProgressMonitor (bool lockGui) + public ProgressMonitor GetSaveProgressMonitor (bool lockGui) { return GetStatusProgressMonitor (GettextCatalog.GetString ("Saving..."), Stock.StatusSolutionOperation, true, false, lockGui); } @@ -108,32 +109,32 @@ namespace MonoDevelop.Ide.Gui /******************************/ - public IProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs) + public ProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs) { return new StatusProgressMonitor (title, icon, showErrorDialogs, true, false, null); } - public IProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle, bool lockGui) + public ProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle, bool lockGui) { return new StatusProgressMonitor (title, icon, showErrorDialogs, showTaskTitle, lockGui, null); } - public IProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle, bool lockGui, Pad statusSourcePad) + public ProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle, bool lockGui, Pad statusSourcePad) { return new StatusProgressMonitor (title, icon, showErrorDialogs, showTaskTitle, lockGui, statusSourcePad); } - public IProgressMonitor GetBackgroundProgressMonitor (string title, IconId icon) + public ProgressMonitor GetBackgroundProgressMonitor (string title, IconId icon) { return new BackgroundProgressMonitor (title, icon); } - public IProgressMonitor GetOutputProgressMonitor (string title, IconId icon, bool bringToFront, bool allowMonitorReuse) + public ProgressMonitor GetOutputProgressMonitor (string title, IconId icon, bool bringToFront, bool allowMonitorReuse) { return GetOutputProgressMonitor (null, title, icon, bringToFront, allowMonitorReuse); } - public IProgressMonitor GetOutputProgressMonitor (string id, string title, IconId icon, bool bringToFront, bool allowMonitorReuse) + public ProgressMonitor GetOutputProgressMonitor (string id, string title, IconId icon, bool bringToFront, bool allowMonitorReuse) { Pad pad = CreateMonitorPad (id, title, icon, bringToFront, allowMonitorReuse, true); pad.Visible = true; @@ -150,7 +151,7 @@ namespace MonoDevelop.Ide.Gui /// For example, if you have a monitor 'm' created with a call to GetOutputProgressMonitor, /// GetPadForMonitor (m) will return the output pad. /// </remarks> - public Pad GetPadForMonitor (IProgressMonitor monitor) + public Pad GetPadForMonitor (ProgressMonitor monitor) { foreach (Pad pad in outputMonitors) { DefaultMonitorPad p = (DefaultMonitorPad) pad.Content; @@ -236,12 +237,12 @@ namespace MonoDevelop.Ide.Gui pad.Destroy (); } - public ISearchProgressMonitor GetSearchProgressMonitor (bool bringToFront) + public SearchProgressMonitor GetSearchProgressMonitor (bool bringToFront) { return GetSearchProgressMonitor (bringToFront, false); } - public ISearchProgressMonitor GetSearchProgressMonitor (bool bringToFront, bool focusPad) + public SearchProgressMonitor GetSearchProgressMonitor (bool bringToFront, bool focusPad) { Pad pad = null; string title = GettextCatalog.GetString ("Search Results"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectLoadProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectLoadProgressMonitor.cs index 783e6b97a7..d48c48479d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectLoadProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectLoadProgressMonitor.cs @@ -29,21 +29,18 @@ using MonoDevelop.Projects.Extensions; namespace MonoDevelop.Ide.Gui { - public class GtkProjectLoadProgressMonitor : WrappedProgressMonitor, IProjectLoadProgressMonitor + public class GtkProjectLoadProgressMonitor : ProjectLoadProgressMonitor { MigrationType? Migration { get; set; } - public MonoDevelop.Projects.Solution CurrentSolution { get; set; } - - public GtkProjectLoadProgressMonitor (IProgressMonitor monitor) - : base (monitor) + public GtkProjectLoadProgressMonitor (ProgressMonitor monitor) { - + AddSlaveMonitor (monitor); } - public MigrationType ShouldMigrateProject () + public override MigrationType ShouldMigrateProject () { if (!IdeApp.IsInitialized) return MigrationType.Ignore; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs index 5e93f19676..f008cf6790 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs @@ -670,7 +670,8 @@ namespace MonoDevelop.Ide.Gui void HandlePathChange (object sender, MonoDevelop.Ide.Gui.Content.DocumentPathChangedEventArgs args) { var pathDoc = (MonoDevelop.Ide.Gui.Content.IPathedDocument) sender; - pathBar.SetPath (pathDoc.CurrentPath); + if (pathBar != null) + pathBar.SetPath (pathDoc.CurrentPath); // pathBar.SetActive (pathDoc.SelectedIndex); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs index df4fd5efbe..9c53d67eb7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs @@ -34,7 +34,7 @@ using MonoDevelop.Core; namespace MonoDevelop.Ide.Gui { - internal class StatusProgressMonitor: BaseProgressMonitor + internal class StatusProgressMonitor: ProgressMonitor { string icon; bool showErrorDialogs; @@ -62,20 +62,20 @@ namespace MonoDevelop.Ide.Gui protected override void OnProgressChanged () { if (showTaskTitles) - statusBar.ShowMessage (icon, CurrentTask); - if (!UnknownWork) - statusBar.SetProgressFraction (GlobalWork); - RunPendingEvents (); + statusBar.ShowMessage (icon, CurrentTaskName); + if (!ProgressIsUnknown) + statusBar.SetProgressFraction (Progress); + DispatchService.RunPendingEvents (); } public void UpdateStatusBar () { if (showTaskTitles) - statusBar.ShowMessage (icon, CurrentTask); + statusBar.ShowMessage (icon, CurrentTaskName); else statusBar.ShowMessage (icon, title); - if (!UnknownWork) - statusBar.SetProgressFraction (GlobalWork); + if (!ProgressIsUnknown) + statusBar.SetProgressFraction (Progress); else statusBar.SetProgressFraction (0); } @@ -87,22 +87,22 @@ namespace MonoDevelop.Ide.Gui statusBar.EndProgress (); try { - if (Errors.Count > 0 || Warnings.Count > 0) { - if (Errors.Count > 0) { - statusBar.ShowError (Errors [Errors.Count - 1]); - } else if (SuccessMessages.Count == 0) { - statusBar.ShowWarning (Warnings [Warnings.Count - 1]); + if (Errors.Length > 0 || Warnings.Length > 0) { + if (Errors.Length > 0) { + statusBar.ShowError (Errors [Errors.Length - 1].Message); + } else if (SuccessMessages.Length == 0) { + statusBar.ShowWarning (Warnings [Warnings.Length - 1]); } base.OnCompleted (); if (showErrorDialogs) - ShowResultDialog (); + this.ShowResultDialog (); return; } - if (SuccessMessages.Count > 0) - statusBar.ShowMessage (MonoDevelop.Ide.Gui.Stock.StatusSuccess, SuccessMessages [SuccessMessages.Count - 1]); + if (SuccessMessages.Length > 0) + statusBar.ShowMessage (MonoDevelop.Ide.Gui.Stock.StatusSuccess, SuccessMessages [SuccessMessages.Length - 1]); } finally { statusBar.StatusSourcePad = statusSourcePad; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs index e5fa795274..d2d14a42dd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs @@ -133,6 +133,14 @@ namespace MonoDevelop.Ide.Gui public static readonly int PagerTriangleSize = 6; public static readonly int PagerHeight = 16; + public static readonly Cairo.Color ErrorBackgroundColor = CairoExtensions.ParseColor ("E27267"); + public static readonly Cairo.Color WarningBackgroundColor = CairoExtensions.ParseColor ("F6C61E"); + public static readonly Cairo.Color InformationBackgroundColor = CairoExtensions.ParseColor ("709DC9"); + + public static readonly Cairo.Color ErrorTextColor = CairoExtensions.ParseColor ("ffffff"); + public static readonly Cairo.Color WarningTextColor = CairoExtensions.ParseColor ("6D5607"); + public static readonly Cairo.Color InformationTextColor = CairoExtensions.ParseColor ("ffffff"); + public static class ParamaterWindows { public static readonly Cairo.Color GradientStartColor = CairoExtensions.ParseColor ("fffee6"); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs index be65157287..de309fd3d1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs @@ -70,7 +70,7 @@ namespace MonoDevelop.Ide.Gui public event EventHandler GuiLocked; public event EventHandler GuiUnlocked; - internal void Initialize (IProgressMonitor monitor) + internal void Initialize (ProgressMonitor monitor) { monitor.BeginTask (GettextCatalog.GetString ("Initializing Main Window"), 4); try { @@ -98,6 +98,15 @@ namespace MonoDevelop.Ide.Gui CheckFileStatus (); }; + IdeApp.ProjectOperations.StartBuild += delegate { + SaveFileStatus (); + }; + + IdeApp.ProjectOperations.EndBuild += delegate { + // The file status checks outputs as well. + CheckFileStatus (); + }; + pads = null; // Make sure we get an up to date pad list. monitor.Step (1); } finally { @@ -279,16 +288,18 @@ namespace MonoDevelop.Ide.Gui public void LockGui () { - IdeApp.CommandService.LockAll (); - if (GuiLocked != null) - GuiLocked (this, EventArgs.Empty); + if (IdeApp.CommandService.LockAll ()) { + if (GuiLocked != null) + GuiLocked (this, EventArgs.Empty); + } } public void UnlockGui () { - IdeApp.CommandService.UnlockAll (); - if (GuiUnlocked != null) - GuiUnlocked (this, EventArgs.Empty); + if (IdeApp.CommandService.UnlockAll ()) { + if (GuiUnlocked != null) + GuiUnlocked (this, EventArgs.Empty); + } } public void SaveAll () @@ -347,9 +358,9 @@ namespace MonoDevelop.Ide.Gui public Pad ShowPad (IPadContent padContent, string id, string label, string defaultPlacement, DockItemStatus defaultStatus, IconId icon) { return ShowPad (new PadCodon (padContent, id, label, defaultPlacement, defaultStatus, icon)); - }
+ } - [Obsolete("Use OpenDocument (FilePath fileName, Project project, bool bringToFront)")]
+ [Obsolete("Use OpenDocument (FilePath fileName, Project project, bool bringToFront)")] public Document OpenDocument (FilePath fileName, bool bringToFront) { return OpenDocument (fileName, bringToFront ? OpenDocumentOptions.Default : OpenDocumentOptions.Default & ~OpenDocumentOptions.BringToFront); @@ -359,15 +370,15 @@ namespace MonoDevelop.Ide.Gui public Document OpenDocument (FilePath fileName, OpenDocumentOptions options = OpenDocumentOptions.Default) { return OpenDocument (fileName, -1, -1, options, null, null); - }
+ } - [Obsolete("Use OpenDocument (FilePath fileName, Project project, Encoding encoding, OpenDocumentOptions options = OpenDocumentOptions.Default)")]
+ [Obsolete("Use OpenDocument (FilePath fileName, Project project, Encoding encoding, OpenDocumentOptions options = OpenDocumentOptions.Default)")] public Document OpenDocument (FilePath fileName, Encoding encoding, OpenDocumentOptions options = OpenDocumentOptions.Default) { return OpenDocument (fileName, -1, -1, options, encoding, null); - }
+ } - [Obsolete("Use OpenDocument (FilePath fileName, Project project, int line, int column, OpenDocumentOptions options = OpenDocumentOptions.Default)")]
+ [Obsolete("Use OpenDocument (FilePath fileName, Project project, int line, int column, OpenDocumentOptions options = OpenDocumentOptions.Default)")] public Document OpenDocument (FilePath fileName, int line, int column, OpenDocumentOptions options = OpenDocumentOptions.Default) { return OpenDocument (fileName, line, column, options, null, null); @@ -495,7 +506,7 @@ namespace MonoDevelop.Ide.Gui } } Counters.OpenDocumentTimer.Trace ("Initializing monitor"); - IProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor ( + ProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor ( GettextCatalog.GetString ("Opening {0}", info.Project != null ? info.FileName.ToRelative (info.Project.ParentSolution.BaseDirectory) : info.FileName), @@ -521,7 +532,7 @@ namespace MonoDevelop.Ide.Gui } } - IViewContent BatchOpenDocument (IProgressMonitor monitor, FilePath fileName, Project project, int line, int column, DockNotebook dockNotebook) + IViewContent BatchOpenDocument (ProgressMonitor monitor, FilePath fileName, Project project, int line, int column, DockNotebook dockNotebook) { if (string.IsNullOrEmpty (fileName)) return null; @@ -818,7 +829,7 @@ namespace MonoDevelop.Ide.Gui return project; } - void RealOpenFile (IProgressMonitor monitor, FileOpenInformation openFileInfo) + void RealOpenFile (ProgressMonitor monitor, FileOpenInformation openFileInfo) { FilePath fileName; @@ -1009,7 +1020,7 @@ namespace MonoDevelop.Ide.Gui FilePath baseDir = args.Item.BaseDirectory; var floatingWindows = new List<DockWindow> (); - using (IProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Loading workspace documents"), Stock.StatusSolutionOperation, true)) { + using (ProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Loading workspace documents"), Stock.StatusSolutionOperation, true)) { var docList = prefs.Files.Distinct (new DocumentUserPrefsFilenameComparer ()).OrderBy (d => d.NotebookId).ToList (); OpenDocumentsInContainer (pm, baseDir, docViews, docList, workbench.TabControl.Container); @@ -1063,14 +1074,14 @@ namespace MonoDevelop.Ide.Gui } } - void OpenDocumentsInContainer (IProgressMonitor pm, FilePath baseDir, List<Tuple<IViewContent,string>> docViews, List<DocumentUserPrefs> list, DockNotebookContainer container) + void OpenDocumentsInContainer (ProgressMonitor pm, FilePath baseDir, List<Tuple<IViewContent,string>> docViews, List<DocumentUserPrefs> list, DockNotebookContainer container) { int currentNotebook = -1; DockNotebook nb = container.GetFirstNotebook (); foreach (var doc in list) { string fileName = baseDir.Combine (doc.FileName).FullPath; - if (File.Exists (fileName)) { + if (GetDocument(fileName) == null && File.Exists (fileName)) { if (doc.NotebookId != currentNotebook) { if (currentNotebook != -1 || nb == null) nb = container.InsertRight (null); @@ -1170,8 +1181,8 @@ namespace MonoDevelop.Ide.Gui ThreadPool.QueueUserWorkItem (delegate { lock (fileStatusLock) { -// DateTime t = DateTime.Now;
- if (fileStatus == null)
+// DateTime t = DateTime.Now; + if (fileStatus == null) return; List<FilePath> modified = new List<FilePath> (); foreach (FileData fd in fileStatus) { @@ -1276,7 +1287,7 @@ namespace MonoDevelop.Ide.Gui return fileName; } set { - fileName = value.CanonicalPath; + fileName = ResolveSymbolicLink (value.CanonicalPath); if (fileName.IsNullOrEmpty) LoggingService.LogError ("FileName == null\n" + Environment.StackTrace); } @@ -1328,6 +1339,36 @@ namespace MonoDevelop.Ide.Gui this.Options &= ~OpenDocumentOptions.BringToFront; } } + + static FilePath ResolveSymbolicLink (FilePath fileName) + { + if (fileName.IsEmpty) + return fileName; + try { + var alreadyVisted = new HashSet<FilePath> (); + while (true) { + if (alreadyVisted.Contains (fileName)) { + LoggingService.LogError ("Cyclic links detected: " + fileName); + return FilePath.Empty; + } + alreadyVisted.Add (fileName); + var linkInfo = new Mono.Unix.UnixSymbolicLinkInfo (fileName); + if (linkInfo.IsSymbolicLink && linkInfo.HasContents) { + FilePath contentsPath = linkInfo.ContentsPath; + if (contentsPath.IsAbsolute) { + fileName = linkInfo.ContentsPath; + } else { + fileName = fileName.ParentDirectory.Combine (contentsPath); + } + fileName = fileName.CanonicalPath; + continue; + } + return ResolveSymbolicLink (fileName.ParentDirectory).Combine (fileName.FileName).CanonicalPath; + } + } catch (Exception) { + return fileName; + } + } } class LoadFileWrapper @@ -1336,10 +1377,10 @@ namespace MonoDevelop.Ide.Gui Project project; FileOpenInformation fileInfo; DefaultWorkbench workbench; - IProgressMonitor monitor; + ProgressMonitor monitor; IViewContent newContent; - public LoadFileWrapper (IProgressMonitor monitor, DefaultWorkbench workbench, IViewDisplayBinding binding, FileOpenInformation fileInfo) + public LoadFileWrapper (ProgressMonitor monitor, DefaultWorkbench workbench, IViewDisplayBinding binding, FileOpenInformation fileInfo) { this.monitor = monitor; this.workbench = workbench; @@ -1347,7 +1388,7 @@ namespace MonoDevelop.Ide.Gui this.binding = binding; } - public LoadFileWrapper (IProgressMonitor monitor, DefaultWorkbench workbench, IViewDisplayBinding binding, Project project, FileOpenInformation fileInfo) + public LoadFileWrapper (ProgressMonitor monitor, DefaultWorkbench workbench, IViewDisplayBinding binding, Project project, FileOpenInformation fileInfo) : this (monitor, workbench, binding, fileInfo) { this.project = project; |