public void NewWebReference()
		{
			// Get the project and project folder
			DotNetProject project = CurrentNode.GetParentDataItem (typeof(DotNetProject), true) as DotNetProject;
			
			// Check and switch the runtime environment for the current project
			if (project.TargetFramework.Id == TargetFrameworkMoniker.NET_1_1)
			{
				string question = "The current runtime environment for your project is set to version 1.0.";
				question += "Web Service is not supported in this version.";
				question += "Do you want switch the runtime environment for this project version 2.0 ?";
				
				AlertButton switchButton = new AlertButton ("_Switch to .NET2"); 
				if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton)
					project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework (TargetFrameworkMoniker.NET_2_0);					
				else
					return;
			}
			
			WebReferenceDialog dialog = new WebReferenceDialog (project);
			dialog.NamespacePrefix = project.DefaultNamespace;
			
			try {
				if (MessageService.RunCustomDialog (dialog) == (int)Gtk.ResponseType.Ok) {
					dialog.SelectedService.GenerateFiles (project, dialog.Namespace, dialog.ReferenceName);
					IdeApp.ProjectOperations.Save(project);
				}
			}
			catch(Exception exception) {
				MessageService.ShowException (exception);
			} finally {
				dialog.Destroy ();
			}
		}
		FileConflictResolution MapResultToFileConflictResolution(AlertButton result)
		{
			if (result == AlertButton.Yes) {
				return FileConflictResolution.Overwrite;
			} else if (result == YesToAllButton) {
				return FileConflictResolution.OverwriteAll;
			} else if (result == NoToAllButton) {
				return FileConflictResolution.IgnoreAll;
			} else {
				return FileConflictResolution.Ignore;
			}
		}
        protected override void Run()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                // Process cached crash reports if there are any and uploading is enabled
                LogReportingService.ProcessCache();
            });

            // Attach a handler for when exceptions need to be processed
            LogReportingService.UnhandledErrorOccured = (enabled, ex, willShutdown) =>
            {
                var doNotSend  = new AlertButton(GettextCatalog.GetString("Do _Not Send"));
                var sendOnce   = new AlertButton(GettextCatalog.GetString("_Send This Time"));
                var alwaysSend = new AlertButton(GettextCatalog.GetString("_Always Send"));

                string message = null;
                string title   = willShutdown
            ? GettextCatalog.GetString("A fatal error has occurred")
            : GettextCatalog.GetString("An error has occurred");

                if (!ShouldPromptToOptIn && enabled.GetValueOrDefault())
                {
                    message = GettextCatalog.GetString(
                        "Details of this error have been automatically sent to Xamarin for analysis.");
                    if (willShutdown)
                    {
                        message += GettextCatalog.GetString(" {0} will now close.", BrandingService.ApplicationName);
                    }
                    MessageService.ShowException(ex, message, title, AlertButton.Ok);
                    return(enabled);
                }

                message = GettextCatalog.GetString(
                    "Details of errors, along with anonymous installation information, can be sent to Xamarin to " +
                    "help improve {0}. Do you wish to send this information?", BrandingService.ApplicationName);
                var result = MessageService.ShowException(ex, message, title, doNotSend, sendOnce, alwaysSend);

                if (result == sendOnce)
                {
                    return(null);
                }
                else if (result == alwaysSend)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
        }
