Browse Source

Derived classes etc. popup opens at cursor position again.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6357 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Martin Koníček 16 years ago
parent
commit
47eb1adee8
  1. 32
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs
  2. 6
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs

32
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs

@ -8,8 +8,9 @@ using System;
using System.Windows; using System.Windows;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Refactoring namespace ICSharpCode.SharpDevelop.Refactoring
{ {
@ -18,6 +19,11 @@ namespace ICSharpCode.SharpDevelop.Refactoring
/// </summary> /// </summary>
public class ContextActionsPopup : ContextActionsPopupBase public class ContextActionsPopup : ContextActionsPopupBase
{ {
/// <summary>
/// DOM Entity (IClass, IMember etc.) for which this popup is displayed.
/// </summary>
public IEntity Symbol { get; set; }
public ContextActionsPopup() public ContextActionsPopup()
{ {
// Close on lost focus // Close on lost focus
@ -37,8 +43,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring
public ContextActionsViewModel Actions public ContextActionsViewModel Actions
{ {
get { return (ContextActionsViewModel)ActionsControl.DataContext; } get { return (ContextActionsViewModel)ActionsControl.DataContext; }
set { set {
ActionsControl.DataContext = value; ActionsControl.DataContext = value;
} }
} }
@ -49,10 +55,26 @@ namespace ICSharpCode.SharpDevelop.Refactoring
public void OpenAtCaretAndFocus() public void OpenAtCaretAndFocus()
{ {
OpenAtMousePosition(); ITextEditor currentEditor = GetCurrentEditor();
//OpenAtPosition(editor, editor.Caret.Line, editor.Caret.Column, true); if (currentEditor == null) {
OpenAtMousePosition();
return;
}
// Should look if symbol under caret is the same as this.Symbol, so that when opened from class browser, popup opens at mouse pos
//var rr = ParserService.Resolve(currentEditor.Caret.Offset, currentEditor.Document, currentEditor.FileName);
OpenAtPosition(currentEditor, currentEditor.Caret.Line, currentEditor.Caret.Column, true);
this.Focus(); this.Focus();
} }
ITextEditor GetCurrentEditor()
{
if (WorkbenchSingleton.Workbench == null)
return null;
var activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
if (activeViewContent == null)
return null;
return activeViewContent.TextEditor;
}
void OpenAtMousePosition() void OpenAtMousePosition()
{ {

6
src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse( var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.ClassesDerivingFrom}", new StringTagPair("Name", baseClass.Name)))}; "${res:SharpDevelop.Refactoring.ClassesDerivingFrom}", new StringTagPair("Name", baseClass.Name)))};
popupViewModel.Actions = new PopupTreeViewModelBuilder().BuildTreeViewModel(derivedClassesTree); popupViewModel.Actions = new PopupTreeViewModelBuilder().BuildTreeViewModel(derivedClassesTree);
return new ContextActionsPopup { Actions = popupViewModel }; return new ContextActionsPopup { Actions = popupViewModel, Symbol = baseClass };
} }
public static ContextActionsPopup MakePopupWithBaseClasses(IClass @class) public static ContextActionsPopup MakePopupWithBaseClasses(IClass @class)
@ -37,7 +37,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse( var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.BaseClassesOf}", new StringTagPair("Name", @class.Name)))}; "${res:SharpDevelop.Refactoring.BaseClassesOf}", new StringTagPair("Name", @class.Name)))};
popupViewModel.Actions = new PopupListViewModelBuilder().BuildListViewModel(baseClassList); popupViewModel.Actions = new PopupListViewModelBuilder().BuildListViewModel(baseClassList);
return new ContextActionsPopup { Actions = popupViewModel }; return new ContextActionsPopup { Actions = popupViewModel, Symbol = @class };
} }
public static ContextActionsPopup MakePopupWithOverrides(IMember member) public static ContextActionsPopup MakePopupWithOverrides(IMember member)
@ -46,7 +46,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse( var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.OverridesOf}", new string[,] {{ "Name", member.FullyQualifiedName }}))}; "${res:SharpDevelop.Refactoring.OverridesOf}", new string[,] {{ "Name", member.FullyQualifiedName }}))};
popupViewModel.Actions = new OverridesPopupTreeViewModelBuilder(member).BuildTreeViewModel(derivedClassesTree); popupViewModel.Actions = new OverridesPopupTreeViewModelBuilder(member).BuildTreeViewModel(derivedClassesTree);
return new ContextActionsPopup { Actions = popupViewModel }; return new ContextActionsPopup { Actions = popupViewModel, Symbol = member };
} }
class PopupViewModelBuilder class PopupViewModelBuilder

Loading…
Cancel
Save