~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor/XmlEditorService.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
using MonoDevelop.Components.Commands;
25
25
using MonoDevelop.Core;
26
 
using MonoDevelop.Core.Gui;
27
26
using MonoDevelop.Ide;
28
27
using MonoDevelop.Ide.Gui;
29
28
using MonoDevelop.Ide.Gui.Content;
39
38
using System.Xml;
40
39
using System.Xml.Schema;
41
40
using System.Xml.XPath;
42
 
using System.Xml.Xsl;
 
41
using System.Xml.Xsl;
 
42
using MonoDevelop.Components;
 
43
using Gtk;
 
44
using MonoDevelop.Components.Extensions;
43
45
 
44
46
namespace MonoDevelop.XmlEditor
45
47
{
415
417
                
416
418
                #region File browsing utilities
417
419
                
 
420
                /// <summary>Allows the user to browse the file system for a stylesheet.</summary>
 
421
                /// <returns>The stylesheet filename the user selected; otherwise null.</returns>
418
422
                public static string BrowseForStylesheetFile ()
419
423
                {
420
 
                        MonoDevelop.Components.FileSelector fs =
421
 
                            new MonoDevelop.Components.FileSelector (GettextCatalog.GetString ("Select XSLT Stylesheet"));
422
 
                        try {
423
 
                                Gtk.FileFilter xmlFiles = new Gtk.FileFilter ();
424
 
                                xmlFiles.Name = "XML Files";
425
 
                                xmlFiles.AddMimeType("text/xml");
426
 
                                fs.AddFilter(xmlFiles);
427
 
                                
428
 
                                Gtk.FileFilter xslFiles = new Gtk.FileFilter ();
429
 
                                xslFiles.Name = "XSL Files";
430
 
                                xslFiles.AddMimeType("text/x-xslt");
431
 
                                xslFiles.AddPattern("*.xslt;*.xsl");
432
 
                                fs.AddFilter(xslFiles);
433
 
                                
434
 
                                return browseCommon (fs);
435
 
                        }
436
 
                        finally {
437
 
                                fs.Destroy ();
438
 
                        }
 
424
                        var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XSLT Stylesheet")) {
 
425
                                TransientFor = IdeApp.Workbench.RootWindow,
 
426
                        };
 
427
                        dlg.AddFilter (new SelectFileDialogFilter (GettextCatalog.GetString ("XML Files", "*.xml")) {
 
428
                                MimeTypes = { "text/xml", "application/xml" },
 
429
                        });
 
430
                        dlg.AddFilter (new SelectFileDialogFilter (GettextCatalog.GetString ("XSL Files"), "*.xslt", "*.xsl") {
 
431
                                MimeTypes = { "text/x-xslt" },
 
432
                        });
 
433
                        dlg.AddAllFilesFilter ();
 
434
                        
 
435
                        if (dlg.Run ())
 
436
                                return dlg.SelectedFile;
 
437
                        return null;
439
438
                }
440
439
                
441
 
                //Allows the user to browse the file system for a schema. Returns the schema file 
442
 
                //name the user selected; otherwise an empty string.
 
440
                /// <summary>Allows the user to browse the file system for a schema.</summary>
 
441
                /// <returns>The schema filename the user selected; otherwise null.</returns>
443
442
                public static string BrowseForSchemaFile ()
444
 
                {
445
 
                        MonoDevelop.Components.FileSelector fs =
446
 
                            new MonoDevelop.Components.FileSelector (GettextCatalog.GetString ("Select XML Schema"));
447
 
                        try {
448
 
                                Gtk.FileFilter xmlFiles = new Gtk.FileFilter ();
449
 
                                xmlFiles.Name = "XML Files";
450
 
                                xmlFiles.AddMimeType("text/xml");
451
 
                                xmlFiles.AddMimeType("application/xml");
452
 
                                xmlFiles.AddPattern ("*.xsd");
453
 
                                fs.AddFilter (xmlFiles);
454
 
                                
455
 
                                return browseCommon (fs);
456
 
                        } finally {
457
 
                                fs.Destroy ();
458
 
                        }
459
 
                }
460
 
                
461
 
                static string browseCommon (MonoDevelop.Components.FileSelector fs)
462
443
                {
463
 
                        fs.SelectMultiple = false;
464
 
                        
465
 
                        Gtk.FileFilter allFiles = new Gtk.FileFilter ();
466
 
                        allFiles.Name = "All Files";
467
 
                        allFiles.AddPattern ("*");
468
 
                        fs.AddFilter(allFiles);
469
 
                        
470
 
                        fs.Modal = true;
471
 
                        fs.TransientFor = MessageService.RootWindow;
472
 
                        fs.DestroyWithParent = true;
473
 
                        int response = fs.Run ();
474
 
                        
475
 
                        if (response == (int)Gtk.ResponseType.Ok) {
476
 
                                return fs.Filename;
477
 
                        } else {
478
 
                                return null;
479
 
                        }
 
444
                        var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema")) {
 
445
                                TransientFor = IdeApp.Workbench.RootWindow,
 
446
                        };
 
447
                        dlg.AddFilter (new SelectFileDialogFilter (GettextCatalog.GetString ("XML Files"), "*.xsd") {
 
448
                                MimeTypes = { "text/xml", "application/xml" },
 
449
                        });
 
450
                        dlg.AddAllFilesFilter ();
 
451
                        
 
452
                        if (dlg.Run ())
 
453
                                return dlg.SelectedFile;
 
454
                        return null;
480
455
                }
481
456
                
482
457
                #endregion