Example #4
0
        protected override void Run()
        {
            // Attach a handler for when exceptions need to be processed
            LoggingService.UnhandledErrorOccurred = (enabled, ex, willShutdown) => {
                if (Platform.IsMac)
                {
                    return(true);
                }

                var doNotSend  = new AlertButton(GettextCatalog.GetString("Do _Not Send"));
                var sendOnce   = new AlertButton(GettextCatalog.GetString("_Send This Time"));
                var alwaysSend = new AlertButton(GettextCatalog.GetString("_Always Send"));

                string message = null;
                string title   = willShutdown
                                        ? GettextCatalog.GetString("A fatal error has occurred")
                                        : GettextCatalog.GetString("An error has occurred");

                if (!ShouldPromptToOptIn && enabled.GetValueOrDefault())
                {
                    if (willShutdown)
                    {
                        message = GettextCatalog.GetString(
                            "Details of this error have been automatically sent to Microsoft for analysis.");
                        message += GettextCatalog.GetString(" {0} will now close.", BrandingService.ApplicationName);
                        MessageService.ShowError(null, title, message, ex, false, AlertButton.Ok);
                    }
                    return(enabled);
                }

                message = GettextCatalog.GetString(
                    "Details of errors, along with anonymous usage information, can be sent to Microsoft to " +
                    "help improve {0}. Do you wish to send this information?", BrandingService.ApplicationName);
                var result = MessageService.ShowError(null, title, message, ex, false, doNotSend, sendOnce, alwaysSend);

                if (result == sendOnce)
                {
                    return(null);
                }
                else if (result == alwaysSend)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
        }
Example #5
0
 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);
 }
		public bool Migrate (MSBuildProject project, string fileName, string language)
		{
			var buttonBackupAndMigrate = new AlertButton (GettextCatalog.GetString ("Back up and migrate"));
			var buttonMigrate = new AlertButton (GettextCatalog.GetString ("Migrate"));
			var buttonIgnore = new AlertButton (GettextCatalog.GetString ("Ignore"));
			var response = MessageService.AskQuestion (
				GettextCatalog.GetString ("Migrate MonoMac Project?"),
				GettextCatalog.GetString (
					"The MonoMac project '{0}' must be migrated to a new format. " +
					"After migration, it will not be able to be opened in " +
					"older versions of MonoDevelop.\n\n" +
					"If you choose to back up the project before migration, a copy of the project " +
					"file will be saved in a 'backup' directory in the project directory.", Path.GetFileNameWithoutExtension (fileName)),
				buttonIgnore, buttonMigrate, buttonBackupAndMigrate);
			if (response == buttonIgnore)
				return false;
			
			FilePath baseDir = Path.GetDirectoryName (fileName);
			
			bool backup = response == buttonBackupAndMigrate;
			if (backup) {
				var backupDirFirst = baseDir.Combine ("backup");
				string backupDir = backupDirFirst;
				int i = 0;
				while (Directory.Exists (backupDir)) {
					backupDir = backupDirFirst + "-" + i.ToString ();
					if (i > 20) {
						throw new Exception ("Too many backup directories");
					}
				}
				Directory.CreateDirectory (backupDir);
				File.Copy (fileName, Path.Combine (backupDir, Path.GetFileName (fileName)));
			}
			
			// Migrate 'Page' build action to 'InterfaceDefinition' (see Bug 147 - XIB files need Build Action other than Page)
			// NOTE: Work around mono bug by calling ToList() before iterating: http://bugzilla.xamarin.com/show_bug.cgi?id=520
			foreach (var item in project.GetAllItems ().Where (item => item.Name == "Page").ToList ()) {
				var newElement = project.doc.CreateElement (BuildAction.InterfaceDefinition);
				newElement.InnerXml = item.Element.InnerXml;
				foreach (System.Xml.XmlAttribute attribute in item.Element.Attributes)
					newElement.SetAttribute (attribute.Name, attribute.Value);
				item.Element.ParentNode.ReplaceChild (newElement, item.Element);
			}
			
			return true;
		}
Example #7
0
		public override void TakeSnapshot ()
		{
			AlertButton button = new AlertButton (GettextCatalog.GetString ("Terminate"));
			bool terminate = MessageService.Confirm (
				GettextCatalog.GetString ("Heap-Buddy requires the application to terminate cleanly.\nAre you sure you want to terminate the application (this might result in the loss of some profiling data)?")
				, button
			);

			if (terminate) {
				lock (sync) {
					State = ProfilerState.TakingSnapshot;
					
					System.Diagnostics.Process.Start ("kill", "-PROF " + Context.AsyncOperation.ProcessId);
					ThreadPool.QueueUserWorkItem (new WaitCallback (AsyncTakeSnapshot));
				}
			}
		}
Example #8
0
		public static bool Publish (IWorkspaceObject entry, FilePath localPath, bool test)
		{
			if (test)
				return true;

			if (!VersionControlService.CheckVersionControlInstalled ())
				return false;

			List<FilePath> files = new List<FilePath> ();

			// Build the list of files to be checked in			
			string moduleName = entry.Name;
			if (localPath == entry.BaseDirectory) {
				GetFiles (files, entry);
			} else if (entry is Project) {
				foreach (ProjectFile file in ((Project)entry).Files.GetFilesInPath (localPath))
					if (file.Subtype != Subtype.Directory)
						files.Add (file.FilePath);
			} else
				return false;

			if (files.Count == 0)
				return false;
	
			SelectRepositoryDialog dlg = new SelectRepositoryDialog (SelectRepositoryMode.Publish);
			try {
				dlg.ModuleName = moduleName;
				dlg.Message = GettextCatalog.GetString ("Initial check-in of module {0}", moduleName);
				do {
					if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Repository != null) {
						AlertButton publishButton = new AlertButton ("_Publish");					
						if (MessageService.AskQuestion (GettextCatalog.GetString ("Are you sure you want to publish the project?"), GettextCatalog.GetString ("The project will be published to the repository '{0}', module '{1}'.", dlg.Repository.Name, dlg.ModuleName), AlertButton.Cancel, publishButton) == publishButton) {
							PublishWorker w = new PublishWorker (dlg.Repository, dlg.ModuleName, localPath, files.ToArray (), dlg.Message);
							w.Start ();
							break;
						}
					} else
						break;
				} while (true);
			} finally {
				dlg.Destroy ();
			}
			return true;
		}
