public override MigrationType ShouldMigrateProject ()
		{
			if (!IdeApp.IsInitialized)
				return MigrationType.Ignore;

			if (Migration.HasValue)
				return Migration.Value;

			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 Project?"),
				BrandingService.BrandApplicationName (GettextCatalog.GetString (
					"One or more projects 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.")),
				buttonIgnore, buttonMigrate, buttonBackupAndMigrate);

			// If we get an unexpected response, the default should be to *not* migrate
			if (response == buttonBackupAndMigrate)
				Migration = MigrationType.BackupAndMigrate;
			else if (response == buttonMigrate)
				Migration = MigrationType.Migrate;
			else 
				Migration = MigrationType.Ignore;

			return Migration.Value;
		}
		public MigrationType ShouldMigrateProject ()
		{
			if (Migration.HasValue)
				return Migration.Value;
			
			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 (
					"One or more projects 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."),
				buttonIgnore, buttonMigrate, buttonBackupAndMigrate);
			if (response == buttonIgnore)
				Migration = MigrationType.Ignore;
			else if (response == buttonMigrate)
				Migration = MigrationType.Migrate;
			else
				Migration = MigrationType.BackupAndMigrate;
			
			return Migration.Value;
		}
		public override void RequestFileEdit (IEnumerable<FilePath> files)
		{
			base.RequestFileEdit (files);

			if (!IdeApp.IsInitialized)
				return;

			List<FilePath> readOnlyFiles = new List<FilePath> ();
			foreach (var f in files) {
				if (File.Exists (f) && File.GetAttributes (f).HasFlag (FileAttributes.ReadOnly))
					readOnlyFiles.Add (f);
			}
			string error;
			if (readOnlyFiles.Count == 1)
				error = GettextCatalog.GetString ("File {0} is read-only", readOnlyFiles [0].FileName);
			else if (readOnlyFiles.Count > 1) {
				var f1 = string.Join (", ", readOnlyFiles.Take (readOnlyFiles.Count - 1).ToArray ());
				var f2 = readOnlyFiles [readOnlyFiles.Count - 1];
				error = GettextCatalog.GetString ("Files {0} and {1} are read-only", f1, f2);
			} else
				return;

			var btn = new AlertButton (readOnlyFiles.Count == 1 ? GettextCatalog.GetString ("Make Writtable") : GettextCatalog.GetString ("Make Writtable"));
			var res = MessageService.AskQuestion (error, GettextCatalog.GetString ("Would you like MonoDevelop to attempt to make the file writable and try again?"), btn, AlertButton.Cancel);
			if (res == AlertButton.Cancel)
				throw new UserException (error) { AlreadyReportedToUser = true };

			foreach (var f in readOnlyFiles) {
				var atts = File.GetAttributes (f);
				File.SetAttributes (f, atts & ~FileAttributes.ReadOnly);
			}
		}
Esempio n. 4
0
 public void DisplayAlert(string title, string message, AlertButton button)
 {
     this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         new MessageDialog(message, title).ShowAsync();
     });
 }
		public override void RequestFileEdit (FilePath file)
		{
			base.RequestFileEdit (file);

			if (!IdeApp.IsInitialized)
				return;

			if (!File.Exists (file))
				return;
			
#if MAC
			// detect 'locked' files on OS X
			var attr = Foundation.NSFileManager.DefaultManager.GetAttributes (file) ;
			if (attr != null && attr.Immutable.HasValue && attr.Immutable.Value) {
				throw new UserException (GettextCatalog.GetString ("File '{0}' is locked.", file));
			}
#endif
			var atts = File.GetAttributes (file);
			if ((atts & FileAttributes.ReadOnly) == 0)
				return;
			
			string error = GettextCatalog.GetString ("File {0} is read-only", file.FileName);

			var btn = new AlertButton (GettextCatalog.GetString ("Make Writable"));
			var res = MessageService.AskQuestion (error, GettextCatalog.GetString ("Would you like {0} to attempt to make the file writable and try again?", BrandingService.ApplicationName), btn, AlertButton.Cancel);
			if (res == AlertButton.Cancel)
				throw new UserException (error) { AlreadyReportedToUser = true };

			File.SetAttributes (file, atts & ~FileAttributes.ReadOnly);
		}
Esempio n. 6
0
 void ButtonClicked(object sender, EventArgs e)
 {
     Gtk.Button clickButton = (Gtk.Button)sender;
     foreach (AlertButton alertButton in buttons)
     {
         if (clickButton.Label == alertButton.Label)
         {
             resultButton = alertButton;
             break;
         }
     }
     this.Destroy();
 }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        protected void OnDropTable()
        {
            TableNode   node       = (TableNode)CurrentNode.DataItem;
            AlertButton dropButton = new AlertButton(AddinCatalog.GetString("Drop"), Gtk.Stock.Delete);

            if (MessageService.Confirm(
                    AddinCatalog.GetString("Are you sure you want to drop table '{0}'", node.Table.Name),
                    dropButton
                    ))
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(OnDropTableThreaded), CurrentNode.DataItem);
            }
        }
Esempio n. 9
0
        private async void OpenFindSourceFileDialog(object sender, EventArgs e)
        {
            var sf = DebuggingService.CurrentFrame;

            if (sf == null)
            {
                LoggingService.LogWarning($"CurrentFrame was null in {nameof (OpenFindSourceFileDialog)}");
                return;
            }
            var dlg = new Ide.Gui.Dialogs.OpenFileDialog(GettextCatalog.GetString("File to Open") + " " + sf.SourceLocation.FileName, FileChooserAction.Open)
            {
                TransientFor         = IdeApp.Workbench.RootWindow,
                ShowEncodingSelector = true,
                ShowViewerSelector   = true
            };

            dlg.DirectoryChangedHandler = (s, path) => {
                return(SourceCodeLookup.TryDebugSourceFolders(sf.SourceLocation.FileName, sf.SourceLocation.FileHash, new string [] { path }));
            };
            if (!dlg.Run())
            {
                return;
            }
            var newFilePath = dlg.SelectedFile;

            try {
                if (File.Exists(newFilePath))
                {
                    var ignoreButton = new AlertButton(GettextCatalog.GetString("Ignore"));
                    if (SourceCodeLookup.CheckFileHash(newFilePath, sf.SourceLocation.FileHash) ||
                        MessageService.AskQuestion(GettextCatalog.GetString("File checksum doesn't match."), 1, ignoreButton, new AlertButton(GettextCatalog.GetString("Cancel"))) == ignoreButton)
                    {
                        SourceCodeLookup.AddLoadedFile(newFilePath, sf.SourceLocation.FileName);
                        sf.UpdateSourceFile(newFilePath);

                        var doc = await IdeApp.Workbench.OpenDocument(newFilePath, null, sf.SourceLocation.Line, 1, OpenDocumentOptions.Debugger);

                        if (doc != null)
                        {
                            await Document.Close(false);
                        }
                    }
                }
                else
                {
                    MessageService.ShowWarning(GettextCatalog.GetString("File not found."));
                }
            } catch (Exception) {
                MessageService.ShowWarning(GettextCatalog.GetString("Error opening file."));
            }
        }
