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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.XPath/XPathQueryPad.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
// MonoDevelop XML Editor
 
3
//
 
4
// Copyright (C) 2006-2007 Matthew Ward
 
5
//
 
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:
 
13
// 
 
14
// The above copyright notice and this permission notice shall be
 
15
// included in all copies or substantial portions of the Software.
 
16
// 
 
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.
 
24
/*
 
25
using Gtk;
 
26
using MonoDevelop.Core;
 
27
using MonoDevelop.Ide.Gui;
 
28
using System;
 
29
 
 
30
namespace MonoDevelop.XmlEditor
 
31
{
 
32
        public class XPathQueryPad : IPadContent, IXmlEditorViewContentProvider
 
33
        {               
 
34
                XPathQueryWidget xpathQueryWidget;
 
35
                bool disposed;
 
36
                
 
37
                public XPathQueryPad()
 
38
                {
 
39
                        xpathQueryWidget = new XPathQueryWidget(this);
 
40
                        xpathQueryWidget.ShowAll();
 
41
                        
 
42
                        IdeApp.Workbench.ActiveDocumentChanged += ActiveDocumentChanged;
 
43
                        LoadProperties();
 
44
                }
 
45
                
 
46
                public void JumpTo(string fileName, int line, int column)
 
47
                {
 
48
                        IdeApp.Workbench.OpenDocument(fileName, Math.Max(1, line), Math.Max(1, column), true);
 
49
                }
 
50
                
 
51
                void IPadContent.Initialize(IPadWindow window)
 
52
                {
 
53
                        window.Title = "XPath Query";
 
54
                        window.Icon = "MonoDevelop.XmlEditor.XPathQueryPad";
 
55
                }
 
56
                
 
57
                public string Id {
 
58
                        get { 
 
59
                                return "MonoDevelop.XmlEditor.XPathQueryPad";
 
60
                        }
 
61
                }
 
62
                
 
63
                public string DefaultPlacement {
 
64
                        get { 
 
65
                                return "Bottom";
 
66
                        }
 
67
                }
 
68
                        
 
69
                public void RedrawContent()
 
70
                {
 
71
                }
 
72
                
 
73
                public Widget Control {
 
74
                        get {
 
75
                                return xpathQueryWidget;
 
76
                        }
 
77
                }
 
78
                
 
79
                public void Dispose()
 
80
                {
 
81
                        if (!disposed) {
 
82
                                disposed = true;
 
83
                                IdeApp.Workbench.ActiveDocumentChanged -= ActiveDocumentChanged;
 
84
                                SaveProperties();
 
85
                        }
 
86
                }
 
87
                                
 
88
                void ActiveDocumentChanged(object source, EventArgs e)
 
89
                {
 
90
                        xpathQueryWidget.UpdateQueryButtonState();
 
91
                }
 
92
                
 
93
                /// <summary>
 
94
                /// Reads the xpath query pad properties and updates
 
95
                /// XPath Query widget.
 
96
                /// </summary>
 
97
                void LoadProperties()
 
98
                {
 
99
                        xpathQueryWidget.Query = XPathQueryPadOptions.LastXPathQuery;
 
100
                
 
101
                        foreach (string xpath in XPathQueryPadOptions.XPathHistory.GetXPaths()) {
 
102
                                xpathQueryWidget.AddXPath(xpath);
 
103
                        }
 
104
                        
 
105
                        foreach (XmlNamespace ns in XPathQueryPadOptions.Namespaces.GetNamespaces()) {
 
106
                                xpathQueryWidget.AddNamespace(ns.Prefix, ns.Uri);
 
107
                        }
 
108
                }
 
109
                
 
110
                /// <summary>
 
111
                /// Updates the xpath query pad properties from the
 
112
                /// XPath Query widget.
 
113
                void SaveProperties()
 
114
                {
 
115
                        XPathQueryPadOptions.LastXPathQuery = xpathQueryWidget.Query;
 
116
                        
 
117
                        XPathHistoryList history = new XPathHistoryList();
 
118
                        foreach (string xpath in xpathQueryWidget.GetXPathHistory()) {
 
119
                                history.Add(xpath);
 
120
                        }
 
121
                        XPathQueryPadOptions.XPathHistory = history;
 
122
                        
 
123
                        XPathNamespaceList namespaces = new XPathNamespaceList();
 
124
                        foreach (XmlNamespace ns in xpathQueryWidget.GetNamespaces()) {
 
125
                                namespaces.Add(ns.Prefix, ns.Uri);
 
126
                        }
 
127
                        XPathQueryPadOptions.Namespaces = namespaces;
 
128
                }
 
129
        }
 
130
}
 
131
*/