Example #9
0
		protected override void Run ()
		{
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				// Process cached crash reports if there are any and uploading is enabled
				LogReportingService.ProcessCache ();
			});
			
			// Attach a handler for when exceptions need to be processed
			LogReportingService.UnhandledErrorOccured = (enabled, ex, willShutdown) => {
				var doNotSend = new AlertButton (GettextCatalog.GetString ("Do _Not Send"));
				var sendOnce = new AlertButton (GettextCatalog.GetString ("_Send This Time"));
				var alwaysSend = new AlertButton (GettextCatalog.GetString ("_Always Send"));
				
				AlertButton[] buttons = null;
				string message = null;
				string title = willShutdown
					? GettextCatalog.GetString ("A fatal error has occurred")
					: GettextCatalog.GetString ("An error has occurred");

				if (!ShouldPromptToOptIn && enabled.GetValueOrDefault ()) {
					message = GettextCatalog.GetString (
						"Details of this error have been automatically sent to Xamarin for analysis.");
					if (willShutdown) {
						message += GettextCatalog.GetString (" {0} will now close.", BrandingService.ApplicationName);
					}
					MessageService.ShowException (ex, message, title, AlertButton.Ok);
					return enabled;
				}

				message = GettextCatalog.GetString (
					"Details of errors, along with anonymous installation information, can be sent to Xamarin to " +
					"help improve {0}. Do you wish to send this information?", BrandingService.ApplicationName);
				var result = MessageService.ShowException (ex, message, title, doNotSend, sendOnce, alwaysSend);

				if (result == sendOnce) {
					return null;
				} else if (result == alwaysSend) {
					return true;
				} else {
					return false;
				}
			};
		}
Example #10
0
		internal static void GenerateMakefiles (SolutionItem entry, Solution solution)
		{
			if (solution == null) {
				AlertButton generateMakefilesButton = new AlertButton (GettextCatalog.GetString ("_Generate Makefiles"));
				if (MessageService.AskQuestion (GettextCatalog.GetString ("Generating Makefiles is not supported for single projects. Do you want to generate them for the full solution - '{0}' ?", entry.ParentSolution.Name),
				                                AlertButton.Cancel,
				                                generateMakefilesButton) == generateMakefilesButton) 
					solution = ((SolutionItem)entry).ParentSolution;
				else
					return;
			}

			DeployContext ctx = null;
			IProgressMonitor monitor = null;

			GenerateMakefilesDialog dialog = new GenerateMakefilesDialog (solution);
			try {
				if (MessageService.RunCustomDialog (dialog) != (int) Gtk.ResponseType.Ok)
					return;

				SolutionDeployer deployer = new SolutionDeployer (dialog.GenerateAutotools);
				if ( deployer.HasGeneratedFiles ( solution ) )
				{
					string msg = GettextCatalog.GetString ( "{0} already exist for this solution.  Would you like to overwrite them?", dialog.GenerateAutotools ? "Autotools files" : "Makefiles" );
					if (MonoDevelop.Ide.MessageService.AskQuestion (msg, AlertButton.Cancel, AlertButton.OverwriteFile) != AlertButton.OverwriteFile)
						return;
				}

				ctx = new DeployContext (new TarballDeployTarget (dialog.GenerateAutotools), "Linux", null);
				monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (true);
				deployer.GenerateFiles (ctx, solution, dialog.DefaultConfiguration, monitor);
			} finally {
				dialog.Destroy ();
				dialog.Dispose ();
				if (ctx != null)
					ctx.Dispose ();
				if (monitor != null)
					monitor.Dispose ();
			}
		}
		//Mac GTK+ is unstable, even between micro releases
		static void CheckGtkVersion (uint major, uint minor, uint micro)
		{
			string url = "http://www.go-mono.com/mono-downloads/download.html";
			
			// to require exact version, also check : || Gtk.Global.CheckVersion (major, minor, micro + 1) == null
			if (Gtk.Global.CheckVersion (major, minor, micro) != null) {
				
				MonoDevelop.Core.LoggingService.LogFatalError ("GTK+ version is incompatible with required version {0}.{1}.{2}.", major, minor, micro);
				
				AlertButton downloadButton = new AlertButton ("Download...", null);
				if (downloadButton == MessageService.GenericAlert (
					Stock.Error,
					"Incompatible Mono Framework Version",
					"MonoDevelop requires a newer version of the Mono Framework.",
					new AlertButton ("Cancel", null), downloadButton))
				{
					OpenUrl (url);
				}
				
				Environment.Exit (1);
			}
		}
		protected override void Run ()
		{
			// Attach a handler for when exceptions need to be processed
			LoggingService.UnhandledErrorOccured = (enabled, ex, willShutdown) => {
				var doNotSend = new AlertButton (GettextCatalog.GetString ("Do _Not Send"));
				var sendOnce = new AlertButton (GettextCatalog.GetString ("_Send This Time"));
				var alwaysSend = new AlertButton (GettextCatalog.GetString ("_Always Send"));
				
				string message = null;
				string title = willShutdown
					? GettextCatalog.GetString ("A fatal error has occurred")
					: GettextCatalog.GetString ("An error has occurred");

				if (!ShouldPromptToOptIn && enabled.GetValueOrDefault ()) {
					if (willShutdown) {
						message = GettextCatalog.GetString (
							"Details of this error have been automatically sent to Xamarin for analysis.");
						message += GettextCatalog.GetString (" {0} will now close.", BrandingService.ApplicationName);
						MessageService.ShowError (null, title, message, ex, false, AlertButton.Ok);
					}
					return enabled;
				}

				message = GettextCatalog.GetString (
					"Details of errors, along with anonymous installation information, can be sent to Xamarin to " +
					"help improve {0}. Do you wish to send this information?", BrandingService.ApplicationName);
				var result = MessageService.ShowError (null, title, message, ex, false, doNotSend, sendOnce, alwaysSend);

				if (result == sendOnce) {
					return null;
				} else if (result == alwaysSend) {
					return true;
				} else {
					return false;
				}
			};
		}
