Permalink
Browse files

2008-07-27 Ivan N. Zlatev <contact@i-nz.net>

	* Fix the creation of new files.


svn path=/trunk/mwf-designer/; revision=108945
  • Loading branch information...
ivanz committed Jul 27, 2008
1 parent 4c50dfe commit e513d598083897d8e7ab1c1bb3cbb51ce0604fbd
Showing with 27 additions and 11 deletions.
  1. +4 −0 ChangeLog
  2. +1 −1 mwf-designer.vpj
  3. +20 −8 src/DesignTime/CodeProvider.cs
  4. +2 −2 src/UI/MainView.cs
View
@@ -1,3 +1,7 @@
+2008-07-27 Ivan N. Zlatev <contact@i-nz.net>
+
+ * Fix the creation of new files.
+
2008-07-24 Ivan N. Zlatev <contact@i-nz.net>
* DesignTime/CodeProvider.cs: Make the search for a code behind file
View
@@ -14,7 +14,7 @@
MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer"
SaveOption="SaveWorkspaceFiles"
- RunFromDir="%rw"
+ RunFromDir="%rp"
ClearProcessBuffer="1"
DependsRef="Release">
<Exec CmdLine="make mono-design"/>
@@ -80,17 +80,14 @@ public CodeProvider (string fileName, ITypeResolutionService resolutionSvc)
if (fileName == null)
throw new ArgumentNullException ("fileName");
- _codeBehindFileName = GetCodeBehindFileName (fileName);
- if (!File.Exists (_codeBehindFileName))
- throw new InvalidOperationException ("No codebehind file for " + fileName);
-
_fileName = fileName;
+ _codeBehindFileName = FindCodeBehindFile (_fileName);
_provider = GetCodeProvider (fileName);
_informationProvider = new EnvironmentInformationProvider (resolutionSvc);
}
- internal static string GetCodeBehindFileName (string file)
+ private static string FindCodeBehindFile (string file)
{
string codeBehindFileName = Path.Combine (Path.GetDirectoryName (file),
(Path.GetFileNameWithoutExtension (file) +
@@ -105,9 +102,19 @@ internal static string GetCodeBehindFileName (string file)
return null;
}
- public static bool IsValid (string file)
+ public static string GetCodeBehindFileName (string file)
{
- return GetCodeBehindFileName (file) != null;
+ if (string.IsNullOrEmpty (file))
+ throw new ArgumentException ("file");
+
+ return Path.Combine (Path.GetDirectoryName (file),
+ (Path.GetFileNameWithoutExtension (file) +
+ ".Designer" + Path.GetExtension (file)));
+ }
+
+ public static bool IsValidFile (string file)
+ {
+ return FindCodeBehindFile (file) != null;
}
public CodeDomProvider CodeDomProvider {
@@ -117,7 +124,9 @@ public static bool IsValid (string file)
public CodeCompileUnit Parse ()
{
- return MergeParse (_fileName, _codeBehindFileName);
+ if (_codeBehindFileName != null)
+ return MergeParse (_fileName, _codeBehindFileName);
+ return null;
}
// The .Designer partial file produced by Visual Studio and SharpDevelop
@@ -200,6 +209,9 @@ private CodeTypeDeclaration GetFirstValidType (CodeCompileUnit document, out str
public void Write (CodeCompileUnit unit)
{
+ if (_codeBehindFileName == null)
+ return;
+
PreProcessCompileUnit (unit);
string namesp = null;
View
@@ -70,7 +70,7 @@ private void openToolStripMenuItem_Click (object sender, EventArgs e)
if (surfaceTabs.TabPages.ContainsKey (dialog.FileName)) {// tab page for file already existing
surfaceTabs.SelectedTab = surfaceTabs.TabPages[dialog.FileName];
} else {
- if (CodeProvider.IsValid (dialog.FileName))
+ if (CodeProvider.IsValidFile (dialog.FileName))
LoadDocument (dialog.FileName, _workspace);
else
MessageBox.Show ("No corresponding .Designer file found for " + dialog.FileName);
@@ -159,7 +159,7 @@ private void newToolStripMenuItem_Click (object sender, EventArgs e)
NewFileDialog dialog = new NewFileDialog (TemplateManager.AvailableTemplates);
if (dialog.ShowDialog () == DialogResult.OK) {
TemplateManager.WriteCode (dialog.Template, dialog.File, CodeProvider.GetCodeBehindFileName (dialog.File),
- dialog.Namespace, dialog.Class);
+ dialog.Namespace, dialog.Class);
this.LoadDocument (dialog.File, _workspace);
}
}

0 comments on commit e513d59

Please sign in to comment.