~ubuntu-branches/ubuntu/raring/monodevelop/raring

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2011-06-29 06:56:25 UTC
  • mfrom: (1.8.1 upstream) (1.3.11 experimental)
  • Revision ID: james.westby@ubuntu.com-20110629065625-7xx19c4vb95j65pl
Tags: 2.5.92+dfsg-1ubuntu1
* Merge from Debian experimental:
 - Dropped patches & changes to debian/control for Moonlight
   + debian/patches/remove_support_for_moonlight.patch,
   + debian/patches/dont_add_moonlight_to_core_addins.patch,
 - Remaining patches:
   + debian/patches/no_appmenu:

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
using MonoDevelop.Core;
30
30
using Mono.TextEditor;
31
31
using MonoDevelop.Ide;
 
32
using Mono.TextEditor.PopupWindow;
 
33
using System.Collections.Generic;
32
34
 
33
35
namespace MonoDevelop.Refactoring.ImplementInterface
34
36
{
48
50
                        if (type == null || type.ClassType != MonoDevelop.Projects.Dom.ClassType.Interface)
49
51
                                return false;
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;
53
55
                }
54
56
                
56
58
                {
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);
60
62
                        
61
63
                        var editor = options.GetTextEditorData ().Parent;
62
64
                        
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;
65
76
                        mode.StartMode ();
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));
70
81
                                }
71
82
                        };
72
83
                }