Example #13
0
 public ConfirmationMessage(AlertButton button) : this()
 {
     ConfirmButton = button;
 }
Example #14
0
 public AlertButtonEventArgs(AlertButton button) : this(button, true)
 {
 }
		public static bool Confirm (string primaryText, AlertButton button)
		{
			return Confirm (primaryText, null, button);
		}
		protected void OnDropView ()
		{
			ViewNode node = (ViewNode)CurrentNode.DataItem;
			AlertButton dropButton = new AlertButton (AddinCatalog.GetString ("Drop"), Gtk.Stock.Delete);
			if (MessageService.Confirm (
				AddinCatalog.GetString ("Are you sure you want to drop view '{0}'", node.View.Name),
				dropButton
			)) {
				ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropViewThreaded), CurrentNode.DataItem);
			}
		}
		async Task<bool> CheckAndBuildForExecute (IBuildTarget executionTarget, ExecutionContext context)
		{
			if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) {
				var bres = await currentBuildOperation.Task;
				if (bres.HasErrors || !IdeApp.Preferences.RunWithWarnings && bres.HasWarnings)
					return false;
			}

			//saves open documents since it may dirty the "needs building" check
			var r = DoBeforeCompileAction ();
			if (r.Failed)
				return false;

			var configuration = IdeApp.Workspace.ActiveConfiguration;

			var buildTarget = executionTarget;
			var buildDeps = buildTarget.GetExecutionDependencies ().ToList ();
			if (buildDeps.Count > 1)
				throw new NotImplementedException ("Multiple execution dependencies not yet supported");
			if (buildDeps.Count != 0)
				buildTarget = buildDeps [0];

			bool needsBuild = FastCheckNeedsBuild (buildTarget, configuration);
			if (!needsBuild) {
				return true;
			}

			if (IdeApp.Preferences.BuildBeforeExecuting) {
				// Building the project may take some time, so we call PrepareExecution so that the target can
				// prepare the execution (for example, it could start a simulator).
				var cs = new CancellationTokenSource ();
				var prepareExecution = buildTarget.PrepareExecution (new ProgressMonitor ().WithCancellationSource (cs), context, configuration);
				var result = await Build (buildTarget, true).Task;

				if (result.HasErrors || (!IdeApp.Preferences.RunWithWarnings && result.HasWarnings)) {
					cs.Cancel ();
					return false;
				}
				else {
					await prepareExecution;
					return true;
				}
			}

			var bBuild = new AlertButton (GettextCatalog.GetString ("Build"));
			var bRun = new AlertButton (Gtk.Stock.Execute, true);
			var res = MessageService.AskQuestion (
				GettextCatalog.GetString ("Outdated Build"),
				GettextCatalog.GetString ("The project you are executing has changes done after the last time it was compiled. Do you want to continue?"),
				2,
				AlertButton.Cancel,
				bBuild,
				bRun);

			// This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
			// drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
			DispatchService.RunPendingEvents ();

			if (res == bRun) {
				return true;
			}

			if (res == bBuild) {
				// Building the project may take some time, so we call PrepareExecution so that the target can
				// prepare the execution (for example, it could start a simulator).
				var cs = new CancellationTokenSource ();
				var prepareExecution = buildTarget.PrepareExecution (new ProgressMonitor ().WithCancellationSource (cs), context, configuration);
				var result = await Build (buildTarget, true).Task;

				if (result.HasErrors || (!IdeApp.Preferences.RunWithWarnings && result.HasWarnings)) {
					cs.Cancel ();
					return false;
				}
				else {
					await prepareExecution;
					return true;
				}
			}

			return false;
		}
		public static bool Confirm (string primaryText, string secondaryText, AlertButton button, bool confirmIsDefault)
		{
			return GenericAlert (MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, confirmIsDefault ? 0 : 1, AlertButton.Cancel, button) == button;
		}
