Skip to content

Commit 2f36a33

Browse files
committed
Merge pull request #685 from Hosch250/next
Fix Rename bug, clean up IDialog interface and dialogs
2 parents 75a6959 + c28d2c7 commit 2f36a33

14 files changed

+228
-345
lines changed

RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System.Windows.Forms;
22
using Rubberduck.Parsing.Symbols;
33

44
namespace Rubberduck.Refactorings.Rename
@@ -11,19 +11,22 @@ public class RenamePresenter
1111
public RenamePresenter(IRenameView view, RenameModel model)
1212
{
1313
_view = view;
14-
_view.OkButtonClicked += OnViewOkButtonClicked;
1514

1615
_model = model;
1716
}
1817

1918
public RenameModel Show()
2019
{
21-
if (_model.Target != null)
20+
if (_model.Target == null) { return null; }
21+
22+
_view.Target = _model.Target;
23+
24+
if (_view.ShowDialog() != DialogResult.OK)
2225
{
23-
_view.Target = _model.Target;
24-
_view.ShowDialog();
26+
return null;
2527
}
2628

29+
_model.NewName = _view.NewName;
2730
return _model;
2831
}
2932

@@ -32,13 +35,14 @@ public RenameModel Show(Declaration target)
3235
_model.PromptIfTargetImplementsInterface(ref target);
3336
_model.Target = target;
3437
_view.Target = target;
35-
_view.ShowDialog();
36-
return _model;
37-
}
3838

39-
private void OnViewOkButtonClicked(object sender, EventArgs e)
40-
{
39+
if (_view.ShowDialog() != DialogResult.OK)
40+
{
41+
return null;
42+
}
43+
4144
_model.NewName = _view.NewName;
45+
return _model;
4246
}
4347
}
4448
}

RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Refactor()
2828
var presenter = _factory.Create();
2929
_model = presenter.Show();
3030

31-
if (_model.Declarations != null)
31+
if (_model != null && _model.Declarations != null)
3232
{
3333
Rename();
3434
}
@@ -44,7 +44,11 @@ public void Refactor(Declaration target)
4444
{
4545
var presenter = _factory.Create();
4646
_model = presenter.Show(target);
47-
Rename();
47+
48+
if (_model != null && _model.Declarations != null)
49+
{
50+
Rename();
51+
}
4852
}
4953

5054
private Declaration AmbiguousId()

RetailCoder.VBE/UI/IDialogView.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace Rubberduck.UI
55
{
66
public interface IDialogView : IDisposable
77
{
8-
event EventHandler CancelButtonClicked;
9-
void OnCancelButtonClicked();
10-
11-
event EventHandler OkButtonClicked;
12-
void OnOkButtonClicked();
13-
148
DialogResult ShowDialog();
159
}
1610
}

RetailCoder.VBE/UI/Refactorings/ExtractMethodDialog.Designer.cs

