Example #1
0
        public override void Run()
        {
            var wb      = Workbench.Instance;
            var exp     = wb.ActiveSiteExplorer;
            var omgr    = ServiceRegistry.GetService <OpenResourceManager>();
            var connMgr = ServiceRegistry.GetService <ServerConnectionManager>();
            var conn    = connMgr.GetConnection(exp.ConnectionName);

            if (exp.SelectedItems.Length > 0)
            {
                int             replaced = 0;
                var             diag     = new FindReplaceDialog();
                Action <string> DoRun    = (string resourceId) =>
                {
                    //To maintain resource integrity, we don't modify any open resources. So we
                    //ask if they want to close down first. If they say no, omit this resource from
                    //the find/replace
                    if (omgr.IsOpen(resourceId, conn))
                    {
                        omgr.CloseEditors(conn, resourceId, false);
                        //Still open. Must've said no
                        if (omgr.IsOpen(resourceId, conn))
                        {
                            LoggingService.Info(string.Format(Strings.SkippingResource, resourceId));
                            return;
                        }
                    }

                    //Re-open in XML editor for user review
                    var ed = (XmlEditor)omgr.Open(resourceId, conn, true, wb.ActiveSiteExplorer);

                    //Do the find/replace. Dirty state would be triggered if any replacements were made
                    //It is then up to the user to review the change and decide whether to save or not
                    ed.FindAndReplace(diag.FindToken, diag.ReplaceToken);

                    replaced++;
                };
                if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (var item in exp.SelectedItems)
                    {
                        if (item.IsFolder)
                        {
                            var resources = conn.ResourceService.GetRepositoryResources(item.ResourceId);
                            foreach (IRepositoryItem resource in resources.Items)
                            {
                                if (resource.ResourceType != "Folder")
                                {
                                    DoRun(resource.ResourceId);
                                }
                            }
                        }
                        else
                        {
                            DoRun(item.ResourceId);
                        }
                    }
                }
            }
        }
Example #2
0
        private void findAndReplaceRegExToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tb = tabControl1.SelectedTab;

            if (tb as EditorTabPage == null)
            {
                return;
            }
            EditorTabPage etb = tb as EditorTabPage;

            findReplaceDialog.SetFocusOnSearchTextField();
            findReplaceDialog.Text += " RegEx";
            if (findReplaceDialog.ShowDialog() == DialogResult.OK)
            {
                etb.FindAndReplaceRegEx(findReplaceDialog.Search, findReplaceDialog.Replacement, findReplaceDialog.Options);
            }
        }
Example #3
0
        private static void ExecuteFindReplace(BoneViewModel target)
        {
            var  dialog = new FindReplaceDialog("Find and Replace in Hierarchy...");
            bool result = dialog.ShowDialog() ?? false;

            if (result)
            {
                FindReplaceRecursive(target, dialog.Find, dialog.Replace);
            }
        }
        private void findAndReplaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditorTabPage etb = GetActiveTab();

            if (etb != null)
            {
                if (findReplaceDialog.ShowDialog() == DialogResult.OK)
                {
                    etb.FindAndReplace(findReplaceDialog.Search, findReplaceDialog.Replacement, findReplaceDialog.Options);
                }
            }
        }
        private void browserDesign_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            modifiedDocument = true;

            if (e.KeyData == (Keys.Control | Keys.F))
            {
                modeTabs.SelectedTab = tabEditor;
                FindReplaceDialog dlgFind = new FindReplaceDialog();
                dlgFind.Scintilla = editor;
                dlgFind.ShowDialog();
                dlgFind.Activate();
                dlgFind.Focus();
                return;
            }
        }
Example #6
0
 private static void ExecuteFindReplace(BoneViewModel target)
 {
     var dialog = new FindReplaceDialog("Find and Replace in Hierarchy...");
     bool result = dialog.ShowDialog() ?? false;
     if (result)
     {
         FindReplaceRecursive(target, dialog.Find, dialog.Replace);
     }
 }