Author: lluis
Date: 2005-12-13 09:37:12 -0500 (Tue, 13 Dec 2005)
New Revision: 54284
Added:
trunk/monodevelop/Core/src/MonoDevelop.Ide/templates/
trunk/monodevelop/Core/src/MonoDevelop.Ide/templates/EmptyClass.xft.xml
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditable.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
2005-12-13 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.Ide.Gui.Content/IEditable.cs: Renamed to
IEditableTextBuffer.
This interface now inherits from IEditableTextFile. Removed some methods
that are now inherited.
* MonoDevelop.Ide.Gui.Content/ITextBuffer.cs: This interface now
inherits
from ITextFile. Moved some methods to the base interface. Removed the
concept of 'position'. Now everything is handled with offsets.
* MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs: Removed the
concept of 'position'. Now everything is handled with offsets.
* MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs:
* MonoDevelop.Ide.Templates/FileTemplate.cs: Added support for CodeDom
based file templates.
* MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs:
* MonoDevelop.Ide.Commands/FileCommands.cs:
Group language specific templates in its own tree branch. Added an entry
for the file name. Templates are now filtered according to the current
project type and language.
* MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs: New files
already have a name, so no need to rename them in the tree.
* MonoDevelop.Ide/MonoDevelop.Ide.addin.xml: Added empty class template.
* MonoDevelop.Ide/MonoDevelop.Ide.mdp: Updated.
* MonoDevelop.Ide.Codons/IDisplayBinding.cs:
* MonoDevelop.Ide.Gui/Workbench.cs:
* MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs:
* MonoDevelop.Ide.Gui/DisplayBindingService.cs: Display bindings are now
per mime type, not per language.
* MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs:
* MonoDevelop.Ide.Gui/DefaultWorkbench.cs:
* MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Track changes in
IEditable.
* MonoDevelop.Ide.Gui/ProjectOperations.cs: Simplified
CreateProjectFile,
since now the file comes with a real name and path.
* MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs:
* MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs:
* MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:
Properly show the name of newly created files, since now they have a
name.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2005-12-13
14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog 2005-12-13
14:37:12 UTC (rev 54284)
@@ -1,3 +1,48 @@
+2005-12-13 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Ide.Gui.Content/IEditable.cs: Renamed to
IEditableTextBuffer.
+ This interface now inherits from IEditableTextFile. Removed some methods
+ that are now inherited.
+ * MonoDevelop.Ide.Gui.Content/ITextBuffer.cs: This interface now
inherits
+ from ITextFile. Moved some methods to the base interface. Removed the
+ concept of 'position'. Now everything is handled with offsets.
+ * MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs: Removed the
+ concept of 'position'. Now everything is handled with offsets.
+
+ * MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs:
+ * MonoDevelop.Ide.Templates/FileTemplate.cs: Added support for CodeDom
+ based file templates.
+
+ * MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs:
+ * MonoDevelop.Ide.Commands/FileCommands.cs:
+ Group language specific templates in its own tree branch. Added an entry
+ for the file name. Templates are now filtered according to the current
+ project type and language.
+
+ * MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs: New files
+ already have a name, so no need to rename them in the tree.
+
+ * MonoDevelop.Ide/MonoDevelop.Ide.addin.xml: Added empty class template.
+ * MonoDevelop.Ide/MonoDevelop.Ide.mdp: Updated.
+
+ * MonoDevelop.Ide.Codons/IDisplayBinding.cs:
+ * MonoDevelop.Ide.Gui/Workbench.cs:
+ * MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs:
+ * MonoDevelop.Ide.Gui/DisplayBindingService.cs: Display bindings are now
+ per mime type, not per language.
+
+ * MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs:
+ * MonoDevelop.Ide.Gui/DefaultWorkbench.cs:
+ * MonoDevelop.Ide.Gui/ViewCommandHandlers.cs: Track changes in
IEditable.
+
+ * MonoDevelop.Ide.Gui/ProjectOperations.cs: Simplified
CreateProjectFile,
+ since now the file comes with a real name and path.
+
+ * MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs:
+ * MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs:
+ * MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs:
+ Properly show the name of newly created files, since now they have a
name.
+
2005-12-05 Jacob Ilsoe Christensen <[EMAIL PROTECTED]>
* MonoDevelop.Ide.Gui.Dialogs/ReplaceInFilesDialog.cs:
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2005-12-13
14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am 2005-12-13
14:37:12 UTC (rev 54284)
@@ -226,6 +226,7 @@
MonoDevelop.Ide.Gui.Pads/SearchResultPad.cs
RES= \
+templates/EmptyClass.xft.xml \
Base.glade \
icons/SplashScreen.png \
icons/Icons.AboutImage
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -41,25 +41,11 @@
IViewContent CreateContentForFile(string fileName);
/// <remarks>
- /// This function determines, if this display binding is able
to create
- /// an IViewContent for the language given by languageName.
+ /// Creates a new IViewContent object for the given mime type
/// </remarks>
/// <returns>
- /// true, if this display binding is able to create
- /// an IViewContent for the language given by languageName.
- /// false otherwise
- /// </returns>
- bool CanCreateContentForLanguage(string languageName);
-
- /// <remarks>
- /// Creates a new IViewContent object for the language given by
- /// languageName with the content given by content
- /// </remarks>
- /// <returns>
/// A newly created IViewContent object.
/// </returns>
- IViewContent CreateContentForLanguage(string languageName,
string content);
-
- IViewContent CreateContentForLanguage(string languageName,
string content, string new_file_name);
+ IViewContent CreateContentForMimeType (string mimeType, string
content);
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/FileCommands.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -58,7 +58,7 @@
{
protected override void Run ()
{
- NewFileDialog fd = new NewFileDialog ();
+ NewFileDialog fd = new NewFileDialog (null, null);
fd.Run ();
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -229,8 +229,8 @@
RedrawAllComponents ();
- if (content is IEditable) {
- ((IEditable)content).TextChanged += new
EventHandler (OnViewTextChanged);
+ if (content is IEditableTextBuffer) {
+ ((IEditableTextBuffer)content).TextChanged +=
new EventHandler (OnViewTextChanged);
}
}
@@ -480,7 +480,7 @@
if (ActiveWorkbenchWindow == null ||
ActiveWorkbenchWindow.ActiveViewContent == null)
return false;
- IEditable editable =
ActiveWorkbenchWindow.ActiveViewContent as IEditable;
+ IEditableTextBuffer editable =
ActiveWorkbenchWindow.ActiveViewContent as IEditableTextBuffer;
if (editable == null)
return false;
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -42,10 +42,14 @@
return codon == null ? null : codon.DisplayBinding;
}
- public IDisplayBinding GetBindingPerLanguageName(string
languagename)
+ public IDisplayBinding GetBindingForMimeType (string mimeType)
{
- DisplayBindingCodon codon =
GetCodonPerLanguageName(languagename);
- return codon == null ? null : codon.DisplayBinding;
+ foreach (DisplayBindingCodon binding in bindings) {
+ if (binding.DisplayBinding != null &&
binding.DisplayBinding.CanCreateContentForMimeType (mimeType)) {
+ return binding.DisplayBinding;
+ }
+ }
+ return null;
}
public DisplayBindingCodon GetCodonPerFileName(string filename)
@@ -72,16 +76,6 @@
return null;
}
- public DisplayBindingCodon GetCodonPerLanguageName(string
languagename)
- {
- foreach (DisplayBindingCodon binding in bindings) {
- if (binding.DisplayBinding != null &&
binding.DisplayBinding.CanCreateContentForLanguage(languagename)) {
- return binding;
- }
- }
- return null;
- }
-
public void AttachSubWindows(IWorkbenchWindow workbenchWindow)
{
foreach (DisplayBindingCodon binding in bindings) {
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -133,7 +133,7 @@
if (filename == null) {
FileSelector fdiag = new FileSelector
(GettextCatalog.GetString ("Save as..."), Gtk.FileChooserAction.Save);
- fdiag.SetFilename
(Window.ViewContent.ContentName);
+ fdiag.CurrentName =
Window.ViewContent.UntitledName;
int response = fdiag.Run ();
filename = fdiag.Filename;
fdiag.Hide ();
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -454,35 +454,12 @@
return res;
}
- public ProjectFile CreateProjectFile (Project parentProject,
string basePath)
+ public void CreateProjectFile (Project parentProject, string
basePath)
{
- NewFileDialog nfd = new NewFileDialog ();
- int res = nfd.Run ();
- nfd.Dispose ();
- if (res != (int) Gtk.ResponseType.Ok) return null;
-
- Document doc = IdeApp.Workbench.ActiveDocument;
- int count = 1;
-
- string baseName = Path.GetFileNameWithoutExtension
(doc.Window.ViewContent.UntitledName);
- string extension = Path.GetExtension
(doc.Window.ViewContent.UntitledName);
-
- // first try the default untitled name of the
viewcontent filename
- string fileName = Path.Combine (basePath, baseName +
extension);
-
- // if it is already in the project, or it does exists
we try to get a name that is
- // untitledName + Numer + extension
- while (parentProject.IsFileInProject (fileName) ||
System.IO.File.Exists (fileName)) {
- fileName = Path.Combine (basePath, baseName +
count.ToString() + extension);
- ++count;
+ using (NewFileDialog nfd = new NewFileDialog
(parentProject, basePath)) {
+ nfd.Run ();
+ nfd.Dispose ();
}
-
- // now we have a valid filename which we could use
- doc.SaveAs (fileName);
-
- ProjectFile newFileInformation = new
ProjectFile(fileName, BuildAction.Compile);
- parentProject.ProjectFiles.Add (newFileInformation);
- return newFileInformation;
}
public bool AddReferenceToProject (Project project)
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceLayout.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -506,7 +506,7 @@
public IWorkbenchWindow ShowView(IViewContent content)
{
Gtk.Image mimeimage = null;
- if (content.IsUntitled) {
+ if (content.IsUntitled && content.UntitledName == null)
{
mimeimage = new Gtk.Image
(FileIconLoader.GetPixbufForType ("gnome-fs-regular", 16));
} else {
mimeimage = new Gtk.Image
(FileIconLoader.GetPixbufForFile (content.ContentName, 16));
@@ -520,7 +520,7 @@
sdiWorkspaceWindow.Closed += new
EventHandler(CloseWindowEvent);
tabControl.InsertPage (sdiWorkspaceWindow, tabLabel,
-1);
-
+
tabLabel.Show();
return sdiWorkspaceWindow;
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/SdiWorkspaceWindow.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -163,8 +163,9 @@
if (content.ContentName == null) {
if (myUntitledTitle == null) {
string baseName =
System.IO.Path.GetFileNameWithoutExtension(content.UntitledName);
- int number = 1;
- bool found = true;
+ int number = 1;
+ bool found = true;
+ myUntitledTitle = baseName +
System.IO.Path.GetExtension (content.UntitledName);
while (found) {
found = false;
foreach (IViewContent
windowContent in workbench.ViewContentCollection) {
@@ -172,14 +173,14 @@
if (title.EndsWith("*")
|| title.EndsWith("+")) {
title =
title.Substring(0, title.Length - 1);
}
- if (title == baseName +
number) {
+ if (title ==
myUntitledTitle) {
+ myUntitledTitle
= baseName + number + System.IO.Path.GetExtension (content.UntitledName);
found = true;
++number;
break;
}
}
}
- myUntitledTitle = baseName + number;
}
newTitle = myUntitledTitle;
} else {
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -128,7 +128,7 @@
[CommandHandler (EditCommands.Undo)]
protected void OnUndo ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.Undo();
}
@@ -136,13 +136,13 @@
[CommandUpdateHandler (EditCommands.Undo)]
protected void OnUpdateUndo (CommandInfo info)
{
- info.Enabled = window.ActiveViewContent is IEditable;
+ info.Enabled = window.ActiveViewContent is
IEditableTextBuffer;
}
[CommandHandler (EditCommands.Redo)]
protected void OnRedo ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null) {
editable.Redo();
}
@@ -151,13 +151,13 @@
[CommandUpdateHandler (EditCommands.Redo)]
protected void OnUpdateRedo (CommandInfo info)
{
- info.Enabled = window.ActiveViewContent is IEditable;
+ info.Enabled = window.ActiveViewContent is
IEditableTextBuffer;
}
[CommandHandler (EditCommands.Cut)]
protected void OnCut ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.ClipboardHandler.Cut(null, null);
}
@@ -165,14 +165,14 @@
[CommandUpdateHandler (EditCommands.Cut)]
protected void OnUpdateCut (CommandInfo info)
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
info.Enabled = editable != null &&
editable.ClipboardHandler.EnableCut;
}
[CommandHandler (EditCommands.Copy)]
protected void OnCopy ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.ClipboardHandler.Copy(null, null);
}
@@ -180,14 +180,14 @@
[CommandUpdateHandler (EditCommands.Copy)]
protected void OnUpdateCopy (CommandInfo info)
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
info.Enabled = editable != null &&
editable.ClipboardHandler.EnableCopy;
}
[CommandHandler (EditCommands.Paste)]
protected void OnPaste ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.ClipboardHandler.Paste(null, null);
}
@@ -195,14 +195,14 @@
[CommandUpdateHandler (EditCommands.Paste)]
protected void OnUpdatePaste (CommandInfo info)
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
info.Enabled = editable != null &&
editable.ClipboardHandler.EnablePaste;
}
[CommandHandler (EditCommands.Delete)]
protected void OnDelete ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.ClipboardHandler.Delete(null, null);
}
@@ -210,14 +210,14 @@
[CommandUpdateHandler (EditCommands.Delete)]
protected void OnUpdateDelete (CommandInfo info)
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
info.Enabled = editable != null &&
editable.ClipboardHandler.EnableDelete;
}
[CommandHandler (EditCommands.SelectAll)]
protected void OnSelectAll ()
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
if (editable != null)
editable.ClipboardHandler.SelectAll(null, null);
}
@@ -225,7 +225,7 @@
[CommandUpdateHandler (EditCommands.SelectAll)]
protected void OnUpdateSelectAll (CommandInfo info)
{
- IEditable editable = window.ActiveViewContent as
IEditable;
+ IEditableTextBuffer editable = window.ActiveViewContent
as IEditableTextBuffer;
info.Enabled = editable != null &&
editable.ClipboardHandler.EnableSelectAll;
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -255,23 +255,23 @@
return WrapDocument (content.WorkbenchWindow);
}
- public Document NewDocument (string defaultName, string
language, string content)
+ public Document NewDocument (string defaultName, string
mimeType, string content)
{
- IDisplayBinding binding =
Services.DisplayBindings.GetBindingPerLanguageName(language);
+ IDisplayBinding binding =
Services.DisplayBindings.GetBindingForMimeType (mimeType);
IViewContent newContent;
if (binding != null) {
- newContent =
binding.CreateContentForLanguage(language, content, defaultName);
+ newContent = binding.CreateContentForMimeType
(mimeType, content);
if (newContent == null) {
- throw new
ApplicationException(String.Format("Created view content was
null{3}DefaultName:{0}{3}Language:{1}{3}Content:{2}", defaultName, language,
content, Environment.NewLine));
+ throw new
ApplicationException(String.Format("Created view content was
null{3}DefaultName:{0}{3}MimeType:{1}{3}Content:{2}", defaultName, mimeType,
content, Environment.NewLine));
}
newContent.UntitledName = defaultName;
- newContent.IsDirty = false;
+ newContent.IsDirty = true;
workbench.ShowView(newContent, true);
Services.DisplayBindings.AttachSubWindows(newContent.WorkbenchWindow);
} else {
- throw new ApplicationException("Can't create
display binding for language " + language);
+ throw new ApplicationException("Can't create
display binding for mime type: " + mimeType);
}
return WrapDocument (newContent.WorkbenchWindow);
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -35,11 +35,6 @@
return false;
}
- public bool CanCreateContentForLanguage(string language)
- {
- return false;
- }
-
public IViewContent CreateContentForFile(string fileName)
{
BrowserPane browserPane = new BrowserPane();
@@ -47,16 +42,11 @@
return browserPane;
}
- public IViewContent CreateContentForLanguage(string language,
string content)
+ public IViewContent CreateContentForMimeType (string mimeType,
string content)
{
return null;
}
- public IViewContent CreateContentForLanguage(string
languageName, string content, string new_file_name)
- {
- return null;
- }
-
public bool CanAttachTo (IViewContent parent)
{
string filename = parent.ContentName;
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IBookmarkBuffer.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -30,8 +30,8 @@
{
public interface IBookmarkBuffer: ITextBuffer
{
- void SetBookmarked (object position, bool mark);
- bool IsBookmarked (object position);
+ void SetBookmarked (int position, bool mark);
+ bool IsBookmarked (int position);
void PrevBookmark ();
void NextBookmark ();
void ClearBookmarks ();
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditable.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditable.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/IEditable.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -6,28 +6,21 @@
// </file>
using System;
+using MonoDevelop.Projects.Text;
namespace MonoDevelop.Ide.Gui.Content
{
- public interface IEditable: ITextBuffer
+ public interface IEditableTextBuffer: ITextBuffer, IEditableTextFile
{
IClipboardHandler ClipboardHandler {
get;
}
- new string Text {
- get;
- set;
- }
-
void Undo();
void Redo();
new string SelectedText { get; set; }
- void InsertText (object position, string text);
- void DeleteText (object position, int length);
-
event EventHandler TextChanged;
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Content/ITextBuffer.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -26,23 +26,20 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using MonoDevelop.Projects.Text;
+
namespace MonoDevelop.Ide.Gui.Content
{
- public interface ITextBuffer
+ public interface ITextBuffer: ITextFile
{
- string Text { get; }
string SelectedText { get; }
- object CursorPosition { get; set; }
- object GetPositionFromOffset (int offset);
- object GetPositionFromLineColumn (int line, int column);
- int GetOffsetFromPosition (object position);
+ int CursorPosition { get; set; }
- object SelectionStartPosition { get; }
- object SelectionEndPosition { get; }
+ int SelectionStartPosition { get; }
+ int SelectionEndPosition { get; }
- void Select (object startPosition, object endPosition);
- void ShowPosition (object position);
- string GetText (object startPosition, object endPosition);
+ void Select (int startPosition, int endPosition);
+ void ShowPosition (int position);
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewFileDialog.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -17,6 +17,7 @@
using MonoDevelop.Core.AddIns;
using MonoDevelop.Ide.Templates;
using MonoDevelop.Ide.Gui;
+using MonoDevelop.Projects;
using Gtk;
using MonoDevelop.Components;
@@ -27,7 +28,7 @@
/// <summary>
/// This class is for creating a new "empty" file
/// </summary>
- internal class NewFileDialog : Dialog, INewFileCreator
+ internal class NewFileDialog : Dialog
{
ArrayList alltemplates = new ArrayList ();
ArrayList categories = new ArrayList ();
@@ -43,13 +44,30 @@
Button okButton;
Button cancelButton;
Label infoLabel;
+ Entry nameEntry;
+
+ Project parentProject;
+ string basePath;
+
+ string currentProjectType = string.Empty;
+ string currentLanguage = string.Empty;
- public NewFileDialog () : base ()
+ public NewFileDialog (Project parentProject, string basePath) :
base ()
{
+ this.parentProject = parentProject;
+ this.basePath = basePath;
+
this.TransientFor = IdeApp.Workbench.RootWindow;
this.BorderWidth = 6;
this.HasSeparator = false;
+ if (parentProject != null) {
+ currentProjectType = parentProject.ProjectType;
+ DotNetProject netproject = parentProject as
DotNetProject;
+ if (netproject != null)
+ currentLanguage =
netproject.LanguageName;
+ }
+
InitializeTemplates ();
}
@@ -90,52 +108,110 @@
void InsertCategories(TreeIter node, ArrayList catarray)
{
foreach (Category cat in catarray) {
+ TreeIter cnode;
if (node.Equals(Gtk.TreeIter.Zero)) {
- node = catStore.AppendValues (cat.Name,
cat.Categories, cat.Templates, cat_imglist[1]);
+ cnode = catStore.AppendValues
(cat.Name, cat.Categories, cat.Templates, cat_imglist[1]);
} else {
- node = catStore.AppendValues (cat.Name,
cat.Categories, cat.Templates, cat_imglist[1]);
+ cnode = catStore.AppendValues (node,
cat.Name, cat.Categories, cat.Templates, cat_imglist[1]);
}
- InsertCategories(node, cat.Categories);
+ if (cat.Categories.Count > 0)
+ InsertCategories (cnode,
cat.Categories);
}
}
- // TODO : insert sub categories
- Category GetCategory(string categoryname)
+ Category GetCategory (string categoryname)
{
- foreach (Category category in categories) {
+ return GetCategory (categories, categoryname);
+ }
+
+ Category GetCategory (ArrayList catList, string categoryname)
+ {
+ foreach (Category category in catList) {
if (category.Name == categoryname) {
return category;
}
}
Category newcategory = new Category(categoryname);
- categories.Add(newcategory);
+ catList.Add(newcategory);
return newcategory;
}
void InitializeTemplates()
{
foreach (FileTemplate template in
FileTemplate.FileTemplates) {
- TemplateItem titem = new TemplateItem(template);
- if (titem.Template.Icon != null) {
- icons[titem.Template.Icon] = 0; //
"create template icon"
+
+ if (template.Icon != null) {
+ icons[template.Icon] = 0; // "create
template icon"
}
- Category cat =
GetCategory(titem.Template.Category);
- cat.Templates.Add(titem);
- if (cat.Selected == false &&
template.WizardPath == null) {
- cat.Selected = true;
- }
- if (!cat.HasSelectedTemplate &&
titem.Template.Files.Count == 1) {
- if
(((FileDescriptionTemplate)titem.Template.Files[0]).Name.StartsWith("Empty")) {
- //titem.Selected = true;
- cat.HasSelectedTemplate = true;
+ // Ignore templates not supported by this
project
+ if (template.ProjectType != "" &&
template.ProjectType != currentProjectType)
+ continue;
+
+ // Ignore templates not supported by the
current language
+ if (template.LanguageName != "" &&
template.LanguageName != "*" && currentLanguage != "" && template.LanguageName
!= currentLanguage)
+ continue;
+
+ if (template.LanguageName == "*") {
+ ILanguageBinding[] langs =
MonoDevelop.Projects.Services.Languages.GetLanguageBindings ();
+ foreach (ILanguageBinding lang in
langs) {
+ IDotNetLanguageBinding dnlang =
lang as IDotNetLanguageBinding;
+ if (dnlang != null &&
dnlang.GetCodeDomProvider () != null) {
+ TemplateItem titem =
new TemplateItem (template, dnlang.Language);
+ AddTemplate (titem,
dnlang.Language);
+ }
}
+ } else {
+ TemplateItem titem = new TemplateItem
(template, template.LanguageName);
+ AddTemplate (titem,
template.LanguageName);
}
- alltemplates.Add(titem);
}
InitializeComponents ();
}
+ void AddTemplate (TemplateItem titem, string templateLanguage)
+ {
+ Category cat = null;
+
+ if (parentProject != null) {
+ if (templateLanguage != "") {
+ if (currentLanguage != "") {
+ // The template requires a
language, and there is a language set, so only show it if they match
+ if (currentLanguage !=
templateLanguage)
+ return;
+ cat = GetCategory
(titem.Template.Category);
+ } else {
+ // The template requires a
language, but there is no current language set, so create a category for it
+ cat = GetCategory
(templateLanguage);
+ cat = GetCategory
(cat.Categories, titem.Template.Category);
+ }
+ } else {
+ cat = GetCategory
(titem.Template.Category);
+ }
+ } else {
+ if (templateLanguage != "") {
+ // The template requires a language,
but there is no current language set, so create a category for it
+ cat = GetCategory (templateLanguage);
+ cat = GetCategory (cat.Categories,
titem.Template.Category);
+ } else {
+ cat = GetCategory
(titem.Template.Category);
+ }
+ }
+
+ cat.Templates.Add (titem);
+
+ if (cat.Selected == false && titem.Template.WizardPath
== null) {
+ cat.Selected = true;
+ }
+ if (!cat.HasSelectedTemplate &&
titem.Template.Files.Count == 1) {
+ if
(((FileDescriptionTemplate)titem.Template.Files[0]).Name.StartsWith("Empty")) {
+ //titem.Selected = true;
+ cat.HasSelectedTemplate = true;
+ }
+ }
+ alltemplates.Add(titem);
+ }
+
// tree view event handlers
void CategoryChange(object sender, EventArgs e)
{
@@ -147,21 +223,36 @@
foreach (TemplateItem item in
(ArrayList)((Gtk.TreeStore)mdl).GetValue (iter, 2)) {
//templateStore.AppendValues
(item.Name, item.Template);
- TemplateView.AddIcon(new
Gtk.Image(Services.Resources.GetBitmap (item.Template.Icon, Gtk.IconSize.Dnd)),
item.Name, item.Template);
+ TemplateView.AddIcon(new
Gtk.Image(Services.Resources.GetBitmap (item.Template.Icon, Gtk.IconSize.Dnd)),
item.Name, item);
}
okButton.Sensitive = false;
}
}
// list view event handlers
- void SelectedIndexChange(object sender, EventArgs e)
+ void SelectedIndexChange (object sender, EventArgs e)
{
- FileTemplate item =
(FileTemplate)TemplateView.CurrentlySelected;
+ UpdateOkStatus ();
+ }
+
+ void NameChanged (object sender, EventArgs e)
+ {
+ UpdateOkStatus ();
+ }
+
+ void UpdateOkStatus ()
+ {
+ TemplateItem sel = (TemplateItem)
TemplateView.CurrentlySelected;
+ if (sel == null)
+ return;
+
+ FileTemplate item = sel.Template;
- if (item != null)
- {
+ if (item != null) {
infoLabel.Text = item.Description;
- okButton.Sensitive = true;
+ okButton.Sensitive = nameEntry.Text.Length > 0;
+ } else {
+ okButton.Sensitive = false;
}
}
@@ -172,16 +263,6 @@
//((ListView)ControlDictionary["templateListView"]).View =
((RadioButton)ControlDictionary["smallIconsRadioButton"]).Checked ? View.List :
View.LargeIcon;
}
- public bool IsFilenameAvailable(string fileName)
- {
- return true;
- }
-
- public void SaveFile(string filename, string content, string
languageName, bool showFile)
- {
- IdeApp.Workbench.NewDocument (filename, languageName,
content);
- }
-
public event EventHandler OnOked;
void OpenEvent(object sender, EventArgs e)
@@ -192,26 +273,12 @@
//propertyService.SetProperty("Dialogs.NewFileDialog.LastSelectedCategory",
((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode.Text);
//if (templateView.Selection.GetSelected (out mdl, out
iter)) {
- if (TemplateView.CurrentlySelected != null) {
- FileTemplate item =
(FileTemplate)TemplateView.CurrentlySelected;
-
- if (item.WizardPath != null) {
- //IProperties customizer = new
DefaultProperties();
- //customizer.SetProperty("Template",
item);
- //customizer.SetProperty("Creator",
this);
- //WizardDialog wizard = new
WizardDialog("File Wizard", customizer, item.WizardPath);
- //if (wizard.ShowDialog() ==
DialogResult.OK) {
- //DialogResult =
DialogResult.OK;
- //}
- } else {
- foreach (FileDescriptionTemplate
newfile in item.Files) {
- SaveFile(newfile.Name,
newfile.Content, item.LanguageName, true);
- }
- }
-
- if (IdeApp.Workbench.ActiveDocument != null) {
- IdeApp.Workbench.ActiveDocument.Select
();
- }
+ if (TemplateView.CurrentlySelected != null &&
nameEntry.Text.Length > 0) {
+ TemplateItem titem = (TemplateItem)
TemplateView.CurrentlySelected;
+ FileTemplate item = titem.Template;
+ if (!item.Create (parentProject, basePath,
titem.Language, nameEntry.Text))
+ return;
+
if (OnOked != null)
OnOked (null, null);
Respond (Gtk.ResponseType.Ok);
@@ -259,10 +326,12 @@
{
FileTemplate template;
string name;
+ string language;
- public TemplateItem(FileTemplate template)
+ public TemplateItem (FileTemplate template, string
language)
{
this.template = template;
+ this.language = language;
this.name = template.Name;
}
@@ -277,6 +346,10 @@
return template;
}
}
+
+ public string Language {
+ get { return language; }
+ }
}
void cancelClicked (object o, EventArgs e) {
@@ -337,6 +410,13 @@
this.VBox.PackStart (viewbox);
this.VBox.PackStart (infoLabelFrame, false, false, 6);
+
+ HBox nameBox = new HBox ();
+ nameBox.PackStart (new Label (GettextCatalog.GetString
("Name:")), false, false, 0);
+ nameEntry = new Entry ();
+ nameBox.PackStart (nameEntry, true, true, 6);
+ nameEntry.Changed += new EventHandler (NameChanged);
+ this.VBox.PackStart (nameBox, false, false, 6);
cat_imglist = new PixbufList();
cat_imglist.Add(Services.Resources.GetBitmap("md-open-folder"));
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/FolderNodeBuilder.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -323,12 +323,9 @@
public void AddNewFileToProject()
{
Project project = CurrentNode.GetParentDataItem
(typeof(Project), true) as Project;
- ProjectFile file =
IdeApp.ProjectOperations.CreateProjectFile (project, GetFolderPath
(CurrentNode.DataItem));
- if (file != null) {
- IdeApp.ProjectOperations.SaveCombine();
- CurrentNode.Expanded = true;
- Tree.AddNodeInsertCallback (file, new
TreeNodeCallback (OnFileInserted));
- }
+ IdeApp.ProjectOperations.CreateProjectFile (project,
GetFolderPath (CurrentNode.DataItem));
+ IdeApp.ProjectOperations.SaveCombine();
+ CurrentNode.Expanded = true;
}
void OnFileInserted (ITreeNavigator nav)
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Search/SearchReplaceManager.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -96,12 +96,12 @@
public static void Replace()
{
if (IdeApp.Workbench.ActiveDocument != null) {
- IEditable editable =
IdeApp.Workbench.ActiveDocument.Content as IEditable;
+ IEditableTextBuffer editable =
IdeApp.Workbench.ActiveDocument.Content as IEditableTextBuffer;
if (editable == null) return;
if (lastResult != null &&
find.DocumentIterator.CurrentFileName == lastResult.FileName) {
- int s1 = editable.GetOffsetFromPosition
(editable.SelectionStartPosition);
- int s2 = editable.GetOffsetFromPosition
(editable.SelectionEndPosition);
+ int s1 =
editable.SelectionStartPosition;
+ int s2 = editable.SelectionEndPosition;
if (lastResult.DocumentOffset == s1 &&
lastResult.DocumentOffset + lastResult.Length == s2)
editable.SelectedText =
SearchOptions.ReplacePattern;
}
@@ -128,8 +128,7 @@
} else {
IBookmarkBuffer textArea = OpenView
(result.FileName) as IBookmarkBuffer;
if (textArea != null) {
- object pos =
textArea.GetPositionFromOffset (result.DocumentOffset);
- textArea.SetBookmarked (pos,
true);
+ textArea.SetBookmarked
(result.DocumentOffset, true);
}
}
}
@@ -185,7 +184,7 @@
find.Reset ();
else {
ITextBuffer textArea = OpenView
(lastResult.FileName) as ITextBuffer;
- if (textArea == null || (lastResult !=
null && textArea.GetOffsetFromPosition (textArea.CursorPosition) !=
lastResult.DocumentOffset + lastResult.Length)) {
+ if (textArea == null || (lastResult !=
null && textArea.CursorPosition != lastResult.DocumentOffset +
lastResult.Length)) {
find.Reset();
}
}
@@ -217,15 +216,14 @@
int startPos = Math.Min
(textArea.Text.Length, Math.Max(0, result.DocumentOffset));
int endPos = Math.Min
(textArea.Text.Length, startPos + result.Length);
- if (startPos ==
textArea.GetOffsetFromPosition (textArea.SelectionStartPosition) &&
- endPos ==
textArea.GetOffsetFromPosition (textArea.SelectionEndPosition)) {
+ if (startPos ==
textArea.SelectionStartPosition && endPos == textArea.SelectionEndPosition) {
// If the result is the same of
what we have selected, search again.
Find (reverse);
return;
}
- textArea.ShowPosition
(textArea.GetPositionFromOffset (endPos));
- textArea.Select
(textArea.GetPositionFromOffset (endPos), textArea.GetPositionFromOffset
(startPos));
+ textArea.ShowPosition (endPos);
+ textArea.Select (endPos, startPos);
}
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -17,13 +17,20 @@
{
string name;
string content;
+ XmlElement domContent;
- public FileDescriptionTemplate(string name, string content)
+ public FileDescriptionTemplate (string name, string content)
{
this.name = name;
this.content = content;
}
+ public FileDescriptionTemplate (string name, XmlElement
domContent)
+ {
+ this.name = name;
+ this.domContent = domContent;
+ }
+
public string Name {
get {
return name;
@@ -35,5 +42,11 @@
return content;
}
}
+
+ public XmlElement CodeDomContent {
+ get {
+ return domContent;
+ }
+ }
}
}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
2005-12-13 14:36:43 UTC (rev 54283)
+++
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplate.cs
2005-12-13 14:37:12 UTC (rev 54284)
@@ -12,11 +12,16 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Reflection;
+using System.CodeDom;
+using System.CodeDom.Compiler;
using MonoDevelop.Core;
using MonoDevelop.Core.AddIns;
using MonoDevelop.Core.Gui;
using MonoDevelop.Ide.Codons;
+using MonoDevelop.Projects;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Projects.CodeGeneration;
namespace MonoDevelop.Ide.Templates
{
@@ -32,7 +37,8 @@
string lastmodified = null;
string name = null;
string category = null;
- string languagename = null;
+ string languagename = "";
+ string projecttype = "";
string description = null;
string icon = null;
@@ -84,6 +90,12 @@
}
}
+ public string ProjectType {
+ get {
+ return projecttype;
+ }
+ }
+
public string Description {
get {
return description;
@@ -129,8 +141,13 @@
name = GettextCatalog.GetString
(config["_Name"].InnerText);
category = config["Category"].InnerText;
- languagename = config["LanguageName"].InnerText;
+ if (config["LanguageName"] != null)
+ languagename = config["LanguageName"].InnerText;
+
+ if (config["ProjectType"] != null)
+ projecttype = config["ProjectType"].InnerText;
+
if (config["_Description"] != null) {
description = GettextCatalog.GetString
(config["_Description"].InnerText);
}
@@ -149,7 +166,14 @@
XmlElement files =
doc.DocumentElement["TemplateFiles"];
XmlNodeList nodes = files.ChildNodes;
foreach (XmlElement filenode in nodes) {
- FileDescriptionTemplate template = new
FileDescriptionTemplate(filenode.Attributes["DefaultName"].InnerText +
filenode.Attributes["DefaultExtension"].InnerText, filenode.InnerText);
+ string tfname = filenode.GetAttribute
("DefaultName") + filenode.GetAttribute ("DefaultExtension");
+ XmlElement domElem = filenode ["CompileUnit"];
+
+ FileDescriptionTemplate template;
+ if (domElem != null)
+ template = new FileDescriptionTemplate
(tfname, domElem);
+ else
+ template = new FileDescriptionTemplate
(tfname, filenode.InnerText);
this.files.Add(template);
}
}
@@ -174,5 +198,132 @@
}
}
}
+
+ public bool Create (Project project, string directory, string
language, string name)
+ {
+ StringParserService sps = (StringParserService)
ServiceManager.GetService (typeof (StringParserService));
+
+ if (WizardPath != null) {
+ //IProperties customizer = new
DefaultProperties();
+ //customizer.SetProperty("Template", item);
+ //customizer.SetProperty("Creator", this);
+ //WizardDialog wizard = new WizardDialog("File
Wizard", customizer, item.WizardPath);
+ //if (wizard.ShowDialog() == DialogResult.OK) {
+ //DialogResult = DialogResult.OK;
+ //}
+ return false;
+ } else {
+ string lastFile = null;
+ foreach (FileDescriptionTemplate newfile in
Files) {
+ string fileName = name;
+ string defaultName = newfile.Name;
+ IDotNetLanguageBinding languageBinding;
+
+ if (language != "") {
+ languageBinding =
GetDotNetLanguageBinding (language);
+ defaultName =
languageBinding.GetFileName (Path.GetFileNameWithoutExtension (defaultName));
+ }
+
+ if (fileName != null) {
+ if (Path.GetExtension (name) !=
Path.GetExtension (defaultName))
+ fileName = fileName +
Path.GetExtension (defaultName);
+ } else {
+ fileName = defaultName;
+ }
+
+ if (directory != null)
+ fileName = Path.Combine
(directory, fileName);
+
+ if (project != null &&
project.IsFileInProject (fileName)) {
+
Services.MessageService.ShowWarning (GettextCatalog.GetString ("The file '{0}'
already exists in the project.", Path.GetFileName (fileName)));
+ return false;
+ }
+
+ string content;
+ if (newfile.CodeDomContent != null)
+ content = GenerateContent
(newfile, language);
+ else
+ content = newfile.Content;
+
+ string ns = project != null ?
project.Name : "Global";
+ string[,] tags = { {"Name",
Path.GetFileNameWithoutExtension (fileName)}, {"Namespace", ns} };
+ content = sps.Parse (content, tags);
+
+ if (directory != null) {
+ if (System.IO.File.Exists
(fileName)) {
+ if
(!Services.MessageService.AskQuestion (GettextCatalog.GetString ("The file
'{0}' already exists. Do you want to replace it?.", Path.GetFileName
(fileName)), GettextCatalog.GetString ("MonoDevelop")))
+ return false;
+ }
+ StreamWriter sw = new
StreamWriter (fileName);
+ sw.Write (content);
+ sw.Close ();
+
+ if (project != null) {
+ ProjectFile pfile = new
ProjectFile (fileName, BuildAction.Compile);
+
project.ProjectFiles.Add (pfile);
+ }
+ lastFile = fileName;
+ } else {
+ // Guess the mime type of the
new file
+ string fn =
Path.GetTempFileName ();
+ string ext = Path.GetExtension
(fileName);
+ int n=0;
+ while (File.Exists (fn + n +
ext))
+ n++;
+ File.Move (fn, fn + n + ext);
+ string mimeType =
Gnome.Vfs.MimeType.GetMimeTypeForUri (fn + n + ext);
+ File.Delete (fn + n + ext);
+ if (mimeType == null ||
mimeType == "")
+ mimeType = "text";
+
+ IdeApp.Workbench.NewDocument
(fileName, mimeType, content);
+ }
+ }
+ if (lastFile != null)
+ IdeApp.Workbench.OpenDocument
(lastFile);
+
+ return true;
+ }
+ }
+
+ string GenerateContent (FileDescriptionTemplate newfile, string
language)
+ {
+ if (language == null || language == "")
+ throw new InvalidOperationException ("Language
not defined in CodeDom based template.");
+
+ IDotNetLanguageBinding binding =
GetDotNetLanguageBinding (language);
+
+ CodeDomProvider provider = binding.GetCodeDomProvider
();
+ if (provider == null)
+ throw new InvalidOperationException ("The
language '" + language + "' does not have support for CodeDom.");
+
+ XmlCodeDomReader xcd = new XmlCodeDomReader ();
+ CodeCompileUnit cu = xcd.ReadCompileUnit
(newfile.CodeDomContent);
+
+ ICodeGenerator generator = provider.CreateGenerator();
+ CodeGeneratorOptions options = new
CodeGeneratorOptions();
+
+ StringWriter sw = new StringWriter ();
+ generator.GenerateCodeFromCompileUnit (cu, sw, options);
+ sw.Close();
+
+ string txt = sw.ToString ();
+ int i = txt.IndexOf ("</autogenerated>");
+ if (i == -1) return txt;
+ i = txt.IndexOf ('\n', i);
+ if (i == -1) return txt;
+ i = txt.IndexOf ('\n', i + 1);
+ if (i == -1) return txt;
+
+ return txt.Substring (i+1);
+ }
+
+ IDotNetLanguageBinding GetDotNetLanguageBinding (string
language)
+ {
+ IDotNetLanguageBinding binding =
MonoDevelop.Projects.Services.Languages.GetBindingPerLanguageName (language) as
IDotNetLanguageBinding;
+ if (binding == null)
+ throw new InvalidOperationException ("Language
'" + language + "' not found");
+ return binding;
+ }
}
}
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
2005-12-13 14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
2005-12-13 14:37:12 UTC (rev 54284)
@@ -879,5 +879,8 @@
</Extension>
+ <Extension path = "/MonoDevelop/FileTemplates">
+ <FileTemplate resource = "EmptyClass.xft.xml"/>
+ </Extension>
</AddIn>
Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2005-12-13 14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
2005-12-13 14:37:12 UTC (rev 54284)
@@ -223,7 +223,6 @@
<File name="./MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs"
subtype="Code" buildaction="Compile" />
<File name="./MonoDevelop.Ide.Templates/FileTemplate.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.Ide.Templates/ICombineEntryDescriptor.cs"
subtype="Code" buildaction="Compile" />
- <File name="./MonoDevelop.Ide.Templates/INewFileCreator.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.Ide.Templates/ProjectDescriptor.cs"
subtype="Code" buildaction="Compile" />
<File name="./MonoDevelop.Ide.Templates/ProjectTemplate.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.Ide.Templates/TextTemplate.cs" subtype="Code"
buildaction="Compile" />
@@ -236,6 +235,7 @@
<File name="./options/TipsOfTheDay.xml" subtype="Code"
buildaction="Nothing" />
<File name="./MonoDevelop.Ide.Gui/AddinUpdateHandler.cs" subtype="Code"
buildaction="Compile" />
<File name="./MonoDevelop.Ide.Gui.OptionPanels/AddInsOptionsPanel.cs"
subtype="Code" buildaction="Compile" />
+ <File name="./templates" subtype="Directory" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Core"
/>
@@ -246,7 +246,7 @@
<ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Dock"
/>
<ProjectReference type="Project" localcopy="True"
refto="MonoDevelop.Components" />
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp,
Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
</Project>
\ No newline at end of file
Added: trunk/monodevelop/Core/src/MonoDevelop.Ide/templates/EmptyClass.xft.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/templates/EmptyClass.xft.xml
2005-12-13 14:36:43 UTC (rev 54283)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/templates/EmptyClass.xft.xml
2005-12-13 14:37:12 UTC (rev 54284)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<Template Originator="Lluis Sanchez" Created="3/09/2001"
LastModified="3/09/2001">
+
+ <TemplateConfiguration>
+ <_Name>Empty Class</_Name>
+ <Icon>md-empty-file-icon</Icon>
+ <Category>General</Category>
+ <LanguageName>*</LanguageName>
+ <_Description>Creates an empty class.</_Description>
+ </TemplateConfiguration>
+
+ <TemplateFiles>
+ <File DefaultName="EmptyClass">
+
+ <CompileUnit>
+ <Namespaces>
+ <Namespace Name="${Namespace}">
+ <Imports>
+ <NamespaceImport
Namespace="System" />
+ </Imports>
+ <Types>
+ <TypeDeclaration
Name="${Name}" IsClass="true">
+ <Members>
+
<Constructor />
+ </Members>
+ </TypeDeclaration>
+ </Types>
+ </Namespace>
+ </Namespaces>
+ </CompileUnit>
+
+ </File>
+ </TemplateFiles>
+
+ <FileOptions/>
+
+</Template>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches