Skip to content

Commit b766737

Browse files
committed
Merge pull request #1018 from SlavaRa/feature/CodeRefactor_MoveDialog
Dialog for Move refactoring command
2 parents 3c0a883 + 2cebef4 commit b766737

File tree

7 files changed

+487
-116
lines changed

7 files changed

+487
-116
lines changed

External/Plugins/CodeRefactor/CodeRefactor.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
<Compile Include="Controls\DividedCheckedListBox.cs">
9999
<SubType>Component</SubType>
100100
</Compile>
101+
<Compile Include="Controls\MoveDialog.cs">
102+
<SubType>Form</SubType>
103+
</Compile>
104+
<Compile Include="Controls\MoveDialog.Designer.cs">
105+
<DependentUpon>MoveDialog.cs</DependentUpon>
106+
</Compile>
101107
<Compile Include="Controls\ProgressDialog.cs">
102108
<SubType>Form</SubType>
103109
</Compile>

External/Plugins/CodeRefactor/Commands/Move.cs

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ namespace CodeRefactor.Commands
3636
{
3737
class Move : RefactorCommand<IDictionary<string, List<SearchMatch>>>
3838
{
39-
4039
public Dictionary<string, string> OldPathToNewPath;
4140
public bool OutputResults;
42-
private bool renaming;
41+
private readonly bool renaming;
42+
private readonly bool updatePackages;
4343
private List<MoveTargetHelper> targets;
4444
private List<string> filesToReopen;
4545
private int currentTargetIndex;
4646
private ASResult currentTargetResult;
47-
4847
private bool targetsOutsideClasspath;
4948

5049
#region Constructors
@@ -56,15 +55,32 @@ public Move(Dictionary<string, string>oldPathToNewPath) : this(oldPathToNewPath,
5655
{
5756
}
5857

58+
/// <summary>
59+
/// A new Move refactoring command.
60+
/// </summary>
61+
/// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
5962
public Move(Dictionary<string, string> oldPathToNewPath, bool outputResults) : this(oldPathToNewPath, outputResults, false)
6063
{
6164
}
6265

63-
public Move(Dictionary<string, string> oldPathToNewPath, bool outputResults, bool renaming)
66+
/// <summary>
67+
/// A new Move refactoring command.
68+
/// </summary>
69+
/// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
70+
public Move(Dictionary<string, string> oldPathToNewPath, bool outputResults, bool renaming) : this(oldPathToNewPath, outputResults, renaming, false)
71+
{
72+
}
73+
74+
/// <summary>
75+
/// A new Move refactoring command.
76+
/// </summary>
77+
/// <param name="outputResults">If true, will send the found results to the trace log and results panel</param>
78+
public Move(Dictionary<string, string> oldPathToNewPath, bool outputResults, bool renaming, bool updatePackages)
6479
{
6580
OldPathToNewPath = oldPathToNewPath;
6681
OutputResults = outputResults;
6782
this.renaming = renaming;
83+
this.updatePackages = updatePackages;
6884
Results = new Dictionary<string, List<SearchMatch>>();
6985
}
7086

@@ -82,35 +98,43 @@ protected override void ExecutionImplementation()
8298
RegisterDocumentHelper(AssociatedDocumentHelper);
8399

84100
CreateListOfMoveTargets();
85-
101+
DialogResult dialogResult;
86102
if (targetsOutsideClasspath)
87103
{
88-
msg = TextHelper.GetString("Info.MovingOutsideClasspath");
89-
title = TextHelper.GetString("FlashDevelop.Title.WarningDialog");
90-
if (MessageBox.Show(msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
104+
if (updatePackages) dialogResult = DialogResult.Yes;
105+
else
106+
{
107+
msg = TextHelper.GetString("Info.MovingOutsideClasspath");
108+
title = TextHelper.GetString("FlashDevelop.Title.WarningDialog");
109+
dialogResult = MessageBox.Show(msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
110+
}
111+
if (dialogResult == DialogResult.Yes)
91112
{
92113
MoveTargets();
93114
ReopenInitialFiles();
94115
}
95116
FireOnRefactorComplete();
96117
return;
97118
}
98-
99-
if (renaming)
119+
if (updatePackages) dialogResult = DialogResult.Yes;
120+
else
100121
{
101-
msg = TextHelper.GetString("Info.RenamingDirectory");
102-
foreach (string path in OldPathToNewPath.Keys)
122+
if (renaming)
103123
{
104-
title = string.Format(TextHelper.GetString("Title.RenameDialog"), Path.GetFileName(path));
105-
break;
124+
msg = TextHelper.GetString("Info.RenamingDirectory");
125+
foreach (string path in OldPathToNewPath.Keys)
126+
{
127+
title = string.Format(TextHelper.GetString("Title.RenameDialog"), Path.GetFileName(path));
128+
break;
129+
}
106130
}
131+
else
132+
{
133+
msg = TextHelper.GetString("Info.MovingFile");
134+
title = TextHelper.GetString("Title.MoveDialog");
135+
}
136+
dialogResult = MessageBox.Show(msg, title, MessageBoxButtons.YesNoCancel);
107137
}
108-
else
109-
{
110-
msg = TextHelper.GetString("Info.MovingFile");
111-
title = TextHelper.GetString("Title.MoveDialog");
112-
}
113-
var dialogResult = MessageBox.Show(msg, title, MessageBoxButtons.YesNoCancel);
114138
if (dialogResult == DialogResult.Cancel)
115139
{
116140
FireOnRefactorComplete();
@@ -150,11 +174,11 @@ private void CreateListOfMoveTargets()
150174
{
151175
string oldPath = item.Key;
152176
string newPath = item.Value;
153-
ITabbedDocument doc;
154177
if (File.Exists(oldPath))
155178
{
156179
newPath = Path.Combine(newPath, Path.GetFileName(oldPath));
157180

181+
ITabbedDocument doc;
158182
if (AssociatedDocumentHelper.InitiallyOpenedFiles.TryGetValue(oldPath, out doc))
159183
{
160184
doc.Save();

External/Plugins/CodeRefactor/Controls/MoveDialog.Designer.cs

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

0 commit comments

Comments
 (0)