Example #19
0
		internal static string ImportFile (Project prj, string file)
		{
			ProjectFile pfile = prj.Files.GetFile (file);
			if (pfile == null) {
				var files = IdeApp.ProjectOperations.AddFilesToProject (prj, new string[] { file }, prj.BaseDirectory);
				if (files.Count == 0 || files[0] == null)
					return null;
				pfile = files [0];
			}
			if (pfile.BuildAction == BuildAction.EmbeddedResource) {
				AlertButton embedButton = new AlertButton (GettextCatalog.GetString ("_Use as Source"));
				if (MessageService.AskQuestion (GettextCatalog.GetString ("You are requesting the file '{0}' to be used as source for an image. However, this file is already added to the project as a resource. Are you sure you want to continue (the file will have to be removed from the resource list)?"), AlertButton.Cancel, embedButton) == embedButton)
					return null;
			}
			pfile.BuildAction = BuildAction.Content;
			DeployProperties props = DeployService.GetDeployProperties (pfile);
			props.UseProjectRelativePath = true;
			return pfile.FilePath;
		}
		protected void OnDropDatabase ()
		{
			DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem;
			AlertButton dropButton = new AlertButton (AddinCatalog.GetString ("Drop"), Gtk.Stock.Delete);
			if (MessageService.Confirm (
				AddinCatalog.GetString ("Are you sure you want to drop database '{0}'", context.ConnectionSettings.Database),
				dropButton
			)) {
				ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropDatabaseThreaded), CurrentNode.DataItem);
			}
		}
		public override bool RequestFileWritePermission (FilePath path)
		{
			if (!File.Exists (path))
				return true;
			if ((File.GetAttributes (path) & FileAttributes.ReadOnly) == 0)
				return true;
			AlertButton but = new AlertButton ("Lock File");
			if (!MessageService.Confirm (GettextCatalog.GetString ("File locking required"), GettextCatalog.GetString ("The file '{0}' must be locked before editing.", path), but))
				return false;
			try {
				Svn.Lock (null, "", false, path);
			} catch (SubversionException ex) {
				MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' could not be unlocked", path), ex.Message);
				return false;
			}
			VersionControlService.NotifyFileStatusChanged (this, path, false);
			return true;
		}
Example #22
0
		void OnOpen ()
		{
			string[] files = GetCurrentFiles ();
			if (files.Length == 0)
				return;
			else if (files.Length == 1) {
				TreePath[] rows = filelist.Selection.GetSelectedRows ();
				int line = 1;
				if (rows.Length == 1 && rows [0].Depth == 2) {
					line = diffRenderer.GetSelectedLine (rows [0]);
					if (line == -1)
						line = 1;
				}
				IdeApp.Workbench.OpenDocument (files [0], line, 0);
			}
			else {
				AlertButton openAll = new AlertButton (GettextCatalog.GetString ("_Open All")); 
				if (MessageService.AskQuestion (GettextCatalog.GetString ("Do you want to open all {0} files?", files.Length), AlertButton.Cancel, openAll) == openAll) {
					for (int n=0; n<files.Length; n++)
						IdeApp.Workbench.OpenDocument (files[n], n==0);
				}
			}
		}
Example #23
0
 public ConfirmationMessage(string primaryText, AlertButton button) : this(button)
 {
     Text = primaryText;
 }
Example #24
0
 public ConfirmationMessage(string primaryText, string secondaryText, AlertButton button) : this(primaryText, button)
 {
     SecondaryText = secondaryText;
 }
		public ConfirmationMessage (string primaryText, AlertButton button): this (button)
		{
			Text = primaryText;
		}
