[Monodevelop-patches-list] r1117 - in branches/MonoDevelop-playground: . src/Plugins src/Plugins/Content src/Plugins/Editor src/Plugins/Node
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Fri Mar 5 14:11:03 EST 2004
Author: jzwart
Date: 2004-03-05 14:11:03 -0500 (Fri, 05 Mar 2004)
New Revision: 1117
Added:
branches/MonoDevelop-playground/src/Plugins/Editor/
branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewer.cs
branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewerFactory.cs
branches/MonoDevelop-playground/src/Plugins/Editor/EditorPlugin.cs
branches/MonoDevelop-playground/src/Plugins/Editor/Makefile.am
branches/MonoDevelop-playground/src/Plugins/Editor/editor.plugin.in
branches/MonoDevelop-playground/src/Plugins/Editor/editor.ui
branches/MonoDevelop-playground/src/Plugins/Node/TextFileNode.cs
Modified:
branches/MonoDevelop-playground/configure.in
branches/MonoDevelop-playground/src/Plugins/Content/ContentManager.cs
branches/MonoDevelop-playground/src/Plugins/Makefile.am
branches/MonoDevelop-playground/src/Plugins/Node/FileNode.cs
branches/MonoDevelop-playground/src/Plugins/Node/Makefile.am
branches/MonoDevelop-playground/src/Plugins/Node/NodePlugin.cs
Log:
Implemented FileOpen action. Added first implementation of the Editor plugin.
Implemented the FileNode class.
Modified: branches/MonoDevelop-playground/configure.in
===================================================================
--- branches/MonoDevelop-playground/configure.in 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/configure.in 2004-03-05 19:11:03 UTC (rev 1117)
@@ -89,5 +89,6 @@
src/Plugins/Workbench/Makefile
src/Plugins/FileBrowser/Makefile
src/Plugins/Content/Makefile
+src/Plugins/Editor/Makefile
monodevelop
])
Modified: branches/MonoDevelop-playground/src/Plugins/Content/ContentManager.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Content/ContentManager.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Content/ContentManager.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -12,6 +12,7 @@
using System;
using System.Collections;
+using System.Reflection;
using Gtk;
using log4net;
using MonoDevelop.Node;
@@ -46,11 +47,13 @@
// Event handlers
////////////////////////////////////////////////////////////////////////
- private void OnFileOpen (object obj, EventArgs args)
+ private void OnFileOpen (object obj, EventArgs e)
{
+ // Ask the user which file to open.
FileChooserDialog fcd = new FileChooserDialog ("Open File",
(Window)Workbench.Workbench.ActiveWorkbench,
- FileChooserAction.Open);
+ FileChooserAction.Open,
+ "gnome-vfs");
fcd.AddButton (Stock.Cancel, ResponseType.Cancel);
fcd.AddButton (Stock.Open, ResponseType.Ok);
fcd.DefaultResponse = (int)ResponseType.Ok;
@@ -61,9 +64,40 @@
return;
string mimetype = Mime.GetMimeType (fcd.Filename);
- Console.WriteLine ("mimetype for {0} is {1}", fcd.Filename, mimetype);
+ log.Debug ("Mimetype for " + fcd.Filename + " is " + mimetype);
- Type type = FileNode.FindFileNodeType (fcd.Filename, true);
+ // Find a FileNode Type for the specified mimetype.
+ FileNodeEntry entry = FileNode.FindFileNodeType (mimetype);
+ if (entry == null) {
+ log.Debug ("No matching FileNode found");
+ return;
+ }
+
+ // Create a new FileNode for the specified file.
+ log.Debug ("Found FileNode type: " + entry.Type);
+ Type[] types = new Type[3];
+ types[0] = typeof (Project);
+ types[1] = typeof (Node);
+ types[2] = typeof (string);
+ ConstructorInfo ci = entry.Type.GetConstructor (BindingFlags.Instance | BindingFlags.Public,
+ null, CallingConventions.HasThis,
+ types, null);
+ object[] args = new object[3];
+ args[0] = null;
+ args[1] = null;
+ args[2] = fcd.Filename;
+ FileNode fn = (FileNode)ci.Invoke (args);
+
+ // Find a suitable INodeViewer which can display the file.
+ foreach (INodeViewerFactory factory in factories) {
+ if (factory.CanDisplayNode (fn)) {
+ log.Debug ("" + factory + " can display node " + fn);
+ INodeViewer viewer = factory.CreateNodeViewer (fn);
+ AppendPage (viewer.ViewerWidget, new Label (fn.DisplayName));
+ viewer.ViewerWidget.ShowAll ();
+ break;
+ }
+ }
}
////////////////////////////////////////////////////////////////////////
Property changes on: branches/MonoDevelop-playground/src/Plugins/Editor
___________________________________________________________________
Name: svn:ignore
+ Makefile
Makefile.in
editor.dll
editor.plugin
Added: branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewer.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewer.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewer.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,67 @@
+//
+// EditorNodeViewer.cs: Node viewer for text/* mimetypes.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using System;
+using Gtk;
+using MonoDevelop.Content;
+
+namespace MonoDevelop.Editor {
+ public class EditorNodeViewer : INodeViewer {
+ private ScrolledWindow structure;
+ private TreeView tree;
+ private ScrolledWindow viewer;
+ private TextView editor;
+ private string description;
+ private string title;
+ private Gdk.Pixbuf icon;
+
+ public EditorNodeViewer ()
+ {
+ structure = new ScrolledWindow ();
+ structure.ShadowType = ShadowType.In;
+ tree = new TreeView ();
+ structure.Add (tree);
+
+ viewer = new ScrolledWindow ();
+ viewer.ShadowType = ShadowType.In;
+ editor = new TextView ();
+ viewer.Add (editor);
+ }
+
+ public Widget StructureWidget {
+ get {
+ return structure;
+ }
+ }
+
+ public Widget ViewerWidget {
+ get {
+ return viewer;
+ }
+ }
+
+ public string ViewerDescription {
+ get {
+ return description;
+ }
+ }
+
+ public string ViewerTitle {
+ get {
+ return title;
+ }
+ }
+
+ public Gdk.Pixbuf ViewerIcon {
+ get {
+ return icon;
+ }
+ }
+ }
+}
Added: branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewerFactory.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewerFactory.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/EditorNodeViewerFactory.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,30 @@
+//
+// EditorNodeViewerFactory.cs: Node viewer factory for text/* mimetypes.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using System;
+using MonoDevelop.Content;
+using MonoDevelop.Node;
+
+namespace MonoDevelop.Editor {
+ public class EditorNodeViewerFactory : INodeViewerFactory {
+ public EditorNodeViewerFactory ()
+ {
+ }
+
+ public bool CanDisplayNode (Node node)
+ {
+ return true;
+ }
+
+ public INodeViewer CreateNodeViewer (Node node)
+ {
+ return new EditorNodeViewer ();
+ }
+ }
+}
Added: branches/MonoDevelop-playground/src/Plugins/Editor/EditorPlugin.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/EditorPlugin.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/EditorPlugin.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,65 @@
+//
+// EditorPlugin.cs: Registers the editor plugin.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using System;
+using MonoDevelop;
+using MonoDevelop.Content;
+using log4net;
+
+namespace MonoDevelop.Editor {
+ public class EditorPlugin : BasePlugin {
+ private static readonly ILog log = LogManager.GetLogger (typeof (EditorPlugin));
+
+ public override string Author {
+ get {
+ return "Jeroen Zwartepoorte";
+ }
+ }
+
+ public override string Copyright {
+ get {
+ return "GPL";
+ }
+ }
+
+ public override string Description {
+ get {
+ return "Editor plugin";
+ }
+ }
+
+ public override string Name {
+ get {
+ return "editor";
+ }
+ }
+
+ public override string Url {
+ get {
+ return "http://www.xs4all.nl/~jeroen/";
+ }
+ }
+
+ public override string Version {
+ get {
+ return "1.0";
+ }
+ }
+
+ public override bool InitializePlugin (byte major, byte minor)
+ {
+ ContentManager.AddNodeViewerFactory (new EditorNodeViewerFactory ());
+ return true;
+ }
+
+ public override void FinalizePlugin ()
+ {
+ }
+ }
+}
Added: branches/MonoDevelop-playground/src/Plugins/Editor/Makefile.am
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/Makefile.am 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/Makefile.am 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,37 @@
+editordir = $(libdir)/monodevelop
+editorassembly = $(editordir)/editor.dll
+editor_DATA = editor.dll
+plugindir = $(monodevelop_plugin_dir)
+plugin_DATA = editor.plugin
+uidir = $(monodevelop_ui_dir)
+ui_DATA = editor.ui
+CLEANFILES = editor.dll editor.plugin
+CSC = mcs
+
+editor_sources = \
+ EditorNodeViewer.cs \
+ EditorNodeViewerFactory.cs \
+ EditorPlugin.cs
+
+editor_assemblies = \
+ -r:../../StartUp/monodevelop.exe \
+ -r:../../Util/util.dll \
+ -r:../Node/node.dll \
+ -r:../Services/services.dll \
+ -r:../Workbench/workbench.dll \
+ -r:../Content/content.dll \
+ -r:log4net.dll \
+ -r:gtk-sharp.dll \
+ -r:gdk-sharp.dll \
+ -r:glib-sharp.dll
+
+editor.dll: $(editor_sources)
+ $(CSC) -debug -t:library -out:editor.dll $(editor_sources) $(editor_assemblies)
+
+editor.plugin: editor.plugin.in
+ sed -e 's^\@assembly\@^$(editorassembly)^g' < $(srcdir)/editor.plugin.in > editor.plugin
+
+EXTRA_DIST = \
+ $(editor_sources) \
+ editor.plugin.in \
+ editor.ui
Added: branches/MonoDevelop-playground/src/Plugins/Editor/editor.plugin.in
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/editor.plugin.in 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/editor.plugin.in 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin version="1.0">
+ <assembly>@assembly@</assembly>
+ <class name="MonoDevelop.Editor.EditorPlugin"/>
+</plugin>
Added: branches/MonoDevelop-playground/src/Plugins/Editor/editor.ui
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Editor/editor.ui 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Editor/editor.ui 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<menubar>
+ <menu name="EditMenu" action="EditMenuAction">
+ <placeholder name="EditEditorPlaceholder">
+ <menuitem name="EditUndo" action="EditUndoAction"/>
+ <menuitem name="EditRedo" action="EditRedoAction"/>
+ <separator/>
+ <menuitem name="EditCut" action="EditCutAction"/>
+ <menuitem name="EditCopy" action="EditCopyAction"/>
+ <menuitem name="EditPaste" action="EditPasteAction"/>
+ <menuitem name="EditDelete" action="EditDeleteAction"/>
+ <separator/>
+ <menuitem name="EditSelectAll" action="EditSelectAllaction"/>
+ </placeholder>
+ </menu>
+</menubar>
+<toolbar name="toolbar">
+ <toolitem name="EditUndo" action="EditUndoAction"/>
+ <toolitem name="EditRedo" action="EditRedoAction"/>
+ <separator/>
+ <toolitem name="EditCut" action="EditCutAction"/>
+ <toolitem name="EditCopy" action="EditCopyAction"/>
+ <toolitem name="EditPaste" action="EditPasteAction"/>
+</toolbar>
Modified: branches/MonoDevelop-playground/src/Plugins/Makefile.am
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Makefile.am 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Makefile.am 2004-03-05 19:11:03 UTC (rev 1117)
@@ -1 +1 @@
-SUBDIRS = Node Services Workbench FileBrowser Content
+SUBDIRS = Node Services Workbench FileBrowser Content Editor
Modified: branches/MonoDevelop-playground/src/Plugins/Node/FileNode.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Node/FileNode.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Node/FileNode.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -12,14 +12,17 @@
using System.IO;
using System.Reflection;
using Gdk;
+using log4net;
namespace MonoDevelop.Node {
public class FileNode : Node {
+ static private readonly ILog log = LogManager.GetLogger (typeof (FileNode));
static private Hashtable fileNodeTypes = new Hashtable ();
private Node parent;
private Project project;
private string filename;
+ private string mimetype;
public override bool CanDelete {
get {
@@ -100,6 +103,12 @@
}
}
+ public string MimeType {
+ get {
+ return mimetype;
+ }
+ }
+
public override Node Parent {
get {
return parent;
@@ -165,50 +174,50 @@
// Static methods
////////////////////////////////////////////////////////////////////////
- static public Type FindFileNodeType (string filename)
+ static public FileNodeEntry FindFileNodeType (string mimetype)
{
- return null;
+ if (fileNodeTypes.Contains (mimetype)) {
+ ArrayList types = fileNodeTypes[mimetype] as ArrayList;
+ return types[0] as FileNodeEntry;
+ } else {
+ Console.WriteLine ("doesn't contain {0}", mimetype);
+ return null;
+ }
}
- static public Type FindFileNodeType (string filename,
- bool includeBackups)
- {
- return null;
- }
-
- static public void RegisterFileNodeType (string extension,
+ static public void RegisterFileNodeType (string mimetype,
string description,
Type type,
Pixbuf icon)
{
ArrayList types;
- if (fileNodeTypes.Contains (extension)) {
- types = fileNodeTypes[extension] as ArrayList;
- types.Add (new FileNodeEntry (extension,
+ if (fileNodeTypes.Contains (mimetype)) {
+ types = fileNodeTypes[mimetype] as ArrayList;
+ types.Add (new FileNodeEntry (mimetype,
description,
type, icon));
- fileNodeTypes[extension] = types;
+ fileNodeTypes[mimetype] = types;
} else {
types = new ArrayList ();
- types.Add (new FileNodeEntry (extension,
+ types.Add (new FileNodeEntry (mimetype,
description,
type, icon));
- fileNodeTypes.Add (extension, types);
+ fileNodeTypes.Add (mimetype, types);
}
}
}
- class FileNodeEntry {
- private string extension;
+ public class FileNodeEntry {
+ private string mimetype;
private string description;
private Type type;
private Pixbuf icon;
- public string Extension {
+ public string MimeType {
get {
- return extension;
+ return mimetype;
}
}
@@ -230,10 +239,10 @@
}
}
- public FileNodeEntry (string extension, string description,
+ public FileNodeEntry (string mimetype, string description,
Type type, Pixbuf icon)
{
- this.extension = extension;
+ this.mimetype = mimetype;
this.description = description;
this.type = type;
this.icon = icon;
Modified: branches/MonoDevelop-playground/src/Plugins/Node/Makefile.am
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Node/Makefile.am 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Node/Makefile.am 2004-03-05 19:11:03 UTC (rev 1117)
@@ -10,7 +10,8 @@
FileNode.cs \
Node.cs \
NodePlugin.cs \
- Project.cs
+ Project.cs \
+ TextFileNode.cs
node_assemblies = \
-r:../../StartUp/monodevelop.exe \
Modified: branches/MonoDevelop-playground/src/Plugins/Node/NodePlugin.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Node/NodePlugin.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Node/NodePlugin.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -53,6 +53,10 @@
public override bool InitializePlugin (byte major, byte minor)
{
+ FileNode.RegisterFileNodeType ("text/x-csharp",
+ "Text file",
+ typeof (TextFileNode),
+ null);
return true;
}
Added: branches/MonoDevelop-playground/src/Plugins/Node/TextFileNode.cs
===================================================================
--- branches/MonoDevelop-playground/src/Plugins/Node/TextFileNode.cs 2004-03-05 17:51:17 UTC (rev 1116)
+++ branches/MonoDevelop-playground/src/Plugins/Node/TextFileNode.cs 2004-03-05 19:11:03 UTC (rev 1117)
@@ -0,0 +1,22 @@
+//
+// TextFileNode.cs: Class for text files.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using log4net;
+
+namespace MonoDevelop.Node {
+ public class TextFileNode : FileNode {
+ static private readonly ILog log = LogManager.GetLogger (typeof (TextFileNode));
+
+ public TextFileNode (Project project, Node parent, string filename)
+ : base (project, parent, filename)
+ {
+ log.Debug ("Created instance of TextFileNode");
+ }
+ }
+}
More information about the Monodevelop-patches-list
mailing list