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:
authorLluis Sanchez <lluis@novell.com>2010-03-17 15:40:31 +0300
committerLluis Sanchez <lluis@novell.com>2010-03-17 15:40:31 +0300
commit3773f909ed32b3b76ba623fa14d6628cc9ba9398 (patch)
tree5171b2b919a078f38edbd5d441492b5e3870abd2 /main
parent26cd98aac012ec3d1a5db043464d8be9575eaff9 (diff)
parent585086f0ea0a49166046bb8f48d2def87907d0e0 (diff)
Merged MD.Projects into MD.Core, and MD.Projects.Gui, MD.Core.Gui and MD.Components into MD.Ide.
svn path=/trunk/monodevelop/; revision=153734
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AsyncDispatchAttribute.cs35
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ConfigurationComboBox.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs16
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs7
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FreeDispatchAttribute.cs35
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs (renamed from main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddEntryEventHandler.cs)40
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncObject.cs36
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs158
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IBaseViewContent.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IMementoCapable.cs (renamed from main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ExitEventHandler.cs)20
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Ide.cs484
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdePreferences.cs297
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdeStartup.cs497
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/LayoutComboBox.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs7
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs1459
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RootWorkspace.cs1334
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs7
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StockIcons.cs146
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs286
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContextAttribute.cs217
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncObject.cs35
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ToolbarComboBox.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchContext.cs1
39 files changed, 834 insertions, 4334 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs
index 44057a1d2f..b35c9c63f5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddinUpdateHandler.cs
@@ -27,22 +27,16 @@
//
using System;
-using System.Collections;
-using System.IO;
using System.Threading;
using Gtk;
using MonoDevelop.Core;
-using Mono.Addins;
using Mono.Addins.Setup;
using Mono.Addins.Gui;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Dialogs;
-using MonoDevelop.Ide.Gui.Dialogs;
using MonoDevelop.Components.Commands;
using MonoDevelop.Core.ProgressMonitoring;
-using MonoDevelop.Core.Gui.ProgressMonitoring;
+using MonoDevelop.Ide.ProgressMonitoring;
namespace MonoDevelop.Ide.Gui
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AsyncDispatchAttribute.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AsyncDispatchAttribute.cs
new file mode 100644
index 0000000000..27711e76f6
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AsyncDispatchAttribute.cs
@@ -0,0 +1,35 @@
+// AsyncDispatchAttribute.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class AsyncDispatchAttribute: Attribute
+ {
+ }
+}
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 ff847a4226..22bf45ec39 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/BackgroundProgressMonitor.cs
@@ -30,8 +30,6 @@
using System;
using System.IO;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Components;
using MonoDevelop.Core.ProgressMonitoring;
using Gtk;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ConfigurationComboBox.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ConfigurationComboBox.cs
index d9f03fd23f..6a2daf70f6 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ConfigurationComboBox.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ConfigurationComboBox.cs
@@ -32,7 +32,6 @@ using System.Collections.ObjectModel;
using MonoDevelop.Core;
using MonoDevelop.Core.Assemblies;
using MonoDevelop.Projects;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components.Commands;
namespace MonoDevelop.Ide.Gui
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 34b837a442..ba0a5558c1 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
@@ -25,26 +25,16 @@
using System;
using System.IO;
-using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;
-using System.CodeDom.Compiler;
-using System.ComponentModel;
-using System.Xml;
using MonoDevelop.Projects;
using Mono.Addins;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Components;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Core.Gui.Dialogs;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Ide.Codons;
using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Projects.Dom.Parser;
+using MonoDevelop.Ide.Codons;
using MonoDevelop.Components.Commands;
using GLib;
@@ -235,7 +225,7 @@ namespace MonoDevelop.Ide.Gui
// TopMenu.Selected += new CommandHandler(OnTopMenuSelected);
// TopMenu.Deselected += new CommandHandler(OnTopMenuDeselected);
- if (!DesktopService.SetGlobalMenu (MonoDevelop.Ide.Gui.IdeApp.CommandService, mainMenuPath))
+ if (!DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath))
topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath);
toolbars = IdeApp.CommandService.CreateToolbarSet (toolbarsPath);
@@ -257,7 +247,7 @@ namespace MonoDevelop.Ide.Gui
bool changed = false;
if (args.PathChanged (mainMenuPath)) {
- if (DesktopService.SetGlobalMenu (MonoDevelop.Ide.Gui.IdeApp.CommandService, mainMenuPath))
+ if (DesktopService.SetGlobalMenu (IdeApp.CommandService, mainMenuPath))
return;
topMenu = IdeApp.CommandService.CreateMenuBar (mainMenuPath);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
index ee06b01f2a..978014f027 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using Mono.Addins;
-using MonoDevelop.Core.Gui.Codons;
using MonoDevelop.Ide.Codons;
namespace MonoDevelop.Ide.Gui
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 253dc84cd9..3e9f8fad09 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DockItemToolbarLoader.cs
@@ -29,7 +29,6 @@ using System.Drawing;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Codons;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components.Docking;
using MonoDevelop.Components.Commands;
using Gtk;
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 d2b3dbab73..daf924ac7e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
@@ -39,7 +39,6 @@ using MonoDevelop.Core.Execution;
using MonoDevelop.Components;
using MonoDevelop.Projects;
using MonoDevelop.Projects.Text;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.Gui.Dialogs;
using MonoDevelop.Projects.Dom;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs
index 51378591a7..0da060dae7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs
@@ -32,7 +32,6 @@ using System.Linq;
using Gdk;
using Gtk;
using MonoDevelop.Ide.Gui;
-using MonoDevelop.Core.Gui;
namespace MonoDevelop.Ide
@@ -62,7 +61,7 @@ namespace MonoDevelop.Ide
Gtk.TreeIter iter;
if (treeviewPads.Selection.GetSelected (out iter)) {
MonoDevelop.Ide.Gui.Pad pad = padListStore.GetValue (iter, 2) as MonoDevelop.Ide.Gui.Pad;
- ShowType (ImageService.GetPixbuf (!pad.Icon.IsNull ? pad.Icon : MonoDevelop.Core.Gui.Stock.MiscFiles, Gtk.IconSize.Dialog),
+ ShowType (ImageService.GetPixbuf (!pad.Icon.IsNull ? pad.Icon : MonoDevelop.Ide.Gui.Stock.MiscFiles, Gtk.IconSize.Dialog),
pad.Title,
"",
"");
@@ -74,7 +73,7 @@ namespace MonoDevelop.Ide
if (!string.IsNullOrEmpty (document.Window.ViewContent.StockIconId))
return ImageService.GetPixbuf (document.Window.ViewContent.StockIconId, iconSize);
if (string.IsNullOrEmpty (document.FileName))
- return ImageService.GetPixbuf (MonoDevelop.Core.Gui.Stock.MiscFiles, iconSize);
+ return ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.MiscFiles, iconSize);
return DesktopService.GetPixbufForFile (document.FileName, iconSize);
}
@@ -282,7 +281,7 @@ namespace MonoDevelop.Ide
foreach (Pad pad in IdeApp.Workbench.Pads) {
if (!pad.Visible)
continue;
- padListStore.AppendValues (ImageService.GetPixbuf (!String.IsNullOrEmpty (pad.Icon) ? pad.Icon : MonoDevelop.Core.Gui.Stock.MiscFiles, IconSize.Menu),
+ padListStore.AppendValues (ImageService.GetPixbuf (!String.IsNullOrEmpty (pad.Icon) ? pad.Icon : MonoDevelop.Ide.Gui.Stock.MiscFiles, IconSize.Menu),
pad.Title,
pad);
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs
index 58b739059a..62648c486f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs
@@ -28,7 +28,7 @@
using System;
using MonoDevelop.Ide.Codons;
-using MonoDevelop.Core.Gui;
+using MonoDevelop.Ide.Desktop;
namespace MonoDevelop.Ide.Gui
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FreeDispatchAttribute.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FreeDispatchAttribute.cs
new file mode 100644
index 0000000000..40fbccb92d
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FreeDispatchAttribute.cs
@@ -0,0 +1,35 @@
+// FreeDispatchAttribute.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class FreeDispatchAttribute: Attribute
+ {
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddEntryEventHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs
index 16839b9c50..43ffea1bd4 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/AddEntryEventHandler.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncContext.cs
@@ -1,9 +1,9 @@
-// AddEntryEventHandler.cs
+// GuiSyncContext.cs
//
// Author:
// Lluis Sanchez Gual <lluis@novell.com>
//
-// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -27,36 +27,26 @@
using System;
-using MonoDevelop.Projects;
+using MonoDevelop.Core;
namespace MonoDevelop.Ide.Gui
{
- public delegate void AddEntryEventHandler (object s, AddEntryEventArgs args);
-
- public class AddEntryEventArgs
+ public class GuiSyncContext: SyncContext
{
- string fileName;
- bool cancel;
- SolutionFolder combine;
-
- public AddEntryEventArgs (SolutionFolder combine, string fileName)
+ public override void Dispatch (StatefulMessageHandler cb, object ob)
{
- this.combine = combine;
- this.fileName = fileName;
- }
-
- public SolutionFolder Combine {
- get { return combine; }
+ if (DispatchService.IsGuiThread)
+ cb (ob);
+ else
+ DispatchService.GuiSyncDispatch (cb, ob);
}
- public string FileName {
- get { return fileName; }
- set { fileName = value; }
- }
-
- public bool Cancel {
- get { return cancel; }
- set { cancel = value; }
+ public override void AsyncDispatch (StatefulMessageHandler cb, object ob)
+ {
+ if (DispatchService.IsGuiThread)
+ cb (ob);
+ else
+ DispatchService.GuiDispatch (cb, ob);
}
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncObject.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncObject.cs
new file mode 100644
index 0000000000..92aa2d43dc
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/GuiSyncObject.cs
@@ -0,0 +1,36 @@
+// GuiSyncObject.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+
+namespace MonoDevelop.Ide.Gui
+{
+ [SyncContext (typeof(GuiSyncContext))]
+ public class GuiSyncObject: SyncObject
+ {
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs
deleted file mode 100644
index efc7778069..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HelpOperations.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-//
-// HelpOperations.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using System.Collections;
-using Monodoc;
-using MonoDevelop.Core.Execution;
-using System.IO;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.Ide.Gui
-{
- public class HelpOperations
- {
- ProcessWrapper pw;
- TextWriter outWriter;
- TextWriter errWriter;
- bool firstCall = true;
- bool useExternalMonodoc = false;
-
- public void ShowHelp (string topic)
- {
- if (topic == null || topic.Trim ().Length == 0)
- return;
-
- if (PropertyService.IsMac) {
- var url = "monodoc://" + System.Web.HttpUtility.UrlEncode (topic);
- string mdapp = new FilePath (typeof (HelpOperations).Assembly.Location)
- .ParentDirectory
- .Combine ("..", "..", "..", "MonoDoc.app").FullPath;
- if (Directory.Exists (mdapp))
- System.Diagnostics.Process.Start ("open", "-a \"" + mdapp + "\" " + url + " --args " + RootDirArg);
- else
- System.Diagnostics.Process.Start ("open", url);
- return;
- }
-
- if (firstCall)
- CheckExternalMonodoc ();
-
- if (useExternalMonodoc)
- ShowHelpExternal (topic);
- }
-
- public bool CanShowHelp (string topic)
- {
- return topic != null && !PropertyService.IsWindows;
- }
-
- void CheckExternalMonodoc ()
- {
- firstCall = false;
- try {
- outWriter = new StringWriter ();
- errWriter = new StringWriter ();
- pw = Runtime.ProcessService.StartProcess (
- "monodoc", "--help", "", outWriter, errWriter,
- delegate {
- if (pw.ExitCode != 0)
- MessageService.ShowError (
- String.Format (
- "MonoDoc exited with a exit code = {0}. Error : {1}",
- pw.ExitCode, errWriter.ToString ()));
- pw = null;
- }, true);
-
- pw.WaitForOutput ();
- if (outWriter.ToString ().IndexOf ("--about") > 0)
- useExternalMonodoc = true;
- pw = null;
- } catch (Exception e) {
- MessageService.ShowError (String.Format (
- "Could not start monodoc : {0}", e.ToString ()));
- }
-
- if (!useExternalMonodoc)
- MessageService.ShowError (
- GettextCatalog.GetString ("You need a newer monodoc to use it externally from monodevelop. Using the integrated help viewer now."));
- }
-
- string RootDirArg {
- get {
- //docrootdir only works on Mono 2.6, but 2.4 should just ignore it
- string mdocroot = HelpService.GetMonoDocCacheRoot ();
- if (mdocroot != null)
- return " --docrootdir=\"" + mdocroot + "\" ";
- return "";
- }
- }
-
- void ShowHelpExternal (string topic)
- {
- try {
- if (pw == null || pw.HasExited == true) {
- outWriter = new StringWriter ();
- errWriter = new StringWriter ();
-
- pw = Runtime.ProcessService.StartProcess (
- "monodoc", "--remote-mode" + RootDirArg, "", outWriter, errWriter,
- delegate {
- if (pw.ExitCode == 0)
- return;
-
- MessageService.ShowError (
- String.Format (
- "MonoDoc exited with a exit code = {0}.",
- pw.ExitCode, errWriter.ToString ()));
- pw = null;
- }, true);
- }
-
- if (pw != null && !pw.HasExited) {
- pw.StandardInput.WriteLine (topic);
- Console.WriteLine (outWriter.ToString ());
- Console.WriteLine (errWriter.ToString ());
- }
- } catch (Exception e) {
- MessageService.ShowException (e);
- useExternalMonodoc = false;
- }
- }
-
- public bool CanShowHelp (ResolveResult result)
- {
- return CanShowHelp (HelpService.GetMonoDocHelpUrl (result));
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IBaseViewContent.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IBaseViewContent.cs
index f47893ad39..e7783fbc0f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IBaseViewContent.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IBaseViewContent.cs
@@ -1,4 +1,4 @@
-// IBaseViewContent.cs
+// IBaseViewContent.cs
//
// Author:
// Viktoria Dudka (viktoriad@remobjects.com)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ExitEventHandler.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IMementoCapable.cs
index 06b8d4e5b9..3fddbdcb19 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ExitEventHandler.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IMementoCapable.cs
@@ -1,10 +1,10 @@
//
-// ExitEventHandler.cs
+// IMementoCapable.cs
//
// Author:
-// Lluis Sanchez Gual
+// Mike Krüger <mkrueger@novell.com>
//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,19 +26,15 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
+using MonoDevelop.Core;
namespace MonoDevelop.Ide.Gui
{
- public delegate void ExitEventHandler (object sender, ExitEventArgs args);
-
- public class ExitEventArgs: EventArgs
+ public interface IMementoCapable
{
- bool cancel;
-
- public bool Cancel {
- get { return cancel; }
- set { cancel = value; }
+ ICustomXmlSerializer Memento {
+ get;
+ set;
}
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs
index f79f426371..71b79d820f 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs
@@ -32,7 +32,6 @@ using System.Drawing;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Codons;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components.Docking;
using MonoDevelop.Components.Commands;
@@ -147,9 +146,6 @@ namespace MonoDevelop.Ide.Gui
PadCodon codon;
SdiWorkbenchLayout layout;
- static IPadWindow lastWindow;
- static IPadWindow lastLocationList;
-
internal DockItem Item { get; set; }
internal PadWindow (SdiWorkbenchLayout layout, PadCodon codon)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Ide.cs
deleted file mode 100644
index 4aa26f3afc..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Ide.cs
+++ /dev/null
@@ -1,484 +0,0 @@
-//
-// IdeApp.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using System.Linq;
-using System.Collections;
-
-using System.Net;
-using System.Net.Sockets;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.Instrumentation;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Dialogs;
-using Mono.Addins;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide.Gui.Dialogs;
-
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Ide.Tasks;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Gui;
-using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Ide.CustomTools;
-
-namespace MonoDevelop.Ide.Gui
-{
- public static class IdeApp
- {
- static bool isInitialized;
- static Workbench workbench;
- static ProjectOperations projectOperations;
- static HelpOperations helpOperations;
- static CommandManager commandService;
- static IdeServices ideServices;
- static RootWorkspace workspace;
- static IdePreferences preferences;
-
- public const int CurrentRevision = 5;
-
- static bool isInitialRun;
- static bool isInitialRunAfterUpgrade;
- static int upgradedFromRevision;
-
- public static event ExitEventHandler Exiting;
- public static event EventHandler Exited;
-
- static EventHandler initializedEvent;
- public static event EventHandler Initialized {
- add {
- if (isInitialized) value (null, EventArgs.Empty);
- else initializedEvent += value;
- }
- remove {
- initializedEvent -= value;
- }
- }
-
- static IdeApp ()
- {
- preferences = new IdePreferences ();
- }
-
- public static Workbench Workbench {
- get { return workbench; }
- }
-
- public static ProjectOperations ProjectOperations {
- get { return projectOperations; }
- }
-
- public static RootWorkspace Workspace {
- get { return workspace; }
- }
-
- public static HelpOperations HelpOperations {
- get { return helpOperations; }
- }
-
- public static CommandManager CommandService {
- get { return commandService; }
- }
-
- public static IdeServices Services {
- get { return ideServices; }
- }
-
- public static IdePreferences Preferences {
- get { return preferences; }
- }
-
- public static bool IsInitialized {
- get {
- return isInitialized;
- }
- }
-
- // Returns true if MD is running for the first time after installing
- public static bool IsInitialRun {
- get { return isInitialRun; }
- }
-
- // Returns true if MD is running for the first time after being upgraded from a previous version
- public static bool IsInitialRunAfterUpgrade {
- get { return isInitialRunAfterUpgrade; }
- }
-
- // If IsInitialRunAfterUpgrade is true, returns the previous version
- public static int UpgradedFromRevision {
- get { return upgradedFromRevision; }
- }
-
- public static Version Version {
- get { return new Version (BuildVariables.PackageVersion); }
- }
-
- public static void Initialize (IProgressMonitor monitor)
- {
- Counters.Initialization.Trace ("Creating Workbench");
- workbench = new Workbench ();
- Counters.Initialization.Trace ("Creating Root Workspace");
- workspace = new RootWorkspace ();
- Counters.Initialization.Trace ("Creating Services");
- projectOperations = new ProjectOperations ();
- helpOperations = new HelpOperations ();
- commandService = new CommandManager ();
- ideServices = new IdeServices ();
- CustomToolService.Init ();
-
- commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted;
- commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished;
-
- KeyBindingService.LoadBindingsFromExtensionPath ("/MonoDevelop/Ide/KeyBindingSchemes");
- KeyBindingService.LoadCurrentBindings ("MD2");
-
- commandService.CommandError += delegate (object sender, CommandErrorArgs args) {
- MessageService.ShowException (args.Exception, args.ErrorMessage);
- };
-
- FileService.ErrorHandler = FileServiceErrorHandler;
-
- monitor.BeginTask (GettextCatalog.GetString("Loading Workbench"), 5);
- Counters.Initialization.Trace ("Loading Commands");
-
- commandService.LoadCommands ("/MonoDevelop/Ide/Commands");
- monitor.Step (1);
-
- Counters.Initialization.Trace ("Initializing Workbench");
- workbench.Initialize (monitor);
- monitor.Step (1);
-
- // register string tag provider (TODO: move to add-in tree :)
- StringParserService.RegisterStringTagProvider (new MonoDevelop.Ide.Commands.DefaultStringTagProvider ());
-
- InternalLog.EnableErrorNotification ();
-
- monitor.Step (1);
-
- Counters.Initialization.Trace ("Restoring Workbench State");
- workbench.Show ("SharpDevelop.Workbench.WorkbenchMemento");
- monitor.Step (1);
-
- Counters.Initialization.Trace ("Flushing GUI events");
- DispatchService.RunPendingEvents ();
- Counters.Initialization.Trace ("Flushed GUI events");
-
- MessageService.RootWindow = workbench.RootWindow;
-
- commandService.EnableIdleUpdate = true;
-
- // Default file format
-
- IdeApp.Services.ProjectService.DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
- IdeApp.Preferences.DefaultProjectFileFormatChanged += delegate {
- IdeApp.Services.ProjectService.DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat;
- };
-
- // Perser service initialization
- MonoDevelop.Projects.Dom.Parser.ProjectDomService.TrackFileChanges = true;
- MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory ();
-
-
- // Startup commands
- Counters.Initialization.Trace ("Running Startup Commands");
- AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged);
- monitor.EndTask ();
-
- // Set initial run flags
- Counters.Initialization.Trace ("Upgrading Settings");
-
- if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) {
- isInitialRun = true;
- PropertyService.Set ("MonoDevelop.Core.FirstRun", false);
- PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
- PropertyService.Set ("MonoDevelop.Core.LastRunVersion", CurrentRevision);
- PropertyService.SaveProperties ();
- }
-
- string lastVersion = PropertyService.Get ("MonoDevelop.Core.LastRunVersion", "1.9.1");
- int lastRevision = PropertyService.Get ("MonoDevelop.Core.LastRunRevision", 0);
- if (lastRevision != CurrentRevision && !isInitialRun) {
- isInitialRunAfterUpgrade = true;
- if (lastRevision == 0) {
- switch (lastVersion) {
- case "1.0": lastRevision = 1; break;
- case "2.0": lastRevision = 2; break;
- case "2.2": lastRevision = 3; break;
- case "2.2.1": lastRevision = 4; break;
- }
- }
- upgradedFromRevision = lastRevision;
- PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion);
- PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision);
- PropertyService.SaveProperties ();
- }
-
- // The ide is now initialized
-
- isInitialized = true;
-
- if (isInitialRun) {
- try {
- OnInitialRun ();
- } catch (Exception e) {
- LoggingService.LogError ("Error found while initializing the IDE", e);
- }
- }
-
- if (isInitialRunAfterUpgrade) {
- try {
- OnUpgraded (upgradedFromRevision);
- } catch (Exception e) {
- LoggingService.LogError ("Error found while initializing the IDE", e);
- }
- }
-
- if (initializedEvent != null)
- initializedEvent (null, EventArgs.Empty);
-
- // Load requested files
- Counters.Initialization.Trace ("Opening Files");
- OpenFiles (StartupInfo.GetRequestedFileList ());
-
- // load previous combine
- if ((bool)PropertyService.Get("SharpDevelop.LoadPrevProjectOnStartup", false)) {
- RecentOpen recentOpen = Workbench.RecentOpen;
-
- if (recentOpen.RecentProjectsCount > 0) {
- IdeApp.Workspace.OpenWorkspaceItem(recentOpen.RecentProjects.First ().ToString()).WaitForCompleted ();
- }
- }
-
- commandService.CommandSelected += OnCommandSelected;
- commandService.CommandDeselected += OnCommandDeselected;
-
- //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS
- MonoDevelop.Projects.HelpService.AsyncInitialize ();
-
- UpdateInstrumentationIcon ();
- IdeApp.Preferences.EnableInstrumentationChanged += delegate {
- UpdateInstrumentationIcon ();
- };
- }
-
- //this method is MIT/X11, 2009, Michael Hutchinson / (c) Novell
- public static void OpenFiles (System.Collections.Generic.IList<string> files)
- {
- if (files.Count == 0)
- return;
-
- if (!IsInitialized) {
- EventHandler onInit = null;
- onInit = delegate {
- Initialized -= onInit;
- OpenFiles (files);
- };
- Initialized += onInit;
- return;
- }
-
- var filteredFiles = new System.Collections.Generic.List<string> ();
-
- //open the firsts sln/workspace file, and remove the others from the list
- //FIXME: can we handle multiple slns?
- bool foundSln = false;
- foreach (string file in files) {
- if (Services.ProjectService.IsWorkspaceItemFile (file)) {
- if (!foundSln) {
- try {
- Workspace.OpenWorkspaceItem (file);
- foundSln = true;
- } catch (Exception ex) {
- LoggingService.LogError ("Unhandled error opening solution/workspace \"" + file + "\"", ex);
- MessageService.ShowException (ex, "Could not load solution: " + file);
- }
- }
- } else {
- filteredFiles.Add (file);
- }
- }
-
- foreach (string file in filteredFiles) {
- try {
- Workbench.OpenDocument (file);
- } catch (Exception ex) {
- LoggingService.LogError ("Unhandled error opening file \"" + file + "\"", ex);
- MessageService.ShowException (ex, "Could not open file: " + file);
- }
- }
-
- Workbench.Present ();
- }
-
- static bool FileServiceErrorHandler (string message, Exception ex)
- {
- MessageService.ShowException (ex, message);
- return true;
- }
-
- static void OnExtensionChanged (object s, ExtensionNodeEventArgs args)
- {
- if (args.Change == ExtensionChange.Add) {
- try {
- if (typeof(CommandHandler).IsInstanceOfType (args.ExtensionObject))
- typeof(CommandHandler).GetMethod ("Run", System.Reflection.BindingFlags.NonPublic|System.Reflection.BindingFlags.Instance, null, Type.EmptyTypes, null).Invoke (args.ExtensionObject, null);
- else
- LoggingService.LogError ("Type " + args.ExtensionObject.GetType () + " must be a subclass of MonoDevelop.Components.Commands.CommandHandler");
- } catch (Exception ex) {
- LoggingService.LogError (ex.ToString ());
- }
- }
- }
-
- static void OnCommandSelected (object s, CommandSelectedEventArgs args)
- {
- string msg = args.CommandInfo.Description;
- if (string.IsNullOrEmpty (msg)) {
- msg = args.CommandInfo.Text;
- // only replace _ outside of markup: usecase : Field <b>some_field</b>
- int idx = msg.IndexOf ('<');
- if (idx < 0)
- idx = msg.Length;
- msg = msg.Substring (0, idx).Replace ("_", "") + msg.Substring (idx);
- }
- if (!string.IsNullOrEmpty (msg))
- Workbench.StatusBar.ShowMessage (msg, args.CommandInfo.UseMarkup);
- }
-
- static void OnCommandDeselected (object s, EventArgs args)
- {
- Workbench.StatusBar.ShowReady ();
- }
-
- public static void Run ()
- {
- // finally run the workbench window ...
- Gtk.Application.Run ();
- }
-
- public static void Exit ()
- {
- if (workbench.Close ())
- Gtk.Application.Quit ();
- }
-
- internal static bool OnExit ()
- {
- if (Exiting != null) {
- ExitEventArgs args = new ExitEventArgs ();
- Exiting (null, args);
- return !args.Cancel;
- }
- return true;
- }
-
- internal static void OnExited ()
- {
- if (Exited != null)
- Exited (null, EventArgs.Empty);
- }
-
- static void OnInitialRun ()
- {
- Workbench.ResetToolbars ();
- SetInitialLayout ();
- }
-
- static void OnUpgraded (int previousRevision)
- {
- // Upgrade to latest msbuild version
- if (IdeApp.Preferences.DefaultProjectFileFormat.StartsWith ("MSBuild"))
- IdeApp.Preferences.DefaultProjectFileFormat = MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.DefaultFormat;
-
- if (previousRevision <= 3) {
- // Reset the current runtime when upgrading from <2.2, to ensure the default runtime is not stuck to an old mono install
- IdeApp.Preferences.DefaultTargetRuntime = Runtime.SystemAssemblyService.CurrentRuntime;
-
- if (PropertyService.Get ("MonoDevelop.Core.Gui.Pads.UseCustomFont", false))
- IdeApp.Preferences.CustomPadFont = PropertyService.Get<string> ("MonoDevelop.Core.Gui.Pads.CustomFont", null);
- }
- if (previousRevision < 5)
- SetInitialLayout ();
- }
-
- static void SetInitialLayout ()
- {
- if (!IdeApp.Workbench.Layouts.Contains ("Solution")) {
- // Create the Solution layout, based on Default
- IdeApp.Workbench.CurrentLayout = "Default";
- IdeApp.Workbench.CurrentLayout = "Solution";
- IdeApp.Workbench.CurrentLayout = "Default";
- IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectSolutionPad> ().Visible = false;
- IdeApp.Workbench.GetPad<FileScout> ().Visible = false;
- IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ClassBrowser.ClassBrowserPad> ().Visible = false;
- foreach (Pad p in IdeApp.Workbench.Pads) {
- if (p.Visible)
- p.AutoHide = true;
- }
- }
- }
-
- static ITimeTracker commandTimeCounter;
-
- static void CommandServiceCommandTargetScanStarted (object sender, EventArgs e)
- {
- commandTimeCounter = Counters.CommandTargetScanTime.BeginTiming ();
- }
-
- static void CommandServiceCommandTargetScanFinished (object sender, EventArgs e)
- {
- commandTimeCounter.End ();
- }
-
- static MonoDevelop.Ide.MonoDevelopStatusBar.StatusIcon instrumentationStatusIcon;
- static void UpdateInstrumentationIcon ()
- {
- if (IdeApp.Preferences.EnableInstrumentation) {
- if (instrumentationStatusIcon == null) {
- instrumentationStatusIcon = IdeApp.Workbench.StatusBar.ShowStatusIcon (ImageService.GetPixbuf (Gtk.Stock.DialogInfo));
- instrumentationStatusIcon.ToolTip = "Instrumentation service enabled";
- instrumentationStatusIcon.EventBox.ButtonPressEvent += delegate {
- InstrumentationService.StartMonitor ();
- };
- }
- } else if (instrumentationStatusIcon != null) {
- instrumentationStatusIcon.Dispose ();
- }
- }
- }
-
- public class IdeServices
- {
- public ProjectService ProjectService {
- get { return MonoDevelop.Projects.Services.ProjectService; }
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdePreferences.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdePreferences.cs
deleted file mode 100644
index 78a3380e86..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdePreferences.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-// IdePreferences.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Assemblies;
-
-namespace MonoDevelop.Ide.Gui
-{
- public enum JumpToFirst {
- Never,
- Error,
- ErrorOrWarning
- }
-
- public enum BuildResultStates {
- Never,
- Always,
- OnErrors,
- OnErrorsOrWarnings
- }
-
- public enum ShowMessageBubbles {
- Never,
- ForErrors,
- ForErrorsAndWarnings
- }
-
- public enum WorkbenchCompactness
- {
- VerySpacious,
- Spacious,
- Normal,
- Compact,
- VeryCompact
- }
-
- public class IdePreferences
- {
- internal IdePreferences ()
- {
- }
-
- public string DefaultProjectFileFormat {
- get { return PropertyService.Get ("MonoDevelop.DefaultFileFormat", MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.DefaultFormat); }
- set { PropertyService.Set ("MonoDevelop.DefaultFileFormat", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> DefaultProjectFileFormatChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.DefaultFileFormat", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.DefaultFileFormat", value); }
- }
-
- public bool LoadPrevSolutionOnStartup {
- get { return PropertyService.Get ("SharpDevelop.LoadPrevProjectOnStartup", false); }
- set { PropertyService.Set ("SharpDevelop.LoadPrevProjectOnStartup", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> LoadPrevSolutionOnStartupChanged {
- add { PropertyService.AddPropertyHandler ("SharpDevelop.LoadPrevProjectOnStartup", value); }
- remove { PropertyService.RemovePropertyHandler ("SharpDevelop.LoadPrevProjectOnStartup", value); }
- }
-
- public bool CreateFileBackupCopies {
- get { return PropertyService.Get ("SharpDevelop.CreateBackupCopy", false); }
- set { PropertyService.Set ("SharpDevelop.CreateBackupCopy", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> CreateFileBackupCopiesChanged {
- add { PropertyService.AddPropertyHandler ("SharpDevelop.CreateBackupCopy", value); }
- remove { PropertyService.RemovePropertyHandler ("SharpDevelop.CreateBackupCopy", value); }
- }
-
- public bool LoadDocumentUserProperties {
- get { return PropertyService.Get ("SharpDevelop.LoadDocumentProperties", true); }
- set { PropertyService.Set ("SharpDevelop.LoadDocumentProperties", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> LoadDocumentUserPropertiesChanged {
- add { PropertyService.AddPropertyHandler ("SharpDevelop.LoadDocumentProperties", value); }
- remove { PropertyService.RemovePropertyHandler ("SharpDevelop.LoadDocumentProperties", value); }
- }
-
- public bool BuildBeforeExecuting {
- get { return PropertyService.Get ("MonoDevelop.Ide.BuildBeforeExecuting", true); }
- set { PropertyService.Set ("MonoDevelop.Ide.BuildBeforeExecuting", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> BuildBeforeExecutingChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.BuildBeforeExecuting", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.BuildBeforeExecuting", value); }
- }
-
- /*public BuildResultStates ShowOutputPadDuringBuild {
- get { return PropertyService.Get ("MonoDevelop.Ide.ShowOutputPadDuringBuild", BuildResultStates.Never); }
- set { PropertyService.Set ("MonoDevelop.Ide.ShowOutputPadDuringBuild", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ShowOutputPadShowOutputPadDuringBuildChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.ShowOutputPadDuringBuild", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.ShowOutputPadDuringBuild", value); }
- }*/
-
- public BuildResultStates ShowOutputPadAfterBuild {
- get { return PropertyService.Get ("MonoDevelop.Ide.ShowOutputPadAfterBuild", BuildResultStates.Never); }
- set { PropertyService.Set ("MonoDevelop.Ide.ShowOutputPadAfterBuild", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ShowOutputPadAfterBuildChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.ShowOutputPadAfterBuild", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.ShowOutputPadAfterBuild", value); }
- }
- /*
- public BuildResultStates ShowErrorPadDuringBuild {
- get { return PropertyService.Get ("MonoDevelop.Ide.ShowErrorPadDuringBuild", BuildResultStates.Never); }
- set { PropertyService.Set ("MonoDevelop.Ide.ShowErrorPadDuringBuild", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ShowErrorPadDuringBuildChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.ShowErrorPadDuringBuild", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.ShowErrorPadDuringBuild", value); }
- }*/
-
- public BuildResultStates ShowErrorPadAfterBuild {
- get { return PropertyService.Get ("MonoDevelop.Ide.ShowErrorPadAfterBuild", BuildResultStates.Never); }
- set { PropertyService.Set ("MonoDevelop.Ide.ShowErrorPadAfterBuild", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ShowErrorPadAfterBuildChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.ShowErrorPadAfterBuild", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.ShowErrorPadAfterBuild", value); }
- }
-
- public JumpToFirst JumpToFirstErrorOrWarning {
- get { return PropertyService.Get ("MonoDevelop.Ide.JumpToFirstErrorOrWarning", JumpToFirst.Error); }
- set { PropertyService.Set ("MonoDevelop.Ide.JumpToFirstErrorOrWarning", value); }
- }
-
- public ShowMessageBubbles ShowMessageBubbles {
- get { return PropertyService.Get ("MonoDevelop.Ide.ShowMessageBubbles", ShowMessageBubbles.ForErrorsAndWarnings); }
- set { PropertyService.Set ("MonoDevelop.Ide.ShowMessageBubbles", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ShowMessageBubblesChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.ShowMessageBubbles", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.ShowMessageBubbles", value); }
- }
-
- public BeforeCompileAction BeforeBuildSaveAction {
- get { return PropertyService.Get ("MonoDevelop.Ide.BeforeCompileAction", BeforeCompileAction.SaveAllFiles); }
- set { PropertyService.Set ("MonoDevelop.Ide.BeforeCompileAction", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> BeforeBuildSaveActionChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.BeforeCompileAction", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.BeforeCompileAction", value); }
- }
-
- public bool RunWithWarnings {
- get { return PropertyService.Get ("MonoDevelop.Ide.RunWithWarnings", true); }
- set { PropertyService.Set ("MonoDevelop.Ide.RunWithWarnings", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> RunWithWarningsChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.RunWithWarnings", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.RunWithWarnings", value); }
- }
-
- public TargetRuntime DefaultTargetRuntime {
- get {
- string id = PropertyService.Get ("MonoDevelop.Ide.DefaultTargetRuntime", "__current");
- if (id == "__current")
- return Runtime.SystemAssemblyService.CurrentRuntime;
- TargetRuntime tr = Runtime.SystemAssemblyService.GetTargetRuntime (id);
- return tr ?? Runtime.SystemAssemblyService.CurrentRuntime;
- }
- set { PropertyService.Set ("MonoDevelop.Ide.DefaultTargetRuntime", value.IsRunning ? "__current" : value.Id); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> DefaultTargetRuntimeChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.DefaultTargetRuntime", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.DefaultTargetRuntime", value); }
- }
-
- public Gtk.IconSize ToolbarSize {
- get { return PropertyService.Get ("MonoDevelop.ToolbarSize", Gtk.IconSize.Menu); }
- set { PropertyService.Set ("MonoDevelop.ToolbarSize", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> ToolbarSizeChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.ToolbarSize", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.ToolbarSize", value); }
- }
-
- public bool BuildWithMSBuild {
- get { return PropertyService.Get ("MonoDevelop.Ide.BuildWithMSBuild", false); }
- set { PropertyService.Set ("MonoDevelop.Ide.BuildWithMSBuild", value); }
- }
-
- public bool EnableInstrumentation {
- get { return PropertyService.Get ("MonoDevelop.EnableInstrumentation", false); }
- set { PropertyService.Set ("MonoDevelop.EnableInstrumentation", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> EnableInstrumentationChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.EnableInstrumentation", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.EnableInstrumentation", value); }
- }
-
- /// <summary>
- /// Font to use for treeview pads. Returns null if no custom font is set.
- /// </summary>
- public string CustomPadFont {
- get { string res = PropertyService.Get<string> ("MonoDevelop.Ide.CustomPadFont", string.Empty); return string.IsNullOrEmpty (res) ? null : res; }
- set { PropertyService.Set ("MonoDevelop.Ide.CustomPadFont", value ?? string.Empty); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> CustomPadFontChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.CustomPadFont", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.CustomPadFont", value); }
- }
-
- /// <summary>
- /// Font to use for output pads. Returns null if no custom font is set.
- /// </summary>
- public string CustomOutputPadFont {
- get { string res = PropertyService.Get<string> ("MonoDevelop.Ide.CustomOutputPadFont", string.Empty); return string.IsNullOrEmpty (res) ? null : res; }
- set { PropertyService.Set ("MonoDevelop.Ide.CustomOutputPadFont", value ?? string.Empty); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> CustomOutputPadFontChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.CustomOutputPadFont", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.CustomOutputPadFont", value); }
- }
-
- public string UserInterfaceLanguage {
- get { return PropertyService.Get ("MonoDevelop.Ide.UserInterfaceLanguage", ""); }
- set { PropertyService.Set ("MonoDevelop.Ide.UserInterfaceLanguage", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> UserInterfaceLanguageChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.UserInterfaceLanguage", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.UserInterfaceLanguage", value); }
- }
-
- public string UserInterfaceTheme {
- get { return PropertyService.Get ("MonoDevelop.Ide.UserInterfaceTheme", ""); }
- set { PropertyService.Set ("MonoDevelop.Ide.UserInterfaceTheme", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> UserInterfaceThemeChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.UserInterfaceTheme", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.UserInterfaceTheme", value); }
- }
-
- public WorkbenchCompactness WorkbenchCompactness {
- get { return PropertyService.Get ("MonoDevelop.Ide.WorkbenchCompactness", WorkbenchCompactness.Normal); }
- set { PropertyService.Set ("MonoDevelop.Ide.WorkbenchCompactness", value); }
- }
-
- public event EventHandler<PropertyChangedEventArgs> WorkbenchCompactnessChanged {
- add { PropertyService.AddPropertyHandler ("MonoDevelop.Ide.WorkbenchCompactness", value); }
- remove { PropertyService.RemovePropertyHandler ("MonoDevelop.Ide.WorkbenchCompactness", value); }
- }
- }
-
- public enum BeforeCompileAction {
- Nothing,
- SaveAllFiles,
- PromptForSave,
- }
-
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdeStartup.cs
deleted file mode 100644
index 9cbebaaf80..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IdeStartup.cs
+++ /dev/null
@@ -1,497 +0,0 @@
-//
-// IdeStartup.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using System.IO;
-using System.Collections;
-using System.Reflection;
-using System.Xml;
-using System.Threading;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Diagnostics;
-
-using Mono.Unix;
-
-using Mono.Addins;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Gui.Dialogs;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Projects.Gui;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Core.Execution;
-
-namespace MonoDevelop.Ide.Gui
-{
- public class IdeStartup: IApplication
- {
- Socket listen_socket = null;
- ArrayList errorsList = new ArrayList ();
- bool initialized;
- internal static string DefaultTheme;
- static readonly int ipcBasePort = 40000;
-
- public int Run (string[] args)
- {
- Counters.Initialization.BeginTiming ();
-
- var options = new MonoDevelopOptions ();
- var optionsSet = new Mono.Options.OptionSet () {
- { "nologo", "Do not display splash screen.", s => options.NoLogo = true },
- { "ipc-tcp", "Use the Tcp channel for inter-process comunication.", s => options.IpcTcp = true },
- { "newwindow", "Do not open in an existing instance of MonoDevelop", s => options.NewWindow = true },
- { "h|?|help", "Show help", s => options.ShowHelp = true },
- };
- var remainingArgs = optionsSet.Parse (args);
- if (options.ShowHelp) {
- Console.WriteLine ("MonoDevelop IDE " + MonoDevelop.Ide.BuildVariables.PackageVersionLabel);
- Console.WriteLine ("Options:");
- optionsSet.WriteOptionDescriptions (Console.Out);
- return 0;
- }
-
- Counters.Initialization.Trace ("Initializing GTK");
- SetupExceptionManager ();
-
- try {
- MonoDevelop.Core.Gui.GLibLogging.Enabled = true;
- } catch (Exception ex) {
- LoggingService.LogError ("Error initialising GLib logging.", ex);
- }
-
- //OSXFIXME
- Gtk.Application.Init ("monodevelop", ref args);
- InternalLog.Initialize ();
- string socket_filename = null;
- EndPoint ep = null;
-
- AddinManager.AddinLoadError += OnAddinError;
-
- StartupInfo.SetCommandLineArgs (remainingArgs.ToArray ());
-
- // If a combine was specified, force --newwindow.
-
- if(!options.NewWindow && StartupInfo.HasFiles) {
- Counters.Initialization.Trace ("Pre-Initializing Runtime to load files in existing window");
- Runtime.Initialize (true);
- foreach (string file in StartupInfo.GetRequestedFileList ()) {
- if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile (file))
- {
- options.NewWindow = true;
- break;
- }
- }
- }
-
- DefaultTheme = Gtk.Settings.Default.ThemeName;
- if (!string.IsNullOrEmpty (IdeApp.Preferences.UserInterfaceTheme))
- Gtk.Settings.Default.ThemeName = IdeApp.Preferences.UserInterfaceTheme;
-
- //don't show the splash screen on the Mac, so instead we get the expected "Dock bounce" effect
- //this also enables the Mac platform service to subscribe to open document events before the GUI loop starts.
- if (PropertyService.IsMac)
- options.NoLogo = true;
-
- IProgressMonitor monitor;
- if (options.NoLogo) {
- monitor = new MonoDevelop.Core.ProgressMonitoring.ConsoleProgressMonitor ();
- } else {
- monitor = SplashScreenForm.SplashScreen;
- SplashScreenForm.SplashScreen.ShowAll ();
- }
-
- Counters.Initialization.Trace ("Initializing Runtime");
- monitor.BeginTask (GettextCatalog.GetString ("Starting MonoDevelop"), 2);
- monitor.Step (1);
- Runtime.Initialize (true);
-
- //make sure that the platform service is initialised so that the Mac platform can subscribe to open-document events
- Counters.Initialization.Trace ("Initializing Platform Service");
- DesktopService.Initialize ();
- monitor.Step (1);
- monitor.EndTask ();
-
- monitor.Step (1);
-
- if (options.IpcTcp) {
- listen_socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
- ep = new IPEndPoint (IPAddress.Loopback, ipcBasePort + HashSDBMBounded (Environment.UserName));
- } else {
- socket_filename = "/tmp/md-" + Environment.GetEnvironmentVariable ("USER") + "-socket";
- listen_socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
- ep = new UnixEndPoint (socket_filename);
- }
-
- // If not opening a combine, connect to existing monodevelop and pass filename(s) and exit
- if (!options.NewWindow && StartupInfo.GetRequestedFileList ().Length > 0) {
- try {
- listen_socket.Connect (ep);
- listen_socket.Send (Encoding.UTF8.GetBytes (String.Join ("\n", StartupInfo.GetRequestedFileList ())));
- return 0;
- } catch {
- // Reset the socket
- if (null != socket_filename && File.Exists (socket_filename))
- File.Delete (socket_filename);
- }
- }
-
- Counters.Initialization.Trace ("Checking System");
- string version = Assembly.GetEntryAssembly ().GetName ().Version.Major + "." + Assembly.GetEntryAssembly ().GetName ().Version.Minor;
-
- if (Assembly.GetEntryAssembly ().GetName ().Version.Build != 0)
- version += "." + Assembly.GetEntryAssembly ().GetName ().Version.Build;
- if (Assembly.GetEntryAssembly ().GetName ().Version.Revision != 0)
- version += "." + Assembly.GetEntryAssembly ().GetName ().Version.Revision;
-
- // System checks
- if (!CheckBug77135 ())
- return 1;
-
- if (!CheckQtCurve ())
- return 1;
-
- CheckFileWatcher ();
-
- Exception error = null;
- int reportedFailures = 0;
-
- try {
- Counters.Initialization.Trace ("Loading Icons");
- //force initialisation before the workbench so that it can register stock icons for GTK before they get requested
- MonoDevelop.Core.Gui.ImageService.Initialize ();
-
- if (errorsList.Count > 0) {
- if (monitor is SplashScreenForm)
- SplashScreenForm.SplashScreen.Hide ();
- AddinLoadErrorDialog dlg = new AddinLoadErrorDialog ((AddinError[]) errorsList.ToArray (typeof(AddinError)), false);
- if (!dlg.Run ())
- return 1;
- if (monitor is SplashScreenForm)
- SplashScreenForm.SplashScreen.Show ();
- reportedFailures = errorsList.Count;
- }
-
- // no alternative for Application.ThreadException?
- // Application.ThreadException += new ThreadExceptionEventHandler(ShowErrorBox);
-
- Counters.Initialization.Trace ("Initializing IdeApp");
- IdeApp.Initialize (monitor);
- monitor.Step (1);
-
- } catch (Exception e) {
- error = e;
- } finally {
- monitor.Dispose ();
- }
-
- if (error != null) {
- MessageService.ShowException (error,
- GettextCatalog.GetString ("MonoDevelop failed to start. The following error has been reported: ") + error.Message);
- return 1;
- }
-
- if (errorsList.Count > reportedFailures) {
- AddinLoadErrorDialog dlg = new AddinLoadErrorDialog ((AddinError[]) errorsList.ToArray (typeof(AddinError)), true);
- dlg.Run ();
- }
-
- errorsList = null;
-
- // FIXME: we should probably track the last 'selected' one
- // and do this more cleanly
- try {
- listen_socket.Bind (ep);
- listen_socket.Listen (5);
- listen_socket.BeginAccept (new AsyncCallback (ListenCallback), listen_socket);
- } catch {
- // Socket already in use
- }
-
- initialized = true;
- MessageService.RootWindow = IdeApp.Workbench.RootWindow;
- Thread.CurrentThread.Name = "GUI Thread";
- Counters.Initialization.Trace ("Running IdeApp");
- Counters.Initialization.EndTiming ();
- IdeApp.Run ();
-
- // unloading services
- if (null != socket_filename)
- File.Delete (socket_filename);
-
- Runtime.Shutdown ();
- System.Environment.Exit (0);
- return 0;
- }
-
- public bool Initialized {
- get { return initialized; }
- }
-
- void OnAddinError (object s, AddinErrorEventArgs args)
- {
- if (errorsList != null)
- errorsList.Add (new AddinError (args.AddinId, args.Message, args.Exception, false));
- }
-
- void ListenCallback (IAsyncResult state)
- {
- Socket sock = (Socket)state.AsyncState;
-
- Socket client = sock.EndAccept (state);
- ((Socket)state.AsyncState).BeginAccept (new AsyncCallback (ListenCallback), sock);
- byte[] buf = new byte[1024];
- client.Receive (buf);
- foreach (string filename in Encoding.UTF8.GetString (buf).Split ('\n')) {
- string trimmed = filename.Trim ();
- string file = "";
- foreach (char c in trimmed) {
- if (c == 0x0000)
- continue;
- file += c;
- }
- GLib.Idle.Add (delegate(){ return openFile (file); });
- }
- }
-
- bool openFile (string file)
- {
- if (string.IsNullOrEmpty (file))
- return false;
-
- Match fileMatch = StartupInfo.fileExpression.Match (file);
- if (null == fileMatch || !fileMatch.Success)
- return false;
-
- int line = 1,
- column = 1;
-
- file = fileMatch.Groups["filename"].Value;
- if (fileMatch.Groups["line"].Success)
- int.TryParse (fileMatch.Groups["line"].Value, out line);
- if (fileMatch.Groups["column"].Success)
- int.TryParse (fileMatch.Groups["column"].Value, out column);
-
- if (MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile (file)) {
- try {
- IdeApp.Workspace.OpenWorkspaceItem (file);
- } catch {
- }
- } else {
- try {
- LoggingService.LogError ("Opening {0} at {1}:{2}", file, line, column);
- IdeApp.Workbench.OpenDocument (file, line, column, true);
- } catch {
- }
- }
- IdeApp.Workbench.Present ();
- return false;
- }
-
- bool CheckQtCurve ()
- {
- if (Gtk.Settings.Default.ThemeName == "QtCurve") {
- string msg = "QtCurve theme not supported";
- string desc = "Your system is using the QtCurve GTK+ theme. This theme is known to cause stability issues in MonoDevelop. Please select another theme in the GTK+ Theme Selector.\n\nIf you click on Proceed, MonoDevelop will switch to the default GTK+ theme.";
- AlertButton res = MessageService.GenericAlert (Gtk.Stock.DialogWarning, msg, desc, AlertButton.Cancel, AlertButton.Proceed);
- if (res == AlertButton.Cancel)
- return false;
- Gtk.Settings.Default.ThemeName = "Gilouche";
- }
- return true;
- }
-
- void CheckFileWatcher ()
- {
- string watchesFile = "/proc/sys/fs/inotify/max_user_watches";
- try {
- if (File.Exists (watchesFile)) {
- string val = File.ReadAllText (watchesFile);
- int n = int.Parse (val);
- if (n <= 9000) {
- string msg = "Inotify watch limit is too low (" + n + ").\n";
- msg += "MonoDevelop will switch to managed file watching.\n";
- msg += "See http://monodevelop.com/Inotify_Watches_Limit for more info.";
- LoggingService.LogWarning (msg);
- Runtime.ProcessService.EnvironmentVariableOverrides["MONO_MANAGED_WATCHER"] =
- Environment.GetEnvironmentVariable ("MONO_MANAGED_WATCHER");
- Environment.SetEnvironmentVariable ("MONO_MANAGED_WATCHER", "1");
- }
- }
- } catch (Exception e) {
- LoggingService.LogWarning ("There was a problem checking whether to use managed file watching", e);
- }
- }
-
- bool CheckBug77135 ()
- {
- try {
- // Check for bug 77135. Some versions of gnome-vfs2 and libgda
- // make MD crash in the file open dialog or in FileIconLoader.
- // Only in Suse.
-
- string path = "/etc/SuSE-release";
- if (!File.Exists (path))
- return true;
-
- // Only run the check for SUSE 10
- StreamReader sr = File.OpenText (path);
- string txt = sr.ReadToEnd ();
- sr.Close ();
-
- if (txt.IndexOf ("SUSE LINUX 10") == -1)
- return true;
-
- string current_libgda;
- string current_gnomevfs;
- string required_libgda = "1.3.91.5.4";
- string required_gnomevfs = "2.12.0.9.2";
-
- StringWriter sw = new StringWriter ();
- ProcessWrapper pw = Runtime.ProcessService.StartProcess ("rpm", "--qf %{version}.%{release} -q libgda", null, sw, null, null);
- pw.WaitForOutput ();
- current_libgda = sw.ToString ().Trim (' ','\n');
-
- sw = new StringWriter ();
- pw = Runtime.ProcessService.StartProcess ("rpm", "--qf %{version}.%{release} -q gnome-vfs2", null, sw, null, null);
- pw.WaitForOutput ();
- current_gnomevfs = sw.ToString ().Trim (' ','\n');
-
- bool fail1 = Addin.CompareVersions (current_libgda, required_libgda) == 1;
- bool fail2 = Addin.CompareVersions (current_gnomevfs, required_gnomevfs) == 1;
-
- if (fail1 || fail2) {
- string msg = GettextCatalog.GetString ("Some packages installed in your system are not compatible with MonoDevelop:\n");
- if (fail1)
- msg += "\nlibgda " + current_libgda + " ("+ GettextCatalog.GetString ("version required: {0}", required_libgda) + ")";
- if (fail2)
- msg += "\ngnome-vfs2 " + current_gnomevfs + " ("+ GettextCatalog.GetString ("version required: {0}", required_gnomevfs) + ")";
- msg += "\n\n";
- msg += GettextCatalog.GetString ("You need to upgrade the previous packages to start using MonoDevelop.");
-
- SplashScreenForm.SplashScreen.Hide ();
- Gtk.MessageDialog dlg = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, msg);
- dlg.Run ();
- dlg.Destroy ();
-
- return false;
- } else
- return true;
- }
- catch (Exception ex)
- {
- // Just ignore for now.
- Console.WriteLine (ex);
- return true;
- }
- }
-
- void SetupExceptionManager ()
- {
- GLib.ExceptionManager.UnhandledException += delegate (GLib.UnhandledExceptionArgs args) {
- var ex = (Exception)args.ExceptionObject;
- LoggingService.LogError ("Unhandled Exception", ex);
- MessageService.ShowException (ex, "Unhandled Exception");
- };
- AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs args) {
- //FIXME: try to save all open files, since we can't prevent the runtime from terminating
- var ex = (Exception)args.ExceptionObject;
- LoggingService.LogFatalError ("Unhandled Exception", ex);
- MessageService.ShowException (ex, "Unhandled Exception. MonoDevelop will now close.");
- };
- }
-
- /// <summary>
- /// Implementation of sdbm-style hash, bounded to a range of 1000.
- /// </summary>
- public static int HashSDBMBounded (string input)
- {
- ulong hash = 0;
-
- try {
- foreach (char c in input)
- hash = (ulong)char.GetNumericValue (c) + (hash << 6) + (hash << 16) - hash;
- } catch {
- // If we overflow, return the intermediate result
- }
-
- return (int)(hash % 1000);
- }
- }
-
-#pragma warning disable 0618
- public class MonoDevelopOptions
- {
- public MonoDevelopOptions ()
- {
- IpcTcp = (PlatformID.Unix != Environment.OSVersion.Platform);
- }
-
- public bool NoLogo { get; set; }
- public bool IpcTcp { get; set; }
- public bool NewWindow { get; set; }
- public bool ShowHelp { get; set; }
- }
-
-#pragma warning restore 0618
-
- public class AddinError
- {
- string addinFile;
- Exception exception;
- bool fatal;
- string message;
-
- public AddinError (string addin, string message, Exception exception, bool fatal)
- {
- this.addinFile = addin;
- this.message = message;
- this.exception = exception;
- this.fatal = fatal;
- }
-
- public string AddinFile {
- get { return addinFile; }
- }
-
- public string Message {
- get { return message; }
- }
-
- public Exception Exception {
- get { return exception; }
- }
-
- public bool Fatal {
- get { return fatal; }
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs
index d11831d646..a1a354e0d8 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/InternalLog.cs
@@ -90,7 +90,7 @@ namespace MonoDevelop.Ide.Gui
if (!errorNotificationEnabled)
return;
ClearErrorIcon ();
- Gdk.Pixbuf pix = MonoDevelop.Core.Gui.ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Menu);
+ Gdk.Pixbuf pix = ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Menu);
errorIcon = IdeApp.Workbench.StatusBar.ShowStatusIcon (pix);
errorIcon.EventBox.ButtonPressEvent += new Gtk.ButtonPressEventHandler (OnShowLogPad);
errorIcon.SetAlertMode (5);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/LayoutComboBox.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/LayoutComboBox.cs
index 7e9c2f5d8c..a86c5d7f7a 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/LayoutComboBox.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/LayoutComboBox.cs
@@ -28,7 +28,6 @@
using System;
using MonoDevelop.Ide;
-using MonoDevelop.Core.Gui;
using Gtk;
namespace MonoDevelop.Ide.Gui
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
index 29271bf2f3..12f389ea05 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.cs
@@ -28,9 +28,8 @@
using System;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using Gtk;
-using MonoDevelop.Projects.Gui.Completion;
+using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Ide.Gui;
namespace MonoDevelop.Ide
@@ -154,13 +153,13 @@ namespace MonoDevelop.Ide
public void ShowError (string error)
{
- ShowMessage (new Image (MonoDevelop.Core.Gui.Stock.Error, IconSize.Menu), error);
+ ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
}
public void ShowWarning (string warning)
{
DispatchService.AssertGuiThread ();
- ShowMessage (new Gtk.Image (MonoDevelop.Core.Gui.Stock.Warning, IconSize.Menu), warning);
+ ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
}
public void ShowMessage (string message)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs
index c73f86a516..ce6788cd32 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs
@@ -31,7 +31,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Codons;
using MonoDevelop.Core;
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 0e48064b3c..68cd0900fa 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs
@@ -31,7 +31,6 @@ using System;
using System.Collections;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Gui.Pads;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Core.Execution;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
deleted file mode 100644
index e5ad72733d..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
+++ /dev/null
@@ -1,1459 +0,0 @@
-//
-// ProjectOperations.cs
-//
-// Author:
-// Lluis Sanchez Gual
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using System.Linq;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.CodeDom.Compiler;
-using System.Collections.Specialized;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Text;
-using MonoDevelop.Projects.Gui.Dialogs;
-using MonoDevelop.Projects.Dom;
-using MonoDevelop.Projects.Dom.Parser;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.Components;
-using MonoDevelop.Core;
-using Mono.Addins;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Core.ProgressMonitoring;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.ProgressMonitoring;
-using MonoDevelop.Core.Gui.Dialogs;
-using MonoDevelop.Ide.Tasks;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Core.Assemblies;
-
-namespace MonoDevelop.Ide.Gui
-{
- /// <summary>
- /// This is the basic interface to the workspace.
- /// </summary>
- public class ProjectOperations
- {
- ProjectService projectService = MonoDevelop.Projects.Services.ProjectService;
- IAsyncOperation currentBuildOperation = NullAsyncOperation.Success;
- IAsyncOperation currentRunOperation = NullAsyncOperation.Success;
- IBuildTarget currentBuildOperationOwner;
- IBuildTarget currentRunOperationOwner;
-
- SelectReferenceDialog selDialog = null;
-
- SolutionItem currentSolutionItem = null;
- WorkspaceItem currentWorkspaceItem = null;
- object currentItem;
-
- BuildResult lastResult = new BuildResult ();
-
- internal ProjectOperations ()
- {
- IdeApp.Workspace.WorkspaceItemUnloaded += OnWorkspaceItemUnloaded;
- IdeApp.Workspace.ItemUnloading += IdeAppWorkspaceItemUnloading;
-
- }
-
- public BuildResult LastCompilerResult {
- get { return lastResult; }
- }
-
- public Project CurrentSelectedProject {
- get {
- return currentSolutionItem as Project;
- }
- }
-
- public Solution CurrentSelectedSolution {
- get {
- return currentWorkspaceItem as Solution;
- }
- }
-
- public IBuildTarget CurrentSelectedBuildTarget {
- get {
- if (currentSolutionItem != null)
- return currentSolutionItem;
- return currentWorkspaceItem;
- }
- }
-
- public WorkspaceItem CurrentSelectedWorkspaceItem {
- get {
- return currentWorkspaceItem;
- }
- internal set {
- if (value != currentWorkspaceItem) {
- WorkspaceItem oldValue = currentWorkspaceItem;
- currentWorkspaceItem = value;
- if (oldValue is Solution || value is Solution)
- OnCurrentSelectedSolutionChanged(new SolutionEventArgs (currentWorkspaceItem as Solution));
- }
- }
- }
-
- public SolutionItem CurrentSelectedSolutionItem {
- get {
- if (currentSolutionItem == null && CurrentSelectedSolution != null)
- return CurrentSelectedSolution.RootFolder;
- return currentSolutionItem;
- }
- internal set {
- if (value != currentSolutionItem) {
- SolutionItem oldValue = currentSolutionItem;
- currentSolutionItem = value;
- if (oldValue is Project || value is Project)
- OnCurrentProjectChanged (new ProjectEventArgs(currentSolutionItem as Project));
- }
- }
- }
-
- public object CurrentSelectedItem {
- get {
- return currentItem;
- }
- internal set {
- currentItem = value;
- }
- }
-
- public string ProjectsDefaultPath {
- get {
- return PropertyService.Get ("MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.DefaultPath", System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Projects"));
- }
- set {
- PropertyService.Set ("MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.DefaultPath", value);
- }
- }
-
- public IAsyncOperation CurrentBuildOperation {
- get { return currentBuildOperation; }
- }
-
- public IAsyncOperation CurrentRunOperation {
- get { return currentRunOperation; }
- set { currentRunOperation = value; }
- }
-
- public bool IsBuilding (IBuildTarget target)
- {
- return !currentBuildOperation.IsCompleted && ContainsTarget (target, currentBuildOperationOwner);
- }
-
- public bool IsRunning (IBuildTarget target)
- {
- return !currentRunOperation.IsCompleted && ContainsTarget (target, currentRunOperationOwner);
- }
-
- internal static bool ContainsTarget (IBuildTarget owner, IBuildTarget target)
- {
- if (owner == target)
- return true;
- else if (owner is WorkspaceItem)
- return ((WorkspaceItem)owner).ContainsItem (target);
- return false;
- }
- /*
- string GetDeclaredFile(IMember item)
- {
- if (item is IMember) {
- IMember mem = (IMember) item;
- if (mem.Region == null)
- return null;
- else if (mem.Region.FileName != null)
- return mem.Region.FileName;
- else if (mem.DeclaringType != null) {
- foreach (IType c in mem.DeclaringType.Parts) {
- if ((mem is IField && c.Fields.Contains((IField)mem)) ||
- (mem is IEvent && c.Events.Contains((IEvent)mem)) ||
- (mem is IProperty && c.Properties.Contains((IProperty)mem)) ||
- (mem is IMethod && c.Methods.Contains((IMethod)mem))) {
- return GetClassFileName(c);
- }
- }
- }
- } else if (item is IType) {
- IType cls = (IType) item;
- return GetClassFileName (cls);
- } else if (item is MonoDevelop.Projects.Parser.LocalVariable) {
- MonoDevelop.Projects.Parser.LocalVariable cls = (MonoDevelop.Projects.Parser.LocalVariable) item;
- return cls.Region.FileName;
- }
- return null;
- }
-
- public bool CanJumpToDeclaration (IMember item)
- {
- return (GetDeclaredFile(item) != null);
- }*/
-
- public bool CanJumpToDeclaration (MonoDevelop.Projects.Dom.INode visitable)
- {
- if (visitable is MonoDevelop.Projects.Dom.IType)
- return ((MonoDevelop.Projects.Dom.IType)visitable).CompilationUnit != null;
- if (visitable is LocalVariable)
- return true;
- IMember member = visitable as MonoDevelop.Projects.Dom.IMember;
- if (member == null || member.DeclaringType == null)
- return false ;
- return member.DeclaringType.CompilationUnit != null;
- }
-
- public void JumpToDeclaration (MonoDevelop.Projects.Dom.INode visitable)
- {
- if (visitable is LocalVariable) {
- LocalVariable var = (LocalVariable)visitable;
- MonoDevelop.Ide.Gui.IdeApp.Workbench.OpenDocument (var.FileName,
- var.Region.Start.Line,
- var.Region.Start.Column,
- true);
- return;
- }
- IMember member = visitable as MonoDevelop.Projects.Dom.IMember;
- if (member == null)
- return;
- string fileName;
- if (member is MonoDevelop.Projects.Dom.IType) {
- try {
- fileName = ((MonoDevelop.Projects.Dom.IType)member).CompilationUnit.FileName;
- } catch (Exception e) {
- LoggingService.LogError ("Can't get file name for type:" + member + ". Try to restart monodevelop.", e);
- fileName = null;
- }
- } else {
- if (member.DeclaringType == null)
- return;
- fileName = member.DeclaringType.CompilationUnit.FileName;
- if (member is ExtensionMethod)
- fileName = ((ExtensionMethod)member).OriginalMethod.DeclaringType.CompilationUnit.FileName;
- }
- Document doc = MonoDevelop.Ide.Gui.IdeApp.Workbench.OpenDocument (fileName, member.Location.Line, member.Location.Column, true);
- if (doc != null) {
- MonoDevelop.Ide.Gui.Content.IUrlHandler handler = doc.ActiveView as MonoDevelop.Ide.Gui.Content.IUrlHandler;
- if (handler != null)
- handler.Open (member.HelpUrl);
- }
- }
-
- public void RenameItem (IWorkspaceFileObject item, string newName)
- {
- ProjectOptionsDialog.RenameItem (item, newName);
- if (item is SolutionItem) {
- Save (((SolutionItem)item).ParentSolution);
- } else {
- IdeApp.Workspace.Save ();
- IdeApp.Workspace.SavePreferences ();
- }
- }
-
- public void Export (IWorkspaceObject item)
- {
- Export (item, null);
- }
-
- public void Export (IWorkspaceObject entry, FileFormat format)
- {
- ExportProjectDialog dlg = new ExportProjectDialog (entry, format);
- try {
- dlg.TransientFor = IdeApp.Workbench.RootWindow;
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
-
- using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor (GettextCatalog.GetString ("Export Project"), null, true, true)) {
- string folder = dlg.TargetFolder;
-
- string file = entry is WorkspaceItem ? ((WorkspaceItem)entry).FileName : ((SolutionEntityItem)entry).FileName;
- Services.ProjectService.Export (mon, file, folder, dlg.Format);
- }
- }
- } finally {
- dlg.Destroy ();
- }
- }
-
- public void Save (IEnumerable<SolutionEntityItem> entries)
- {
- List<IWorkspaceFileObject> items = new List<IWorkspaceFileObject> ();
- foreach (IWorkspaceFileObject it in entries)
- items.Add (it);
- Save (items);
- }
-
- public void Save (SolutionEntityItem entry)
- {
- if (!entry.FileFormat.CanWrite (entry)) {
- IWorkspaceFileObject itemContainer = GetContainer (entry);
- if (SelectValidFileFormat (itemContainer))
- Save (itemContainer);
- return;
- }
-
- if (!AllowSave (entry))
- return;
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
- try {
- entry.Save (monitor);
- monitor.ReportSuccess (GettextCatalog.GetString ("Project saved."));
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- public void Save (Solution item)
- {
- if (!item.FileFormat.CanWrite (item)) {
- if (!SelectValidFileFormat (item))
- return;
- }
-
- if (!AllowSave (item))
- return;
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
- try {
- item.Save (monitor);
- monitor.ReportSuccess (GettextCatalog.GetString ("Solution saved."));
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- public void Save (IEnumerable<IWorkspaceFileObject> items)
- {
- int count = items.Count ();
- if (count == 0)
- return;
-
- // Verify that the file format for each item is still valid
-
- HashSet<IWorkspaceFileObject> fixedItems = new HashSet<IWorkspaceFileObject> ();
- HashSet<IWorkspaceFileObject> failedItems = new HashSet<IWorkspaceFileObject> ();
-
- foreach (IWorkspaceFileObject entry in items) {
- IWorkspaceFileObject itemContainer = GetContainer (entry);
- if (fixedItems.Contains (itemContainer) || failedItems.Contains (itemContainer))
- continue;
- if (!entry.FileFormat.CanWrite (entry)) {
- // Can't save the project using this format. Try to find a valid format for the whole solution
- if (SelectValidFileFormat (itemContainer))
- fixedItems.Add (itemContainer);
- else
- failedItems.Add (itemContainer);
- }
- }
- if (fixedItems.Count > 0)
- Save (fixedItems);
-
- if (failedItems.Count > 0 || fixedItems.Count > 0) {
- // Some file format changes were required, and some items were saved.
- // Get a list of items not yet saved.
- List<IWorkspaceFileObject> notSavedEntries = new List<IWorkspaceFileObject> ();
- foreach (IWorkspaceFileObject entry in items) {
- IWorkspaceFileObject itemContainer = GetContainer (entry);
- if (!fixedItems.Contains (itemContainer) && !failedItems.Contains (itemContainer))
- notSavedEntries.Add (entry);
- }
- items = notSavedEntries;
- }
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
- try {
- monitor.BeginTask (null, count);
- foreach (IWorkspaceFileObject item in items) {
- if (AllowSave (item))
- item.Save (monitor);
- monitor.Step (1);
- }
- monitor.EndTask ();
- monitor.ReportSuccess (GettextCatalog.GetString ("Items saved."));
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- public void Save (IWorkspaceFileObject item)
- {
- if (item is SolutionEntityItem)
- Save ((SolutionEntityItem) item);
- else if (item is Solution)
- Save ((Solution)item);
-
- if (!item.FileFormat.CanWrite (item)) {
- IWorkspaceFileObject ci = GetContainer (item);
- if (SelectValidFileFormat (ci))
- Save (ci);
- return;
- }
-
- if (!AllowSave (item))
- return;
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
- try {
- item.Save (monitor);
- monitor.ReportSuccess (GettextCatalog.GetString ("Item saved."));
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- bool AllowSave (IWorkspaceFileObject item)
- {
- if (HasChanged (item))
- return MessageService.Confirm (
- GettextCatalog.GetString ("Some project files have been changed from outside MonoDevelop. Do you want to overwrite them?"),
- GettextCatalog.GetString ("Changes done in those files will be overwritten by MonoDevelop."),
- AlertButton.OverwriteFile);
- else
- return true;
- }
-
- bool HasChanged (IWorkspaceFileObject item)
- {
- if (item.ItemFilesChanged)
- return true;
- if (item is WorkspaceItem) {
- foreach (SolutionEntityItem eitem in ((WorkspaceItem)item).GetAllSolutionItems<SolutionEntityItem> ())
- if (eitem.ItemFilesChanged)
- return true;
- }
- return false;
- }
-
- IWorkspaceFileObject GetContainer (IWorkspaceFileObject item)
- {
- SolutionEntityItem si = item as SolutionEntityItem;
- if (si != null && si.ParentSolution != null && !si.ParentSolution.FileFormat.SupportsMixedFormats)
- return si.ParentSolution;
- else
- return item;
- }
-
- bool SelectValidFileFormat (IWorkspaceFileObject item)
- {
- SelectFileFormatDialog dlg = new SelectFileFormatDialog (item);
- try {
- if (dlg.Run () == (int) Gtk.ResponseType.Ok && dlg.Format != null) {
- item.ConvertToFormat (dlg.Format, true);
- return true;
- }
- return false;
- } finally {
- dlg.Destroy ();
- }
- }
-
- public void MarkFileDirty (string filename)
- {
- Project entry = IdeApp.Workspace.GetProjectContainingFile (filename);
- if (entry != null) {
- entry.SetNeedsBuilding (true);
- }
- }
-
- public void ShowOptions (IWorkspaceObject entry)
- {
- ShowOptions (entry, null);
- }
-
- public void ShowOptions (IWorkspaceObject entry, string panelId)
- {
- if (entry is SolutionEntityItem) {
- SolutionEntityItem selectedProject = (SolutionEntityItem) entry;
-
- ProjectOptionsDialog optionsDialog = new ProjectOptionsDialog (IdeApp.Workbench.RootWindow, selectedProject);
- SolutionItemConfiguration conf = selectedProject.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
- optionsDialog.CurrentConfig = conf != null ? conf.Name : null;
- try {
- if (panelId != null)
- optionsDialog.SelectPanel (panelId);
-
- if (optionsDialog.Run() == (int)Gtk.ResponseType.Ok) {
- selectedProject.SetNeedsBuilding (true);
- foreach (object ob in optionsDialog.ModifiedObjects) {
- if (ob is Solution) {
- Save ((Solution)ob);
- return;
- }
- }
- Save (selectedProject);
- IdeApp.Workspace.SavePreferences ();
- }
- } finally {
- optionsDialog.Destroy ();
- }
- } else if (entry is Solution) {
- Solution solution = (Solution) entry;
-
- CombineOptionsDialog optionsDialog = new CombineOptionsDialog (IdeApp.Workbench.RootWindow, solution);
- optionsDialog.CurrentConfig = IdeApp.Workspace.ActiveConfigurationId;
- try {
- if (panelId != null)
- optionsDialog.SelectPanel (panelId);
- if (optionsDialog.Run () == (int) Gtk.ResponseType.Ok) {
- Save (solution);
- IdeApp.Workspace.SavePreferences (solution);
- }
- } finally {
- optionsDialog.Destroy ();
- }
- }
- else {
- ItemOptionsDialog optionsDialog = new ItemOptionsDialog (IdeApp.Workbench.RootWindow, entry);
- try {
- if (panelId != null)
- optionsDialog.SelectPanel (panelId);
- if (optionsDialog.Run () == (int) Gtk.ResponseType.Ok) {
- if (entry is IBuildTarget)
- ((IBuildTarget)entry).SetNeedsBuilding (true, IdeApp.Workspace.ActiveConfiguration);
- if (entry is IWorkspaceFileObject)
- Save ((IWorkspaceFileObject) entry);
- else {
- SolutionItem si = entry as SolutionItem;
- if (si.ParentSolution != null)
- Save (si.ParentSolution);
- }
- IdeApp.Workspace.SavePreferences ();
- }
- } finally {
- optionsDialog.Destroy ();
- }
- }
- }
-
- public void NewSolution ()
- {
- NewSolution (null);
- }
-
- public void NewSolution (string defaultTemplate)
- {
- NewProjectDialog pd = new NewProjectDialog (null, true, null);
- if (defaultTemplate != null)
- pd.SelectTemplate (defaultTemplate);
- pd.Run ();
- pd.Destroy ();
- }
-
- public WorkspaceItem AddNewWorkspaceItem (Workspace parentWorkspace)
- {
- return AddNewWorkspaceItem (parentWorkspace, null);
- }
-
- public WorkspaceItem AddNewWorkspaceItem (Workspace parentWorkspace, string defaultItemId)
- {
- NewProjectDialog npdlg = new NewProjectDialog (null, false, parentWorkspace.BaseDirectory);
- npdlg.SelectTemplate (defaultItemId);
- try {
- if (npdlg.Run () == (int) Gtk.ResponseType.Ok && npdlg.NewItem != null) {
- parentWorkspace.Items.Add ((WorkspaceItem) npdlg.NewItem);
- Save (parentWorkspace);
- return (WorkspaceItem) npdlg.NewItem;
- }
- } finally {
- npdlg.Destroy ();
- }
- return null;
- }
-
- public WorkspaceItem AddWorkspaceItem (Workspace parentWorkspace)
- {
- WorkspaceItem res = null;
-
- FileSelector fdiag = new FileSelector (GettextCatalog.GetString ("Add to Workspace"));
- try {
- fdiag.SetCurrentFolder (parentWorkspace.BaseDirectory);
- fdiag.SelectMultiple = false;
- if (fdiag.Run () == (int) Gtk.ResponseType.Ok) {
- try {
- res = AddWorkspaceItem (parentWorkspace, fdiag.Filename);
- }
- catch (Exception ex) {
- MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", fdiag.Filename));
- }
- }
- } finally {
- fdiag.Destroy ();
- }
-
- return res;
- }
-
- public WorkspaceItem AddWorkspaceItem (Workspace parentWorkspace, string itemFileName)
- {
- using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
- WorkspaceItem it = Services.ProjectService.ReadWorkspaceItem (monitor, itemFileName);
- if (it != null) {
- parentWorkspace.Items.Add (it);
- Save (parentWorkspace);
- }
- return it;
- }
- }
-
- public SolutionItem CreateProject (SolutionFolder parentFolder)
- {
- SolutionItem res = null;
- string basePath = parentFolder != null ? parentFolder.BaseDirectory : null;
- NewProjectDialog npdlg = new NewProjectDialog (parentFolder, false, basePath);
- npdlg.Run ();
- npdlg.Destroy ();
- return res;
- }
-
- public SolutionItem AddSolutionItem (SolutionFolder parentFolder)
- {
- SolutionItem res = null;
-
- FileSelector fdiag = new FileSelector (GettextCatalog.GetString ("Add to Solution"));
- try {
- fdiag.SetCurrentFolder (parentFolder.BaseDirectory);
- fdiag.SelectMultiple = false;
- if (fdiag.Run () == (int) Gtk.ResponseType.Ok) {
- try {
- res = AddSolutionItem (parentFolder, fdiag.Filename);
- }
- catch (Exception ex) {
- MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", fdiag.Filename));
- }
- }
- } finally {
- fdiag.Destroy ();
- }
-
- if (res != null)
- IdeApp.Workspace.Save ();
-
- return res;
- }
-
- public SolutionItem AddSolutionItem (SolutionFolder folder, string entryFileName)
- {
- AddEntryEventArgs args = new AddEntryEventArgs (folder, entryFileName);
- if (AddingEntryToCombine != null)
- AddingEntryToCombine (this, args);
- if (args.Cancel)
- return null;
- using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
- return folder.AddItem (monitor, args.FileName, true);
- }
- }
-
- public void CreateProjectFile (Project parentProject, string basePath)
- {
- CreateProjectFile (parentProject, basePath, null);
- }
-
- public void CreateProjectFile (Project parentProject, string basePath, string selectedTemplateId)
- {
- NewFileDialog nfd = null;
- try {
- nfd = new NewFileDialog (parentProject, basePath);
- if (selectedTemplateId != null)
- nfd.SelectTemplate (selectedTemplateId);
- nfd.Run ();
- } finally {
- if (nfd != null) nfd.Destroy ();
- }
- }
-
- public bool AddReferenceToProject (DotNetProject project)
- {
- try {
- if (selDialog == null)
- selDialog = new SelectReferenceDialog ();
-
- selDialog.SetProject (project);
-
- if (selDialog.Run() == (int)Gtk.ResponseType.Ok) {
- ProjectReferenceCollection newRefs = selDialog.ReferenceInformations;
-
- ArrayList toDelete = new ArrayList ();
- foreach (ProjectReference refInfo in project.References)
- if (!newRefs.Contains (refInfo))
- toDelete.Add (refInfo);
-
- foreach (ProjectReference refInfo in toDelete)
- project.References.Remove (refInfo);
-
- foreach (ProjectReference refInfo in selDialog.ReferenceInformations)
- if (!project.References.Contains (refInfo))
- project.References.Add(refInfo);
-
- return true;
- }
- else
- return false;
- } finally {
- selDialog.Hide ();
- }
- }
-
- public bool SelectProjectReferences (ProjectReferenceCollection references, AssemblyContext ctx, TargetFramework targetVersion)
- {
- try {
- if (selDialog == null)
- selDialog = new SelectReferenceDialog ();
-
- selDialog.SetReferenceCollection (references, ctx, targetVersion);
-
- if (selDialog.Run() == (int)Gtk.ResponseType.Ok) {
- references.Clear ();
- references.AddRange (selDialog.ReferenceInformations);
- return true;
- }
- else
- return false;
- } finally {
- if (selDialog != null)
- selDialog.Hide ();
- }
- }
-
- public void RemoveSolutionItem (SolutionItem item)
- {
- string question = GettextCatalog.GetString ("Do you really want to remove project '{0}' from '{1}'?", item.Name, item.ParentFolder.Name);
- string secondaryText = GettextCatalog.GetString ("The Delete option physically removes the project files from disc.");
-
- SolutionEntityItem prj = item as SolutionEntityItem;
- if (prj == null) {
- if (MessageService.Confirm (question, AlertButton.Remove) && IdeApp.Workspace.RequestItemUnload (item))
- RemoveItemFromSolution (prj);
- return;
- }
-
- AlertButton result = MessageService.AskQuestion (question, secondaryText,
- AlertButton.Delete, AlertButton.Cancel, AlertButton.Remove);
- if (result == AlertButton.Delete) {
- if (!IdeApp.Workspace.RequestItemUnload (prj))
- return;
- ConfirmProjectDeleteDialog dlg = new ConfirmProjectDeleteDialog (prj);
- if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
-
- // Remove the project before removing the files to avoid unnecessary events
- RemoveItemFromSolution (prj);
-
- List<FilePath> files = dlg.GetFilesToDelete ();
- dlg.Destroy ();
- using (IProgressMonitor monitor = new MonoDevelop.Core.Gui.ProgressMonitoring.MessageDialogProgressMonitor (true)) {
- monitor.BeginTask (GettextCatalog.GetString ("Deleting Files..."), files.Count);
- foreach (FilePath file in files) {
- try {
- if (Directory.Exists (file))
- FileService.DeleteDirectory (file);
- else
- FileService.DeleteFile (file);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("The file or directory '{0}' could not be deleted.", file), ex);
- }
- monitor.Step (1);
- }
- monitor.EndTask ();
- }
- } else
- dlg.Destroy ();
- }
- else if (result == AlertButton.Remove && IdeApp.Workspace.RequestItemUnload (prj)) {
- RemoveItemFromSolution (prj);
- }
- }
-
- void RemoveItemFromSolution (SolutionItem prj)
- {
- Solution sol = prj.ParentSolution;
- prj.ParentFolder.Items.Remove (prj);
- prj.Dispose ();
- IdeApp.ProjectOperations.Save (sol);
- }
-
- public bool CanExecute (IBuildTarget entry)
- {
- ExecutionContext context = new ExecutionContext (Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors);
- return CanExecute (entry, context);
- }
-
- public bool CanExecute (IBuildTarget entry, IExecutionHandler handler)
- {
- ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
- return entry.CanExecute (context, IdeApp.Workspace.ActiveConfiguration);
- }
-
- public bool CanExecute (IBuildTarget entry, ExecutionContext context)
- {
- return entry.CanExecute (context, IdeApp.Workspace.ActiveConfiguration);
- }
-
- public IAsyncOperation Execute (IBuildTarget entry)
- {
- return Execute (entry, Runtime.ProcessService.DefaultExecutionHandler);
- }
-
- public IAsyncOperation Execute (IBuildTarget entry, IExecutionHandler handler)
- {
- ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
- return Execute (entry, context);
- }
-
- public IAsyncOperation Execute (IBuildTarget entry, ExecutionContext context)
- {
- if (currentRunOperation != null && !currentRunOperation.IsCompleted) return currentRunOperation;
-
- IProgressMonitor monitor = new MessageDialogProgressMonitor ();
-
- DispatchService.ThreadDispatch (delegate {
- ExecuteSolutionItemAsync (monitor, entry, context);
- });
- currentRunOperation = monitor.AsyncOperation;
- currentRunOperationOwner = entry;
- currentRunOperation.Completed += delegate { currentRunOperationOwner = null; };
- return currentRunOperation;
- }
-
- void ExecuteSolutionItemAsync (IProgressMonitor monitor, IBuildTarget entry, ExecutionContext context)
- {
- try {
- OnBeforeStartProject ();
- entry.Execute (monitor, context, IdeApp.Workspace.ActiveConfiguration);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Execution failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- public void Clean (IBuildTarget entry)
- {
- entry.RunTarget (new NullProgressMonitor (), ProjectService.CleanTarget, IdeApp.Workspace.ActiveConfiguration);
- }
-
- public IAsyncOperation BuildFile (string file)
- {
- Project tempProject = projectService.CreateSingleFileProject (file);
- if (tempProject != null) {
- IAsyncOperation aop = Build (tempProject);
- aop.Completed += delegate { tempProject.Dispose (); };
- return aop;
- } else {
- MessageService.ShowError (GettextCatalog.GetString ("The file {0} can't be compiled.", file));
- return NullAsyncOperation.Failure;
- }
- }
-
- public IAsyncOperation ExecuteFile (string file)
- {
- Project tempProject = projectService.CreateSingleFileProject (file);
- if (tempProject != null) {
- IAsyncOperation aop = Execute (tempProject);
- aop.Completed += delegate { tempProject.Dispose (); };
- return aop;
- } else {
- MessageService.ShowError(GettextCatalog.GetString ("No runnable executable found."));
- return NullAsyncOperation.Failure;
- }
- }
-
- public bool CanExecuteFile (string file)
- {
- return CanExecuteFile (file, Runtime.ProcessService.DefaultExecutionHandler);
- }
-
- public bool CanExecuteFile (string file, IExecutionHandler handler)
- {
- ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
- return CanExecuteFile (file, context);
- }
-
- public bool CanExecuteFile (string file, ExecutionContext context)
- {
- Project tempProject = projectService.CreateSingleFileProject (file);
- if (tempProject != null) {
- bool res = CanExecute (tempProject, context);
- tempProject.Dispose ();
- return res;
- }
- else
- return false;
- }
-
- public IAsyncOperation ExecuteFile (string file, IExecutionHandler handler)
- {
- ExecutionContext context = new ExecutionContext (handler, IdeApp.Workbench.ProgressMonitors);
- return ExecuteFile (file, context);
- }
-
- public IAsyncOperation ExecuteFile (string file, ExecutionContext context)
- {
- Project tempProject = projectService.CreateSingleFileProject (file);
- if (tempProject != null) {
- IAsyncOperation aop = Execute (tempProject, context);
- aop.Completed += delegate { tempProject.Dispose (); };
- return aop;
- } else {
- MessageService.ShowError(GettextCatalog.GetString ("No runnable executable found."));
- return NullAsyncOperation.Failure;
- }
- }
-
- public IAsyncOperation Rebuild (IBuildTarget entry)
- {
- if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation;
-
- Clean (entry);
- return Build (entry);
- }
-// bool errorPadInitialized = false;
- public IAsyncOperation Build (IBuildTarget entry)
- {
- if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation;
- /*
- if (!errorPadInitialized) {
- try {
- Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
- errorsPad.Window.PadHidden += delegate {
- content.IsOpenedAutomatically = false;
- };
-
- Pad monitorPad = IdeApp.Workbench.Pads.FirstOrDefault (pad => pad.Content == ((OutputProgressMonitor)((AggregatedProgressMonitor)monitor).MasterMonitor).OutputPad);
- monitorPad.Window.PadHidden += delegate {
- monitorPad.IsOpenedAutomatically = false;
- };
- } finally {
- errorPadInitialized = true;
- }
- }
- */
-
- DoBeforeCompileAction ();
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
-
- BeginBuild (monitor);
-
- DispatchService.ThreadDispatch (delegate {
- BuildSolutionItemAsync (entry, monitor);
- }, null);
- currentBuildOperation = monitor.AsyncOperation;
- currentBuildOperationOwner = entry;
- currentBuildOperation.Completed += delegate { currentBuildOperationOwner = null; };
- return currentBuildOperation;
- }
-
- void BuildSolutionItemAsync (IBuildTarget entry, IProgressMonitor monitor)
- {
- BuildResult result = null;
- try {
- SolutionItem it = entry as SolutionItem;
- if (it != null)
- result = it.Build (monitor, IdeApp.Workspace.ActiveConfiguration, true);
- else
- result = entry.RunTarget (monitor, ProjectService.BuildTarget, IdeApp.Workspace.ActiveConfiguration);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Build failed."), ex);
- }
- DispatchService.GuiDispatch (
- delegate {
- BuildDone (monitor, result, entry); // BuildDone disposes the monitor
- });
- }
-
- void DoBeforeCompileAction ()
- {
- BeforeCompileAction action = IdeApp.Preferences.BeforeBuildSaveAction;
-
- switch (action) {
- case BeforeCompileAction.Nothing:
- break;
- case BeforeCompileAction.PromptForSave:
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.IsDirty && doc.Project != null) {
- if (MessageService.AskQuestion (
- GettextCatalog.GetString ("Save changed documents before building?"),
- GettextCatalog.GetString ("Some of the open documents have unsaved changes."),
- AlertButton.BuildWithoutSave, AlertButton.Save) == AlertButton.Save) {
- MarkFileDirty (doc.FileName);
- doc.Save ();
- }
- else
- break;
- }
- }
- break;
- case BeforeCompileAction.SaveAllFiles:
- foreach (Document doc in new List<Document> (IdeApp.Workbench.Documents))
- if (doc.IsDirty && doc.Project != null)
- doc.Save ();
- break;
- default:
- System.Diagnostics.Debug.Assert(false);
- break;
- }
- }
-
- void BeginBuild (IProgressMonitor monitor)
- {
- TaskService.Errors.ClearByOwner (this);
- if (StartBuild != null)
- StartBuild (this, new BuildEventArgs (monitor, true));
- }
-
- void BuildDone (IProgressMonitor monitor, BuildResult result, IBuildTarget entry)
- {
- Task[] tasks = null;
- try {
- if (result != null) {
- lastResult = result;
- monitor.Log.WriteLine ();
- monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
-
- tasks = new Task [result.Errors.Count];
- for (int n=0; n<tasks.Length; n++) {
- tasks [n] = new Task (result.Errors [n]);
- tasks [n].Owner = this;
- }
-
- TaskService.Errors.AddRange (tasks);
- TaskService.Errors.ResetLocationList ();
- IdeApp.Workbench.ActiveLocationList = TaskService.Errors;
-
- string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
- string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);
-
- if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) {
- monitor.ReportSuccess (GettextCatalog.GetString ("Build successful."));
- } else if (result.ErrorCount == 0 && result.WarningCount > 0) {
- monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString);
- } else if (result.ErrorCount > 0) {
- monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null);
- } else {
- monitor.ReportError(GettextCatalog.GetString("Build failed."), null);
- }
- OnEndBuild (monitor, lastResult.FailedBuildCount == 0);
- } else
- OnEndBuild (monitor, false);
-
- try {
- Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
- MonoDevelop.Ide.Gui.Pads.ErrorListPad content = (MonoDevelop.Ide.Gui.Pads.ErrorListPad)errorsPad.Content;
- switch (IdeApp.Preferences.ShowErrorPadAfterBuild) {
- case BuildResultStates.Always:
- if (!errorsPad.Visible)
- errorsPad.IsOpenedAutomatically = true;
- errorsPad.Visible = true;
- errorsPad.BringToFront ();
- break;
- case BuildResultStates.Never:
- break;
- case BuildResultStates.OnErrors:
- if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error))
- goto case BuildResultStates.Always;
- goto case BuildResultStates.Never;
- case BuildResultStates.OnErrorsOrWarnings:
- if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning))
- goto case BuildResultStates.Always;
- goto case BuildResultStates.Never;
- }
- } catch {}
- Task jumpTask = null;
- switch (IdeApp.Preferences.JumpToFirstErrorOrWarning) {
- case JumpToFirst.Error:
- jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error);
- break;
- case JumpToFirst.ErrorOrWarning:
- jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning);
- break;
- }
- if (jumpTask != null)
- jumpTask.JumpToPosition ();
-
- } finally {
- monitor.Dispose ();
- }
- }
-
- public string[] AddFilesToProject (Project project, string[] files, string targetDirectory)
- {
- int action = -1;
- IProgressMonitor monitor = null;
-
- if (files.Length > 10) {
- monitor = new MonoDevelop.Core.Gui.ProgressMonitoring.MessageDialogProgressMonitor (true);
- monitor.BeginTask (GettextCatalog.GetString("Adding files..."), files.Length);
- }
-
- List<string> newFileList = new List<string> ();
-
- using (monitor) {
-
- foreach (string file in files) {
- if (monitor != null)
- monitor.Log.WriteLine (file);
- if (file.StartsWith (project.BaseDirectory)) {
- newFileList.Add (MoveCopyFile (project, targetDirectory, file, true, true));
- } else {
- Gtk.MessageDialog md = new Gtk.MessageDialog (
- IdeApp.Workbench.RootWindow,
- Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
- Gtk.MessageType.Question, Gtk.ButtonsType.None,
- GettextCatalog.GetString ("{0} is outside the project directory, what should I do?", file));
-
- try {
- Gtk.CheckButton remember = null;
- if (files.Length > 1) {
- remember = new Gtk.CheckButton (GettextCatalog.GetString ("Use the same action for all selected files."));
- md.VBox.PackStart (remember, false, false, 0);
- }
-
- int LINK_VALUE = 3;
- int COPY_VALUE = 1;
- int MOVE_VALUE = 2;
-
- md.AddButton (GettextCatalog.GetString ("_Link"), LINK_VALUE);
- md.AddButton (Gtk.Stock.Copy, COPY_VALUE);
- md.AddButton (GettextCatalog.GetString ("_Move"), MOVE_VALUE);
- md.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
- md.VBox.ShowAll ();
-
- int ret = -1;
- if (action < 0) {
- ret = md.Run ();
- if (ret < 0)
- return newFileList.ToArray ();
- if (remember != null && remember.Active) action = ret;
- } else {
- ret = action;
- }
-
- try {
- string nf = MoveCopyFile (project, targetDirectory, file,
- (ret == MOVE_VALUE) || (ret == LINK_VALUE), ret == LINK_VALUE);
- newFileList.Add (nf);
- }
- catch (Exception ex) {
- MessageService.ShowException (ex, GettextCatalog.GetString ("An error occurred while attempt to move/copy that file. Please check your permissions."));
- newFileList.Add (null);
- }
- } finally {
- md.Destroy ();
- }
- }
- if (monitor != null)
- monitor.Step (1);
- }
- }
- return newFileList.ToArray ();
- }
-
- string MoveCopyFile (Project project, string baseDirectory, string filename, bool move, bool alreadyInPlace)
- {
- if (FileService.IsDirectory (filename))
- return null;
-
- string name = System.IO.Path.GetFileName (filename);
- string newfilename = alreadyInPlace ? filename : Path.Combine (baseDirectory, name);
-
- if (filename != newfilename) {
- if (File.Exists (newfilename)) {
- if (!MessageService.Confirm (GettextCatalog.GetString ("The file '{0}' already exists. Do you want to replace it?", newfilename), AlertButton.OverwriteFile))
- return null;
- }
- FileService.CopyFile (filename, newfilename);
- if (move)
- FileService.DeleteFile (filename);
- }
-
- project.AddFile (newfilename);
- return newfilename;
- }
-
- public void TransferFiles (IProgressMonitor monitor, Project sourceProject, FilePath sourcePath, Project targetProject, FilePath targetPath, bool removeFromSource, bool copyOnlyProjectFiles)
- {
- // When transfering directories, targetPath is the directory where the source
- // directory will be transfered, including the destination directory or file name.
- // For example, if sourcePath is /a1/a2/a3 and targetPath is /b1/b2, the
- // new folder or file will be /b1/b2
-
- if (targetProject == null)
- throw new ArgumentNullException ("targetProject");
-
- if (!targetPath.IsChildPathOf (targetProject.BaseDirectory))
- throw new ArgumentException ("Invalid project folder: " + targetPath);
-
- if (sourceProject != null && !sourcePath.IsChildPathOf (sourceProject.BaseDirectory))
- throw new ArgumentException ("Invalid project folder: " + sourcePath);
-
- if (copyOnlyProjectFiles && sourceProject == null)
- throw new ArgumentException ("A source project must be specified if copyOnlyProjectFiles is True");
-
- bool sourceIsFolder = Directory.Exists (sourcePath);
-
- bool movingFolder = (removeFromSource && sourceIsFolder && (
- !copyOnlyProjectFiles ||
- IsDirectoryHierarchyEmpty (sourcePath)));
-
- // Get the list of files to copy
-
- List<ProjectFile> filesToMove = null;
- try {
- //get the real ProjectFiles
- if (sourceProject != null) {
- var virtualPath = sourcePath.ToRelative (sourceProject.BaseDirectory);
- filesToMove = sourceProject.Files.GetFilesInVirtualPath (virtualPath).ToList ();
- }
- //get all the non-project files and create fake ProjectFiles
- if (!copyOnlyProjectFiles || sourceProject == null) {
- var col = new List<ProjectFile> ();
- GetAllFilesRecursive (sourcePath, col);
- if (sourceProject != null) {
- var names = new HashSet<string> (filesToMove.Select (f => sourceProject.BaseDirectory.Combine (f.ProjectVirtualPath).ToString ()));
- foreach (var f in col)
- if (names.Add (f.Name))
- filesToMove.Add (f);
- } else {
- filesToMove = col;
- }
- }
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Could not get any file from '{0}'.", sourcePath), ex);
- return;
- }
-
- // If copying a single file, bring any grouped children along
- if (filesToMove.Count == 1 && sourceProject != null) {
- var pf = filesToMove[0];
- if (pf != null && pf.HasChildren)
- foreach (ProjectFile child in pf.DependentChildren)
- filesToMove.Add (child);
- }
-
- // Ensure that the destination folder is created, even if no files
- // are copied
-
- try {
- if (sourceIsFolder && !Directory.Exists (targetPath) && !movingFolder)
- FileService.CreateDirectory (targetPath);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Could not create directory '{0}'.", targetPath), ex);
- return;
- }
-
- // Transfer files
- // If moving a folder, do it all at once
-
- if (movingFolder) {
- try {
- FileService.MoveDirectory (sourcePath, targetPath);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Directory '{0}' could not be moved.", sourcePath), ex);
- return;
- }
- }
-
- monitor.BeginTask (GettextCatalog.GetString ("Copying files..."), filesToMove.Count);
-
- foreach (ProjectFile file in filesToMove) {
- bool fileIsLink = file.Project != null && file.IsLink;
-
- var sourceFile = fileIsLink
- ? file.Project.BaseDirectory.Combine (file.ProjectVirtualPath)
- : file.FilePath;
- var newFile = sourceIsFolder ? targetPath.Combine (sourceFile.ToRelative (sourcePath)) : targetPath;
-
- if (!movingFolder && !fileIsLink) {
- try {
- FilePath fileDir = newFile.ParentDirectory;
- if (!Directory.Exists (fileDir) && !file.IsLink)
- FileService.CreateDirectory (fileDir);
- if (removeFromSource)
- FileService.MoveFile (sourceFile, newFile);
- else
- FileService.CopyFile (sourceFile, newFile);
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("File '{0}' could not be created.", newFile), ex);
- monitor.Step (1);
- continue;
- }
- }
-
- if (sourceProject != null) {
- if (removeFromSource && sourceProject.Files.Contains (file))
- sourceProject.Files.Remove (file);
- if (fileIsLink) {
- var linkFile = (sourceProject == targetProject)? file : (ProjectFile) file.Clone ();
- if (movingFolder) {
- var abs = linkFile.Link.ToAbsolute (sourceProject.BaseDirectory);
- var relSrc = abs.ToRelative (sourcePath);
- var absTarg = relSrc.ToAbsolute (targetPath);
- linkFile.Link = absTarg.ToRelative (targetProject.BaseDirectory);
- } else {
- linkFile.Link = newFile.ToRelative (targetProject.BaseDirectory);
- }
- targetProject.Files.Add (linkFile);
- } else if (targetProject.Files.GetFile (newFile) == null) {
- ProjectFile projectFile = (ProjectFile) file.Clone ();
- projectFile.Name = newFile;
- targetProject.Files.Add (projectFile);
- }
- }
-
- monitor.Step (1);
- }
-
- // If this was the last item in the folder, make sure we keep
- // a reference to the folder, so it is not deleted from the tree.
- if (removeFromSource && sourceProject != null) {
- var folder = sourcePath.ParentDirectory;
- if (!sourceProject.Files.GetFilesInVirtualPath (folder).Any ()) {
- var folderFile = new ProjectFile (sourceProject.BaseDirectory.Combine (folder));
- folderFile.Subtype = Subtype.Directory;
- sourceProject.Files.Add (folderFile);
- }
- }
-
- monitor.EndTask ();
- }
-
- void GetAllFilesRecursive (string path, List<ProjectFile> files)
- {
- if (File.Exists (path)) {
- files.Add (new ProjectFile (path));
- return;
- }
-
- if (Directory.Exists (path)) {
- foreach (string file in Directory.GetFiles (path))
- files.Add (new ProjectFile (file));
-
- foreach (string dir in Directory.GetDirectories (path))
- GetAllFilesRecursive (dir, files);
- }
- }
-
- bool IsDirectoryHierarchyEmpty (string path)
- {
- if (Directory.GetFiles(path).Length > 0) return false;
- foreach (string dir in Directory.GetDirectories (path))
- if (!IsDirectoryHierarchyEmpty (dir)) return false;
- return true;
- }
-
- void OnBeforeStartProject()
- {
- if (BeforeStartProject != null) {
- BeforeStartProject(this, null);
- }
- }
-
- void OnEndBuild (IProgressMonitor monitor, bool success)
- {
- if (EndBuild != null) {
- EndBuild (this, new BuildEventArgs (monitor, success));
- }
- }
-
- void IdeAppWorkspaceItemUnloading (object sender, ItemUnloadingEventArgs args)
- {
- if (IsBuilding (args.Item))
- CurrentBuildOperation.Cancel ();
- if (IsRunning (args.Item)) {
- if (MessageService.Confirm (GettextCatalog.GetString ("The project '{0}' is currently running. It will have to be stopped. Do you want to continue?", currentRunOperationOwner.Name), AlertButton.Yes)) {
- CurrentRunOperation.Cancel ();
- } else
- args.Cancel = true;
- }
- }
-
- void OnWorkspaceItemUnloaded (object s, WorkspaceItemEventArgs args)
- {
- if (ContainsTarget (args.Item, currentSolutionItem))
- CurrentSelectedSolutionItem = null;
- if (ContainsTarget (args.Item, currentWorkspaceItem))
- CurrentSelectedWorkspaceItem = null;
- if ((currentItem is IBuildTarget) && ContainsTarget (args.Item, ((IBuildTarget)currentItem)))
- CurrentSelectedItem = null;
- }
-
- protected virtual void OnCurrentSelectedSolutionChanged(SolutionEventArgs e)
- {
- if (CurrentSelectedSolutionChanged != null) {
- CurrentSelectedSolutionChanged (this, e);
- }
- }
-
- protected virtual void OnCurrentProjectChanged(ProjectEventArgs e)
- {
- if (CurrentSelectedProject != null) {
- StringParserService.Properties["PROJECTNAME"] = CurrentSelectedProject.Name;
- }
- if (CurrentProjectChanged != null) {
- CurrentProjectChanged (this, e);
- }
- }
-
- public event BuildEventHandler StartBuild;
- public event BuildEventHandler EndBuild;
- public event EventHandler BeforeStartProject;
-
- public event EventHandler<SolutionEventArgs> CurrentSelectedSolutionChanged;
- public event ProjectEventHandler CurrentProjectChanged;
-
- // Fired just before an entry is added to a combine
- public event AddEntryEventHandler AddingEntryToCombine;
- }
-
- class ParseProgressMonitorFactory: IProgressMonitorFactory
- {
- public IProgressMonitor CreateProgressMonitor ()
- {
- return new BackgroundProgressMonitor (GettextCatalog.GetString ("Code completion database generation"), "md-parser");
- }
- }
-
- class OpenDocumentFileProvider: ITextFileProvider
- {
- public IEditableTextFile GetEditableTextFile (FilePath filePath)
- {
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.FileName == filePath) {
- IEditableTextFile ef = doc.GetContent<IEditableTextFile> ();
- if (ef != null) return ef;
- }
- }
- return null;
- }
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RootWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RootWorkspace.cs
deleted file mode 100644
index 9b5f213bfd..0000000000
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RootWorkspace.cs
+++ /dev/null
@@ -1,1334 +0,0 @@
-// RootWorkspace.cs
-//
-// Author:
-// Lluis Sanchez Gual <lluis@novell.com>
-//
-// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
-//
-// 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 System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Xml;
-using MonoDevelop.Projects;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Assemblies;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Serialization;
-using MonoDevelop.Projects.CodeGeneration;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Ide.Gui.Content;
-using System.Runtime.CompilerServices;
-using MonoDevelop.Core.Instrumentation;
-
-namespace MonoDevelop.Ide.Gui
-{
- public class RootWorkspace: IBuildTarget, IWorkspaceObject
- {
- WorkspaceItemCollection items;
-// IParserDatabase parserDatabase;
- string activeConfiguration;
- bool useDefaultRuntime;
-
- ProjectFileEventHandler fileAddedToProjectHandler;
- ProjectFileEventHandler fileRemovedFromProjectHandler;
- ProjectFileRenamedEventHandler fileRenamedInProjectHandler;
- ProjectFileEventHandler fileChangedInProjectHandler;
- ProjectFileEventHandler filePropertyChangedInProjectHandler;
- ProjectReferenceEventHandler referenceAddedToProjectHandler;
- ProjectReferenceEventHandler referenceRemovedFromProjectHandler;
- SolutionItemChangeEventHandler itemAddedToSolutionHandler;
- SolutionItemChangeEventHandler itemRemovedFromSolutionHandler;
- EventHandler<WorkspaceItemChangeEventArgs> descendantItemAddedHandler;
- EventHandler<WorkspaceItemChangeEventArgs> descendantItemRemovedHandler;
- EventHandler configurationsChanged;
-
- internal RootWorkspace ()
- {
- fileAddedToProjectHandler = (ProjectFileEventHandler) DispatchService.GuiDispatch (new ProjectFileEventHandler (NotifyFileAddedToProject));
- fileRemovedFromProjectHandler = (ProjectFileEventHandler) DispatchService.GuiDispatch (new ProjectFileEventHandler (NotifyFileRemovedFromProject));
- fileRenamedInProjectHandler = (ProjectFileRenamedEventHandler) DispatchService.GuiDispatch (new ProjectFileRenamedEventHandler (NotifyFileRenamedInProject));
- fileChangedInProjectHandler = (ProjectFileEventHandler) DispatchService.GuiDispatch (new ProjectFileEventHandler (NotifyFileChangedInProject));
- filePropertyChangedInProjectHandler = (ProjectFileEventHandler) DispatchService.GuiDispatch (new ProjectFileEventHandler (NotifyFilePropertyChangedInProject));
- referenceAddedToProjectHandler = (ProjectReferenceEventHandler) DispatchService.GuiDispatch (new ProjectReferenceEventHandler (NotifyReferenceAddedToProject));
- referenceRemovedFromProjectHandler = (ProjectReferenceEventHandler) DispatchService.GuiDispatch (new ProjectReferenceEventHandler (NotifyReferenceRemovedFromProject));
-
- itemAddedToSolutionHandler = (SolutionItemChangeEventHandler) DispatchService.GuiDispatch (new SolutionItemChangeEventHandler (NotifyItemAddedToSolution));
- itemRemovedFromSolutionHandler = (SolutionItemChangeEventHandler) DispatchService.GuiDispatch (new SolutionItemChangeEventHandler (NotifyItemRemovedFromSolution));
-
- descendantItemAddedHandler = (EventHandler<WorkspaceItemChangeEventArgs>) DispatchService.GuiDispatch (new EventHandler<WorkspaceItemChangeEventArgs> (NotifyDescendantItemAdded));
- descendantItemRemovedHandler = (EventHandler<WorkspaceItemChangeEventArgs>) DispatchService.GuiDispatch (new EventHandler<WorkspaceItemChangeEventArgs> (NotifyDescendantItemRemoved));
- configurationsChanged = (EventHandler) DispatchService.GuiDispatch (new EventHandler (NotifyConfigurationsChanged));
-
- FileService.FileRemoved += (EventHandler<FileEventArgs>) DispatchService.GuiDispatch (new EventHandler<FileEventArgs> (CheckFileRemove));
- FileService.FileRenamed += (EventHandler<FileCopyEventArgs>) DispatchService.GuiDispatch (new EventHandler<FileCopyEventArgs> (CheckFileRename));
-
- // Set the initial active runtime
- UseDefaultRuntime = true;
- IdeApp.Preferences.DefaultTargetRuntimeChanged += delegate {
- // If the default runtime changes and current active is default, update it
- if (UseDefaultRuntime) {
- Runtime.SystemAssemblyService.DefaultRuntime = IdeApp.Preferences.DefaultTargetRuntime;
- useDefaultRuntime = true;
- }
- };
-
- GLib.Timeout.Add (2000, OnRunProjectChecks);
- }
-
- public WorkspaceItemCollection Items {
- get {
- if (items == null)
- items = new RootWorkspaceItemCollection (this);
- return items;
- }
- }
- /*
- public IParserDatabase ParserDatabase {
- get {
- if (parserDatabase == null) {
- parserDatabase = Services.ParserService.CreateParserDatabase ();
- parserDatabase.TrackFileChanges = true;
- parserDatabase.ParseProgressMonitorFactory = new ParseProgressMonitorFactory ();
- }
- return parserDatabase;
- }
- }*/
-
- public string ActiveConfigurationId {
- get {
- return activeConfiguration;
- }
- set {
- if (activeConfiguration != value) {
- activeConfiguration = value;
- if (ActiveConfigurationChanged != null)
- ActiveConfigurationChanged (this, EventArgs.Empty);
- }
- }
- }
-
- public ConfigurationSelector ActiveConfiguration {
- get { return new SolutionConfigurationSelector (activeConfiguration); }
- }
-
- public TargetRuntime ActiveRuntime {
- get {
- return Runtime.SystemAssemblyService.DefaultRuntime;
- }
- set {
- useDefaultRuntime = false;
- Runtime.SystemAssemblyService.DefaultRuntime = value;
- }
- }
-
- public bool UseDefaultRuntime {
- get { return useDefaultRuntime; }
- set {
- if (useDefaultRuntime != value) {
- useDefaultRuntime = value;
- if (value)
- Runtime.SystemAssemblyService.DefaultRuntime = IdeApp.Preferences.DefaultTargetRuntime;
- }
- }
- }
-
- public bool IsOpen {
- get { return Items.Count > 0; }
- }
-
- public CodeRefactorer GetCodeRefactorer (Solution solution)
- {
- CodeRefactorer refactorer = new CodeRefactorer (solution);
- refactorer.TextFileProvider = new OpenDocumentFileProvider ();
- return refactorer;
- }
-
- IDictionary IExtendedDataItem.ExtendedProperties {
- get {
- throw new NotSupportedException ("Root namespace can't have extended properties.");
- }
- }
-
- string IWorkspaceObject.Name {
- get {
- return "MonoDevelop Workspace";
- }
- set {
- throw new NotSupportedException ("Can't change the name of the root workspace.");
- }
- }
-
- public FilePath BaseDirectory {
- get {
- return IdeApp.ProjectOperations.ProjectsDefaultPath;
- }
- }
-
- FilePath IWorkspaceObject.BaseDirectory {
- get {
- return BaseDirectory;
- }
- set {
- throw new NotSupportedException ();
- }
- }
-
- FilePath IWorkspaceObject.ItemDirectory {
- get {
- return BaseDirectory;
- }
- }
-
- public AuthorInformation GetAuthorInformation (SolutionItem item)
- {
- if (item != null)
- return GetAuthorInformation (item.ParentSolution);
- return AuthorInformation.Default;
- }
-
- public AuthorInformation GetAuthorInformation (Solution solution)
- {
- if (solution == null)
- return AuthorInformation.Default;
- AuthorInformation info = solution.UserProperties.GetValue<AuthorInformation> ("AuthorInfo");
- return info ?? AuthorInformation.Default;
- }
-
-#region Model queries
-
- public SolutionEntityItem FindSolutionItem (string fileName)
- {
- foreach (WorkspaceItem it in Items) {
- SolutionEntityItem si = it.FindSolutionItem (fileName);
- if (si != null)
- return si;
- }
- return null;
- }
-
- public ReadOnlyCollection<SolutionItem> GetAllSolutionItems ()
- {
- return GetAllSolutionItems<SolutionItem> ();
- }
-
- public virtual ReadOnlyCollection<T> GetAllSolutionItems<T> () where T: SolutionItem
- {
- List<T> list = new List<T> ();
- foreach (WorkspaceItem it in Items) {
- list.AddRange (it.GetAllSolutionItems<T> ());
- }
- return list.AsReadOnly ();
- }
-
- public ReadOnlyCollection<Project> GetAllProjects ()
- {
- return GetAllSolutionItems<Project> ();
- }
-
- public ReadOnlyCollection<Solution> GetAllSolutions ()
- {
- return GetAllItems<Solution> ();
- }
-
- public ReadOnlyCollection<T> GetAllItems<T> () where T:WorkspaceItem
- {
- List<T> list = new List<T> ();
- foreach (WorkspaceItem it in Items)
- GetAllItems<T> (list, it);
- return list.AsReadOnly ();
- }
-
- void GetAllItems<T> (List<T> list, WorkspaceItem item) where T: WorkspaceItem
- {
- if (item is T)
- list.Add ((T) item);
-
- if (item is Workspace) {
- foreach (WorkspaceItem citem in ((Workspace)item).Items)
- GetAllItems<T> (list, citem);
- }
- }
-
- public Project GetProjectContainingFile (string fileName)
- {
- foreach (WorkspaceItem it in Items) {
- Project p = it.GetProjectContainingFile (fileName);
- if (p != null)
- return p;
- }
- return null;
- }
-
-#endregion
-
-#region Build and run operations
-
- public void Save ()
- {
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
- try {
- Save (monitor);
- monitor.ReportSuccess (GettextCatalog.GetString ("Workspace saved."));
- } catch (Exception ex) {
- monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
- } finally {
- monitor.Dispose ();
- }
- }
-
- public IAsyncOperation Build ()
- {
- return IdeApp.ProjectOperations.Build (this);
- }
-
- public void Clean ()
- {
- IdeApp.ProjectOperations.Clean (this);
- }
-
- public IAsyncOperation Execute ()
- {
- if (IdeApp.ProjectOperations.CurrentSelectedSolution != null)
- return IdeApp.ProjectOperations.Execute (IdeApp.ProjectOperations.CurrentSelectedSolution);
- else {
- MessageService.ShowError (GettextCatalog.GetString ("No solution has been selected"), GettextCatalog.GetString ("The solution to be executed must be selected in the solution pad."));
- return null;
- }
- }
-
- public bool CanExecute ()
- {
- if (IdeApp.ProjectOperations.CurrentSelectedSolution != null)
- return IdeApp.ProjectOperations.CanExecute (IdeApp.ProjectOperations.CurrentSelectedSolution);
- else {
- return false;
- }
- }
-
- bool IBuildTarget.CanExecute (ExecutionContext context, ConfigurationSelector configuration)
- {
- if (IdeApp.ProjectOperations.CurrentSelectedSolution != null)
- return IdeApp.ProjectOperations.CurrentSelectedSolution.CanExecute (context, configuration);
- else {
- return false;
- }
- }
-
- public void Dispose ()
- {
- }
-
- public void Save (IProgressMonitor monitor)
- {
- monitor.BeginTask (GettextCatalog.GetString ("Saving Workspace..."), Items.Count);
- foreach (WorkspaceItem it in Items) {
- it.Save (monitor);
- monitor.Step (1);
- }
- monitor.EndTask ();
- }
-
- BuildResult IBuildTarget.RunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration)
- {
- BuildResult result = null;
- foreach (WorkspaceItem it in Items) {
- BuildResult res = it.RunTarget (monitor, target, configuration);
- if (res != null) {
- if (result == null)
- result = new BuildResult ();
- result.Append (res);
- }
- }
- return result;
- }
-
- public void Execute (MonoDevelop.Core.IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
- {
- Solution sol = IdeApp.ProjectOperations.CurrentSelectedSolution;
- if (sol == null) {
- ReadOnlyCollection<Solution> sols = GetAllSolutions ();
- if (sols.Count > 0)
- sol = sols [0];
- }
- if (sol != null)
- sol.Execute (monitor, context, configuration);
- else
- throw new UserException (GettextCatalog.GetString ("No solution has been selected."));
- }
-
- public bool NeedsBuilding ()
- {
- return NeedsBuilding (IdeApp.Workspace.ActiveConfiguration) || IsDirtyFileInCombine;
- }
-
- public bool NeedsBuilding (ConfigurationSelector configuration)
- {
- foreach (WorkspaceItem it in Items) {
- if (it.NeedsBuilding (configuration))
- return true;
- }
- return false;
- }
-
- public void SetNeedsBuilding (bool needsBuilding, ConfigurationSelector configuration)
- {
- foreach (WorkspaceItem it in Items)
- it.SetNeedsBuilding (needsBuilding, configuration);
- }
-
- bool IsDirtyFileInCombine {
- get {
- foreach (Project projectEntry in GetAllProjects()) {
- foreach (ProjectFile fInfo in projectEntry.Files) {
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.IsDirty && doc.FileName == fInfo.FilePath) {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
-
- public ReadOnlyCollection<string> GetConfigurations ()
- {
- List<string> configs = new List<string> ();
- foreach (WorkspaceItem it in Items) {
- foreach (string conf in it.GetConfigurations ()) {
- if (!configs.Contains (conf))
- configs.Add (conf);
- }
- }
- return configs.AsReadOnly ();
- }
-#endregion
-
-#region Opening and closing
-
- public void SavePreferences ()
- {
- foreach (WorkspaceItem it in Items)
- SavePreferences (it);
- }
-
- public bool Close ()
- {
- return Close (true);
- }
-
- public bool Close (bool saveWorkspacePreferencies)
- {
- if (Items.Count > 0) {
-
- // Request permission for unloading the items
- foreach (WorkspaceItem it in new List<WorkspaceItem> (Items)) {
- if (!RequestItemUnload (it))
- return false;
- }
-
- if (saveWorkspacePreferencies)
- SavePreferences ();
-
- Document[] docs = new Document[IdeApp.Workbench.Documents.Count];
- IdeApp.Workbench.Documents.CopyTo (docs, 0);
- foreach (Document doc in docs) {
- if (doc.HasProject) {
- if (!doc.Close ())
- return false;
- }
- }
-
- foreach (WorkspaceItem it in new List<WorkspaceItem> (Items)) {
- try {
- Items.Remove (it);
- it.Dispose ();
- } catch (Exception ex) {
- MessageService.ShowException (ex, GettextCatalog.GetString ("Could not close solution '{0}'.", it.Name));
- }
- }
- }
- return true;
- }
-
- public void CloseWorkspaceItem (WorkspaceItem item)
- {
- if (!Items.Contains (item))
- throw new InvalidOperationException ("Only top level items can be closed.");
-
- if (RequestItemUnload (item))
- Items.Remove (item);
- }
-
- public bool RequestItemUnload (IBuildTarget item)
- {
- if (ItemUnloading != null) {
- try {
- ItemUnloadingEventArgs args = new ItemUnloadingEventArgs (item);
- ItemUnloading (this, args);
- return !args.Cancel;
- } catch (Exception ex) {
- LoggingService.LogError ("Exception in ItemUnloading.", ex);
- }
- }
- return true;
- }
-
- public IAsyncOperation OpenWorkspaceItem (string filename)
- {
- return OpenWorkspaceItem (filename, true);
- }
-
- public IAsyncOperation OpenWorkspaceItem (string filename, bool closeCurrent)
- {
- return OpenWorkspaceItem (filename, closeCurrent, true);
- }
-
- public IAsyncOperation OpenWorkspaceItem (string filename, bool closeCurrent, bool loadPreferences)
- {
- if (closeCurrent) {
- if (!Close ())
- return MonoDevelop.Core.ProgressMonitoring.NullAsyncOperation.Failure;
- }
-
- if (filename.StartsWith ("file://"))
- filename = new Uri(filename).LocalPath;
-
- IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true);
-
- DispatchService.BackgroundDispatch (delegate {
- BackgroundLoadWorkspace (monitor, filename, loadPreferences);
- });
- return monitor.AsyncOperation;
- }
-
- void ReattachDocumentProjects (IEnumerable<string> closedDocs)
- {
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.Project == null && doc.IsFile) {
- Project p = GetProjectContainingFile (doc.FileName);
- if (p != null)
- doc.SetProject (p);
- }
- }
- if (closedDocs != null) {
- foreach (string doc in closedDocs) {
- IdeApp.Workbench.OpenDocument (doc, false);
- }
- }
- }
-
- void BackgroundLoadWorkspace (IProgressMonitor monitor, string filename, bool loadPreferences)
- {
- WorkspaceItem item = null;
- ITimeTracker timer = Counters.OpenWorkspaceItemTimer.BeginTiming ();
-
- try {
- if (!File.Exists (filename)) {
- monitor.ReportError (GettextCatalog.GetString ("File not found: {0}", filename), null);
- monitor.Dispose ();
- return;
- }
-
- if (!Services.ProjectService.IsWorkspaceItemFile (filename)) {
- if (!Services.ProjectService.IsSolutionItemFile (filename)) {
- monitor.ReportError (GettextCatalog.GetString ("File is not a project or solution: {0}", filename), null);
- monitor.Dispose ();
- return;
- }
-
- // It is a project, not a solution. Try to create a dummy solution and add the project to it
-
- timer.Trace ("Getting wrapper solution");
- item = IdeApp.Services.ProjectService.GetWrapperSolution (monitor, filename);
- }
-
- if (item == null) {
- timer.Trace ("Reading item");
- item = Services.ProjectService.ReadWorkspaceItem (monitor, filename);
- if (monitor.IsCancelRequested) {
- monitor.Dispose ();
- return;
- }
- }
-
- timer.Trace ("Registering to recent list");
- IdeApp.Workbench.RecentOpen.AddLastProject (item.FileName, item.Name);
-
- timer.Trace ("Adding to items list");
- Items.Add (item);
-
- timer.Trace ("Searching for new files");
- SearchForNewFiles ();
-
- } catch (Exception ex) {
- monitor.ReportError ("Load operation failed.", ex);
-
- // Don't use 'finally' to dispose the monitor, since it has to be disposed later
- monitor.Dispose ();
- timer.End ();
- return;
- }
-
- Gtk.Application.Invoke (delegate {
- using (monitor) {
- try {
- if (Items.Count == 1 && loadPreferences) {
- timer.Trace ("Restoring workspace preferences");
- RestoreWorkspacePreferences (item);
- }
- timer.Trace ("Reattaching documents");
- ReattachDocumentProjects (null);
- monitor.ReportSuccess (GettextCatalog.GetString ("Solution loaded."));
- } finally {
- timer.End ();
- }
- }
- });
- }
-
- void SearchForNewFiles ()
- {
- foreach (Project p in GetAllProjects()) {
- if (p.NewFileSearch != NewFileSearch.None)
- SearchNewFiles (p);
- }
- }
-
-
- void SearchNewFiles (Project project)
- {
- List<string> newFiles = new List<string> ();
- string[] collection = Directory.GetFiles (project.BaseDirectory, "*", SearchOption.AllDirectories);
-
- HashSet<string> projectFiles = new HashSet<string> ();
- foreach (string file in project.GetItemFiles (true))
- projectFiles.Add (file);
-
- foreach (string sfile in collection) {
- if (projectFiles.Contains (Path.GetFullPath (sfile)))
- continue;
- if (IdeApp.Services.ProjectService.IsSolutionItemFile (sfile) || IdeApp.Services.ProjectService.IsWorkspaceItemFile (sfile))
- continue;
- string extension = Path.GetExtension(sfile).ToUpper();
- string file = Path.GetFileName (sfile);
-
- if (extension != ".SCC" && // source safe control files -- Svante Lidmans
- extension != ".DLL" &&
- extension != ".PDB" &&
- extension != ".EXE" &&
- extension != ".CMBX" &&
- extension != ".PRJX" &&
- extension != ".SWP" &&
- extension != ".MDSX" &&
- extension != ".MDS" &&
- extension != ".MDP" &&
- extension != ".PIDB" &&
- extension != ".PIDB-JOURNAL" &&
- !file.EndsWith ("make.sh") &&
- !file.EndsWith ("~") &&
- !file.StartsWith (".") &&
- !(Path.GetDirectoryName(sfile).IndexOf("CVS") != -1) &&
- !(Path.GetDirectoryName(sfile).IndexOf(".svn") != -1) &&
- !(Path.GetDirectoryName(sfile).IndexOf(Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar) != -1) &&
- !file.StartsWith ("Makefile") &&
- !Path.GetDirectoryName(file).EndsWith("ProjectDocumentation")) {
-
- newFiles.Add(sfile);
- }
- }
-
- if (newFiles.Count > 0) {
- if (project.NewFileSearch == NewFileSearch.OnLoadAutoInsert) {
- foreach (string file in newFiles) {
- project.AddFile (file);
- }
- } else {
- DispatchService.GuiDispatch (
- delegate (object state) {
- NewFilesMessage message = (NewFilesMessage) state;
- IncludeNewFilesDialog includeNewFilesDialog = new IncludeNewFilesDialog (message.Project);
- includeNewFilesDialog.AddFiles (message.NewFiles);
- includeNewFilesDialog.TransientFor = IdeApp.Workbench.RootWindow;
- includeNewFilesDialog.Run ();
- includeNewFilesDialog.Destroy ();
- },
- new NewFilesMessage (project, newFiles)
- );
- }
- }
- }
-
- private class NewFilesMessage
- {
- public Project Project;
- public List<string> NewFiles;
- public NewFilesMessage (Project p, List<string> newFiles)
- {
- this.Project = p;
- this.NewFiles = newFiles;
- }
- }
-
- void RestoreWorkspacePreferences (WorkspaceItem item)
- {
- // Restore local configuration data
-
- try {
- WorkspaceUserData data = item.UserProperties.GetValue<WorkspaceUserData> ("MonoDevelop.Ide.Workspace");
- if (data != null) {
- ActiveConfigurationId = data.ActiveConfiguration;
- if (string.IsNullOrEmpty (data.ActiveRuntime))
- UseDefaultRuntime = true;
- else {
- TargetRuntime tr = Runtime.SystemAssemblyService.GetTargetRuntime (data.ActiveRuntime);
- if (tr != null)
- ActiveRuntime = tr;
- else
- UseDefaultRuntime = true;
- }
- }
- }
- catch (Exception ex) {
- LoggingService.LogError ("Exception while loading user solution preferences.", ex);
- }
-
- // Allow add-ins to restore preferences
-
- if (LoadingUserPreferences != null) {
- UserPreferencesEventArgs args = new UserPreferencesEventArgs (item, item.UserProperties);
- try {
- LoadingUserPreferences (this, args);
- } catch (Exception ex) {
- LoggingService.LogError ("Exception in LoadingUserPreferences.", ex);
- }
- }
- }
-
- public void SavePreferences (WorkspaceItem item)
- {
- // Local configuration info
-
- WorkspaceUserData data = new WorkspaceUserData ();
- data.ActiveConfiguration = ActiveConfigurationId;
- data.ActiveRuntime = UseDefaultRuntime ? null : ActiveRuntime.Id;
- item.UserProperties.SetValue ("MonoDevelop.Ide.Workspace", data);
-
- // Allow add-ins to fill-up data
-
- if (StoringUserPreferences != null) {
- UserPreferencesEventArgs args = new UserPreferencesEventArgs (item, item.UserProperties);
- try {
- StoringUserPreferences (this, args);
- } catch (Exception ex) {
- LoggingService.LogError ("Exception in UserPreferencesRequested.", ex);
- }
- }
-
- // Save the file
-
- item.SaveUserProperties ();
- }
-
- bool OnRunProjectChecks ()
- {
- // If any project has been modified, reload it
- foreach (WorkspaceItem it in new List<WorkspaceItem> (Items))
- OnCheckWorkspaceItem (it);
- return true;
- }
-
- void OnCheckWorkspaceItem (WorkspaceItem item)
- {
- if (item.NeedsReload) {
- IEnumerable<string> closedDocs;
- if (AllowReload (item.GetAllProjects (), out closedDocs)) {
- if (item.ParentWorkspace == null) {
- string file = item.FileName;
- SavePreferences ();
- CloseWorkspaceItem (item);
- OpenWorkspaceItem (file, false);
- }
- else {
- using (IProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true)) {
- item.ParentWorkspace.ReloadItem (m, item);
- ReattachDocumentProjects (closedDocs);
- }
- }
-
- return;
- } else
- item.NeedsReload = false;
- }
-
- if (item is Workspace) {
- Workspace ws = (Workspace) item;
- List<WorkspaceItem> items = new List<WorkspaceItem> (ws.Items);
- foreach (WorkspaceItem it in items)
- OnCheckWorkspaceItem (it);
- }
- else if (item is Solution) {
- Solution sol = (Solution) item;
- OnCheckProject (sol.RootFolder);
- }
- }
-
- void OnCheckProject (SolutionItem entry)
- {
- if (entry.NeedsReload) {
- IEnumerable projects = null;
- if (entry is Project) {
- projects = new Project [] { (Project) entry };
- } else if (entry is SolutionFolder) {
- projects = ((SolutionFolder)entry).GetAllProjects ();
- }
-
- IEnumerable<string> closedDocs;
-
- if (AllowReload (projects, out closedDocs)) {
- using (IProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
- // Root folders never need to reload
- entry.ParentFolder.ReloadItem (m, entry);
- ReattachDocumentProjects (closedDocs);
- }
- return;
- } else
- entry.NeedsReload = false;
- }
-
- if (entry is SolutionFolder) {
- ArrayList ens = new ArrayList ();
- foreach (SolutionItem ce in ((SolutionFolder)entry).Items)
- ens.Add (ce);
- foreach (SolutionItem ce in ens)
- OnCheckProject (ce);
- }
- }
-
-// bool AllowReload (IEnumerable projects)
-// {
-// IEnumerable<string> closedDocs;
-// return AllowReload (projects, out closedDocs);
-// }
-
- bool AllowReload (IEnumerable projects, out IEnumerable<string> closedDocs)
- {
- closedDocs = null;
-
- if (projects == null)
- return true;
-
- List<Document> docs = new List<Document> ();
- foreach (Project p in projects) {
- docs.AddRange (GetOpenDocuments (p, false));
- }
-
- if (docs.Count == 0)
- return true;
-
- // Find a common project reload capability
-
- bool hasUnsaved = false;
- bool hasNoFiles = false;
- ProjectReloadCapability prc = ProjectReloadCapability.Full;
- foreach (Document doc in docs) {
- if (doc.IsDirty)
- hasUnsaved = true;
- if (!doc.IsFile)
- hasNoFiles = true;
- ISupportsProjectReload pr = doc.GetContent<ISupportsProjectReload> ();
- if (pr != null) {
- ProjectReloadCapability c = pr.ProjectReloadCapability;
- if ((int) c < (int) prc)
- prc = c;
- }
- else
- prc = ProjectReloadCapability.None;
- }
-
- string msg = null;
-
- switch (prc) {
- case ProjectReloadCapability.None:
- if (hasNoFiles && hasUnsaved)
- msg = GettextCatalog.GetString ("WARNING: Some documents may need to be closed, and unsaved data will be lost. You will be asked to save the unsaved documents.");
- else if (hasNoFiles)
- msg = GettextCatalog.GetString ("WARNING: Some documents may need to be reloaded or closed, and unsaved data will be lost. You will be asked to save the unsaved documents.");
- else if (hasUnsaved)
- msg = GettextCatalog.GetString ("WARNING: Some files may need to be reloaded, and unsaved data will be lost. You will be asked to save the unsaved files.");
- else
- goto case ProjectReloadCapability.UnsavedData;
- break;
-
- case ProjectReloadCapability.UnsavedData:
- msg = GettextCatalog.GetString ("Some files may need to be reloaded, and editing status for those files (such as the undo queue) will be lost.");
- break;
- }
- if (msg != null) {
- if (!MessageService.Confirm (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", docs[0].Project.Name), msg, AlertButton.Reload))
- return false;
- }
-
- List<string> closed = new List<string> ();
-
- foreach (Document doc in docs) {
- if (doc.IsDirty)
- hasUnsaved = true;
- ISupportsProjectReload pr = doc.GetContent<ISupportsProjectReload> ();
- if (pr != null)
- doc.SetProject (null);
- else {
- FilePath file = doc.IsFile ? doc.FileName : FilePath.Null;
- EventHandler saved = delegate {
- if (doc.IsFile)
- file = doc.FileName;
- };
- doc.Saved += saved;
- try {
- if (!doc.Close ())
- return false;
- else if (!file.IsNullOrEmpty && File.Exists (file))
- closed.Add (file);
- } finally {
- doc.Saved -= saved;
- }
- }
- }
- closedDocs = closed;
-
- return true;
- }
-
- internal List<Document> GetOpenDocuments (Project project, bool modifiedOnly)
- {
- List<Document> docs = new List<Document> ();
- foreach (Document doc in IdeApp.Workbench.Documents) {
- if (doc.Project == project && (!modifiedOnly || doc.IsDirty)) {
- docs.Add (doc);
- }
- }
- return docs;
- }
-
-
-#endregion
-
-#region Event handling
-
- internal void NotifyItemAdded (WorkspaceItem item)
- {
- if (DispatchService.IsGuiThread)
- NotifyItemAddedGui (item);
- else
- Gtk.Application.Invoke (delegate {
- NotifyItemAddedGui (item);
- });
- }
-
- void NotifyItemAddedGui (WorkspaceItem item)
- {
- try {
-// Mono.Profiler.RuntimeControls.EnableProfiler ();
- MonoDevelop.Projects.Dom.Parser.ProjectDomService.Load (item);
-// Mono.Profiler.RuntimeControls.DisableProfiler ();
-// Console.WriteLine ("PARSE LOAD: " + (DateTime.Now - t).TotalMilliseconds);
- } catch (Exception ex) {
- LoggingService.LogError ("Could not load parser database.", ex);
- }
-
- Workspace ws = item as Workspace;
- if (ws != null) {
- ws.DescendantItemAdded += descendantItemAddedHandler;
- ws.DescendantItemRemoved += descendantItemRemovedHandler;
- }
- item.ConfigurationsChanged += configurationsChanged;
-
- WorkspaceItemEventArgs args = new WorkspaceItemEventArgs (item);
- NotifyDescendantItemAdded (this, args);
- NotifyConfigurationsChanged (null, args);
-
- if (WorkspaceItemOpened != null)
- WorkspaceItemOpened (this, args);
- if (Items.Count == 1) {
- IdeApp.Workbench.CurrentLayout = "Solution";
- if (FirstWorkspaceItemOpened != null)
- FirstWorkspaceItemOpened (this, args);
- }
- }
-
- internal void NotifyItemRemoved (WorkspaceItem item)
- {
- if (DispatchService.IsGuiThread)
- NotifyItemRemovedGui (item);
- else
- Gtk.Application.Invoke (delegate {
- NotifyItemRemovedGui (item);
- });
- }
-
- internal void NotifyItemRemovedGui (WorkspaceItem item)
- {
- Workspace ws = item as Workspace;
- if (ws != null) {
- ws.DescendantItemAdded -= descendantItemAddedHandler;
- ws.DescendantItemRemoved -= descendantItemRemovedHandler;
- }
- item.ConfigurationsChanged -= configurationsChanged;
-
- if (Items.Count == 0) {
- IdeApp.Workbench.CurrentLayout = "Default";
- if (LastWorkspaceItemClosed != null)
- LastWorkspaceItemClosed (this, EventArgs.Empty);
- }
-
- WorkspaceItemEventArgs args = new WorkspaceItemEventArgs (item);
- NotifyConfigurationsChanged (null, args);
-
- if (WorkspaceItemClosed != null)
- WorkspaceItemClosed (this, args);
-
- MonoDevelop.Projects.Dom.Parser.ProjectDomService.Unload (item);
-// ParserDatabase.Unload (item);
-
- NotifyDescendantItemRemoved (this, args);
- }
-
- void SubscribeSolution (Solution sol)
- {
- sol.FileAddedToProject += fileAddedToProjectHandler;
- sol.FileRemovedFromProject += fileRemovedFromProjectHandler;
- sol.FileRenamedInProject += fileRenamedInProjectHandler;
- sol.FileChangedInProject += fileChangedInProjectHandler;
- sol.FilePropertyChangedInProject += filePropertyChangedInProjectHandler;
- sol.ReferenceAddedToProject += referenceAddedToProjectHandler;
- sol.ReferenceRemovedFromProject += referenceRemovedFromProjectHandler;
- sol.SolutionItemAdded += itemAddedToSolutionHandler;
- sol.SolutionItemRemoved += itemRemovedFromSolutionHandler;
- }
-
- void UnsubscribeSolution (Solution solution)
- {
- solution.FileAddedToProject -= fileAddedToProjectHandler;
- solution.FileRemovedFromProject -= fileRemovedFromProjectHandler;
- solution.FileRenamedInProject -= fileRenamedInProjectHandler;
- solution.FileChangedInProject -= fileChangedInProjectHandler;
- solution.FilePropertyChangedInProject -= filePropertyChangedInProjectHandler;
- solution.ReferenceAddedToProject -= referenceAddedToProjectHandler;
- solution.ReferenceRemovedFromProject -= referenceRemovedFromProjectHandler;
- solution.SolutionItemAdded -= itemAddedToSolutionHandler;
- solution.SolutionItemRemoved -= itemRemovedFromSolutionHandler;
- }
-
- void NotifyConfigurationsChanged (object s, EventArgs a)
- {
- if (ConfigurationsChanged != null)
- ConfigurationsChanged (this, a);
- }
-
- void NotifyFileRemovedFromProject (object sender, ProjectFileEventArgs e)
- {
- if (FileRemovedFromProject != null) {
- FileRemovedFromProject(this, e);
- }
- }
-
- void NotifyFileAddedToProject (object sender, ProjectFileEventArgs e)
- {
- if (FileAddedToProject != null) {
- FileAddedToProject (this, e);
- }
- }
-
- internal void NotifyFileRenamedInProject (object sender, ProjectFileRenamedEventArgs e)
- {
- if (FileRenamedInProject != null) {
- FileRenamedInProject (this, e);
- }
- }
-
- internal void NotifyFileChangedInProject (object sender, ProjectFileEventArgs e)
- {
- if (FileChangedInProject != null) {
- FileChangedInProject (this, e);
- }
- }
-
- internal void NotifyFilePropertyChangedInProject (object sender, ProjectFileEventArgs e)
- {
- if (FilePropertyChangedInProject != null) {
- FilePropertyChangedInProject (this, e);
- }
- }
-
- internal void NotifyReferenceAddedToProject (object sender, ProjectReferenceEventArgs e)
- {
- if (ReferenceAddedToProject != null) {
- ReferenceAddedToProject (this, e);
- }
- }
-
- internal void NotifyReferenceRemovedFromProject (object sender, ProjectReferenceEventArgs e)
- {
- if (ReferenceRemovedFromProject != null) {
- ReferenceRemovedFromProject (this, e);
- }
- }
-
- void NotifyItemAddedToSolution (object sender, SolutionItemEventArgs args)
- {
- // Delay the notification of this event to ensure that the new project is properly
- // registered in the parser database when it is fired
-
- Gtk.Application.Invoke (delegate {
- if (ItemAddedToSolution != null)
- ItemAddedToSolution (sender, args);
- });
- }
-
- void NotifyItemRemovedFromSolution (object sender, SolutionItemEventArgs args)
- {
- NotifyItemRemovedFromSolutionRec (sender, args.SolutionItem, args.Solution);
- }
-
- void NotifyItemRemovedFromSolutionRec (object sender, SolutionItem e, Solution sol)
- {
- if (e == IdeApp.ProjectOperations.CurrentSelectedSolutionItem)
- IdeApp.ProjectOperations.CurrentSelectedSolutionItem = null;
-
- if (e is SolutionFolder) {
- foreach (SolutionItem ce in ((SolutionFolder)e).Items)
- NotifyItemRemovedFromSolutionRec (sender, ce, sol);
- }
- if (ItemRemovedFromSolution != null)
- ItemRemovedFromSolution (sender, new SolutionItemEventArgs (e, sol));
- }
-
- void NotifyDescendantItemAdded (object s, WorkspaceItemEventArgs args)
- {
- // If a top level item has been moved to a child item, remove it from
- // the top
- if (s != this && Items.Contains (args.Item))
- Items.Remove (args.Item);
- foreach (WorkspaceItem item in args.Item.GetAllItems ()) {
- if (item is Solution)
- SubscribeSolution ((Solution)item);
- OnItemLoaded (item);
- }
- }
-
- void NotifyDescendantItemRemoved (object s, WorkspaceItemEventArgs args)
- {
- foreach (WorkspaceItem item in args.Item.GetAllItems ()) {
- OnItemUnloaded (item);
- if (item is Solution)
- UnsubscribeSolution ((Solution)item);
- }
- }
-
- void OnItemLoaded (WorkspaceItem item)
- {
- try {
- if (WorkspaceItemLoaded != null)
- WorkspaceItemLoaded (this, new WorkspaceItemEventArgs (item));
- if (item is Solution && SolutionLoaded != null)
- SolutionLoaded (this, new SolutionEventArgs ((Solution)item));
- } catch (Exception ex) {
- LoggingService.LogError ("Error in SolutionOpened event.", ex);
- }
- }
-
- void OnItemUnloaded (WorkspaceItem item)
- {
- try {
- if (WorkspaceItemUnloaded != null)
- WorkspaceItemUnloaded (this, new WorkspaceItemEventArgs (item));
- if (item is Solution && SolutionUnloaded != null)
- SolutionUnloaded (this, new SolutionEventArgs ((Solution)item));
- } catch (Exception ex) {
- LoggingService.LogError ("Error in SolutionClosed event.", ex);
- }
- }
-
- void CheckFileRemove(object sender, FileEventArgs e)
- {
- foreach (Solution sol in GetAllSolutions ())
- sol.RootFolder.RemoveFileFromProjects (e.FileName);
- }
-
- void CheckFileRename(object sender, FileCopyEventArgs e)
- {
- foreach (Solution sol in GetAllSolutions ())
- sol.RootFolder.RenameFileInProjects (e.SourceFile, e.TargetFile);
- }
-
-#endregion
-
-#region Event declaration
-
- public event ProjectFileEventHandler FileRemovedFromProject;
- public event ProjectFileEventHandler FileAddedToProject;
- public event ProjectFileEventHandler FileChangedInProject;
- public event ProjectFileEventHandler FilePropertyChangedInProject;
- public event ProjectFileRenamedEventHandler FileRenamedInProject;
-
- public event EventHandler<SolutionEventArgs> SolutionLoaded;
- public event EventHandler<SolutionEventArgs> SolutionUnloaded;
- public event EventHandler<WorkspaceItemEventArgs> FirstWorkspaceItemOpened;
- public event EventHandler LastWorkspaceItemClosed;
- public event EventHandler<WorkspaceItemEventArgs> WorkspaceItemLoaded;
- public event EventHandler<WorkspaceItemEventArgs> WorkspaceItemUnloaded;
- public event EventHandler<WorkspaceItemEventArgs> WorkspaceItemOpened;
- public event EventHandler<WorkspaceItemEventArgs> WorkspaceItemClosed;
- public event EventHandler<UserPreferencesEventArgs> StoringUserPreferences;
- public event EventHandler<UserPreferencesEventArgs> LoadingUserPreferences;
- public event EventHandler<ItemUnloadingEventArgs> ItemUnloading;
-
- public event EventHandler<SolutionEventArgs> CurrentSelectedSolutionChanged;
-
- public event ProjectReferenceEventHandler ReferenceAddedToProject;
- public event ProjectReferenceEventHandler ReferenceRemovedFromProject;
-
- // Fired just before an entry is added to a combine
- public event SolutionItemEventHandler ItemAddedToSolution;
- public event SolutionItemEventHandler ItemRemovedFromSolution;
-
- public event EventHandler ActiveConfigurationChanged;
- public event EventHandler ConfigurationsChanged;
-
- public event EventHandler RuntimesChanged {
- add { Runtime.SystemAssemblyService.RuntimesChanged += value; }
- remove { Runtime.SystemAssemblyService.RuntimesChanged -= value; }
- }
-
- public event EventHandler ActiveRuntimeChanged {
- add { Runtime.SystemAssemblyService.DefaultRuntimeChanged += value; }
- remove { Runtime.SystemAssemblyService.DefaultRuntimeChanged -= value; }
- }
-#endregion
- }
-
- class RootWorkspaceItemCollection: WorkspaceItemCollection
- {
- RootWorkspace parent;
-
- public RootWorkspaceItemCollection (RootWorkspace parent)
- {
- this.parent = parent;
- }
-
- protected override void ClearItems ()
- {
- if (parent != null) {
- List<WorkspaceItem> items = new List<WorkspaceItem> (this);
- foreach (WorkspaceItem it in items)
- parent.NotifyItemRemoved (it);
- }
- else
- base.ClearItems ();
- }
-
- protected override void InsertItem (int index, WorkspaceItem item)
- {
- base.InsertItem (index, item);
- if (parent != null)
- parent.NotifyItemAdded (item);
- }
-
- protected override void RemoveItem (int index)
- {
- WorkspaceItem item = this [index];
- base.RemoveItem (index);
- if (parent != null)
- parent.NotifyItemRemoved (item);
- }
-
- protected override void SetItem (int index, WorkspaceItem item)
- {
- WorkspaceItem oldItem = this [index];
- base.SetItem (index, item);
- if (parent != null) {
- parent.NotifyItemRemoved (oldItem);
- parent.NotifyItemAdded (item);
- }
- }
- }
-
- public class UserPreferencesEventArgs: WorkspaceItemEventArgs
- {
- PropertyBag properties;
-
- public PropertyBag Properties {
- get {
- return properties;
- }
- }
-
- public UserPreferencesEventArgs (WorkspaceItem item, PropertyBag properties): base (item)
- {
- this.properties = properties;
- }
- }
-
- [DataItem ("Workspace")]
- class WorkspaceUserData
- {
- [ItemProperty]
- public string ActiveConfiguration;
- [ItemProperty]
- public string ActiveRuntime;
- }
-
- public class ItemUnloadingEventArgs: EventArgs
- {
- IBuildTarget item;
-
- public bool Cancel { get; set; }
-
- public IBuildTarget Item {
- get {
- return item;
- }
- }
-
- public ItemUnloadingEventArgs (IBuildTarget item)
- {
- this.item = item;
- }
- }
-}
-
-namespace Mono.Profiler {
- public class RuntimeControls {
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void TakeHeapSnapshot ();
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void EnableProfiler ();
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern void DisableProfiler ();
- }
-}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
index 2e464c4ee1..ddf15051a2 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
@@ -34,7 +34,6 @@ using System.Linq;
using MonoDevelop.Core;
using Gtk;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components;
using Mono.Addins;
using MonoDevelop.Ide.Commands;
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 f9dd8e396b..1d34970b5b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
@@ -31,7 +31,6 @@ using System.IO;
using Gtk;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components;
using MonoDevelop.Ide.Commands;
using MonoDevelop.Components.Commands;
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 d2fedd5a0e..78acc52022 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs
@@ -27,14 +27,9 @@
//
-using System;
using System.Collections.Generic;
-using System.IO;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Dialogs;
-using MonoDevelop.Core.Gui.ProgressMonitoring;
-using MonoDevelop.Core;
using MonoDevelop.Ide.Gui.Dialogs;
+using MonoDevelop.Ide.ProgressMonitoring;
namespace MonoDevelop.Ide.Gui
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StockIcons.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StockIcons.cs
new file mode 100644
index 0000000000..9cdafe0d22
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StockIcons.cs
@@ -0,0 +1,146 @@
+// Stock.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class Stock
+ {
+ public static readonly IconId AddNamespace = "md-add-namespace";
+ public static readonly IconId BreakPoint = "md-break-point";
+ public static readonly IconId BuildCombine = "md-build-combine";
+ public static readonly IconId BuildCurrentSelectedProject = "md-build-current-selected-project";
+ public static readonly IconId Class = "md-class";
+ public static readonly IconId ClearAllBookmarks = "md-clear-all-bookmarks";
+ public static readonly IconId CloseAllDocuments = "md-close-all-documents";
+ public static readonly IconId CloseCombine = "md-close-combine-icon";
+ public static readonly IconId CloseIcon = Gtk.Stock.Close;
+ public static readonly IconId ClosedFolder = "md-closed-folder";
+ public static readonly IconId ClosedReferenceFolder = "md-closed-reference-folder";
+ public static readonly IconId ClosedResourceFolder = "md-closed-resource-folder";
+ public static readonly IconId Solution = "md-solution";
+ public static readonly IconId Workspace = "md-workspace";
+ public static readonly IconId CopyIcon = Gtk.Stock.Copy;
+ public static readonly IconId CutIcon = Gtk.Stock.Cut;
+ public static readonly IconId Delegate = "md-delegate";
+ public static readonly IconId DeleteIcon = Gtk.Stock.Delete;
+ public static readonly IconId Empty = "md-empty";
+ public static readonly IconId EmptyFileIcon = "md-empty-file-icon";
+ public static readonly IconId Enum = "md-enum";
+ public static readonly IconId Error = Gtk.Stock.DialogError;
+ public static readonly IconId Event = "md-event";
+ public static readonly IconId ExecutionMarker = "md-execution-marker";
+ public static readonly IconId Field = "md-field";
+ public static readonly IconId FileXmlIcon = "md-file-xml-icon";
+ public static readonly IconId FindIcon = Gtk.Stock.Find;
+ public static readonly IconId FindInFiles = "md-find-in-files";
+ public static readonly IconId FindNextIcon = "md-find-next-icon";
+ public static readonly IconId FullScreen = Gtk.Stock.Fullscreen;
+ public static readonly IconId GotoNextbookmark = "md-goto-nextbookmark";
+ public static readonly IconId GotoPrevbookmark = "md-goto-prevbookmark";
+ public static readonly IconId Information = Gtk.Stock.DialogInfo;
+ public static readonly IconId Interface = "md-interface";
+ public static readonly IconId InternalClass = "md-internal-class";
+ public static readonly IconId InternalDelegate = "md-internal-delegate";
+ public static readonly IconId InternalEnum = "md-internal-enum";
+ public static readonly IconId InternalEvent = "md-internal-event";
+ public static readonly IconId InternalField = "md-internal-field";
+ public static readonly IconId InternalInterface = "md-internal-interface";
+ public static readonly IconId InternalMethod = "md-internal-method";
+ public static readonly IconId InternalProperty = "md-internal-property";
+ public static readonly IconId InternalStruct = "md-internal-struct";
+ public static readonly IconId Literal = "md-literal";
+ public static readonly IconId Method = "md-method";
+ public static readonly IconId MiscFiles = "md-misc-files";
+ public static readonly IconId NameSpace = "md-name-space";
+ public static readonly IconId NewDocumentIcon = Gtk.Stock.New;
+ public static readonly IconId NewFolderIcon = "md-new-folder-icon";
+ public static readonly IconId NewProjectIcon = "md-new-project-icon";
+ public static readonly IconId NextWindowIcon = Gtk.Stock.GoForward;
+ public static readonly IconId OpenFileIcon = Gtk.Stock.Open;
+ public static readonly IconId OpenFolder = "md-open-folder";
+ public static readonly IconId OpenProjectIcon = "md-open-project-icon";
+ public static readonly IconId OpenReferenceFolder = "md-open-reference-folder";
+ public static readonly IconId OpenResourceFolder = "md-open-resource-folder";
+ public static readonly IconId Options = Gtk.Stock.Preferences;
+ public static readonly IconId OutputIcon = "md-output-icon";
+ public static readonly IconId PasteIcon = Gtk.Stock.Paste;
+ public static readonly IconId PreView = Gtk.Stock.PrintPreview;
+ public static readonly IconId PrevWindowIcon = Gtk.Stock.GoBack;
+ public static readonly IconId Print = Gtk.Stock.Print;
+ public static readonly IconId PrivateClass = "md-private-class";
+ public static readonly IconId PrivateDelegate = "md-private-delegate";
+ public static readonly IconId PrivateEnum = "md-private-enum";
+ public static readonly IconId PrivateEvent = "md-private-event";
+ public static readonly IconId PrivateField = "md-private-field";
+ public static readonly IconId PrivateInterface = "md-private-interface";
+ public static readonly IconId PrivateMethod = "md-private-method";
+ public static readonly IconId PrivateProperty = "md-private-property";
+ public static readonly IconId PrivateStruct = "md-private-struct";
+ public static readonly IconId PropertiesIcon = "md-properties-icon";
+ public static readonly IconId Property = "md-property";
+ public static readonly IconId ProtectedClass = "md-protected-class";
+ public static readonly IconId ProtectedDelegate = "md-protected-delegate";
+ public static readonly IconId ProtectedEnum = "md-protected-enum";
+ public static readonly IconId ProtectedEvent = "md-protected-event";
+ public static readonly IconId ProtectedField = "md-protected-field";
+ public static readonly IconId ProtectedInterface = "md-protected-interface";
+ public static readonly IconId ProtectedMethod = "md-protected-method";
+ public static readonly IconId ProtectedProperty = "md-protected-property";
+ public static readonly IconId ProtectedStruct = "md-protected-struct";
+ public static readonly IconId Question = Gtk.Stock.DialogQuestion;
+ public static readonly IconId QuitIcon = Gtk.Stock.Quit;
+ public static readonly IconId RedoIcon = Gtk.Stock.Redo;
+ public static readonly IconId Reference = "md-reference";
+ public static readonly IconId ReplaceIcon = Gtk.Stock.FindAndReplace;
+ public static readonly IconId ReplaceInFiles = "md-replace-in-files";
+ public static readonly IconId ResourceFileIcon = "md-resource-file-icon";
+ public static readonly IconId RunProgramIcon = Gtk.Stock.Execute;
+ public static readonly IconId SaveAllIcon = "md-save-all-icon";
+ public static readonly IconId SaveAsIcon = Gtk.Stock.SaveAs;
+ public static readonly IconId SaveIcon = Gtk.Stock.Save;
+ public static readonly IconId MonoDevelop = "md-monodevelop";
+ public static readonly IconId Project = "md-project";
+ public static readonly IconId SplitWindow = "md-split-window";
+ public static readonly IconId Struct = "md-struct";
+ public static readonly IconId TaskListIcon = "md-task-list-icon";
+ public static readonly IconId TextFileIcon = "md-text-file-icon";
+ public static readonly IconId TipOfTheDay = "md-tip-of-the-day";
+ public static readonly IconId ToggleBookmark = "md-toggle-bookmark";
+ public static readonly IconId UndoIcon = Gtk.Stock.Undo;
+ public static readonly IconId Warning = Gtk.Stock.DialogWarning;
+ public static readonly IconId WebSearchIcon = "md-web-search-icon";
+ public static readonly IconId XmlFileIcon = "md-xml-file-icon";
+ public static readonly IconId Addin = "md-addin";
+ public static readonly IconId SolutionFolderOpen = "md-solution-folder-open";
+ public static readonly IconId SolutionFolderClosed = "md-solution-folder-closed";
+
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs
new file mode 100644
index 0000000000..4491df322c
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContext.cs
@@ -0,0 +1,286 @@
+// SyncContext.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+using System.Text;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.Remoting.Contexts;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Activation;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class SyncContext
+ {
+ [ThreadStatic]
+ static SyncContext context;
+
+ static Hashtable delegateFactories = new Hashtable ();
+ static ModuleBuilder module;
+ static AssemblyBuilder asmBuilder;
+ static int typeCounter;
+
+ public static void SetContext (SyncContext ctx)
+ {
+ context = ctx;
+ }
+
+ public static SyncContext GetContext ()
+ {
+ return context;
+ }
+
+ public virtual void Dispatch (StatefulMessageHandler cb, object ob)
+ {
+ cb (ob);
+ }
+
+ public virtual void AsyncDispatch (StatefulMessageHandler cb, object ob)
+ {
+ cb.BeginInvoke (ob, null, null);
+ }
+
+ public Delegate CreateSynchronizedDelegate (Delegate del)
+ {
+ lock (delegateFactories.SyncRoot)
+ {
+ Type delType = del.GetType();
+ IDelegateFactory factory = delegateFactories [delType] as IDelegateFactory;
+ if (factory == null)
+ {
+ Type t = GetDelegateFactoryType (delType);
+ factory = Activator.CreateInstance (t) as IDelegateFactory;
+ delegateFactories [delType] = factory;
+ }
+ return factory.Create (del, this);
+ }
+ }
+
+ Type GetDelegateFactoryType (Type delegateType)
+ {
+ MethodInfo invoke = delegateType.GetMethod ("Invoke");
+ ModuleBuilder module = GetModuleBuilder ();
+
+ // *** Data class
+ StringBuilder typeNameBuilder = new StringBuilder ();
+ typeNameBuilder.Append ("__");
+ typeNameBuilder.Append (delegateType.Name);
+ Type[] generics = delegateType.GetGenericArguments ();
+ if (generics != null) {
+ foreach (Type t in generics) {
+ typeNameBuilder.Append ("_");
+ typeNameBuilder.Append (t.Name);
+ }
+ }
+ TypeBuilder dataTypeBuilder = module.DefineType (typeNameBuilder + "_DelegateData_" + (typeCounter++), TypeAttributes.Public, typeof(object), Type.EmptyTypes);
+
+ // Parameters
+ ParameterInfo[] pars = invoke.GetParameters ();
+ FieldBuilder[] paramFields = new FieldBuilder [pars.Length];
+ Type[] paramTypes = new Type[pars.Length];
+ for (int n=0; n<pars.Length; n++)
+ {
+ ParameterInfo pi = pars [n];
+ paramFields [n] = dataTypeBuilder.DefineField ("p" + n, pi.ParameterType, FieldAttributes.Public);
+ paramTypes [n] = pi.ParameterType;
+ }
+
+ // Return value
+ FieldBuilder returnField = null;
+ if (invoke.ReturnType != typeof(void))
+ returnField = dataTypeBuilder.DefineField ("ret", invoke.ReturnType, FieldAttributes.Public);
+
+ // Constructor
+ ConstructorBuilder dataCtor = dataTypeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
+ ConstructorInfo baseCtor = typeof(object).GetConstructor (Type.EmptyTypes);
+ ILGenerator gen = dataCtor.GetILGenerator();
+ gen.Emit (OpCodes.Ldarg_0);
+ gen.Emit (OpCodes.Call, baseCtor);
+ gen.Emit (OpCodes.Ret);
+
+
+ // *** Factory class
+
+ TypeBuilder typeBuilder = module.DefineType (typeNameBuilder + "_DelegateFactory_" + typeCounter, TypeAttributes.Public, typeof(object), new Type[] {typeof(IDelegateFactory)});
+
+ // Context and target delegate field
+
+ FieldBuilder contextField = typeBuilder.DefineField ("context", typeof(SyncContext), FieldAttributes.Public);
+ FieldBuilder targetField = typeBuilder.DefineField ("target", delegateType, FieldAttributes.Public);
+
+ // Constructor
+
+ ConstructorBuilder ctor = typeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
+ gen = ctor.GetILGenerator();
+ gen.Emit (OpCodes.Ldarg_0);
+ gen.Emit (OpCodes.Call, baseCtor);
+ gen.Emit (OpCodes.Ret);
+
+ // Dispatch method
+
+ MethodBuilder methodDispatch = typeBuilder.DefineMethod ("Dispatch", MethodAttributes.Public, typeof(void), new Type[] {typeof(object)});
+ gen = methodDispatch.GetILGenerator();
+
+ LocalBuilder data = gen.DeclareLocal (dataTypeBuilder);
+ gen.Emit (OpCodes.Ldarg_1);
+ gen.Emit (OpCodes.Castclass, dataTypeBuilder);
+ gen.Emit (OpCodes.Stloc, data);
+
+ if (returnField != null)
+ gen.Emit (OpCodes.Ldloc, data);
+
+ gen.Emit (OpCodes.Ldarg_0);
+ gen.Emit (OpCodes.Ldfld, targetField);
+
+ for (int n=0; n<pars.Length; n++) {
+ gen.Emit (OpCodes.Ldloc, data);
+ gen.Emit (OpCodes.Ldfld, paramFields[n]);
+ }
+ gen.Emit (OpCodes.Callvirt, invoke);
+
+ if (returnField != null)
+ gen.Emit (OpCodes.Stfld, returnField);
+
+ gen.Emit (OpCodes.Ret);
+
+ // ProxyCall method
+
+ MethodBuilder methodProxyCall = typeBuilder.DefineMethod ("ProxyCall", MethodAttributes.Public, invoke.ReturnType, paramTypes);
+ gen = methodProxyCall.GetILGenerator();
+
+ data = gen.DeclareLocal (dataTypeBuilder);
+ gen.Emit (OpCodes.Newobj, dataCtor);
+ gen.Emit (OpCodes.Stloc, data);
+
+ for (int n=0; n<paramFields.Length; n++) {
+ gen.Emit (OpCodes.Ldloc, data);
+ gen.Emit (OpCodes.Ldarg, n+1);
+ gen.Emit (OpCodes.Stfld, paramFields[n]);
+ }
+ gen.Emit (OpCodes.Ldarg_0);
+ gen.Emit (OpCodes.Ldfld, contextField);
+ gen.Emit (OpCodes.Ldarg_0);
+ gen.Emit (OpCodes.Ldftn, methodDispatch);
+ gen.Emit (OpCodes.Newobj, typeof(StatefulMessageHandler).GetConstructor (new Type[] {typeof(object), typeof(IntPtr)} ));
+ gen.Emit (OpCodes.Ldloc, data);
+
+ if (returnField != null) {
+ gen.Emit (OpCodes.Callvirt, typeof(SyncContext).GetMethod ("Dispatch"));
+ gen.Emit (OpCodes.Ldloc, data);
+ gen.Emit (OpCodes.Ldfld, returnField);
+ }
+ else {
+ gen.Emit (OpCodes.Callvirt, typeof(SyncContext).GetMethod ("AsyncDispatch"));
+ }
+ gen.Emit (OpCodes.Ret);
+
+ // Create method
+
+ MethodBuilder methodCreate = typeBuilder.DefineMethod ("Create", MethodAttributes.Public | MethodAttributes.Virtual, typeof(Delegate), new Type[] {typeof(Delegate), typeof(SyncContext)});
+ gen = methodCreate.GetILGenerator();
+ LocalBuilder vthis = gen.DeclareLocal (typeBuilder);
+ gen.Emit (OpCodes.Newobj, ctor);
+ gen.Emit (OpCodes.Stloc, vthis);
+ gen.Emit (OpCodes.Ldloc, vthis);
+ gen.Emit (OpCodes.Ldarg_1);
+ gen.Emit (OpCodes.Castclass, delegateType);
+ gen.Emit (OpCodes.Stfld, targetField);
+ gen.Emit (OpCodes.Ldloc, vthis);
+ gen.Emit (OpCodes.Ldarg_2);
+ gen.Emit (OpCodes.Stfld, contextField);
+ gen.Emit (OpCodes.Ldloc, vthis);
+ gen.Emit (OpCodes.Ldftn, methodProxyCall);
+ gen.Emit (OpCodes.Newobj, delegateType.GetConstructor (new Type[] {typeof(object), typeof(IntPtr)} ));
+ gen.Emit (OpCodes.Ret);
+ typeBuilder.DefineMethodOverride (methodCreate, typeof(IDelegateFactory).GetMethod ("Create"));
+
+ dataTypeBuilder.CreateType ();
+ return typeBuilder.CreateType ();
+ }
+
+ static ModuleBuilder GetModuleBuilder ()
+ {
+ if (module == null)
+ {
+ AppDomain myDomain = System.Threading.Thread.GetDomain();
+ AssemblyName myAsmName = new AssemblyName();
+ myAsmName.Name = "MonoDevelop.DelegateGenerator.GeneratedAssembly";
+
+ asmBuilder = myDomain.DefineDynamicAssembly (myAsmName, AssemblyBuilderAccess.RunAndSave);
+ module = asmBuilder.DefineDynamicModule ("MonoDevelop.DelegateGenerator.GeneratedAssembly", "MonoDevelop.DelegateGenerator.GeneratedAssembly.dll");
+ }
+ return module;
+ }
+ }
+
+ public interface IDelegateFactory
+ {
+ Delegate Create (Delegate del, SyncContext ctx);
+ }
+
+
+ /* Sample class generated for the EventHandler delegate
+
+ class __EventHandler_DelegateData
+ {
+ public object psender;
+ public EventArgs pargs;
+ }
+
+ class __EventHandler_DelegateFactory: IDelegateFactory
+ {
+ EventHandler target;
+ SyncContext context;
+
+ public Delegate Create (Delegate del, SyncContext ctx)
+ {
+ __EventHandler_DelegateFactory vthis = new __EventHandler_DelegateFactory ();
+ vthis.target = del;
+ vthis.context = ctx;
+ return new EventHandler (vthis.ProxyCall);
+ }
+
+ public void ProxyCall (object sender, EventArgs args)
+ {
+ __EventHandler_DelegateData data = new __EventHandler_DelegateData ();
+ data.psender = sender;
+ data.pargs = args;
+ StatefulMessageHandler msg = new StatefulMessageHandler (Dispatch);
+ context.AsyncDispatch (msg, data);
+ }
+
+ public void Dispatch (object obj)
+ {
+ __EventHandler_DelegateData data = (__EventHandler_DelegateData) obj;
+ target (data.psender, data.pargs);
+ }
+ }
+
+ */
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContextAttribute.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContextAttribute.cs
new file mode 100644
index 0000000000..49123167de
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncContextAttribute.cs
@@ -0,0 +1,217 @@
+// SyncContextAttribute.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.Remoting.Contexts;
+using System.Runtime.Remoting.Messaging;
+using System.Runtime.Remoting.Activation;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class SyncContextAttribute: ContextAttribute, IContributeObjectSink
+ {
+ Type contextType;
+ SyncContext syncContext;
+
+ public SyncContextAttribute (Type contextType): base ("syncContextProperty")
+ {
+ this.contextType = contextType;
+ }
+
+ public override bool IsContextOK (Context ctx, IConstructionCallMessage msg)
+ {
+ SyncContext sctx = SyncContext.GetContext ();
+ if (sctx == null || (sctx.GetType() != contextType)) {
+ syncContext = (SyncContext) Activator.CreateInstance (contextType);
+ return false;
+ }
+ else {
+ syncContext = sctx;
+ return true;
+ }
+ }
+
+ public IMessageSink GetObjectSink (MarshalByRefObject ob, IMessageSink nextSink)
+ {
+ return new SyncContextDispatchSink (nextSink, syncContext, ob);
+ }
+
+ public Type ConextType
+ {
+ get { return contextType; }
+ }
+ }
+
+ internal class SyncContextDispatchSink: IMessageSink
+ {
+ IMessageSink nextSink;
+ SyncContext syncContext;
+ MarshalByRefObject target;
+ static bool isMono;
+
+ static SyncContextDispatchSink ()
+ {
+ isMono = Type.GetType ("Mono.Runtime") != null;
+ }
+
+ class MsgData
+ {
+ public IMessage InMessage;
+ public IMessage OutMessage;
+ public IMessageSink ReplySink;
+ }
+
+ public SyncContextDispatchSink (IMessageSink nextSink, SyncContext syncContext, MarshalByRefObject ob)
+ {
+ this.nextSink = nextSink;
+ this.syncContext = syncContext;
+ target = ob;
+ }
+
+ public IMessage SyncProcessMessage (IMessage msg)
+ {
+ if (syncContext == null) return nextSink.SyncProcessMessage (msg);
+
+ IMethodMessage mm = (IMethodMessage)msg;
+
+ if ((mm.MethodBase.Name == "FieldGetter" || mm.MethodBase.Name == "FieldSetter") && mm.MethodBase.DeclaringType == typeof(object)) {
+ return nextSink.SyncProcessMessage (msg);
+ }
+
+ MethodBase mb = GetRealMethod (mm);
+
+ if (mb.IsDefined (typeof(FreeDispatchAttribute), true)) {
+ return nextSink.SyncProcessMessage (msg);
+ }
+
+ if (mb.IsDefined (typeof(AsyncDispatchAttribute), true)) {
+ AsyncProcessMessage (msg, DummySink.Instance);
+ return new ReturnMessage (null, null, 0, null, (IMethodCallMessage)mm);
+ }
+
+ MsgData md = new MsgData ();
+ md.InMessage = msg;
+ SyncContext oldCtx = SyncContext.GetContext ();
+ try {
+ SyncContext.SetContext (syncContext);
+ syncContext.Dispatch (new StatefulMessageHandler (DispatchMessage), md);
+ } finally {
+ SyncContext.SetContext (oldCtx);
+ }
+
+ return md.OutMessage;
+ }
+
+ MethodBase GetRealMethod (IMethodMessage mm)
+ {
+ if (PropertyService.IsWindows) {
+ // HACK: When running on .NET, mm.MethodBase returns the method for the type of the proxy
+ // instead of the target type. There is no legal way of getting the target type, so we have
+ // to use reflection here.
+ FieldInfo fi = mm.GetType ().GetField ("_ID", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (fi != null) {
+ object id = fi.GetValue (mm);
+ PropertyInfo pi = id.GetType ().GetProperty ("ServerType", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (pi != null) {
+ Type t = (Type) pi.GetValue (id, null);
+ MethodBase met = t.GetMethod (mm.MethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, (Type[])mm.MethodSignature, null);
+ if (met != null)
+ return met;
+ }
+ }
+ }
+ return mm.MethodBase;
+ }
+
+ void DispatchMessage (object data)
+ {
+ MsgData md = (MsgData)data;
+ md.OutMessage = nextSink.SyncProcessMessage (md.InMessage);
+ }
+
+ public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+ {
+ if (syncContext == null) return nextSink.AsyncProcessMessage (msg, replySink);
+
+ // Make a copy of the message since MS.NET seems to free the original message
+ // once it has been dispatched.
+ if (!isMono)
+ msg = new MethodCall (msg);
+
+ MsgData md = new MsgData ();
+ md.InMessage = msg;
+ md.ReplySink = replySink;
+ syncContext.AsyncDispatch (new StatefulMessageHandler (AsyncDispatchMessage), md);
+ return null;
+ }
+
+ void AsyncDispatchMessage (object data)
+ {
+ MsgData md = (MsgData)data;
+ if (isMono) {
+ md.ReplySink.SyncProcessMessage (nextSink.SyncProcessMessage (md.InMessage));
+ } else {
+ // In MS.NET, async calls have to be dispatched using ExecuteMessage,
+ // but this doesn't work in mono because mono will route the message
+ // through the remoting context sink again causing an infinite loop.
+ IMethodCallMessage msg = (IMethodCallMessage) md.InMessage;
+ msg.MethodBase.Invoke (target, msg.Args);
+ }
+ }
+
+ public IMessageSink NextSink
+ {
+ get { return nextSink; }
+ }
+ }
+
+ internal class DummySink: IMessageSink
+ {
+ public static DummySink Instance = new DummySink();
+
+ public IMessage SyncProcessMessage (IMessage msg)
+ {
+ // Ignore
+ return null;
+ }
+
+ public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+ {
+ // Ignore
+ return null;
+ }
+
+ public IMessageSink NextSink
+ {
+ get { return null; }
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncObject.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncObject.cs
new file mode 100644
index 0000000000..402b5e46c2
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SyncObject.cs
@@ -0,0 +1,35 @@
+// SyncObject.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
+//
+// 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 System;
+
+namespace MonoDevelop.Ide.Gui
+{
+ public class SyncObject: ContextBoundObject
+ {
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
index 3b33ac73ea..9053ec1907 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs
@@ -28,10 +28,9 @@
using System;
using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Projects.Gui.Completion;
+using MonoDevelop.Ide.CodeCompletion;
using Mono.TextEditor.Highlighting;
using System.Collections.Generic;
-using MonoDevelop.Core.Gui;
namespace MonoDevelop.Ide.Gui
{
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ToolbarComboBox.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ToolbarComboBox.cs
index 896d97c316..4b7257cf8b 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ToolbarComboBox.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ToolbarComboBox.cs
@@ -29,7 +29,6 @@
using System;
using MonoDevelop.Core;
using MonoDevelop.Projects;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Components.Commands;
namespace MonoDevelop.Ide.Gui
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
index f4b3c94883..b342236516 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
@@ -28,20 +28,13 @@
using System;
-using System.Collections;
using System.Diagnostics;
using System.IO;
-using Gtk;
using MonoDevelop.Core;
-using Mono.Addins;
-using MonoDevelop.Core.Gui;
-using MonoDevelop.Core.Gui.Dialogs;
using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Components;
using MonoDevelop.Components.Commands;
using MonoDevelop.Ide.Commands;
-using MonoDevelop.Ide.Gui.Dialogs;
namespace MonoDevelop.Ide.Gui
{
@@ -112,7 +105,7 @@ namespace MonoDevelop.Ide.Gui
[CommandHandler (FileCommands.ReloadFile)]
protected void OnReloadFile ()
{
- if (MessageService.GenericAlert (MonoDevelop.Core.Gui.Stock.Warning,
+ if (MessageService.GenericAlert (MonoDevelop.Ide.Gui.Stock.Warning,
GettextCatalog.GetString ("Revert unsaved changes to document '{0}'?", Path.GetFileName (doc.Name)),
GettextCatalog.GetString ("All changes made to the document will be permanently lost."), 0, AlertButton.Cancel, AlertButton.Revert) == AlertButton.Revert)
doc.Reload ();
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 70c3a89197..8ba4c6086d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
@@ -38,12 +38,13 @@ using System.Threading;
using MonoDevelop.Core.Execution;
using MonoDevelop.Projects;
using MonoDevelop.Core;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Codons;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.Gui.Pads;
-using MonoDevelop.Core.Gui.Dialogs;
+using MonoDevelop.Ide.Gui.Dialogs;
+using MonoDevelop.Ide.Desktop;
using Mono.Addins;
+using MonoDevelop.Ide.Projects;
namespace MonoDevelop.Ide.Gui
{
@@ -540,8 +541,8 @@ namespace MonoDevelop.Ide.Gui
if (parentWindow == null)
parentWindow = IdeApp.Workbench.RootWindow;
- MonoDevelop.Projects.Gui.Dialogs.DefaultPolicyOptionsDialog ops
- = new MonoDevelop.Projects.Gui.Dialogs.DefaultPolicyOptionsDialog (parentWindow);
+ DefaultPolicyOptionsDialog ops
+ = new DefaultPolicyOptionsDialog (parentWindow);
try {
if (panelId != null)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchContext.cs
index 28f24800bc..935faaab83 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchContext.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/WorkbenchContext.cs
@@ -27,7 +27,6 @@ using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic;
-using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Codons;
namespace MonoDevelop.Ide.Gui