Example #26
0
		//use events.. 
		public void UpdateProject (IProgressMonitor monitor, bool promptForRemoval)
		{
			if (!IntegrationEnabled)
				return;

			if (ownerProject == null)
				throw new InvalidOperationException ("Internal Error: ownerProject not set");

			this.monitor = monitor;

			try {
				Makefile.GetVariables ();
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString (
					"Invalid Makefile '{0}'. Disabling Makefile integration.", AbsoluteMakefileName), e);
				IntegrationEnabled = false;

				return;
			}

			//FIXME: Improve the message
			if (promptForRemoval) {
				AlertButton projectButton = new AlertButton ("_Project");
				AlertButton makefileButton = new AlertButton ("_Makefile");
				AlertButton choice = MessageService.AskQuestion (GettextCatalog.GetString ("Enabling Makefile integration. You can choose to have either the Project or the Makefile be used as the master copy. This is done only when enabling this feature. After this, the Makefile will be taken as the master copy."),
				                                                 projectButton, makefileButton);
				if (choice == projectButton) {
					//Sync Project --> Makefile
					dirty = true;
					return;
				}
			}

			dirty = true;
			encodeValues = null;

			try {
				if (IsAutotoolsProject) {
					string path = Path.Combine (AbsoluteConfigureInPath, "configure.in");
					if (!File.Exists (path))
						path = Path.Combine (AbsoluteConfigureInPath, "configure.ac");
					
					configuredPackages = null;
					WeakReference weakref;
					if (PkgManagerTable.TryGetValue (path, out weakref)) {
						if (weakref.IsAlive) {
							configuredPackages = (ConfiguredPackagesManager) weakref.Target;
							FileInfo finfo = new FileInfo (path);
							if (finfo.LastWriteTime > configuredPackages.LastWriteTime)
								// file has changed since last time we parsed it!
								configuredPackages = null;
						}
					}

					// no entry in table or it got collected or file has changed
					if (configuredPackages == null) {
						configuredPackages = new ConfiguredPackagesManager (path);
						PkgManagerTable [path] = new WeakReference (configuredPackages);
						ownerProject.ExtendedProperties ["MonoDevelop.Autotools.ConfiguredPackagesManager"] = configuredPackages;
					}
				}
			} catch (Exception e) {
				LoggingService.LogWarning (
					"Error trying to read configure.in ('{0}') for project '{1}':\n{2}",
					AbsoluteConfigureInPath, OwnerProject.Name, e.ToString ());

				monitor.ReportWarning (GettextCatalog.GetString (
					"Error trying to read configure.in ('{0}') for project '{1}':\n{2}",
					AbsoluteConfigureInPath, OwnerProject.Name, e.Message));
			}

			ReadFiles (BuildFilesVar, BuildAction.Compile, "Build", promptForRemoval);
			ReadFiles (DeployFilesVar, BuildAction.Content, "Deploy", promptForRemoval);
			ReadFiles (OthersVar, BuildAction.None, "Others", promptForRemoval);
			ReadFiles (ResourcesVar, BuildAction.EmbeddedResource, "Resources", promptForRemoval);

			if (!SyncReferences)
				return;

			try {
				SaveReferences = true;

				//Do these for DotNetProject only
				DotNetProject dotnetProject = ownerProject as DotNetProject;
				if (dotnetProject != null) {
					GacRefVar.Extra.Clear ();
					AsmRefVar.Extra.Clear ();
					ProjectRefVar.Extra.Clear ();

					existingGacRefs = new Dictionary<string, ProjectReference> ();
					requiredPackageVersions = new Dictionary<string,string> ();
					newGacRefs = new Dictionary<string, ProjectReference> ();

					List<ProjectReference> toRemove = new List<ProjectReference> ();
					foreach (ProjectReference pref in dotnetProject.References) {
						if (pref.ReferenceType == ReferenceType.Gac) {
							string [] files = pref.GetReferencedFileNames (ConfigurationSelector.Default);
							if (files == null)
								continue;

							if (pref.ReferenceType == ReferenceType.Gac) {
								// Store the package version required by this reference. We'll use
								// the same version when trying to match references coming from the makefile
								SystemAssembly asm = assemblyContext.GetAssemblyFromFullName (pref.StoredReference, pref.Package != null ? pref.Package.Name : null, dotnetProject.TargetFramework);
								if (asm != null && asm.Package != null)
									requiredPackageVersions [asm.Package.Name] = asm.Package.Version;
							}
							// this should help normalize paths like /foo//bar/../
							string fullpath = Path.GetFullPath (files [0]);
							if (existingGacRefs.ContainsKey (fullpath))
								toRemove.Add (pref);
							else
								existingGacRefs [fullpath] = pref;
						}
					}

					// Remove the repeats
					foreach (ProjectReference pref in toRemove)
						dotnetProject.References.Remove (pref);

					ReadReferences (GacRefVar, ReferenceType.Gac, "Gac References", dotnetProject);

					// !SaveReferences indicates that previous ref reading failed
					if (SaveReferences && String.Compare (AsmRefVar.Name, GacRefVar.Name) != 0)
						ReadReferences (AsmRefVar, ReferenceType.Assembly, "Asm References", dotnetProject);
					if (SaveReferences && (String.Compare (ProjectRefVar.Name, GacRefVar.Name) != 0) && 
						(String.Compare (ProjectRefVar.Name, AsmRefVar.Name) != 0))
						ReadReferences (ProjectRefVar, ReferenceType.Project, "Project References", dotnetProject);
					
					//Resolve References
					//Required when UpdateProject gets called by ui
					if (ownerProject.ParentSolution != null)
						ResolveProjectReferences (ownerProject.ParentSolution.RootFolder, monitor);

					foreach (ProjectReference pr in existingGacRefs.Values)
						dotnetProject.References.Remove (pr);

					existingGacRefs.Clear ();
					newGacRefs.Clear ();
				}
			} catch (Exception e) {
				string msg = GettextCatalog.GetString (
					"Error in loading references: {0}. Skipping syncing of references", e.Message);
				LoggingService.LogWarning (msg);
				monitor.ReportWarning (msg);

				SaveReferences = false;
			}

			this.monitor = null;
		}
Example #27
0
		bool CheckSCPlugin ()
		{
			if (Platform.IsMac && Directory.Exists ("/Library/Contextual Menu Items/SCFinderPlugin.plugin")) {
				string message = "SCPlugin not supported";
				string detail = "MonoDevelop has detected that SCPlugin (scplugin.tigris.org) is installed. " +
				                "SCPlugin is a Subversion extension for Finder that is known to cause crashes in MonoDevelop and" +
				                "other applications running on Mac OSX 10.9 (Mavericks) or upper. Please uninstall SCPlugin " +
				                "before proceeding.";
				var close = new AlertButton (BrandingService.BrandApplicationName (GettextCatalog.GetString ("Close MonoDevelop")));
				var info = new AlertButton (GettextCatalog.GetString ("More Information"));
				var cont = new AlertButton (GettextCatalog.GetString ("Continue Anyway"));
				while (true) {
					var res = MessageService.GenericAlert (Gtk.Stock.DialogWarning, message, BrandingService.BrandApplicationName (detail), info, cont, close);
					if (res == close) {
						LoggingService.LogInternalError ("SCPlugin detected", new Exception ("SCPlugin detected. Closing."));
						return false;
					}
					if (res == info)
						DesktopService.ShowUrl ("https://bugzilla.xamarin.com/show_bug.cgi?id=21755");
					if (res == cont) {
						bool exists = Directory.Exists ("/Library/Contextual Menu Items/SCFinderPlugin.plugin");
						LoggingService.LogInternalError ("SCPlugin detected", new Exception ("SCPlugin detected. Continuing " + (exists ? "Installed." : "Uninstalled.")));
						return true;
					}
				}
			}
			return true;
		}
