2
// MonoDevelop XML Editor
4
// Copyright (C) 2006-2007 Matthew Ward
6
// Permission is hereby granted, free of charge, to any person obtaining
7
// a copy of this software and associated documentation files (the
8
// "Software"), to deal in the Software without restriction, including
9
// without limitation the rights to use, copy, modify, merge, publish,
10
// distribute, sublicense, and/or sell copies of the Software, and to
11
// permit persons to whom the Software is furnished to do so, subject to
12
// the following conditions:
14
// The above copyright notice and this permission notice shall be
15
// included in all copies or substantial portions of the Software.
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
using MonoDevelop.Core;
27
using MonoDevelop.Ide.Gui;
30
namespace MonoDevelop.XmlEditor
32
public class XPathQueryPad : IPadContent, IXmlEditorViewContentProvider
34
XPathQueryWidget xpathQueryWidget;
37
public XPathQueryPad()
39
xpathQueryWidget = new XPathQueryWidget(this);
40
xpathQueryWidget.ShowAll();
42
IdeApp.Workbench.ActiveDocumentChanged += ActiveDocumentChanged;
46
public void JumpTo(string fileName, int line, int column)
48
IdeApp.Workbench.OpenDocument(fileName, Math.Max(1, line), Math.Max(1, column), true);
51
void IPadContent.Initialize(IPadWindow window)
53
window.Title = "XPath Query";
54
window.Icon = "MonoDevelop.XmlEditor.XPathQueryPad";
59
return "MonoDevelop.XmlEditor.XPathQueryPad";
63
public string DefaultPlacement {
69
public void RedrawContent()
73
public Widget Control {
75
return xpathQueryWidget;
83
IdeApp.Workbench.ActiveDocumentChanged -= ActiveDocumentChanged;
88
void ActiveDocumentChanged(object source, EventArgs e)
90
xpathQueryWidget.UpdateQueryButtonState();
94
/// Reads the xpath query pad properties and updates
95
/// XPath Query widget.
99
xpathQueryWidget.Query = XPathQueryPadOptions.LastXPathQuery;
101
foreach (string xpath in XPathQueryPadOptions.XPathHistory.GetXPaths()) {
102
xpathQueryWidget.AddXPath(xpath);
105
foreach (XmlNamespace ns in XPathQueryPadOptions.Namespaces.GetNamespaces()) {
106
xpathQueryWidget.AddNamespace(ns.Prefix, ns.Uri);
111
/// Updates the xpath query pad properties from the
112
/// XPath Query widget.
113
void SaveProperties()
115
XPathQueryPadOptions.LastXPathQuery = xpathQueryWidget.Query;
117
XPathHistoryList history = new XPathHistoryList();
118
foreach (string xpath in xpathQueryWidget.GetXPathHistory()) {
121
XPathQueryPadOptions.XPathHistory = history;
123
XPathNamespaceList namespaces = new XPathNamespaceList();
124
foreach (XmlNamespace ns in xpathQueryWidget.GetNamespaces()) {
125
namespaces.Add(ns.Prefix, ns.Uri);
127
XPathQueryPadOptions.Namespaces = namespaces;