Lines changed: 74 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/Refactorings/ExtractMethodDialog.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private void Localize()
3131
{
3232
Text = RubberduckUI.ExtractMethod_Caption;
3333
OkButton.Text = RubberduckUI.OK;
34-
CancelButton.Text = RubberduckUI.CancelButtonText;
34+
CancelDialogButton.Text = RubberduckUI.CancelButtonText;
3535

3636
TitleLabel.Text = RubberduckUI.ExtractMethod_TitleText;
3737
InstructionsLabel.Text = RubberduckUI.ExtractMethod_InstructionsText;
@@ -75,9 +75,6 @@ private void InitializeParameterGrid()
7575

7676
private void RegisterViewEvents()
7777
{
78-
OkButton.Click += OkButtonOnClick;
79-
CancelButton.Click += CancelButton_Click;
80-
8178
SetReturnValueCheck.CheckedChanged += SetReturnValueCheck_CheckedChanged;
8279
MethodNameBox.TextChanged += MethodNameBox_TextChanged;
8380
MethodAccessibilityCombo.SelectedIndexChanged += MethodAccessibilityCombo_SelectedIndexChanged;
@@ -155,30 +152,6 @@ private void OnViewEvent(EventHandler target, EventArgs args = null)
155152
handler(this, args ?? EventArgs.Empty);
156153
}
157154

158-
public event EventHandler CancelButtonClicked;
159-
160-
public void OnCancelButtonClicked()
161-
{
162-
OnViewEvent(CancelButtonClicked);
163-
}
164-
165-
private void CancelButton_Click(object sender, EventArgs e)
166-
{
167-
OnCancelButtonClicked();
168-
}
169-
170-
public event EventHandler OkButtonClicked;
171-
172-
public void OnOkButtonClicked()
173-
{
174-
OnViewEvent(OkButtonClicked);
175-
}
176-
177-
private void OkButtonOnClick(object sender, EventArgs e)
178-
{
179-
OnOkButtonClicked();
180-
}
181-
182155
private string _preview;
183156
public string Preview
184157
{

RetailCoder.VBE/UI/Refactorings/ExtractMethodDialog.resx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,4 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
121-
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
122-
<value>
123-
AAABAAEAEA4AAAEAIADgAwAAFgAAACgAAAAQAAAAHAAAAAEAIAAAAAAAuAMAAAAAAAAAAAAAAAAAAAAA
124-
AAAAAAAAAAAAAAAAAB4AAABxAAEBtQEYGOMCLCz3AzEx/AIhIewABwfFAAAAiQAAADYAAAABAAAAAAAA
125-
AAAAAAAAAAAAAQAAAJIDODj5CJqa/wzh4f8O/f3/Dv///w7///8O////De/v/wq0tP8ES0v/AAAAewAA
126-
AAAAAAAAAAAAAAAAAEcFWlr/Dv///w7///8O////Dv///w7///8O////Dv///w7///8O////Dvv7/wMw
127-
MPkAAAAgAAAAAAAAAAAAAQGpC8zM/w7///8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/
128-
//8JoKD/AAAAfAAAAAAAAAAAARMT4g78/P8O////Dv///w7///8O////Dv///w7///8O////Dv///w7/
129-
//8O////DNzc/wAAALAAAAAAAAAAAAImJvcO////Dv///w7///8O////Dv///w7///8O////Dv///w7/
130-
//8O////Dv///w3o6P8AAAC8AAAAAAAAAAACHh7vDv///w7///8O////Dv///w7///8O////Dv///w7/
131-
//8O////Dv///w7///8LxMT/AAAAngAAAAAAAAAAAAQExg3o6P8O////Dv///wmnp/8GZ2f/B3l5/wZ1
132-
df8Kr6//Dv///w7///8O////Bmxs/wAAAFIAAAAAAAAAAAAAAGwHgoL/Dv///wq+vv8BDAzTAAAAOQAA
133-
AE8BDQ3yDNLS/w7///8O////Dv///wZlZf8AABS4AAAPgQAAAA0AAAAIAQwM1AVjY/8ABwfEAAAAGAAA
134-
AAAAAABNBnJy/w7///8O////Dv///w7///8N5ub/AAM+/wAA4P8AAC62AAAAAAAAACAAAABLAAAAAgAA
135-
AAAAAAAAAAAAaAiUlP8O////Dv///wvKyv8Lvr7/Dvv7/wEQMf8AAP//AACF/wAAAAAAAAAAAAAAAAAA
136-
AAAAAAAAAAAAAAAAADkFV1f/Dv///w7///8HdHT/Blxc/wvMzP8AAAXWAAAoogAAF58AAAAAAAAAAAAA
137-
AAAAAAAAAAAAAAAAAAAAAAAAAAEBrwiQkP8O+/v/Dv///wzY2P8CLCz1AAAAMQAAAAAAAAAAAAAAAAAA
138-
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAACHARkZ4wIpKfQABga8AAAANgAAAAAAAAAAAAAAAMAH
139-
AAAABwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAQAAACMAAAA/AAAAP4DAAD+BwAA
140-
</value>
141-
</data>
142120
</root>

RetailCoder.VBE/UI/Refactorings/RemoveParametersDialog.Designer.cs

Lines changed: 44 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/Refactorings/RemoveParametersDialog.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public RemoveParametersDialog()
2424
private void InitializeCaptions()
2525
{
2626
OkButton.Text = RubberduckUI.OK;
27-
CancelButton.Text = RubberduckUI.CancelButtonText;
27+
CancelDialogButton.Text = RubberduckUI.CancelButtonText;
2828
Text = RubberduckUI.RemoveParamsDialog_Caption;
2929
TitleLabel.Text = RubberduckUI.RemoveParamsDialog_TitleText;
3030
InstructionsLabel.Text = RubberduckUI.RemoveParamsDialog_InstructionsLabelText;
@@ -60,27 +60,6 @@ public void InitializeParameterGrid()
6060
MethodParametersGrid.Columns.Add(column);
6161
}
6262

63-
private void OkButtonClick(object sender, EventArgs e)
64-
{
65-
OnOkButtonClicked();
66-
}
67-
68-
public event EventHandler CancelButtonClicked;
69-
public void OnCancelButtonClicked()
70-
{
71-
Hide();
72-
}
73-
74-
public event EventHandler OkButtonClicked;
75-
public void OnOkButtonClicked()
76-
{
77-
var handler = OkButtonClicked;
78-
if (handler != null)
79-
{
80-
handler(this, EventArgs.Empty);
81-
}
82-
}
83-
8463
private void MarkAsRemovedParam()
8564
{
8665
if (_selectedItem != null)

0 commit comments

Comments
 (0)