Browse Source

Fixed SD2-416: Multi-instance Search and Replace dialog

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@386 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
97f2383785
  1. 5
      src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs
  2. 16
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs
  3. 35
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Commands/SearchMainMenuCommands.cs
  4. 22
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplaceDialog.cs
  5. 1
      src/Tools/UpdateAssemblyInfo/Main.cs

5
src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs

@ -30,10 +30,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{ {
public override void Run() public override void Run()
{ {
if (!GotoDialog.IsVisible) { GotoDialog.ShowSingleInstance();
GotoDialog gnd = new GotoDialog();
gnd.Show(WorkbenchSingleton.MainForm);
}
} }
} }

16
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs

@ -27,7 +27,17 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
public class GotoDialog : BaseSharpDevelopForm public class GotoDialog : BaseSharpDevelopForm
{ {
public static bool IsVisible = false; static GotoDialog Instance = null;
public static void ShowSingleInstance()
{
if (Instance == null) {
Instance = new GotoDialog();
Instance.Show(WorkbenchSingleton.MainForm);
} else {
Instance.Focus();
}
}
ListView listView; ListView listView;
TextBox textBox; TextBox textBox;
@ -122,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
IsVisible = false; Instance = null;
base.OnClosed(e); base.OnClosed(e);
} }
@ -320,7 +330,6 @@ namespace ICSharpCode.SharpDevelop.Gui
void CancelButtonClick(object sender, EventArgs e) void CancelButtonClick(object sender, EventArgs e)
{ {
IsVisible = false;
Close(); Close();
} }
@ -368,7 +377,6 @@ namespace ICSharpCode.SharpDevelop.Gui
throw new NotImplementedException("Unknown tag: " + tag); throw new NotImplementedException("Unknown tag: " + tag);
} }
} finally { } finally {
IsVisible = false;
Close(); Close();
} }
} }

35
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Commands/SearchMainMenuCommands.cs

@ -35,7 +35,7 @@ namespace SearchAndReplace
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null && (window.ViewContent is ITextEditorControlProvider)) { if (window != null && (window.ViewContent is ITextEditorControlProvider)) {
TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl; TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
string selectedText = textarea.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText; string selectedText = textarea.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText;
if (selectedText != null && selectedText.Length > 0) { if (selectedText != null && selectedText.Length > 0) {
SearchOptions.CurrentFindPattern = selectedText; SearchOptions.CurrentFindPattern = selectedText;
@ -46,17 +46,7 @@ namespace SearchAndReplace
public override void Run() public override void Run()
{ {
SetSearchPattern(); SetSearchPattern();
SearchAndReplaceDialog.ShowSingleInstance(SearchAndReplaceMode.Search);
SearchAndReplaceDialog searchAndReplaceDialog = new SearchAndReplaceDialog(SearchAndReplaceMode.Search);
searchAndReplaceDialog.Show();
// if (SearchReplaceManager.ReplaceDialog != null) {
// SearchReplaceManager.ReplaceDialog.SetSearchPattern(SearchReplaceManager.SearchOptions.SearchPattern);
// } else {
// ReplaceDialog rd = new ReplaceDialog(false);
// rd.Owner = (Form)WorkbenchSingleton.Workbench;
// rd.Show();
// }
} }
} }
@ -64,31 +54,16 @@ namespace SearchAndReplace
{ {
public override void Run() public override void Run()
{ {
try { SearchReplaceManager.FindNext();
SearchReplaceManager.FindNext();
} catch (Exception e) {
MessageService.ShowError(e);
}
} }
} }
public class Replace : AbstractMenuCommand public class Replace : AbstractMenuCommand
{ {
public override void Run() public override void Run()
{ {
Find.SetSearchPattern(); Find.SetSearchPattern();
SearchAndReplaceDialog searchAndReplaceDialog = new SearchAndReplaceDialog(SearchAndReplaceMode.Replace); SearchAndReplaceDialog.ShowSingleInstance(SearchAndReplaceMode.Replace);
searchAndReplaceDialog.Show();
//
//
// if (SearchReplaceManager.ReplaceDialog != null) {
// SearchReplaceManager.ReplaceDialog.SetSearchPattern(SearchReplaceManager.SearchOptions.SearchPattern);
// } else {
// ReplaceDialog rd = new ReplaceDialog(true);
// rd.Owner = (Form)WorkbenchSingleton.Workbench;
// rd.Show();
// }
} }
} }
} }

22
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplaceDialog.cs

@ -24,6 +24,23 @@ namespace SearchAndReplace
public static string SearchPattern = ""; public static string SearchPattern = "";
public static string ReplacePattern = ""; public static string ReplacePattern = "";
static SearchAndReplaceDialog Instance;
public static void ShowSingleInstance(SearchAndReplaceMode searchAndReplaceMode)
{
if (Instance == null) {
Instance = new SearchAndReplaceDialog(searchAndReplaceMode);
Instance.Show(WorkbenchSingleton.MainForm);
} else {
if (searchAndReplaceMode == SearchAndReplaceMode.Search) {
Instance.searchButton.PerformClick();
} else {
Instance.replaceButton.PerformClick();
}
Instance.Focus();
}
}
ToolStripButton searchButton = new ToolStripButton(); ToolStripButton searchButton = new ToolStripButton();
ToolStripButton replaceButton = new ToolStripButton(); ToolStripButton replaceButton = new ToolStripButton();
@ -62,7 +79,7 @@ namespace SearchAndReplace
Controls.Add(toolStrip); Controls.Add(toolStrip);
SetSearchAndReplaceMode(); SetSearchAndReplaceMode();
this.StartPosition = FormStartPosition.Manual; this.StartPosition = FormStartPosition.Manual;
this.Location = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.SearchAndReplaceDialog.Location", GetDefaultLocation()); this.Location = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.SearchAndReplaceDialog.Location", GetDefaultLocation());
} }
@ -71,13 +88,14 @@ namespace SearchAndReplace
Rectangle parent = WorkbenchSingleton.MainForm.Bounds; Rectangle parent = WorkbenchSingleton.MainForm.Bounds;
Size size = this.Size; Size size = this.Size;
return new Point(parent.Left + (parent.Width - size.Width) / 2, return new Point(parent.Left + (parent.Width - size.Width) / 2,
parent.Top + (parent.Height - size.Height) / 2); parent.Top + (parent.Height - size.Height) / 2);
} }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{ {
base.OnClosing(e); base.OnClosing(e);
PropertyService.Set("ICSharpCode.SharpDevelop.Gui.SearchAndReplaceDialog.Location", this.Location); PropertyService.Set("ICSharpCode.SharpDevelop.Gui.SearchAndReplaceDialog.Location", this.Location);
Instance = null;
} }
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)

1
src/Tools/UpdateAssemblyInfo/Main.cs

@ -114,6 +114,7 @@ namespace UpdateAssemblyInfo
string[] dontTouchList = new string[] { string[] dontTouchList = new string[] {
"Main/StartUp/Project/", // Startup is special case "Main/StartUp/Project/", // Startup is special case
"Libraries/log4net/", "Libraries/log4net/",
"Libraries/NUnit.Framework/",
"Libraries/DockPanel_Src/", "Libraries/DockPanel_Src/",
"AddIns/Misc/Debugger/TreeListView/Project/", "AddIns/Misc/Debugger/TreeListView/Project/",
}; };

Loading…
Cancel
Save