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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.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 MonoDevelop.Ide.Execution;
42
42
using CustomCommand = MonoDevelop.Projects.CustomCommand;
43
43
using System.Linq;
 
44
using MonoDevelop.Ide.Projects;
 
45
using MonoDevelop.Projects.Policies;
44
46
 
45
47
namespace MonoDevelop.Ide.Commands
46
48
{
61
63
                AddNewFiles,
62
64
                AddFiles,
63
65
                NewFolder,
 
66
                AddFilesFromFolder,
 
67
                AddExistingFolder,
64
68
                IncludeToProject,
65
69
                BuildSolution,
66
70
                Build,
151
155
        {
152
156
                protected override void Update (CommandInfo info)
153
157
                {
154
 
                        info.Enabled = ((IdeApp.Workspace.IsOpen) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
 
158
                        info.Enabled = ((IdeApp.ProjectOperations.CurrentSelectedSolution != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
155
159
                }
156
160
 
157
161
                protected override void Run ()
158
162
                {
159
163
                        //Build solution
160
 
                        IdeApp.ProjectOperations.Build (IdeApp.Workspace);
 
164
                        IdeApp.ProjectOperations.Build (IdeApp.ProjectOperations.CurrentSelectedSolution);
161
165
                }
162
166
        }
163
167
 
169
173
                                IBuildTarget buildTarget = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;
170
174
                                info.Enabled = ((buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
171
175
                                if (buildTarget != null) {
172
 
                                        info.Text = GettextCatalog.GetString ("B_uild {0}", buildTarget.Name);
 
176
                                        info.Text = GettextCatalog.GetString ("B_uild {0}", buildTarget.Name.Replace ("_","__"));
173
177
                                        if (buildTarget is SolutionFolder)
174
178
                                                info.Description = GettextCatalog.GetString ("Build solution {0}", buildTarget.Name);
175
179
                                        else if (buildTarget is Project)
181
185
                        else {
182
186
                                info.Enabled = ((IdeApp.Workbench.ActiveDocument != null) && (IdeApp.Workbench.ActiveDocument.IsBuildTarget) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
183
187
                                if (IdeApp.Workbench.ActiveDocument != null) {
184
 
                                        info.Text = GettextCatalog.GetString ("B_uild {0}", Path.GetFileName (IdeApp.Workbench.ActiveDocument.Name));
 
188
                                        info.Text = GettextCatalog.GetString ("B_uild {0}", Path.GetFileName (IdeApp.Workbench.ActiveDocument.Name).Replace ("_","__"));
185
189
                    info.Description = GettextCatalog.GetString ("Build {0}", Path.GetFileName (IdeApp.Workbench.ActiveDocument.Name));
186
190
                                }
187
191
                        }
203
207
        {
204
208
                protected override void Update (CommandInfo info)
205
209
                {
206
 
                        info.Enabled = ((IdeApp.Workspace.IsOpen) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
 
210
                        info.Enabled = ((IdeApp.ProjectOperations.CurrentSelectedSolution != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
207
211
                }
208
212
 
209
213
                protected override void Run ()
210
214
                {
211
215
                        //Build solution
212
 
                        IdeApp.ProjectOperations.Rebuild (IdeApp.Workspace);
 
216
                        IdeApp.ProjectOperations.Rebuild (IdeApp.ProjectOperations.CurrentSelectedSolution);
213
217
                }
214
218
        }
215
219
 
221
225
                                IBuildTarget buildTarget = IdeApp.ProjectOperations.CurrentSelectedBuildTarget;
222
226
                                info.Enabled = ((buildTarget != null) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
223
227
                                if (buildTarget != null) {
224
 
                                        info.Text = GettextCatalog.GetString ("R_ebuild {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name);
 
228
                                        info.Text = GettextCatalog.GetString ("R_ebuild {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name.Replace ("_","__"));
225
229
                                        info.Description = GettextCatalog.GetString ("Rebuild {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name);
226
230
                                }
227
231
                        }
228
232
                        else {
229
233
                                info.Enabled = ((IdeApp.Workbench.ActiveDocument != null) && (IdeApp.Workbench.ActiveDocument.IsBuildTarget) && (IdeApp.ProjectOperations.CurrentBuildOperation.IsCompleted));
230
234
                                if (info.Enabled) {
231
 
                                        info.Text = GettextCatalog.GetString ("R_ebuild {0}", IdeApp.Workbench.ActiveDocument.FileName);
 
235
                                        info.Text = GettextCatalog.GetString ("R_ebuild {0}", IdeApp.Workbench.ActiveDocument.FileName.FileName.Replace ("_","__"));
232
236
                                        info.Description = GettextCatalog.GetString ("Rebuild {0}", IdeApp.Workbench.ActiveDocument.FileName);
233
237
                                }
234
238
                        }
261
265
                public static bool CanRun (IExecutionHandler executionHandler)
262
266
                {
263
267
            if (IdeApp.Workspace.IsOpen)
264
 
                return (IdeApp.ProjectOperations.CanExecute (IdeApp.Workspace, executionHandler)) && !(IdeApp.ProjectOperations.CurrentSelectedItem is Workspace);
 
268
                return IdeApp.ProjectOperations.CurrentSelectedSolution != null && IdeApp.ProjectOperations.CanExecute (IdeApp.ProjectOperations.CurrentSelectedSolution, executionHandler);
265
269
            else
266
270
                return (IdeApp.Workbench.ActiveDocument != null) && (IdeApp.Workbench.ActiveDocument.CanRun (executionHandler));
267
271
                }
288
292
            }
289
293
            else {
290
294
                if (!IdeApp.Preferences.BuildBeforeExecuting)
291
 
                    IdeApp.ProjectOperations.Execute (IdeApp.Workspace, executionHandler);
 
295
                    IdeApp.ProjectOperations.Execute (IdeApp.ProjectOperations.CurrentSelectedSolution, executionHandler);
292
296
                else {
293
 
                    IAsyncOperation asyncOperation = IdeApp.ProjectOperations.Build (IdeApp.Workspace);
 
297
                                        Solution sol = IdeApp.ProjectOperations.CurrentSelectedSolution;
 
298
                    IAsyncOperation asyncOperation = IdeApp.ProjectOperations.Build (sol);
294
299
                    asyncOperation.Completed += delegate {
295
300
                        if ((asyncOperation.Success) || (IdeApp.Preferences.RunWithWarnings && asyncOperation.SuccessWithWarnings))
296
 
                            IdeApp.ProjectOperations.Execute (IdeApp.Workspace, executionHandler);
 
301
                            IdeApp.ProjectOperations.Execute (sol, executionHandler);
297
302
                    };
298
303
                }
299
304
 
393
398
                        if (IdeApp.ProjectOperations.CurrentSelectedBuildTarget == null)
394
399
                                info.Enabled = false;
395
400
                        else {
396
 
                                info.Text = GettextCatalog.GetString ("C_lean {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name);
 
401
                                info.Text = GettextCatalog.GetString ("C_lean {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name.Replace ("_","__"));
397
402
                                info.Description = GettextCatalog.GetString ("Clean {0}", IdeApp.ProjectOperations.CurrentSelectedBuildTarget.Name);
398
403
                        }
399
404
                }
408
413
        {
409
414
                protected override void Update (CommandInfo info)
410
415
                {
411
 
                        if (!IdeApp.Workspace.IsOpen)
412
 
                                info.Enabled = false;
 
416
                        info.Enabled = IdeApp.ProjectOperations.CurrentSelectedSolution != null;
413
417
                }
414
418
 
415
419
                protected override void Run ()
416
420
                {
417
 
                        IdeApp.ProjectOperations.Clean (IdeApp.Workspace);
 
421
                        IdeApp.ProjectOperations.Clean (IdeApp.ProjectOperations.CurrentSelectedSolution);
418
422
                }
419
423
        }
420
424
 
528
532
                        IdeApp.Workspace.ActiveRuntime = (MonoDevelop.Core.Assemblies.TargetRuntime) dataItem;
529
533
                }
530
534
        }
 
535
        
 
536
        class ApplyPolicyHandler: CommandHandler
 
537
        {
 
538
                protected override void Update (CommandInfo info)
 
539
                {
 
540
                        info.Enabled = IdeApp.ProjectOperations.CurrentSelectedSolutionItem != null || IdeApp.ProjectOperations.CurrentSelectedSolution != null;
 
541
                }
 
542
                
 
543
                protected override void Run ()
 
544
                {
 
545
                        ApplyPolicyDialog dlg = new ApplyPolicyDialog ((IPolicyProvider)IdeApp.ProjectOperations.CurrentSelectedSolutionItem ?? (IPolicyProvider)IdeApp.ProjectOperations.CurrentSelectedSolution);
 
546
                        dlg.Run ();
 
547
                        dlg.Destroy ();
 
548
                }
 
549
        }
 
550
        
 
551
        class ExportPolicyHandler: CommandHandler
 
552
        {
 
553
                protected override void Update (CommandInfo info)
 
554
                {
 
555
                        info.Enabled = IdeApp.ProjectOperations.CurrentSelectedSolutionItem != null || IdeApp.ProjectOperations.CurrentSelectedSolution != null;
 
556
                }
 
557
                
 
558
                protected override void Run ()
 
559
                {
 
560
                        ExportProjectPolicyDialog dlg = new ExportProjectPolicyDialog ((IPolicyProvider)IdeApp.ProjectOperations.CurrentSelectedSolutionItem ?? (IPolicyProvider)IdeApp.ProjectOperations.CurrentSelectedSolution);
 
561
                        dlg.Run ();
 
562
                        dlg.Destroy ();
 
563
                }
 
564
        }
531
565
}