Esempio n. 10
0
        internal static void OnAlertCb(string message)
        {
            var arr = message.Split('|');

            if (arr.Length != 2)
            {
                return;
            }
            int         alertId = Convert.ToInt32(arr[0]);
            AlertParams param;

            if (!map.TryGetValue(alertId, out param))
            {
                return;
            }
            map.Remove(alertId);

            AlertButton button = (AlertButton)(Convert.ToInt32(arr[1]));

            switch (button)
            {
            case AlertButton.Yes:
                if (param.onYesButtonPress != null)
                {
                    param.onYesButtonPress(button);
                }
                break;

            case AlertButton.No:
                if (param.onNoButtonPress != null)
                {
                    param.onNoButtonPress(button);
                }
                break;

            case AlertButton.Neutral:
                if (param.onNeutralButtonPress != null)
                {
                    param.onNeutralButtonPress(button);
                }
                break;

            default:
                return;
            }

            if (param.onButtonPress != null)
            {
                param.onButtonPress(button);
            }
        }
Esempio n. 11
0
        static bool ConfirmDelete(FilePath folder)
        {
            var question = new QuestionMessage {
                Text          = GettextCatalog.GetString("Are you sure you want to remove directory {0}?", folder),
                SecondaryText = GettextCatalog.GetString("The directory and any files it contains will be permanently removed from your hard disk.")
            };

            question.Buttons.Add(AlertButton.Delete);
            question.Buttons.Add(AlertButton.Cancel);

            AlertButton result = MessageService.AskQuestion(question);

            return(result == AlertButton.Delete);
        }
Esempio n. 12
0
        void Build()
        {
            message = new GenericMessage {
                Text          = GettextCatalog.GetString(".NET Core SDK is not installed. This is required to build and run .NET Core projects."),
                DefaultButton = 1,
                Icon          = Stock.Information
            };

            downloadButton = new AlertButton(GettextCatalog.GetString("Download .NET Core..."));
            message.Buttons.Add(AlertButton.Cancel);
            message.Buttons.Add(downloadButton);

            message.AlertButtonClicked += AlertButtonClicked;
        }
Esempio n. 13
0
        async void OnOKClicked(object sender, EventArgs e)
        {
            var properties = Properties;

            ((Widget)this).Destroy();
            var changes = await this.rename(properties);

            ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor(Title, null);


            if (ChangedDocuments != null)
            {
                AlertButton result = null;
                var         msg    = new QuestionMessage();
                msg.Buttons.Add(AlertButton.MakeWriteable);
                msg.Buttons.Add(AlertButton.Cancel);
                msg.AllowApplyToAll = true;

                foreach (var path in ChangedDocuments)
                {
                    try {
                        var attr = File.GetAttributes(path);
                        if (attr.HasFlag(FileAttributes.ReadOnly))
                        {
                            msg.Text          = GettextCatalog.GetString("File {0} is read-only", path);
                            msg.SecondaryText = GettextCatalog.GetString("Would you like to make the file writable?");
                            result            = MessageService.AskQuestion(msg);

                            if (result == AlertButton.Cancel)
                            {
                                return;
                            }
                            else if (result == AlertButton.MakeWriteable)
                            {
                                try {
                                    File.SetAttributes(path, attr & ~FileAttributes.ReadOnly);
                                } catch (Exception ex) {
                                    MessageService.ShowError(ex.Message);
                                    return;
                                }
                            }
                        }
                    } catch (Exception ex) {
                        MessageService.ShowError(ex.Message);
                        return;
                    }
                }
            }
            RefactoringService.AcceptChanges(monitor, changes);
        }
Esempio n. 14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            IniData configdata;

            try
            {
                configdata = (new FileIniDataParser()).ReadFile("alerts.ini");
                int lastbuttonbottom = 0;
                foreach (var section in configdata.Sections)
                {
                    List <SAMERegion> Regions = new List <SAMERegion>();
                    foreach (var key in section.Keys)
                    {
                        if (key.KeyName.IndexOf("FIPS") == 0)
                        {
                            int fipsState  = Convert.ToInt32(key.Value.Substring(1, 2));
                            int fipsCounty = Convert.ToInt32(key.Value.Substring(3, 3));
                            Regions.Add(new SAMERegion(new SAMEState(fipsState, ""), new SAMECounty(fipsCounty, "", new SAMEState(fipsState, ""))));
                        }
                    }
                    string callsign;
                    if (section.Keys["Callsign"].Length == 8)
                    {
                        callsign = section.Keys["Callsign"];
                    }
                    if (section.Keys["Callsign"].Length > 8)
                    {
                        callsign = section.Keys["Callsign"].Substring(0, 8);
                    }
                    else
                    {
                        callsign = section.Keys["Callsign"].PadRight(8);
                    }
                    AlertButton newbutton = new AlertButton(player, section.Keys["Originator"], section.Keys["Event"], Regions, section.Keys["Length"], callsign, (section.Keys["Audio"] == "wav"), section.Keys["Announcement"],
                                                            Convert.ToBoolean(section.Keys["Attn"]), Convert.ToBoolean(section.Keys["1050"]));

                    AlertButtons.Add(newbutton);
                    this.Controls.Add(newbutton.playbutton);
                    newbutton.playbutton.Text  = section.SectionName;
                    newbutton.playbutton.Width = 255;
                    newbutton.playbutton.Top   = lastbuttonbottom + 8;
                    lastbuttonbottom           = newbutton.playbutton.Bottom;
                    this.Height = lastbuttonbottom + 48;
                }
            }
            catch
            {
                MessageBox.Show("Problem reading alerts.ini");
            }
        }
        void Build()
        {
            message = new GenericMessage {
                Text          = defaultMessage,
                DefaultButton = 1,
                Icon          = Stock.Information
            };

            downloadButton = new AlertButton(GettextCatalog.GetString("Download .NET Core..."));
            message.Buttons.Add(AlertButton.Cancel);
            message.Buttons.Add(downloadButton);

            message.AlertButtonClicked += AlertButtonClicked;
        }
Esempio n. 16
0
        public static void Error(string pCaption, string pText, int followUpId)
        {
            m_AlertDialogError = new AlertControl()
            {
                AutoFormDelay = 10000
            };

            AlertButton btnDiagnose = new AlertButton(Common.Resources.magnifying_glass);
            btnDiagnose.Hint = "Diagnose audio to see more details";
            m_AlertDialogError.Buttons.Add(btnDiagnose);
            m_AlertDialogError.ButtonClick += new AlertButtonClickEventHandler((sender, e) => AlertButton_Click(sender, e, followUpId));

            m_AlertDialogError.BeforeFormShow += m_AlertDialogError_BeforeFormShow;
            m_AlertDialogError.Show(new Form(), pCaption, pText);
        }
Esempio n. 17
0
        void OnWindowClosing(object sender, WorkbenchWindowEventArgs args)
        {
            IWorkbenchWindow window = (IWorkbenchWindow)sender;

            if (!args.Forced && window.ViewContent != null && window.ViewContent.IsDirty)
            {
                AlertButton result = MessageService.GenericAlert(Stock.Warning,
                                                                 GettextCatalog.GetString("Save the changes to document '{0}' before closing?",
                                                                                          window.ViewContent.IsUntitled
                                                        ? window.ViewContent.UntitledName
                                                        : System.IO.Path.GetFileName(window.ViewContent.ContentName)),
                                                                 GettextCatalog.GetString("If you don't save, all changes will be permanently lost."),
                                                                 AlertButton.CloseWithoutSave, AlertButton.Cancel, window.ViewContent.IsUntitled ? AlertButton.SaveAs : AlertButton.Save);
                if (result == AlertButton.Save || result == AlertButton.SaveAs)
                {
                    if (window.ViewContent.ContentName == null)
                    {
                        FindDocument(window).Save();
                        args.Cancel = window.ViewContent.IsDirty;
                    }
                    else
                    {
                        try {
                            if (window.ViewContent.IsFile)
                            {
                                window.ViewContent.Save(window.ViewContent.ContentName);
                            }
                            else
                            {
                                window.ViewContent.Save();
                            }
                        }
                        catch (Exception ex) {
                            args.Cancel = true;
                            MessageService.ShowException(ex, GettextCatalog.GetString("The document could not be saved."));
                        }
                    }
                }
                else
                {
                    args.Cancel = result != AlertButton.CloseWithoutSave;
                    if (!args.Cancel)
                    {
                        window.ViewContent.DiscardChanges();
                    }
                }
            }
        }