Example #28
0
		internal static CheckResult CheckBeforeDebugging (IBuildTarget target)
		{
			if (IdeApp.Preferences.BuildBeforeExecuting)
				return CheckResult.BuildBeforeRun;
			
			if (!target.NeedsBuilding (IdeApp.Workspace.ActiveConfiguration))
				return CheckResult.Run;
			
			AlertButton bBuild = new AlertButton (GettextCatalog.GetString ("Build"));
			AlertButton bRun = new AlertButton (Gtk.Stock.Execute, true);
			AlertButton res = MessageService.AskQuestion (
			                                 GettextCatalog.GetString ("Outdated Debug Information"), 
			                                 GettextCatalog.GetString ("The project you are executing has changes done after the last time it was compiled. The debug information may be outdated. Do you want to continue?"),
			                                 2,
			                                 AlertButton.Cancel,
			                                 bBuild,
			                                 bRun);

			// This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
			// drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
			DispatchService.RunPendingEvents ();

			if (res == AlertButton.Cancel)
				return CheckResult.Cancel;

			if (res == bRun)
				return CheckResult.Run;

			return CheckResult.BuildBeforeRun;
		}
Example #29
0
		public IAsyncOperation CheckAndBuildForExecute (IBuildTarget executionTarget)
		{
			if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) {
				return new FinishBuildAndCheckAgainOperation (currentBuildOperation, () => CheckAndBuildForExecute (executionTarget));
			}

			//saves open documents since it may dirty the "needs building" check
			var r = DoBeforeCompileAction ();
			if (r.Failed)
				return NullAsyncOperation.Failure;

			var configuration = IdeApp.Workspace.ActiveConfiguration;

			var buildTarget = executionTarget;
			var ewo = buildTarget as IExecutableWorkspaceObject;
			if (ewo != null) {
				var buildDeps = ewo.GetExecutionDependencies ().ToList ();
				if (buildDeps.Count > 1)
					throw new NotImplementedException ("Multiple execution dependencies not yet supported");
				buildTarget = buildDeps [0];
			}

			bool needsBuild = FastCheckNeedsBuild (buildTarget, configuration);
			if (!needsBuild) {
				return NullAsyncOperation.Success;
			}

			if (IdeApp.Preferences.BuildBeforeExecuting) {
				return new CheckAndBuildForExecuteOperation (Build (buildTarget, true));
			}

			var bBuild = new AlertButton (GettextCatalog.GetString ("Build"));
			var bRun = new AlertButton (Gtk.Stock.Execute, true);
			var res = MessageService.AskQuestion (
				GettextCatalog.GetString ("Outdated Build"),
				GettextCatalog.GetString ("The project you are executing has changes done after the last time it was compiled. Do you want to continue?"),
				2,
				AlertButton.Cancel,
				bBuild,
				bRun);

			// This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
			// drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
			DispatchService.RunPendingEvents ();

			if (res == bRun) {
				return NullAsyncOperation.Success;
			}

			if (res == bBuild) {
				return new CheckAndBuildForExecuteOperation (Build (buildTarget, true));
			}

			return NullAsyncOperation.Failure;
		}
		public static bool Confirm (string primaryText, AlertButton button, bool confirmIsDefault)
		{
			return Confirm (primaryText, null, button, confirmIsDefault);
		}
Example #31
0
		public bool AddFilesToSolutionFolder (SolutionFolder folder, string[] files)
		{
			QuestionMessage msg = new QuestionMessage ();
			AlertButton keepButton = new AlertButton (GettextCatalog.GetString ("Keep file path"));
			msg.Buttons.Add (keepButton);
			msg.Buttons.Add (AlertButton.Copy);
			msg.Buttons.Add (AlertButton.Move);
			msg.Buttons.Add (AlertButton.Cancel);
			msg.AllowApplyToAll = true;
			
			bool someAdded = false;
			
			foreach (string file in files) {
				FilePath fp = file;
				FilePath dest = folder.BaseDirectory.Combine (fp.FileName);
				
				if (folder.IsRoot) {
					// Don't allow adding files to the root folder. VS doesn't allow it
					// If there is no existing folder, create one
					var itemsFolder = (SolutionFolder) folder.Items.Where (item => item.Name == "Solution Items").FirstOrDefault ();
					if (itemsFolder == null) {
						itemsFolder = new SolutionFolder ();
						itemsFolder.Name = "Solution Items";
						folder.AddItem (itemsFolder);
					}
					folder = itemsFolder;
				}
				
				if (!fp.IsChildPathOf (folder.BaseDirectory)) {
					msg.Text = GettextCatalog.GetString ("The file {0} is outside the folder directory. What do you want to do?", fp.FileName);
					AlertButton res = MessageService.AskQuestion (msg);
					if (res == AlertButton.Cancel)
						return someAdded;
					if (res == AlertButton.Copy) {
						FileService.CopyFile (file, dest);
						fp = dest;
					} else if (res == AlertButton.Move) {
						FileService.MoveFile (file, dest);
						fp = dest;
					}
				}
				folder.Files.Add (fp);
				someAdded = true;
			}
			return someAdded;
		}
		public ConfirmationMessage (AlertButton button): this ()
		{
			ConfirmButton = button;
		}
