~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
using System.Collections.Generic;
11
11
using MonoDevelop.Core.Assemblies;
12
12
using System.Threading.Tasks;
 
13
using System.ServiceModel;
13
14
 
14
15
namespace MonoDevelop.WebReferences.Commands
15
16
{
45
46
                        dialog.NamespacePrefix = project.DefaultNamespace;
46
47
                        
47
48
                        try {
48
 
                                if (MessageService.RunCustomDialog (dialog) == (int)Gtk.ResponseType.Ok) {
49
 
                                        dialog.SelectedService.GenerateFiles (project, dialog.Namespace, dialog.ReferenceName);
50
 
                                        IdeApp.ProjectOperations.Save(project);
51
 
                                }
52
 
                        }
53
 
                        catch(Exception exception) {
 
49
                                if (MessageService.RunCustomDialog (dialog) != (int)Gtk.ResponseType.Ok)
 
50
                                        return;
 
51
 
 
52
                                dialog.SelectedService.GenerateFiles (project, dialog.Namespace, dialog.ReferenceName);
 
53
                                IdeApp.ProjectOperations.Save(project);
 
54
                        } catch (Exception exception) {
54
55
                                MessageService.ShowException (exception);
55
56
                        } finally {
56
57
                                dialog.Destroy ();
57
58
                        }
58
59
                }
59
 
                
 
60
 
60
61
                [CommandUpdateHandler (MonoDevelop.WebReferences.WebReferenceCommands.Update)]
61
62
                [CommandUpdateHandler (MonoDevelop.WebReferences.WebReferenceCommands.UpdateAll)]
62
63
                void CanUpdateWebReferences (CommandInfo ci)
89
90
                                DispatchService.ThreadDispatch (() => {
90
91
                                        for (int i = 0; i < items.Count; i ++) {
91
92
                                                DispatchService.GuiDispatch (() => UpdateReferenceContext.SetProgressFraction (Math.Max (0.1, (double)i / items.Count)));
92
 
                                                items [i].Update();
 
93
                                                try {
 
94
                                                        items [i].Update();
 
95
                                                } catch (Exception ex) {
 
96
                                                        DispatchService.GuiSyncDispatch (() => {
 
97
                                                                MessageService.ShowException (ex, GettextCatalog.GetString ("Failed to update Web Reference '{0}'", items [i].Name));
 
98
                                                                DisposeUpdateContext ();
 
99
                                                        });
 
100
                                                        return;
 
101
                                                }
93
102
                                        }
94
103
                                        
95
104
                                        DispatchService.GuiDispatch (() => {
139
148
                        IdeApp.ProjectOperations.Save(project);
140
149
                        IdeApp.Workbench.StatusBar.ShowMessage("Deleted all Web References");
141
150
                }
 
151
 
 
152
                [CommandUpdateHandler (MonoDevelop.WebReferences.WebReferenceCommands.Configure)]
 
153
                void CanConfigureWebReferences (CommandInfo ci)
 
154
                {
 
155
                        var item = CurrentNode.DataItem as WebReferenceItem;
 
156
                        ci.Enabled = item != null && WCFConfigWidget.IsSupported (item);
 
157
                }
 
158
 
 
159
                /// <summary>Execute the command for configuring a web reference in a project.</summary>
 
160
                [CommandHandler (MonoDevelop.WebReferences.WebReferenceCommands.Configure)]
 
161
                public void Configure ()
 
162
                {
 
163
                        var item = (WebReferenceItem) CurrentNode.DataItem;
 
164
 
 
165
                        if (!WCFConfigWidget.IsSupported (item))
 
166
                                return;
 
167
 
 
168
                        WCF.ReferenceGroup refgroup;
 
169
                        WCF.ClientOptions options;
 
170
 
 
171
                        try {
 
172
                                refgroup = WCF.ReferenceGroup.Read (item.MapFile.FilePath);
 
173
                                if (refgroup == null || refgroup.ClientOptions == null)
 
174
                                        return;
 
175
                                options = refgroup.ClientOptions;
 
176
                        } catch {
 
177
                                return;
 
178
                        }
 
179
 
 
180
                        var dialog = new WebReferenceDialog (item, options);
 
181
 
 
182
                        try {
 
183
                                if (MessageService.RunCustomDialog (dialog) != (int)Gtk.ResponseType.Ok)
 
184
                                        return;
 
185
                                if (!dialog.Modified)
 
186
                                        return;
 
187
                                
 
188
                                refgroup.Save (item.MapFile.FilePath);
 
189
                                UpdateReferences (new [] { item });
 
190
                        } catch (Exception exception) {
 
191
                                MessageService.ShowException (exception);
 
192
                        } finally {
 
193
                                dialog.Destroy ();
 
194
                        }
 
195
                }
142
196
        }       
143
197
}