48
50
if (type == null || type.ClassType != MonoDevelop.Projects.Dom.ClassType.Interface)
50
52
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
51
IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
53
IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
52
54
return declaringType != null && options.ResolveResult.ResolvedExpression.IsInInheritableTypeContext;
57
59
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
58
60
IType interfaceType = options.Dom.GetType (options.ResolveResult.ResolvedType);
59
IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
61
IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
61
63
var editor = options.GetTextEditorData ().Parent;
63
InsertionCursorEditMode mode = new InsertionCursorEditMode (editor, HelperMethods.GetInsertionPoints (editor.Document, declaringType));
65
InsertionCursorEditMode mode = new InsertionCursorEditMode (editor, CodeGenerationService.GetInsertionPoints (options.Document, declaringType));
66
ModeHelpWindow helpWindow = new ModeHelpWindow ();
67
helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
68
helpWindow.TitleText = GettextCatalog.GetString ("<b>Implement Interface -- Targeting</b>");
69
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
70
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
71
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
72
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Declare interface implementation</b> at target point.")));
73
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this refactoring.")));
74
mode.HelpWindow = helpWindow;
64
75
mode.CurIndex = mode.InsertionPoints.Count - 1;
66
77
mode.Exited += delegate(object s, InsertionCursorEventArgs args) {
67
78
if (args.Success) {
68
CodeGenerator generator = CodeGenerator.CreateGenerator (options.GetTextEditorData ().Document.MimeType);
69
args.InsertionPoint.Insert (editor, generator.CreateInterfaceImplementation (declaringType, interfaceType, true));
79
CodeGenerator generator = options.Document.CreateCodeGenerator ();
80
args.InsertionPoint.Insert (options.GetTextEditorData (), generator.CreateInterfaceImplementation (declaringType, interfaceType, true));