Example #33
0
		void OnOpen (object s, EventArgs args)
		{
			string[] files = GetCurrentFiles ();
			if (files.Length == 0)
				return;
			else if (files.Length == 1) {
				TreePath[] rows = filelist.Selection.GetSelectedRows ();
				int line = 1;
				if (rows.Length == 1 && rows [0].Depth == 2) {
					line = diffRenderer.GetSelectedLine (rows [0]);
					if (line == -1)
						line = 1;
				}
				var proj = IdeApp.Workspace.GetProjectsContainingFile (files [0]).FirstOrDefault ();
				IdeApp.Workbench.OpenDocument (files [0], proj, line, 0);
			}
			else {
				AlertButton openAll = new AlertButton (GettextCatalog.GetString ("_Open All"));
				if (MessageService.AskQuestion (GettextCatalog.GetString ("Do you want to open all {0} files?", files.Length), AlertButton.Cancel, openAll) == openAll) {
					for (int n = 0; n < files.Length; n++) {
						var proj = IdeApp.Workspace.GetProjectsContainingFile (files [n]).FirstOrDefault ();
						IdeApp.Workbench.OpenDocument (files [n], proj, n == 0);
					}
				}
			}
		public ConfirmationMessage (string primaryText, string secondaryText, AlertButton button): this (primaryText, button)
		{
			SecondaryText = secondaryText;
		}
Example #35
0
 public static bool Confirm(string primaryText, AlertButton button)
 {
     return(Confirm(primaryText, null, button));
 }
Example #36
0
		internal protected override bool InstallDependencies ()
		{
			if (IsDependentOnXcodeCLITools.Value) {
				var button = new AlertButton (GettextCatalog.GetString ("Install"));
				if (MessageService.AskQuestion (
					GettextCatalog.GetString ("This solution may be using Subversion. Do you want to install Xcode Command Line Tools now?"),
					BrandingService.BrandApplicationName (
						GettextCatalog.GetString ("Xcode Command Line Tools are not currently installed, and are required to use Subversion.\nPlease restart MonoDevelop after the installation to enable Subversion support.")),
					AlertButton.Cancel,
					button) == button) {
					var p = Process.Start ("xcode-select", "--install");
					p.WaitForExit ();
				}
				return false;
			}
			return true;
		}
Example #37
0
 public static bool Confirm(string primaryText, AlertButton button, bool confirmIsDefault)
 {
     return(Confirm(primaryText, null, button, confirmIsDefault));
 }
Example #38
0
		static void CheckGtkVersion (uint major, uint minor, uint micro)
		{
			// to require exact version, also check
			//: || Gtk.Global.CheckVersion (major, minor, micro + 1) == null
			//
			if (Gtk.Global.CheckVersion (major, minor, micro) != null) {
				
				LoggingService.LogFatalError (
					"GTK+ version is incompatible with required version {0}.{1}.{2}.",
					major, minor, micro
				);
				
				var downloadButton = new AlertButton ("Download Mono Framework", null);
				if (downloadButton == MessageService.GenericAlert (
					Stock.Error,
					GettextCatalog.GetString ("Some dependencies need to be updated"),
					GettextCatalog.GetString (
						"{0} requires a newer version of GTK+, which is included with the Mono Framework. Please " +
						"download and install the latest stable Mono Framework package and restart {0}.",
						BrandingService.ApplicationName
					),
					new AlertButton ("Quit", null), downloadButton))
				{
					OpenUrl (monoDownloadUrl);
				}
				
				Environment.Exit (1);
			}
		}
Example #39
0
 public static bool Confirm(string primaryText, string secondaryText, AlertButton button, bool confirmIsDefault)
 {
     return(GenericAlert(MonoDevelop.Ide.Gui.Stock.Question, primaryText, secondaryText, confirmIsDefault ? 0 : 1, AlertButton.Cancel, button) == button);
 }
Example #40
0
		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 Remove option remove the project from the solution, but it will not physically delete any file from disk.");
			
			SolutionEntityItem prj = item as SolutionEntityItem;
			if (prj == null) {
				if (MessageService.Confirm (question, AlertButton.Remove) && IdeApp.Workspace.RequestItemUnload (item))
					RemoveItemFromSolution (prj);
				return;
			}
			
			AlertButton delete = new AlertButton (GettextCatalog.GetString ("Delete from Disk"));
			AlertButton result = MessageService.AskQuestion (question, secondaryText,
			                                                 delete, AlertButton.Cancel, AlertButton.Remove);
			if (result == delete) {
				if (!IdeApp.Workspace.RequestItemUnload (prj))
					return;
				ConfirmProjectDeleteDialog dlg = new ConfirmProjectDeleteDialog (prj);
				if (MessageService.RunCustomDialog (dlg) == (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 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);
			}
		}
Example #41
0
 public AlertButtonEventArgs(AlertButton button, bool closeDialog)
 {
     Button      = button;
     CloseDialog = closeDialog;
 }