Esempio n. 18
0
        public static void RemoveSnapshot(IProfilingSnapshot snapshot)
        {
            AlertButton removeFromProject = new AlertButton(GettextCatalog.GetString("_Remove from Project"), Gtk.Stock.Remove);
            AlertButton result            = MessageService.AskQuestion(GettextCatalog.GetString("Are you sure you want to remove snapshot '{0}'?", snapshot.Name),
                                                                       GettextCatalog.GetString("Delete physically removes the file from disc."),
                                                                       AlertButton.Delete, AlertButton.Cancel, removeFromProject);

            if (result != AlertButton.Cancel)
            {
                ProfilingService.ProfilingSnapshots.Remove(snapshot);
                if (result == AlertButton.Delete && File.Exists(snapshot.FileName))
                {
                    FileService.DeleteFile(snapshot.FileName);
                }
            }
        }
 public override bool ValidateChanges()
 {
     if (ConfiguredSolution != null && widget.ResourceNamingChanged)
     {
         string      msg    = GettextCatalog.GetString("The resource naming policy has changed");
         string      detail = GettextCatalog.GetString("Changing the resource naming policy may cause run-time errors if the code using resources is not properly updated. There are two options:\n\nUpdate all resource identifiers to match the new policy. This will require changes in the source code that references resources using the old policy. Identifiers explicitly set using the file properties pad won't be changed.\n\nKeep curent resource identifiers. It doesn't require source code changes. Resources added from now on will use the new policy.");
         AlertButton update = new AlertButton(GettextCatalog.GetString("Update Identifiers"));
         AlertButton keep   = new AlertButton(GettextCatalog.GetString("Keep Current Identifiers"));
         AlertButton res    = MessageService.AskQuestion(msg, detail, AlertButton.Cancel, update, keep);
         if (res == AlertButton.Cancel)
         {
             return(false);
         }
         migrateIds = res == keep;
     }
     return(base.ValidateChanges());
 }
        // Creates a file and saves it to disk. Returns the path to the new file
        // All parameters are optional (can be null)
        public string SaveFile(SolutionFolderItem policyParent, Project project, string language, string baseDirectory, string entryName)
        {
            string      file           = GetFileName(policyParent, project, language, baseDirectory, entryName);
            AlertButton questionResult = null;

            if (File.Exists(file))
            {
                questionResult = MessageService.AskQuestion(GettextCatalog.GetString("File already exists"),
                                                            GettextCatalog.GetString("File {0} already exists.\nDo you want to overwrite the existing file or add it to the project?", file),
                                                            AlertButton.Cancel,
                                                            AlertButton.AddExistingFile,
                                                            AlertButton.OverwriteFile);
                if (questionResult == AlertButton.Cancel)
                {
                    return(null);
                }
            }

            if (!Directory.Exists(Path.GetDirectoryName(file)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(file));
            }

            if (questionResult == null || questionResult == AlertButton.OverwriteFile)
            {
                Stream stream = CreateFileContent(policyParent, project, language, file, entryName);

                byte []    buffer = new byte [2048];
                int        nr;
                FileStream fs = null;
                try {
                    fs = File.Create(file);
                    while ((nr = stream.Read(buffer, 0, 2048)) > 0)
                    {
                        fs.Write(buffer, 0, nr);
                    }
                } finally {
                    stream.Close();
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }
            return(file);
        }
Esempio n. 21
0
        private void ShowNotify(string msg)
        {
            if (messagebox == null)
            {
                messagebox = new AlertControl();
                messagebox.AutoFormDelay = 2000;
                //   messagebox.AllowHtmlText = true;
                messagebox.ShowPinButton = false;

                AlertButton btn1 = new AlertButton(Resource1.打开文件);// global::DXApplication1.Properties.Resources.open_16x16;);
                btn1.Hint = "打开文件";
                btn1.Name = "buttonOpen";
                messagebox.Buttons.Add(btn1);
                messagebox.ButtonClick += Messagebox_ButtonClick;
            }
            messagebox.Show(this.ParentForm, "信息", msg);
        }
Esempio n. 22
0
        TargetConvert QueryConversion(string text)
        {
            AlertButton vs2005 = new AlertButton(GettextCatalog.GetString("Convert to MSBuild"));

            AlertButton choice = MessageService.AskQuestion(text,
                                                            GettextCatalog.GetString("Converting to MSBuild format will overwrite existing files."),
                                                            AlertButton.Cancel, vs2005);

            if (choice == vs2005)
            {
                return(TargetConvert.VisualStudio);
            }
            else
            {
                return(TargetConvert.None);
            }
        }
Esempio n. 23
0
        public override void DeleteMultipleItems()
        {
            var             modifiedSolutionsToSave = new HashSet <Solution> ();
            QuestionMessage msg = new QuestionMessage();

            msg.SecondaryText = GettextCatalog.GetString("The Delete option permanently removes the file from your hard disk. Click Remove from Solution if you only want to remove it from your current solution.");
            AlertButton removeFromSolution = new AlertButton(GettextCatalog.GetString("_Remove from Solution"), Gtk.Stock.Remove);

            msg.Buttons.Add(AlertButton.Delete);
            msg.Buttons.Add(AlertButton.Cancel);
            msg.Buttons.Add(removeFromSolution);
            msg.AllowApplyToAll = true;

            foreach (ITreeNavigator nav in CurrentNodes)
            {
                SolutionFolderFileNode file = (SolutionFolderFileNode)nav.DataItem;
                if (file.Parent.IsRoot)
                {
                    msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution folder {1}?", file.FileName.FileName, file.Parent.Name);
                }
                else
                {
                    msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution {1}?", file.FileName.FileName, file.Parent.ParentSolution.Name);
                }
                AlertButton result = MessageService.AskQuestion(msg);
                if (result == AlertButton.Cancel)
                {
                    return;
                }

                file.Parent.Files.Remove(file.FileName);

                if (result == AlertButton.Delete)
                {
                    FileService.DeleteFile(file.FileName);
                }

                if (file.Parent != null && file.Parent.ParentSolution != null)
                {
                    modifiedSolutionsToSave.Add(file.Parent.ParentSolution);
                }
            }

            IdeApp.ProjectOperations.SaveAsync(modifiedSolutionsToSave);
        }
Esempio n. 24
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));
                }
            }
        }
