|
|
|
@ -32,16 +32,16 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// This class is for creating a new "empty" file
|
|
|
|
/// This class is for creating a new "empty" file
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class NewFileDialog : BaseSharpDevelopForm, INewFileCreator |
|
|
|
public class NewFileDialog : BaseSharpDevelopForm |
|
|
|
{ |
|
|
|
{ |
|
|
|
ArrayList alltemplates = new ArrayList(); |
|
|
|
ArrayList alltemplates = new ArrayList(); |
|
|
|
ArrayList categories = new ArrayList(); |
|
|
|
ArrayList categories = new ArrayList(); |
|
|
|
Hashtable icons = new Hashtable(); |
|
|
|
Hashtable icons = new Hashtable(); |
|
|
|
bool allowUntitledFiles; |
|
|
|
bool allowUntitledFiles; |
|
|
|
string basePath; |
|
|
|
string basePath; |
|
|
|
List<string> createdFiles = new List<string>(); |
|
|
|
List<KeyValuePair<string, PropertyGroup>> createdFiles = new List<KeyValuePair<string, PropertyGroup>>(); |
|
|
|
|
|
|
|
|
|
|
|
public List<string> CreatedFiles { |
|
|
|
public List<KeyValuePair<string, PropertyGroup>> CreatedFiles { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return createdFiles; |
|
|
|
return createdFiles; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -367,16 +367,21 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SaveFile(string filename, string content, string languageName, bool showFile) |
|
|
|
public void SaveFile(FileDescriptionTemplate newfile, string content) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string parsedFileName = StringParser.Parse(filename); |
|
|
|
string parsedFileName = StringParser.Parse(newfile.Name); |
|
|
|
IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(languageName), StringParser.Parse(content)); |
|
|
|
if (newfile.IsDependentFile && Path.IsPathRooted(parsedFileName)) { |
|
|
|
if (window != null) { |
|
|
|
File.WriteAllText(parsedFileName, StringParser.Parse(content), ParserService.DefaultFileEncoding); |
|
|
|
createdFiles.Add(parsedFileName); |
|
|
|
} else { |
|
|
|
|
|
|
|
IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(newfile.Language), StringParser.Parse(content)); |
|
|
|
|
|
|
|
if (window == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (Path.IsPathRooted(parsedFileName)) { |
|
|
|
if (Path.IsPathRooted(parsedFileName)) { |
|
|
|
window.ViewContent.Save(parsedFileName); |
|
|
|
window.ViewContent.Save(parsedFileName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
createdFiles.Add(new KeyValuePair<string, PropertyGroup>(parsedFileName, newfile.CreateMSBuildProperties())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string GenerateValidClassName(string className) |
|
|
|
string GenerateValidClassName(string className) |
|
|
|
@ -460,7 +465,7 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
ScriptRunner scriptRunner = new ScriptRunner(); |
|
|
|
ScriptRunner scriptRunner = new ScriptRunner(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) { |
|
|
|
foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) { |
|
|
|
SaveFile(newfile.Name, scriptRunner.CompileScript(item.Template, newfile), newfile.Language, true); |
|
|
|
SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile)); |
|
|
|
} |
|
|
|
} |
|
|
|
DialogResult = DialogResult.OK; |
|
|
|
DialogResult = DialogResult.OK; |
|
|
|
} |
|
|
|
} |
|
|
|
|