~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/EncapsulateFieldDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
using Mono.TextEditor;
42
42
using System.Linq;
43
43
using System.Collections.Generic;
 
44
using Mono.TextEditor.PopupWindow;
44
45
 
45
46
namespace MonoDevelop.Refactoring {
46
47
 
49
50
                IType declaringType;
50
51
                ListStore store;
51
52
                ListStore visibilityStore;
52
 
                TextEditor editor;
 
53
                MonoDevelop.Ide.Gui.Document editor;
53
54
                
54
55
                private const int colCheckedIndex = 0;
55
56
                private const int colFieldNameIndex = 1;
58
59
                private const int colReadOnlyIndex = 4;
59
60
                private const int colFieldIndex = 5;
60
61
 
61
 
                public EncapsulateFieldDialog (TextEditor editor, ProjectDom ctx, IType declaringType)
 
62
                public EncapsulateFieldDialog (MonoDevelop.Ide.Gui.Document editor, ProjectDom ctx, IType declaringType)
62
63
                        : this (editor, declaringType, null)
63
64
                {}
64
65
 
65
 
                public EncapsulateFieldDialog (TextEditor editor, ProjectDom ctx, IField field)
 
66
                public EncapsulateFieldDialog (MonoDevelop.Ide.Gui.Document editor, ProjectDom ctx, IField field)
66
67
                        : this (editor, field.DeclaringType, field)
67
68
                {}
68
69
 
69
 
                private EncapsulateFieldDialog (TextEditor editor, IType declaringType, IField field)
 
70
                private EncapsulateFieldDialog (MonoDevelop.Ide.Gui.Document editor, IType declaringType, IField field)
70
71
                {
71
72
                        this.editor = editor;
72
73
                        this.declaringType = declaringType;
407
408
                                data.Add (new FieldData (field, propertyName, read_only, mod));
408
409
                        } while (store.IterNext (ref iter));
409
410
                        
410
 
                        InsertionCursorEditMode mode = new InsertionCursorEditMode (editor, HelperMethods.GetInsertionPoints (editor.Document, declaringType));
 
411
                        InsertionCursorEditMode mode = new InsertionCursorEditMode (editor.Editor.Parent, CodeGenerationService.GetInsertionPoints (editor, declaringType));
 
412
                        ModeHelpWindow helpWindow = new ModeHelpWindow ();
 
413
                        helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
 
414
                        helpWindow.TitleText = GettextCatalog.GetString ("<b>Encapsulate Field -- Targeting</b>");
 
415
                        helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
 
416
                        helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
 
417
                        helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
 
418
                        helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Declare new property</b> at target point.")));
 
419
                        helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this refactoring.")));
 
420
                        mode.HelpWindow = helpWindow;
411
421
                        mode.CurIndex = mode.InsertionPoints.Count - 1;
412
422
                        int idx = -1, i = 0;
413
423
                        DomLocation lastLocation = DomLocation.Empty;
422
432
                        mode.StartMode ();
423
433
                        mode.Exited += delegate(object s, InsertionCursorEventArgs args) {
424
434
                                if (args.Success) {
425
 
                                        CodeGenerator generator = CodeGenerator.CreateGenerator (editor.Document.MimeType);
 
435
                                        CodeGenerator generator =  CodeGenerator.CreateGenerator (editor.Editor.Document.MimeType, editor.Editor.Options.TabsToSpaces, editor.Editor.Options.TabSize, editor.Editor.EolMarker);
426
436
                                        StringBuilder code = new StringBuilder ();
427
437
                                        for (int j = 0; j < data.Count; j++) {
428
438
                                                if (j > 0) {
432
442
                                                var f = data[j];
433
443
                                                code.Append (generator.CreateFieldEncapsulation (declaringType, f.Field, f.PropertyName, f.Modifiers, f.ReadOnly));
434
444
                                        }
435
 
                                        args.InsertionPoint.Insert (editor, code.ToString ());
 
445
                                        args.InsertionPoint.Insert (editor.Editor, code.ToString ());
436
446
                                }
437
447
                        };
438
448
                        ((Widget) this).Destroy ();