Esempio n. 25
0
        void ButtonClicked(object sender, EventArgs e)
        {
            Gtk.Button clickButton = (Gtk.Button)sender;
            foreach (AlertButton alertButton in buttons)
            {
                if (clickButton.Label == alertButton.Label)
                {
                    resultButton = alertButton;
                    break;
                }
            }
            bool close = message.NotifyClicked(resultButton);

            if (close)
            {
                this.Destroy();
            }
        }
        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();
            }
        }
        public async void NewWebReference()
        {
            // Get the project and project folder
            var 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 msg1     = GettextCatalog.GetString("The current runtime environment for your project is set to version 1.0.");
                string msg2     = GettextCatalog.GetString("Web Service is not supported in this version.");
                string msg3     = GettextCatalog.GetString("Do you want switch the runtime environment for this project version 2.0?");
                string question = $"{msg1} {msg2} {msg3}";

                var switchButton = new AlertButton(GettextCatalog.GetString("_Switch to .NET 2.0"));
                if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton)
                {
                    project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker.NET_2_0);
                }
                else
                {
                    return;
                }
            }

            var dialog = new WebReferenceDialog(project);

            dialog.NamespacePrefix = project.DefaultNamespace;

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

                await dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName);

                await IdeApp.ProjectOperations.SaveAsync(project);
            } catch (Exception exception) {
                MessageService.ShowError(GettextCatalog.GetString("The web reference could not be added"), exception);
            } finally {
                dialog.Destroy();
                dialog.Dispose();
            }
        }
Esempio n. 28
0
        public override bool RequestFileWritePermission(params FilePath [] paths)
        {
            var toLock = new List <FilePath>();

            foreach (var path in paths)
            {
                if (!File.Exists(path))
                {
                    continue;
                }
                if (!TryGetVersionInfo(path, out var info))
                {
                    continue;
                }
                if (!info.IsVersioned || !Svn.HasNeedLock(path) || (File.GetAttributes(path) & FileAttributes.ReadOnly) == 0)
                {
                    continue;
                }
                toLock.Add(path);
            }

            if (toLock.Count == 0)
            {
                return(true);
            }

            AlertButton but = new AlertButton(GettextCatalog.GetString("Lock File"));

            if (!MessageService.Confirm(GettextCatalog.GetString("The following files must be locked before editing."),
                                        String.Join("\n", toLock.Select(u => u.ToString())), but))
            {
                return(false);
            }

            try {
                Svn.Lock(null, "", false, toLock.ToArray());
            } catch (SubversionException ex) {
                MessageService.ShowError(GettextCatalog.GetString("File could not be unlocked."), ex.Message);
                return(false);
            }

            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(this, toLock.ToArray()));
            return(true);
        }
Esempio n. 29
0
        protected void OnEmptyTable()
        {
            TableNode node = (TableNode)CurrentNode.DataItem;

            AlertButton emptyButton = new AlertButton(AddinCatalog.GetString("Empty Table"));

            if (MessageService.Confirm(
                    AddinCatalog.GetString("Are you sure you want to empty table '{0}'", node.Table.Name),
                    emptyButton
                    ))
            {
                IdentifierExpression tableId = new IdentifierExpression(node.Table.Name);
                DeleteStatement      del     = new DeleteStatement(new FromTableClause(tableId));

                IPooledDbConnection conn    = node.ConnectionContext.ConnectionPool.Request();
                IDbCommand          command = conn.CreateCommand(del);
                conn.ExecuteNonQueryAsync(command, new ExecuteCallback <int> (OnEmptyTableCallback), null);
            }
        }
        public static void ShowDotNetCoreNotInstalledError(DotNetCoreNotFoundException ex)
        {
            var message        = new GenericMessage(ex.Message, ex.Details);
            var downloadButton = new AlertButton(GettextCatalog.GetString("Go to download"));

            message.Icon = Stock.Error;
            message.Buttons.Add(downloadButton);
            message.Buttons.Add(AlertButton.Ok);
            message.DefaultButton = 1;
            var dialog = new AlertDialog(message);

            dialog.TransientFor = IdeApp.Workbench.RootWindow;
            var result = dialog.Run();

            if (result == downloadButton)
            {
                DesktopService.ShowUrl("https://www.microsoft.com/net/core");
            }
        }
        public override void RequestFileEdit(FilePath file)
        {
            base.RequestFileEdit(file);

            if (!IdeApp.IsInitialized)
            {
                return;
            }

            if (!File.Exists(file))
            {
                return;
            }

#if MAC
            // detect 'locked' files on OS X
            var attr = Foundation.NSFileManager.DefaultManager.GetAttributes(file);
            if (attr != null && attr.Immutable.HasValue && attr.Immutable.Value)
            {
                throw new UserException(GettextCatalog.GetString("File '{0}' is locked.", file));
            }
#endif
            var atts = File.GetAttributes(file);
            if ((atts & FileAttributes.ReadOnly) == 0)
            {
                return;
            }

            string error = GettextCatalog.GetString("File {0} is read-only", file.FileName);

            var btn = new AlertButton(GettextCatalog.GetString("Make Writable"));
            var res = MessageService.AskQuestion(error, GettextCatalog.GetString("Would you like {0} to attempt to make the file writable and try again?", BrandingService.ApplicationName), btn, AlertButton.Cancel);
            if (res == AlertButton.Cancel)
            {
                throw new UserException(error)
                      {
                          AlreadyReportedToUser = true
                      }
            }
            ;

            File.SetAttributes(file, atts & ~FileAttributes.ReadOnly);
        }
Esempio n. 32
0
 FileConflictAction MapResultToFileConflictResolution(AlertButton result)
 {
     if (result == AlertButton.Yes)
     {
         return(FileConflictAction.Overwrite);
     }
     else if (result == YesToAllButton)
     {
         return(FileConflictAction.OverwriteAll);
     }
     else if (result == NoToAllButton)
     {
         return(FileConflictAction.IgnoreAll);
     }
     else
     {
         return(FileConflictAction.Ignore);
     }
 }
        internal void FormSubmitwithDDT()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            try
            {
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(FileUpload));
                string wanted_path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\GlobalSQA\\"));
                Helpers.ExcelLib.populateInCollection(wanted_path + "TestData.xlsx", "Data");
                FileUpload.SendKeys(wanted_path + "NUNNA.jpg");
                Name.Click();
                Name.SendKeys(Helpers.ExcelLib.ReadData(2, "Name"));
                Email.SendKeys(Helpers.ExcelLib.ReadData(2, "Email"));
                Website.SendKeys(Helpers.ExcelLib.ReadData(2, "WebSite"));
                SelectElement expe = new SelectElement(Experience);
                expe.SelectByValue(Helpers.ExcelLib.ReadData(2, "Experiene"));
                Functional.Click();
                Automation.Click();
                Manual.Click();
                Education.Click();
                AlertButton.Click();
                IAlert alert = driver.SwitchTo().Alert();
                alert.Accept();
                IAlert alert1 = driver.SwitchTo().Alert();
                alert1.Accept();
                Helpers.HelperClass.GetElementAndScrollTo(driver, By.XPath("//textarea[@class='textarea']"));
                Comment.Click();
                Comment.SendKeys(Helpers.ExcelLib.ReadData(2, "Comment"));
                string FilledForm = Helpers.HelperClass.SaveScreenshot(driver, "FilledForm");
                Test.Log(Status.Pass, "Before form Submitted", MediaEntityBuilder.CreateScreenCaptureFromPath(FilledForm).Build());
                Submit.Click();
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(ResponseMesage));
                Helpers.HelperClass.GetElementAndScrollTo(driver, By.XPath("//div[@class='twelve columns']//h3"));
                String responseMsg = ResponseMesage.Text;
                Assert.AreEqual(responseMsg, Helpers.ExcelLib.ReadData(2, "Assertion"));
                string ResponseMsgScreenShot = Helpers.HelperClass.SaveScreenshot(driver, "ResponseMsgScreenShot");
                Test.Log(Status.Pass, "After Response Generated", MediaEntityBuilder.CreateScreenCaptureFromPath(ResponseMsgScreenShot).Build());
            }
            catch (Exception e)
            {
                Test.Log(AventStack.ExtentReports.Status.Fail, "Test failed,please check the logs" + e);
            }
        }
        public void RemoveItem()
        {
            Solution  solution = CurrentNode.DataItem as Solution;
            Workspace parent   = CurrentNode.GetParentDataItem(typeof(Workspace), false) as Workspace;

            if (parent == null)
            {
                return;
            }

            AlertButton res = MessageService.AskQuestion(GettextCatalog.GetString("Do you really want to remove solution {0} from workspace {1}?", solution.Name, parent.Name), AlertButton.Remove);

            if (res == AlertButton.Remove)
            {
                parent.Items.Remove(solution);
                solution.Dispose();
                IdeApp.Workspace.Save();
            }
        }
