2
// NavigateToCommand.cs
5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
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:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
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
27
using System.Collections.Generic;
29
using MonoDevelop.Components.Commands;
30
using MonoDevelop.Core;
32
namespace MonoDevelop.Ide.NavigateToDialog
34
public enum Commands {
38
class GotoTypeHandler : CommandHandler
40
protected override void Run ()
42
var dialog = new NavigateToDialog (NavigateToType.Types, false) {
43
Title = GettextCatalog.GetString ("Go to Type"),
45
IEnumerable<NavigateToDialog.OpenLocation> locations = null;
47
if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
48
dialog.Sensitive = false;
49
locations = dialog.Locations;
54
if (locations != null) {
55
foreach (var loc in locations)
56
IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
60
protected override void Update (CommandInfo info)
62
info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;
66
class GotoFileHandler : CommandHandler
68
protected override void Run ()
70
var dialog = new NavigateToDialog (NavigateToType.Files, false) {
71
Title = GettextCatalog.GetString ("Go to File"),
73
IEnumerable<NavigateToDialog.OpenLocation> locations = null;
75
if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
76
dialog.Sensitive = false;
77
locations = dialog.Locations;
82
if (locations != null) {
83
foreach (var loc in locations)
84
IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
88
protected override void Update (CommandInfo info)
90
info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;
94
class NavigateToHandler : CommandHandler
96
protected override void Run ()
98
var dialog = new NavigateToDialog (NavigateToType.All, true);
99
IEnumerable<NavigateToDialog.OpenLocation> locations = null;
101
if (MessageService.RunCustomDialog (dialog, MessageService.RootWindow) == (int)ResponseType.Ok) {
102
dialog.Sensitive = false;
103
locations = dialog.Locations;
108
if (locations != null) {
109
foreach (var loc in locations)
110
IdeApp.Workbench.OpenDocument (loc.Filename, loc.Line, loc.Column);
114
protected override void Update (CommandInfo info)
116
info.Enabled = IdeApp.Workspace.IsOpen || IdeApp.Workbench.Documents.Count != 0;