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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.NavigateToDialog/NavigateToCommand.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:
1
 
// 
2
 
// NavigateToCommand.cs
3
 
//  
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@novell.com>
6
 
// 
7
 
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
8
 
// 
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
using System;
27
 
using System.Collections.Generic;
28
 
using Gtk;
29
 
using MonoDevelop.Components.Commands;
30
 
using MonoDevelop.Core;
31
 
 
32
 
namespace MonoDevelop.Ide.NavigateToDialog
33
 
{
34
 
        public enum Commands {
35
 
                NavigateTo
36
 
        }
37
 
        
38
 
        class GotoTypeHandler : CommandHandler
39
 
        {
40
 
                protected override void Run ()
41
 
                {
42
 
                        var dialog = new NavigateToDialog (NavigateToType.Types, false) {
43
 
                                Title = GettextCatalog.GetString ("Go to Type"),
44
 
                        };
45
 
                        IEnumerable<NavigateToDialog.OpenLocation> locations = null;
46
 
                        try {
47
 
                                if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
48
 
                                        dialog.Sensitive = false;
49
 
                                        locations = dialog.Locations;
50
 
                                }
51
 
                        } finally {
52
 
                                dialog.Destroy ();
53
 
                        }
54
 
                        if (locations != null) {
55
 
                                foreach (var loc in locations)
56
 
                                        IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
57
 
                        }
58
 
                }
59
 
                
60
 
                protected override void Update (CommandInfo info)
61
 
                {
62
 
                        info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;
63
 
                }
64
 
        }
65
 
        
66
 
        class GotoFileHandler : CommandHandler
67
 
        {
68
 
                protected override void Run ()
69
 
                {
70
 
                        var dialog = new NavigateToDialog (NavigateToType.Files, false) {
71
 
                                Title = GettextCatalog.GetString ("Go to File"),
72
 
                        };
73
 
                        IEnumerable<NavigateToDialog.OpenLocation> locations = null;
74
 
                        try {
75
 
                                if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
76
 
                                        dialog.Sensitive = false;
77
 
                                        locations = dialog.Locations;
78
 
                                }
79
 
                        } finally {
80
 
                                dialog.Destroy ();
81
 
                        }
82
 
                        if (locations != null) {
83
 
                                foreach (var loc in locations)
84
 
                                        IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
85
 
                        }
86
 
                }
87
 
                
88
 
                protected override void Update (CommandInfo info)
89
 
                {
90
 
                        info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;
91
 
                }
92
 
        }       
93
 
        
94
 
        class NavigateToHandler : CommandHandler
95
 
        {
96
 
                protected override void Run ()
97
 
                {
98
 
                        var dialog = new NavigateToDialog (NavigateToType.All, true);
99
 
                        IEnumerable<NavigateToDialog.OpenLocation> locations = null;
100
 
                        try {
101
 
                                if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
102
 
                                        dialog.Sensitive = false;
103
 
                                        locations = dialog.Locations;
104
 
                                }
105
 
                        } finally {
106
 
                                dialog.Destroy ();
107
 
                        }
108
 
                        if (locations != null) {
109
 
                                foreach (var loc in locations)
110
 
                                        IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
111
 
                        }
112
 
                }
113
 
                
114
 
                protected override void Update (CommandInfo info)
115
 
                {
116
 
                        info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;
117
 
                }
118
 
        }
119
 
}
120