~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameItemDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
// THE SOFTWARE.
26
26
 
27
27
using System;
28
 
using System.Linq;
29
28
 
30
29
using Gtk;
31
30
 
32
31
using MonoDevelop.Core;
33
32
using MonoDevelop.Projects.Dom;
34
 
using MonoDevelop.Projects.Dom.Parser;
35
33
using MonoDevelop.Projects.CodeGeneration;
36
34
using System.Collections.Generic;
37
 
using MonoDevelop.Ide.Gui;
 
35
using MonoDevelop.Ide;
38
36
 
39
37
namespace MonoDevelop.Refactoring.Rename
40
38
{
48
46
                {
49
47
                        this.options = options;
50
48
                        this.rename = rename;
51
 
 
 
49
                        if (options.SelectedItem is IMethod && ((IMethod)options.SelectedItem).IsConstructor) {
 
50
                                options.SelectedItem = ((IMethod)options.SelectedItem).DeclaringType;
 
51
                        }
52
52
                        this.Build ();
53
53
 
54
54
                        if (options.SelectedItem is IType) {
57
57
                                        // not supported for inner types
58
58
                                        this.renameFileFlag.Visible = true;
59
59
                                        this.renameFileFlag.Active = true;
 
60
                                        // if more than one type is in the file, only rename the file as defilt if the file name contains the type name
 
61
                                        // see Bug 603938 - Renaming a Class in a file with multiple classes renames the file
 
62
                                        if (options.Document.CompilationUnit != null && options.Document.CompilationUnit.Types.Count > 1) 
 
63
                                                this.renameFileFlag.Active = options.Document.FileName.FileNameWithoutExtension.Contains (type.Name);
60
64
                                } else {
61
65
                                        this.renameFileFlag.Active = false;
62
66
                                }
108
112
                        entry.Activated += OnEntryActivated;
109
113
                        
110
114
                        buttonOk.Clicked += OnOKClicked;
111
 
                        buttonCancel.Clicked += OnCancelClicked;
112
115
                        buttonPreview.Clicked += OnPreviewClicked;
113
116
                        entry.Changed += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName (); };
114
117
                        ValidateName ();
121
124
                                return true;
122
125
                        ValidationResult result = nameValidator.ValidateName (this.options.SelectedItem, entry.Text);
123
126
                        if (!result.IsValid) {
124
 
                                imageWarning.IconName = Stock.DialogError;
 
127
                                imageWarning.IconName = Gtk.Stock.DialogError;
125
128
                        } else if (result.HasWarning) {
126
 
                                imageWarning.IconName = Stock.DialogWarning;
 
129
                                imageWarning.IconName = Gtk.Stock.DialogWarning;
127
130
                        } else {
128
 
                                imageWarning.IconName = Stock.Apply;
 
131
                                imageWarning.IconName = Gtk.Stock.Apply;
129
132
                        }
130
133
                        labelWarning.Text = result.Message;
131
134
                        return result.IsValid;
142
145
                        if (buttonOk.Sensitive)
143
146
                                buttonOk.Click ();
144
147
                }
145
 
 
146
 
                void OnCancelClicked (object sender, EventArgs e)
147
 
                {
148
 
                        this.Destroy ();
149
 
                }
150
148
                
151
149
                RenameRefactoring.RenameProperties Properties {
152
150
                        get {
169
167
                {
170
168
                        List<Change> changes = rename.PerformChanges (options, Properties);
171
169
                        ((Widget)this).Destroy ();
172
 
                        RefactoringPreviewDialog refactoringPreviewDialog = new RefactoringPreviewDialog (options.Dom, changes);
173
 
                        refactoringPreviewDialog.Show ();
 
170
                        MessageService.ShowCustomDialog (new RefactoringPreviewDialog (options.Dom, changes));
174
171
                }
175
172
        }
176
173