Esempio n. 35
0
        async Task <bool> ShowSaveUI(bool force)
        {
            if (!force && controller.HasUnsavedChanges)
            {
                AlertButton result = MessageService.GenericAlert(Stock.Warning,
                                                                 GettextCatalog.GetString("Save the changes to document '{0}' before closing?", controller.DocumentTitle),
                                                                 GettextCatalog.GetString("If you don't save, all changes will be permanently lost."),
                                                                 AlertButton.CloseWithoutSave, AlertButton.Cancel, controller.IsNewDocument ? AlertButton.SaveAs : AlertButton.Save);

                if (result == AlertButton.Save)
                {
                    await Save();

                    if (controller.HasUnsavedChanges)
                    {
                        // This may happen if the save operation failed
                        Select();
                        return(false);
                    }
                }
                else if (result == AlertButton.SaveAs)
                {
                    var resultSaveAs = await SaveAs();

                    if (!resultSaveAs || controller.HasUnsavedChanges)
                    {
                        // This may happen if the save operation failed or Save As was canceled
                        Select();
                        return(false);
                    }
                }
                else if (result == AlertButton.CloseWithoutSave)
                {
                    return(true);
                }
                else if (result == AlertButton.Cancel)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 36
0
        public AlertDialog SetButton(DialogButtonInterface whichButton, string text, OnButtonClick onButtonClick)
        {
            AlertButton alertButton = new AlertButton(whichButton, text, onButtonClick);
            
            switch(whichButton)
            {
                case DialogButtonInterface.BUTTON_POSITIVE:
                    _PositiveButton = alertButton;
                    break;
                default:
                case DialogButtonInterface.BUTTON_NEUTRAL:
                    _NeutralButton = alertButton;
                    break;
                case DialogButtonInterface.BUTTON_NEGATIVE:
                    _NegativeButton = alertButton;
                    break;
            }

            return this;
        }
		public override void RequestFileEdit (IEnumerable<FilePath> files)
		{
			base.RequestFileEdit (files);

			if (!IdeApp.IsInitialized)
				return;

			List<FilePath> readOnlyFiles = new List<FilePath> ();
			foreach (var f in files) {
				if (!File.Exists (f))
					continue;
				if (File.GetAttributes (f).HasFlag (FileAttributes.ReadOnly))
					readOnlyFiles.Add (f);
				#if MAC
				// detect 'locked' files on OS X
				var attr = Foundation.NSFileManager.DefaultManager.GetAttributes (f) ;
				if (attr != null && attr.Immutable.HasValue && attr.Immutable.Value) {
					throw new UserException (GettextCatalog.GetString ("File '{0}' is locked.", f));
				}
				#endif
			}
			string error;
			if (readOnlyFiles.Count == 1)
				error = GettextCatalog.GetString ("File {0} is read-only", readOnlyFiles [0].FileName);
			else if (readOnlyFiles.Count > 1) {
				var f1 = string.Join (", ", readOnlyFiles.Take (readOnlyFiles.Count - 1).ToArray ());
				var f2 = readOnlyFiles [readOnlyFiles.Count - 1];
				error = GettextCatalog.GetString ("Files {0} and {1} are read-only", f1, f2);
			} else
				return;

			var btn = new AlertButton (GettextCatalog.GetString ("Make Writable"));
			var res = MessageService.AskQuestion (error, GettextCatalog.GetString ("Would you like {0} to attempt to make the file writable and try again?", BrandingService.ApplicationName), btn, AlertButton.Cancel);
			if (res == AlertButton.Cancel)
				throw new UserException (error) { AlreadyReportedToUser = true };

			foreach (var f in readOnlyFiles) {
				var atts = File.GetAttributes (f);
				File.SetAttributes (f, atts & ~FileAttributes.ReadOnly);
			}
		}
        public override MigrationType ShouldMigrateProject()
        {
            if (!IdeApp.IsInitialized)
            {
                return(MigrationType.Ignore);
            }

            if (Migration.HasValue)
            {
                return(Migration.Value);
            }

            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 Project?"),
                BrandingService.BrandApplicationName(GettextCatalog.GetString(
                                                         "One or more projects 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.")),
                buttonIgnore, buttonMigrate, buttonBackupAndMigrate);

            // If we get an unexpected response, the default should be to *not* migrate
            if (response == buttonBackupAndMigrate)
            {
                Migration = MigrationType.BackupAndMigrate;
            }
            else if (response == buttonMigrate)
            {
                Migration = MigrationType.Migrate;
            }
            else
            {
                Migration = MigrationType.Ignore;
            }

            return(Migration.Value);
        }
Esempio n. 39
0
		public GtkErrorDialog (Window parent, string title, string message, AlertButton[] buttons)
		{
			if (string.IsNullOrEmpty (title))
				throw new ArgumentException ();
			if (buttons == null)
				throw new ArgumentException ();
			
			Title = BrandingService.ApplicationName;
			TransientFor = parent;
			Modal = true;
			WindowPosition = Gtk.WindowPosition.CenterOnParent;
			DefaultWidth = 624;
			DefaultHeight = 142;
			
			this.VBox.BorderWidth = 2;
			
			var hbox = new HBox () {
				Spacing = 6,
				BorderWidth = 12,
			};
			
			var errorImage = new Image (Gtk.Stock.DialogError, IconSize.Dialog) {
				Yalign = 0F,
			};
			hbox.PackStart (errorImage, false, false, 0);
			this.VBox.Add (hbox);
			
			var vbox = new VBox () {
				Spacing = 6,
			};
			hbox.PackEnd (vbox, true, true, 0);
			
			var titleLabel = new Label () {
				Markup = "<b>" + GLib.Markup.EscapeText (title) + "</b>",
				Xalign = 0F,
			};
			vbox.PackStart (titleLabel, false, false, 0);
			
			if (!string.IsNullOrWhiteSpace (message)) {
				message = message.Trim ();
				var descriptionLabel = new Label (message) {
					Xalign = 0F,
					Selectable = true,
				};
				descriptionLabel.LineWrap = true;
				descriptionLabel.WidthRequest = 500;
				descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0));
				vbox.PackStart (descriptionLabel, false, false, 0);
			}
			
			expander = new Expander (GettextCatalog.GetString ("Details")) {
				CanFocus = true,
				Visible = false,
			};
			vbox.PackEnd (expander, true, true, 0);
			
			var sw = new ScrolledWindow () {
				HeightRequest = 180,
				ShadowType = ShadowType.Out,
			};
			expander.Add (sw);
			
			detailsTextView = new TextView () {
				CanFocus = true,
			};
			detailsTextView.KeyPressEvent += TextViewKeyPressed;
			sw.Add (detailsTextView);
			
			var aa = this.ActionArea;
			aa.Spacing = 10;
			aa.LayoutStyle = ButtonBoxStyle.End;
			aa.BorderWidth = 5;
			aa.Homogeneous = true;
			
			expander.Activated += delegate {
				this.AllowGrow = expander.Expanded;
				GLib.Timeout.Add (100, delegate {
					Resize (DefaultWidth, 1);
					return false;
				});
			};
			
			tagNoWrap = new TextTag ("nowrap");
			tagNoWrap.WrapMode = WrapMode.None;
			detailsTextView.Buffer.TagTable.Add (tagNoWrap);
			
			tagWrap = new TextTag ("wrap");
			tagWrap.WrapMode = WrapMode.Word;
			detailsTextView.Buffer.TagTable.Add (tagWrap);
			
			this.Buttons = buttons;
			for (int i = 0; i < Buttons.Length; i++) {
				Gtk.Button button;
				button = new Gtk.Button (Buttons[i].Label);
				button.ShowAll ();
				AddActionWidget (button, i);
			}
			
			Child.ShowAll ();
			Hide ();
		}
