Skip to content

Commit 2693ec0

Browse files
author
SlavaRa
committed
Implement RefactorMenu.MoveMenuItem
1 parent 4e41d26 commit 2693ec0

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

External/Plugins/CodeRefactor/PluginMain.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ private void CreateMenuItems()
239239
{
240240
this.refactorMainMenu = new RefactorMenu(true);
241241
this.refactorMainMenu.RenameMenuItem.Click += this.RenameClicked;
242+
refactorMainMenu.MoveMenuItem.Click += MoveClicked;
242243
this.refactorMainMenu.OrganizeMenuItem.Click += this.OrganizeImportsClicked;
243244
this.refactorMainMenu.TruncateMenuItem.Click += this.TruncateImportsClicked;
244245
this.refactorMainMenu.ExtractMethodMenuItem.Click += this.ExtractMethodClicked;
@@ -248,6 +249,7 @@ private void CreateMenuItems()
248249
this.refactorMainMenu.BatchMenuItem.Click += this.BatchMenuItemClicked;
249250
this.refactorContextMenu = new RefactorMenu(false);
250251
this.refactorContextMenu.RenameMenuItem.Click += this.RenameClicked;
252+
refactorContextMenu.MoveMenuItem.Click += MoveClicked;
251253
this.refactorContextMenu.OrganizeMenuItem.Click += this.OrganizeImportsClicked;
252254
this.refactorContextMenu.TruncateMenuItem.Click += this.TruncateImportsClicked;
253255
this.refactorContextMenu.DelegateMenuItem.Click += this.DelegateMethodsClicked;
@@ -277,6 +279,7 @@ private void CreateMenuItems()
277279
private void RegisterMenuItems()
278280
{
279281
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.Rename", this.refactorMainMenu.RenameMenuItem);
282+
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.Move", refactorMainMenu.MoveMenuItem);
280283
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.ExtractMethod", this.refactorMainMenu.ExtractMethodMenuItem);
281284
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.ExtractLocalVariable", this.refactorMainMenu.ExtractLocalVariableMenuItem);
282285
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.GenerateDelegateMethods", this.refactorMainMenu.DelegateMenuItem);
@@ -285,6 +288,7 @@ private void RegisterMenuItems()
285288
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.CodeGenerator", this.refactorMainMenu.CodeGeneratorMenuItem);
286289
PluginBase.MainForm.RegisterShortcutItem("RefactorMenu.BatchProcess", this.refactorMainMenu.BatchMenuItem);
287290
PluginBase.MainForm.RegisterSecondaryItem("RefactorMenu.Rename", this.refactorContextMenu.RenameMenuItem);
291+
PluginBase.MainForm.RegisterSecondaryItem("RefactorMenu.Move", refactorContextMenu.MoveMenuItem);
288292
PluginBase.MainForm.RegisterSecondaryItem("RefactorMenu.ExtractMethod", this.refactorContextMenu.ExtractMethodMenuItem);
289293
PluginBase.MainForm.RegisterSecondaryItem("RefactorMenu.ExtractLocalVariable", this.refactorContextMenu.ExtractLocalVariableMenuItem);
290294
PluginBase.MainForm.RegisterSecondaryItem("RefactorMenu.GenerateDelegateMethods", this.refactorContextMenu.DelegateMenuItem);
@@ -353,25 +357,33 @@ private void UpdateMenuItems()
353357
this.refactorMainMenu.OrganizeMenuItem.Enabled = organize;
354358
this.refactorMainMenu.TruncateMenuItem.Enabled = truncate;
355359
}
360+
refactorMainMenu.MoveMenuItem.Enabled = false;
361+
refactorContextMenu.MoveMenuItem.Enabled = false;
356362
this.surroundContextMenu.Enabled = false;
357363
this.refactorMainMenu.SurroundMenu.Enabled = false;
358364
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = false;
359365
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = false;
360366
this.refactorMainMenu.ExtractMethodMenuItem.Enabled = false;
361367
this.refactorMainMenu.ExtractLocalVariableMenuItem.Enabled = false;
362368
ITabbedDocument document = PluginBase.MainForm.CurrentDocument;
363-
if (document != null && document.IsEditable && langIsValid && document.SciControl.SelTextSize > 1)
369+
if (document != null && document.IsEditable && langIsValid)
364370
{
365-
Int32 selEnd = document.SciControl.SelectionEnd;
366-
Int32 selStart = document.SciControl.SelectionStart;
367-
if (!document.SciControl.PositionIsOnComment(selEnd) || !document.SciControl.PositionIsOnComment(selStart))
371+
bool isValidFile = IsValidFile(document.FileName);
372+
refactorMainMenu.MoveMenuItem.Enabled = isValidFile;
373+
refactorContextMenu.MoveMenuItem.Enabled = isValidFile;
374+
if (document.SciControl.SelTextSize > 1)
368375
{
369-
this.surroundContextMenu.Enabled = true;
370-
this.refactorMainMenu.SurroundMenu.Enabled = true;
371-
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = true;
372-
this.refactorMainMenu.ExtractMethodMenuItem.Enabled = true;
373-
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = true;
374-
this.refactorMainMenu.ExtractLocalVariableMenuItem.Enabled = true;
376+
Int32 selEnd = document.SciControl.SelectionEnd;
377+
Int32 selStart = document.SciControl.SelectionStart;
378+
if (!document.SciControl.PositionIsOnComment(selEnd) || !document.SciControl.PositionIsOnComment(selStart))
379+
{
380+
this.surroundContextMenu.Enabled = true;
381+
this.refactorMainMenu.SurroundMenu.Enabled = true;
382+
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = true;
383+
this.refactorMainMenu.ExtractMethodMenuItem.Enabled = true;
384+
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = true;
385+
this.refactorMainMenu.ExtractLocalVariableMenuItem.Enabled = true;
386+
}
375387
}
376388
}
377389
this.refactorContextMenu.CodeGeneratorMenuItem.Enabled = isValid;
@@ -428,6 +440,14 @@ private void RenameClicked(Object sender, EventArgs e)
428440
}
429441
}
430442

443+
/// <summary>
444+
/// Invoked when the user selects the "Move" command
445+
/// </summary>
446+
static void MoveClicked(object sender, EventArgs e)
447+
{
448+
449+
}
450+
431451
/// <summary>
432452
///
433453
/// </summary>

0 commit comments

Comments
 (0)