~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorDisplayBinding.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
using MonoDevelop.Core;
29
29
using MonoDevelop.Ide.Gui;
30
30
using MonoDevelop.Ide;
 
31
using MonoDevelop.Ide.Codons;
 
32
using MonoDevelop.Projects;
31
33
 
32
34
namespace MonoDevelop.SourceEditor
33
35
{
34
 
        public class SourceEditorDisplayBinding : DisplayBinding
 
36
        public class SourceEditorDisplayBinding : IViewDisplayBinding
35
37
        {
36
38
                public static FilePath SyntaxModePath {
37
39
                        get {
38
 
                                return PropertyService.ConfigPath.Combine ("syntaxmodes");
 
40
                                return PropertyService.DataPath.Combine ("HighlightingSchemes");
39
41
                        }
40
42
                }
41
43
                
63
65
                }
64
66
                
65
67
                
66
 
                public override string Name {
 
68
                public string Name {
67
69
                        get {
68
70
                                return GettextCatalog.GetString ("Source Code Editor");
69
71
                        }
70
72
                }
71
73
                
72
 
                public override MonoDevelop.Ide.Gui.IViewContent CreateContentForUri (string fileName)
 
74
                public bool CanHandle (FilePath fileName, string mimeType, Project ownerProject)
 
75
                {
 
76
                        if (string.IsNullOrEmpty (mimeType))
 
77
                                return false;
 
78
                        return DesktopService.GetMimeTypeIsText (mimeType);
 
79
                }
 
80
                
 
81
                public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject)
73
82
                {
74
83
                        return new SourceEditorView ();
75
84
                }
76
85
 
77
 
                public override bool CanCreateContentForMimeType (string mimetype)
78
 
                {
79
 
                        if (String.IsNullOrEmpty (mimetype))
80
 
                                return false;
81
 
                        return DesktopService.GetMimeTypeIsText (mimetype);
82
 
                }
83
 
 
84
 
                public override MonoDevelop.Ide.Gui.IViewContent CreateContentForMimeType (string mimeType, System.IO.Stream content)
85
 
                {
86
 
                        SourceEditorView result = new SourceEditorView ();
87
 
                        result.Document.MimeType = mimeType;
88
 
                        if (content != null) {
89
 
                                using (StreamReader reader = new StreamReader (content)) {
90
 
                                        result.Document.Text = reader.ReadToEnd ();
91
 
                                }
92
 
                        }
93
 
                        return result;
94
 
                }
95
 
 
96
 
                public override bool CanCreateContentForUri (string fileName)
 
86
                public bool CanHandleFile (string fileName)
97
87
                {
98
88
                        string mt = DesktopService.GetMimeTypeForUri (fileName);
99
89
                        return DesktopService.GetMimeTypeIsText (mt);
100
90
                }
 
91
                
 
92
                public bool CanUseAsDefault {
 
93
                        get { return true; }
 
94
                }
101
95
        }
102
96
}