Esempio n. 40
0
		void DropNode (Set<SolutionEntityItem> projectsToSave, object dataObject, DragOperation operation)
		{
			FilePath targetPath = GetFolderPath (CurrentNode.DataItem);
			FilePath source;
			string what;
			Project targetProject = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
			Project sourceProject;
			System.Collections.Generic.IEnumerable<ProjectFile> groupedChildren = null;
			
			if (dataObject is ProjectFolder) {
				source = ((ProjectFolder) dataObject).Path;
				sourceProject = ((ProjectFolder) dataObject).Project;
				what = Path.GetFileName (source);
			}
			else if (dataObject is ProjectFile) {
				ProjectFile file = (ProjectFile) dataObject;
				sourceProject = file.Project;
				if (sourceProject != null && file.IsLink) {
					source = sourceProject.BaseDirectory.Combine (file.ProjectVirtualPath);
				} else {
					source = file.FilePath;
				}
				groupedChildren = file.DependentChildren;
				what = null;
			}
			else if (dataObject is Gtk.SelectionData) {
				SelectionData data = (SelectionData) dataObject;
				if (data.Type != "text/uri-list")
					return;
				string sources = System.Text.Encoding.UTF8.GetString (data.Data);
				string[] files = sources.Split (new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
				for (int n=0; n<files.Length; n++) {
					Uri uri = new Uri (files[n]);
					if (uri.Scheme != "file")
						return;
					if (Directory.Exists (uri.LocalPath))
						return;
					files[n] = uri.LocalPath;
				}
				
				IdeApp.ProjectOperations.AddFilesToProject (targetProject, files, targetPath);
				projectsToSave.Add (targetProject);
				return;
			}
			else
				return;

			targetPath = targetPath.Combine (source.FileName);
			// If copying to the same directory, make a copy with a different name
			if (targetPath == source)
				targetPath = ProjectOperations.GetTargetCopyName (targetPath, dataObject is ProjectFolder);
			
			if (dataObject is ProjectFolder) {
				string q;
				if (operation == DragOperation.Move) {
					if (targetPath.ParentDirectory == targetProject.BaseDirectory)
						q = GettextCatalog.GetString ("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
					else
						q = GettextCatalog.GetString ("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetPath.FileName);
					if (!MessageService.Confirm (q, AlertButton.Move))
						return;
				}
				else {
					if (targetPath.ParentDirectory == targetProject.BaseDirectory)
						q = GettextCatalog.GetString ("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
					else
						q = GettextCatalog.GetString ("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetPath.FileName);
					if (!MessageService.Confirm (q, AlertButton.Copy))
						return;
				}
			} else if (dataObject is ProjectFile) {
				if (File.Exists (targetPath))
					if (!MessageService.Confirm (GettextCatalog.GetString ("The file '{0}' already exists. Do you want to overwrite it?", targetPath.FileName), AlertButton.OverwriteFile))
						return;
			}
			
			ArrayList filesToSave = new ArrayList ();
			foreach (Document doc in IdeApp.Workbench.Documents) {
				if (doc.IsDirty && doc.IsFile) {
					if (doc.Name == source || doc.Name.StartsWith (source + Path.DirectorySeparatorChar)) {
						filesToSave.Add (doc);
					} else if (groupedChildren != null) {
						foreach (ProjectFile f in groupedChildren)
							if (doc.Name == f.Name)
								filesToSave.Add (doc);
					}
				}
			}
			
			if (filesToSave.Count > 0) {
				StringBuilder sb = new StringBuilder ();
				foreach (Document doc in filesToSave) {
					if (sb.Length > 0) sb.Append (",\n");
					sb.Append (Path.GetFileName (doc.Name));
				}
				
				string question;
				
				if (operation == DragOperation.Move) {
					if (filesToSave.Count == 1)
						question = GettextCatalog.GetString ("Do you want to save the file '{0}' before the move operation?", sb.ToString ());
					else
						question = GettextCatalog.GetString ("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString ());
				} else {
					if (filesToSave.Count == 1)
						question = GettextCatalog.GetString ("Do you want to save the file '{0}' before the copy operation?", sb.ToString ());
					else
						question = GettextCatalog.GetString ("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString ());
				}
				AlertButton noSave = new AlertButton (GettextCatalog.GetString ("Don't Save"));
				AlertButton res = MessageService.AskQuestion (question, AlertButton.Cancel, noSave, AlertButton.Save);
				if (res == AlertButton.Cancel)
					return;
				else if (res == AlertButton.Save) { 
					try {
						foreach (Document doc in filesToSave) {
							doc.Save ();
						}
					} catch (Exception ex) {
						MessageService.ShowException (ex, GettextCatalog.GetString ("Save operation failed."));
						return;
					}
				}
			}

			if (operation == DragOperation.Move && sourceProject != null)
				projectsToSave.Add (sourceProject);
			if (targetProject != null)
				projectsToSave.Add (targetProject);
			
			using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString("Copying files..."), MonoDevelop.Ide.Gui.Stock.CopyIcon, true))
			{
				bool move = operation == DragOperation.Move;
				IdeApp.ProjectOperations.TransferFiles (monitor, sourceProject, source, targetProject, targetPath, move, false);
			}
		}
Esempio n. 41
0
        private void init(Form formMain, int MinuteForDelaying)
        {
            //init toolTipStyleController
            toolTipStyleController = new ToolTipController();
            toolTipStyleController.Active = true;
            toolTipStyleController.AllowHtmlText = true;
            toolTipStyleController.Rounded = true;
            toolTipStyleController.ShowBeak = true;
            toolTipStyleController.ToolTipType = ToolTipType.SuperTip;

            //controlBroadCast
            controlBroadCast = new AlertControl();
            controlBroadCast.ButtonClick += new AlertButtonClickEventHandler(controlBroadCast_ButtonClick);
            btnDelete = new AlertButton(HelpImage.getImage2020("stop.png"));
            btnDelete.Hint = "Không xem lại thông báo lần sau";
            btnDelete.Name = "btnDelete";
            controlBroadCast.Buttons.Add(btnDelete);
            this.formMain = formMain;
            this.delay = MinuteForDelaying * 60000;
            this.timer = new Timer();
            timer.Interval = 2000;
            timer.Tick += new EventHandler(timer_Tick);
        }
		public override void DeleteMultipleItems ()
		{
			var modifiedSolutionsToSave = new HashSet<Solution> ();
			QuestionMessage msg = new QuestionMessage ();
			msg.SecondaryText = GettextCatalog.GetString ("The Delete option permanently removes the file from your hard disk. Click Remove from Solution if you only want to remove it from your current solution.");
			AlertButton removeFromSolution = new AlertButton (GettextCatalog.GetString ("_Remove from Solution"), Gtk.Stock.Remove);
			msg.Buttons.Add (AlertButton.Delete);
			msg.Buttons.Add (AlertButton.Cancel);
			msg.Buttons.Add (removeFromSolution);
			msg.AllowApplyToAll = true;

			foreach (ITreeNavigator nav in CurrentNodes) {
				SolutionFolderFileNode file = (SolutionFolderFileNode) nav.DataItem;
				if (file.Parent.IsRoot)
					msg.Text = GettextCatalog.GetString ("Are you sure you want to remove the file {0} from the solution folder {1}?", file.FileName.FileName, file.Parent.Name);
				else
					msg.Text = GettextCatalog.GetString ("Are you sure you want to remove the file {0} from the solution {1}?", file.FileName.FileName, file.Parent.ParentSolution.Name);
				AlertButton result = MessageService.AskQuestion (msg);
				if (result == AlertButton.Cancel)
					return;
				
				file.Parent.Files.Remove (file.FileName);
				
				if (result == AlertButton.Delete) {
					FileService.DeleteFile (file.FileName);
				}

				if (file.Parent != null && file.Parent.ParentSolution != null) {
					modifiedSolutionsToSave.Add (file.Parent.ParentSolution);
				}
			}
				
			IdeApp.ProjectOperations.SaveAsync (modifiedSolutionsToSave);
		}
Esempio n. 43
0
		void ButtonClicked (object sender, EventArgs e) 
		{
			Gtk.Button clickButton = (Gtk.Button)sender;
			foreach (AlertButton alertButton in buttons) {
				if (clickButton.Label == alertButton.Label) {
					resultButton = alertButton;
					break;
				}
			}
			this.Destroy ();
		}
		static AlertButton[] GetDeleteConfirmationButtons (bool includeDelete, AlertButton removeFromProject)
		{
			if (includeDelete)
				return new [] { AlertButton.Delete, AlertButton.Cancel, removeFromProject };
			return new [] { AlertButton.Cancel, removeFromProject };
		}
        public override void DeleteMultipleItems()
        {
            var projects = new Set<SolutionEntityItem> ();
            var folders = new List<ProjectFolder> ();
            foreach (ITreeNavigator node in CurrentNodes)
                folders.Add ((ProjectFolder) node.DataItem);

            var removeButton = new AlertButton (GettextCatalog.GetString ("_Remove from Project"), Gtk.Stock.Remove);
            var question = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString (
                "The Delete option permanently removes the directory and any files it contains from your hard disk. " +
                "Click Remove from Project if you only want to remove it from your current solution.")
            };
            question.Buttons.Add (AlertButton.Cancel);
            question.Buttons.Add (AlertButton.Delete);
            question.Buttons.Add (removeButton);

            var deleteOnlyQuestion = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString ("The directory and any files it contains will be permanently removed from your hard disk. ")
            };
            deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
            deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);

            foreach (var folder in folders) {
                var project = folder.Project;

                AlertButton result;

                if (project == null) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result == AlertButton.Delete) {
                        DeleteFolder (folder);
                        continue;
                    } else
                        break;
                }

                var folderRelativePath = folder.Path.ToRelative (project.BaseDirectory);
                var files = project.Files.GetFilesInVirtualPath (folderRelativePath).ToList ();
                var folderPf = project.Files.GetFileWithVirtualPath (folderRelativePath);
                bool isProjectFolder = files.Count == 0 && folderPf == null;

                //if the parent directory has already been removed, there may be nothing to do
                if (isProjectFolder) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result != AlertButton.Delete)
                        break;
                }
                else {
                    question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
                        folder.Name, project.Name);
                    result = MessageService.AskQuestion (question);
                    if (result != removeButton && result != AlertButton.Delete)
                        break;

                    projects.Add (project);

                    //remove the files and link files in the directory
                    foreach (var f in files)
                        project.Files.Remove (f);

                    // also remove the folder's own ProjectFile, if it exists
                    // FIXME: it probably was already in the files list
                    if (folderPf != null)
                        project.Files.Remove (folderPf);
                }

                if (result == AlertButton.Delete) {
                    DeleteFolder (folder);
                } else {
                    //explictly remove the node from the tree, since it currently only tracks real folder deletions
                    folder.Remove ();
                }

                if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) {
                    // If it's the last item in the parent folder, make sure we keep a reference to the parent
                    // folder, so it is not deleted from the tree.
                    var inParentFolder = project.Files.GetFilesInVirtualPath (folderRelativePath.ParentDirectory);
                    if (!inParentFolder.Skip (1).Any ()) {
                        project.Files.Add (new ProjectFile (folder.Path.ParentDirectory) {
                            Subtype = Subtype.Directory,
                        });
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }
Esempio n. 46
0
        void DropNode(HashSet<SolutionEntityItem> projectsToSave, object dataObject, HashSet<ProjectFile> groupedFiles, DragOperation operation)
        {
            FilePath targetDirectory = GetFolderPath (CurrentNode.DataItem);
            FilePath source;
            string what;
            Project targetProject = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
            Project sourceProject;
            IEnumerable<ProjectFile> groupedChildren = null;

            if (dataObject is ProjectFolder) {
                source = ((ProjectFolder) dataObject).Path;
                sourceProject = ((ProjectFolder) dataObject).Project;
                what = Path.GetFileName (source);
            }
            else if (dataObject is ProjectFile) {
                ProjectFile file = (ProjectFile) dataObject;

                // if this ProjectFile is one of the grouped files being pulled in by a parent being copied/moved, ignore it
                if (groupedFiles.Contains (file))
                    return;

                if (file.DependsOnFile != null && operation == DragOperation.Move) {
                    // unlink this file from its parent (since its parent is not being moved)
                    file.DependsOn = null;

                    // if moving a linked file into its containing folder, simply unlink it from its parent
                    if (file.FilePath.ParentDirectory == targetDirectory) {
                        projectsToSave.Add (targetProject);
                        return;
                    }
                }

                sourceProject = file.Project;
                if (sourceProject != null && file.IsLink) {
                    source = sourceProject.BaseDirectory.Combine (file.ProjectVirtualPath);
                } else {
                    source = file.FilePath;
                }
                groupedChildren = file.DependentChildren;
                what = null;
            }
            else if (dataObject is Gtk.SelectionData) {
                SelectionData data = (SelectionData) dataObject;
                if (data.Type != "text/uri-list")
                    return;
                string sources = System.Text.Encoding.UTF8.GetString (data.Data);
                Console.WriteLine ("text/uri-list:\n{0}", sources);
                string[] files = sources.Split (new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int n=0; n<files.Length; n++) {
                    Uri uri = new Uri (files[n]);
                    if (uri.Scheme != "file")
                        return;
                    if (Directory.Exists (uri.LocalPath))
                        return;
                    files[n] = uri.LocalPath;
                }

                IdeApp.ProjectOperations.AddFilesToProject (targetProject, files, targetDirectory);
                projectsToSave.Add (targetProject);
                return;
            }
            else
                return;

            var targetPath = targetDirectory.Combine (source.FileName);
            // If copying to the same directory, make a copy with a different name
            if (targetPath == source)
                targetPath = ProjectOperations.GetTargetCopyName (targetPath, dataObject is ProjectFolder);

            var targetChildPaths = groupedChildren != null ? groupedChildren.Select (child => {
                var targetChildPath = targetDirectory.Combine (child.FilePath.FileName);

                if (targetChildPath == child.FilePath)
                    targetChildPath = ProjectOperations.GetTargetCopyName (targetChildPath, false);

                return targetChildPath;
            }).ToList () : null;

            if (dataObject is ProjectFolder) {
                string q;
                if (operation == DragOperation.Move) {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                        q = GettextCatalog.GetString ("Do you really want to move the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    else
                        q = GettextCatalog.GetString ("Do you really want to move the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    if (!MessageService.Confirm (q, AlertButton.Move))
                        return;
                }
                else {
                    if (targetPath.ParentDirectory == targetProject.BaseDirectory)
                        q = GettextCatalog.GetString ("Do you really want to copy the folder '{0}' to the root folder of project '{1}'?", what, targetProject.Name);
                    else
                        q = GettextCatalog.GetString ("Do you really want to copy the folder '{0}' to the folder '{1}'?", what, targetDirectory.FileName);
                    if (!MessageService.Confirm (q, AlertButton.Copy))
                        return;
                }
            } else if (dataObject is ProjectFile) {
                foreach (var file in new FilePath[] { targetPath }.Concat (targetChildPaths)) {
                    if (File.Exists (file))
                        if (!MessageService.Confirm (GettextCatalog.GetString ("The file '{0}' already exists. Do you want to overwrite it?", file.FileName), AlertButton.OverwriteFile))
                            return;
                }
            }

            var filesToSave = new List<Document> ();
            foreach (Document doc in IdeApp.Workbench.Documents) {
                if (doc.IsDirty && doc.IsFile) {
                    if (doc.Name == source || doc.Name.StartsWith (source + Path.DirectorySeparatorChar)) {
                        filesToSave.Add (doc);
                    } else if (groupedChildren != null) {
                        foreach (ProjectFile f in groupedChildren)
                            if (doc.Name == f.Name)
                                filesToSave.Add (doc);
                    }
                }
            }

            if (filesToSave.Count > 0) {
                StringBuilder sb = new StringBuilder ();
                foreach (Document doc in filesToSave) {
                    if (sb.Length > 0) sb.Append (",\n");
                    sb.Append (Path.GetFileName (doc.Name));
                }

                string question;

                if (operation == DragOperation.Move) {
                    if (filesToSave.Count == 1)
                        question = GettextCatalog.GetString ("Do you want to save the file '{0}' before the move operation?", sb.ToString ());
                    else
                        question = GettextCatalog.GetString ("Do you want to save the following files before the move operation?\n\n{0}", sb.ToString ());
                } else {
                    if (filesToSave.Count == 1)
                        question = GettextCatalog.GetString ("Do you want to save the file '{0}' before the copy operation?", sb.ToString ());
                    else
                        question = GettextCatalog.GetString ("Do you want to save the following files before the copy operation?\n\n{0}", sb.ToString ());
                }
                AlertButton noSave = new AlertButton (GettextCatalog.GetString ("Don't Save"));
                AlertButton res = MessageService.AskQuestion (question, AlertButton.Cancel, noSave, AlertButton.Save);
                if (res == AlertButton.Cancel)
                    return;
                if (res == AlertButton.Save) {
                    try {
                        foreach (Document doc in filesToSave) {
                            doc.Save ();
                        }
                    } catch (Exception ex) {
                        MessageService.ShowException (ex, GettextCatalog.GetString ("Save operation failed."));
                        return;
                    }
                }
            }

            if (operation == DragOperation.Move && sourceProject != null)
                projectsToSave.Add (sourceProject);
            if (targetProject != null)
                projectsToSave.Add (targetProject);

            bool move = operation == DragOperation.Move;
            var opText = move ? GettextCatalog.GetString ("Moving files...") : GettextCatalog.GetString ("Copying files...");

            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (opText, Stock.StatusSolutionOperation, true)) {
                // If we drag and drop a node in the treeview corresponding to a directory, do not move
                // the entire directory. We should only move the files which exist in the project. Otherwise
                // we will need a lot of hacks all over the code to prevent us from incorrectly moving version
                // control related files such as .svn directories

                // Note: if we are transferring a ProjectFile, this will copy/move the ProjectFile's DependentChildren as well.
                IdeApp.ProjectOperations.TransferFiles (monitor, sourceProject, source, targetProject, targetPath, move, true);
            }
        }
		public override void DeleteMultipleItems ()
		{
			bool hasChildren = false;
			List<ProjectFile> files = new List<ProjectFile> ();
			Set<SolutionEntityItem> projects = new Set<SolutionEntityItem> ();
			foreach (ITreeNavigator node in CurrentNodes) {
				ProjectFile pf = (ProjectFile) node.DataItem;
				projects.Add (pf.Project);
				if (pf.HasChildren)
					hasChildren = true;
				files.Add (pf);
			}
			
			AlertButton removeFromProject = new AlertButton (GettextCatalog.GetString ("_Remove from Project"), Gtk.Stock.Remove);
			
			string question, secondaryText;
			
			secondaryText = GettextCatalog.GetString ("The Delete option permanently removes the file from your hard disk. " +
				"Click Remove from Project if you only want to remove it from your current solution.");
			
			if (hasChildren) {
				if (files.Count == 1)
					question = GettextCatalog.GetString ("Are you sure you want to remove the file {0} and " + 
					                                     "its code-behind children from project {1}?",
					                                     Path.GetFileName (files[0].Name), files[0].Project.Name);
				else
					question = GettextCatalog.GetString ("Are you sure you want to remove the selected files and " + 
					                                     "their code-behind children from the project?");
			} else {
				if (files.Count == 1)
					question = GettextCatalog.GetString ("Are you sure you want to remove file {0} from project {1}?",
					                                     Path.GetFileName (files[0].Name), files[0].Project.Name);
				else
					question = GettextCatalog.GetString ("Are you sure you want to remove the selected files from the project?");
			}
			
			AlertButton result = MessageService.AskQuestion (question, secondaryText,
			                                                 AlertButton.Delete, AlertButton.Cancel, removeFromProject);
			if (result != removeFromProject && result != AlertButton.Delete) 
				return;
			   
			foreach (ProjectFile file in files) {
				Project project = file.Project;
				var inFolder = project.Files.GetFilesInVirtualPath (file.ProjectVirtualPath.ParentDirectory).ToList ();
				if (inFolder.Count == 1 && inFolder [0] == file) {
					// This is the last project file in the folder. Make sure we keep
					// a reference to the folder, so it is not deleted from the tree.
					ProjectFile folderFile = new ProjectFile (project.BaseDirectory.Combine (file.ProjectVirtualPath.ParentDirectory));
					folderFile.Subtype = Subtype.Directory;
					project.Files.Add (folderFile);
				}
				
				if (file.HasChildren) {
					foreach (ProjectFile f in file.DependentChildren) {
						project.Files.Remove (f);
						if (result == AlertButton.Delete)
							FileService.DeleteFile (f.Name);
					}
				}
			
				project.Files.Remove (file);
				if (result == AlertButton.Delete && !file.IsLink)
					FileService.DeleteFile (file.Name);
			}

			IdeApp.ProjectOperations.Save (projects);
		}
		void ButtonClicked (object sender, EventArgs e) 
		{
			Gtk.Button clickButton = (Gtk.Button)sender;
			foreach (AlertButton alertButton in buttons) {
				if (clickButton.Label == alertButton.Label) {
					resultButton = alertButton;
					break;
				}
			}
			bool close = message.NotifyClicked (resultButton);
			if (close)
				this.Destroy ();
		}