public void RemoveItem() { ProjectFolder folder = (ProjectFolder) CurrentNode.DataItem as ProjectFolder; bool yes = Runtime.MessageService.AskQuestion (String.Format (GettextCatalog.GetString ("Do you want to remove folder {0}?"), folder.Name)); if (!yes) return; Project project = folder.Project; ProjectFile[] files = folder.Project.ProjectFiles.GetFilesInPath (folder.Path); ProjectFile[] inParentFolder = project.ProjectFiles.GetFilesInPath (Path.GetDirectoryName (folder.Path)); if (inParentFolder.Length == files.Length) { // This is the last folder in the parent folder. Make sure we keep // a reference to the folder, so it is not deleted from the tree. ProjectFile folderFile = new ProjectFile (Path.GetDirectoryName (folder.Path)); folderFile.Subtype = Subtype.Directory; project.ProjectFiles.Add (folderFile); } foreach (ProjectFile file in files) folder.Project.ProjectFiles.Remove (file); // folder.Remove (); Runtime.ProjectService.SaveCombine(); }
/// <summary> /// <para>Adds a <see cref='.ProjectFile'/> with the specified value to the /// <see cref='.ProjectFileCollection'/> .</para> /// </summary> /// <param name='value'>The <see cref='.ProjectFile'/> to add.</param> /// <returns> /// <para>The index at which the new element was inserted.</para> /// </returns> /// <seealso cref='.ProjectFileCollection.AddRange'/> public int Add(ProjectFile value) { int i = List.Add(value); if (project != null) { if (value.Project != null) throw new InvalidOperationException ("ProjectFile already belongs to a project"); value.SetProject (project); project.NotifyFileAddedToProject (value); } return i; }
/// <summary> /// <para>Returns the index of a <see cref='.ProjectFile'/> in /// the <see cref='.ProjectFileCollection'/> .</para> /// </summary> /// <param name='value'>The <see cref='.ProjectFile'/> to locate.</param> /// <returns> /// <para>The index of the <see cref='.ProjectFile'/> of <paramref name='value'/> in the /// <see cref='.ProjectFileCollection'/>, if found; otherwise, -1.</para> /// </returns> /// <seealso cref='.ProjectFileCollection.Contains'/> public int IndexOf(ProjectFile value) { return List.IndexOf(value); }
/// <summary> /// <para>Copies the <see cref='.ProjectFileCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the /// specified index.</para> /// </summary> /// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.ProjectFileCollection'/> .</para></param> /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param> /// <returns> /// <para>None.</para> /// </returns> /// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.ProjectFileCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception> /// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception> /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception> /// <seealso cref='System.Array'/> public void CopyTo(ProjectFile[] array, int index) { List.CopyTo(array, index); }
/// <summary> /// <para>Gets a value indicating whether the /// <see cref='.ProjectFileCollection'/> contains the specified <see cref='.ProjectFile'/>.</para> /// </summary> /// <param name='value'>The <see cref='.ProjectFile'/> to locate.</param> /// <returns> /// <para><see langword='true'/> if the <see cref='.ProjectFile'/> is contained in the collection; /// otherwise, <see langword='false'/>.</para> /// </returns> /// <seealso cref='.ProjectFileCollection.IndexOf'/> public bool Contains(ProjectFile value) { return List.Contains(value); }
public ProjectFile AddFile(string filename, BuildAction action) { foreach (ProjectFile fInfo in ProjectFiles) { if (fInfo.Name == filename) { return fInfo; } } ProjectFile newFileInformation = new ProjectFile (filename, action); ProjectFiles.Add (newFileInformation); return newFileInformation; }
public ProjectFileRenamedEventArgs(Project project, ProjectFile file, string oldName) : base(project, file) { this.oldName = oldName; }
public void AddNewFolder() { Project project = CurrentNode.GetParentDataItem (typeof(Project), true) as Project; string baseFolderPath = GetFolderPath (CurrentNode.DataItem); string directoryName = Path.Combine (baseFolderPath, GettextCatalog.GetString("New Folder")); int index = -1; if (Directory.Exists(directoryName)) { while (Directory.Exists(directoryName + (++index + 1))) ; } if (index >= 0) { directoryName += index + 1; } Directory.CreateDirectory (directoryName); ProjectFile newFolder = new ProjectFile (directoryName); newFolder.Subtype = Subtype.Directory; project.ProjectFiles.Add (newFolder); Tree.AddNodeInsertCallback (new ProjectFolder (directoryName, project), new TreeNodeCallback (OnFileInserted)); }
void AddFile(ProjectFile file, Project project) { ITreeBuilder tb = Context.GetTreeBuilder (); if (file.BuildAction != BuildAction.EmbedAsResource) { string filePath = Path.GetDirectoryName (file.Name); object data; if (file.Subtype == Subtype.Directory) data = new ProjectFolder (file.Name, project); else data = file; // Already there? if (tb.MoveToObject (data)) return; if (filePath != project.BaseDirectory) { if (tb.MoveToObject (new ProjectFolder (filePath, project))) tb.AddChild (data); else { // Make sure there is a path to that folder tb = FindParentFolderNode (filePath, project); if (tb != null) tb.UpdateChildren (); } } else { if (tb.MoveToObject (project)) tb.AddChild (data); } } else { if (tb.MoveToObject (new ResourceFolder (project))) tb.AddChild (file); } }
internal void NotifyFileChangedInProject(ProjectFile file) { OnFileChangedInProject (new ProjectFileEventArgs (this, file)); }
internal void NotifyFileRemovedFromProject(ProjectFile file) { isDirty = true; OnFileRemovedFromProject (new ProjectFileEventArgs (this, file)); }
internal void NotifyFileAddedToProject(ProjectFile file) { isDirty = true; OnFileAddedToProject (new ProjectFileEventArgs (this, file)); }
public void SearchNewFiles() { if (newFileSearch == NewFileSearch.None) { return; } StringCollection newFiles = new StringCollection(); StringCollection collection = Runtime.FileUtilityService.SearchDirectory (BaseDirectory, "*"); foreach (string sfile in collection) { string extension = Path.GetExtension(sfile).ToUpper(); string file = Path.GetFileName (sfile); if (!IsFileInProject(sfile) && extension != ".SCC" && // source safe control files -- Svante Lidmans extension != ".DLL" && extension != ".PDB" && extension != ".EXE" && extension != ".CMBX" && extension != ".PRJX" && extension != ".SWP" && extension != ".MDSX" && extension != ".MDS" && extension != ".MDP" && extension != ".PIDB" && !file.EndsWith ("make.sh") && !file.EndsWith ("~") && !file.StartsWith (".") && !(Path.GetDirectoryName(sfile).IndexOf("CVS") != -1) && !(Path.GetDirectoryName(sfile).IndexOf(".svn") != -1) && !file.StartsWith ("Makefile") && !Path.GetDirectoryName(file).EndsWith("ProjectDocumentation")) { newFiles.Add(sfile); } } if (newFiles.Count > 0) { if (newFileSearch == NewFileSearch.OnLoadAutoInsert) { foreach (string file in newFiles) { ProjectFile newFile = new ProjectFile(file); newFile.BuildAction = IsCompileable(file) ? BuildAction.Compile : BuildAction.Nothing; ProjectFiles.Add(newFile); } } else { Runtime.DispatchService.GuiDispatch (new MessageHandler (new IncludeFilesDialog (this, newFiles).ShowDialog)); } } }
public void AddFile(ProjectFile projectFile) { ProjectFiles.Add (projectFile); }
/// <summary> /// <para>Inserts a <see cref='.ProjectFile'/> into the <see cref='.ProjectFileCollection'/> at the specified index.</para> /// </summary> /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param> /// <param name=' value'>The <see cref='.ProjectFile'/> to insert.</param> /// <returns><para>None.</para></returns> /// <seealso cref='.ProjectFileCollection.Add'/> public void Insert(int index, ProjectFile value) { List.Insert(index, value); if (project != null) { if (value.Project != null) throw new InvalidOperationException ("ProjectFile already belongs to a project"); value.SetProject (project); project.NotifyFileAddedToProject (value); } }
void RemoveFile(ProjectFile file, Project project) { ITreeBuilder tb = Context.GetTreeBuilder (); if (file.Subtype == Subtype.Directory) { if (!tb.MoveToObject (new ProjectFolder (file.Name, project))) return; tb.MoveToParent (); tb.UpdateAll (); return; } else { if (tb.MoveToObject (file)) { tb.Remove (true); if (file.BuildAction == BuildAction.EmbedAsResource) return; } else { string parentPath = Path.GetDirectoryName (file.Name); if (!tb.MoveToObject (new ProjectFolder (parentPath, project))) return; } } while (tb.DataItem is ProjectFolder) { ProjectFolder f = (ProjectFolder) tb.DataItem; if (!Directory.Exists (f.Path) || project.ProjectFiles.GetFilesInPath (f.Path).Length == 0) tb.Remove (true); else break; } }
/// <summary> /// <para> Removes a specific <see cref='.ProjectFile'/> from the /// <see cref='.ProjectFileCollection'/> .</para> /// </summary> /// <param name='value'>The <see cref='.ProjectFile'/> to remove from the <see cref='.ProjectFileCollection'/> .</param> /// <returns><para>None.</para></returns> /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception> public void Remove(ProjectFile value) { List.Remove (value); if (project != null) { value.SetProject (null); project.NotifyFileRemovedFromProject (value); } }
public void RemoveItem() { ProjectFile file = CurrentNode.DataItem as ProjectFile; Project project = CurrentNode.GetParentDataItem (typeof(Project), false) as Project; bool yes = Runtime.MessageService.AskQuestion (String.Format (GettextCatalog.GetString ("Are you sure you want to remove file {0} from project {1}?"), Path.GetFileName (file.Name), project.Name)); if (!yes) return; ProjectFile[] inFolder = project.ProjectFiles.GetFilesInPath (Path.GetDirectoryName (file.Name)); if (inFolder.Length == 1 && inFolder [0] == file) { // This is the last project file in the folder. Make sure we keep // a reference to the folder, so it is not deleted from the tree. ProjectFile folderFile = new ProjectFile (Path.GetDirectoryName (file.Name)); folderFile.Subtype = Subtype.Directory; project.ProjectFiles.Add (folderFile); } project.ProjectFiles.Remove (file); Runtime.ProjectService.SaveCombine(); }
void AcceptEvent(object sender, EventArgs e) { TreeIter first; store.GetIterFirst(out first); TreeIter current = first; for (int i = 0; i < store.IterNChildren() ; ++i) { // get column raw values bool isSelected = (bool) store.GetValue(current, 0); string fileName = (string) store.GetValue(current, 1); // process raw values into actual project details string file = fileUtilityService.RelativeToAbsolutePath(project.BaseDirectory,fileName); ProjectFile finfo = new ProjectFile(file); if (isSelected) { finfo.BuildAction = project.IsCompileable(file) ? BuildAction.Compile : BuildAction.Nothing; } else { finfo.BuildAction = BuildAction.Exclude; } project.ProjectFiles.Add(finfo); store.IterNext(ref current); } Runtime.ProjectService.SaveCombine (); IncludeFilesDialogWidget.Destroy(); }
public ProjectFile CreateProjectFile(Project parentProject, string basePath) { NewFileDialog nfd = new NewFileDialog (); int res = nfd.Run (); nfd.Dispose (); if (res != (int) Gtk.ResponseType.Ok) return null; IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; int count = 1; string baseName = Path.GetFileNameWithoutExtension(window.ViewContent.UntitledName); string extension = Path.GetExtension(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; } // now we have a valid filename which we could use window.ViewContent.Save (fileName); ProjectFile newFileInformation = new ProjectFile(fileName, BuildAction.Compile); parentProject.ProjectFiles.Add (newFileInformation); return newFileInformation; }
public ProjectFileEventArgs(Project project, ProjectFile file) { this.project = project; this.file = file; }
/// <summary> /// <para>Copies the elements of an array to the end of the <see cref='.ProjectFileCollection'/>.</para> /// </summary> /// <param name='value'> /// An array of type <see cref='.ProjectFile'/> containing the objects to add to the collection. /// </param> /// <returns> /// <para>None.</para> /// </returns> /// <seealso cref='.ProjectFileCollection.Add'/> public void AddRange(ProjectFile[] value) { for (int i = 0; (i < value.Length); i = (i + 1)) { this.Add(value[i]); } }
public string CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage) { StringParserService stringParserService = Runtime.StringParserService; FileUtilityService fileUtilityService = Runtime.FileUtilityService; if (projectOptions.GetAttribute ("language") == "") { if (defaultLanguage == null || defaultLanguage == "") throw new InvalidOperationException ("Language not specified in template"); projectOptions.SetAttribute ("language", defaultLanguage); } Project_ project = Runtime.ProjectService.CreateProject (projectType, projectCreateInformation, projectOptions); if (project == null) { Runtime.MessageService.ShowError(String.Format (GettextCatalog.GetString ("Can't create project with type : {0}"), projectType)); return String.Empty; } string newProjectName = stringParserService.Parse(name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} }); project.Name = newProjectName; // Add References foreach (ProjectReference projectReference in references) { project.ProjectReferences.Add(projectReference); } foreach (FileDescriptionTemplate file in resources) { string fileName = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + stringParserService.Parse(file.Name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} }); ProjectFile resource = new ProjectFile (fileName); resource.BuildAction = BuildAction.EmbedAsResource; project.ProjectFiles.Add(resource); if (File.Exists(fileName)) { if (!Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("File {0} already exists, do you want to overwrite\nthe existing file ?"), fileName), GettextCatalog.GetString ("File already exists"))) { continue; } } try { if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } StreamWriter sr = File.CreateText(fileName); sr.Write(stringParserService.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}})); sr.Close(); } catch (Exception ex) { Runtime.MessageService.ShowError(ex, String.Format (GettextCatalog.GetString ("File {0} could not be written."), fileName)); } } // Add Files foreach (FileDescriptionTemplate file in files) { string fileName = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + stringParserService.Parse(file.Name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} }); project.ProjectFiles.Add(new ProjectFile(fileName)); if (File.Exists(fileName)) { if (!Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("File {0} already exists, do you want to overwrite\nthe existing file ?"), fileName), GettextCatalog.GetString ("File already exists"))) { continue; } } try { if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } StreamWriter sr = File.CreateText(fileName); sr.Write(stringParserService.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}})); sr.Close(); } catch (Exception ex) { Runtime.MessageService.ShowError(ex, String.Format (GettextCatalog.GetString ("File {0} could not be written."), fileName)); } } // Save project string projectLocation = fileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.ProjectBasePath) + newProjectName + ".mdp"; using (IProgressMonitor monitor = Runtime.TaskService.GetSaveProgressMonitor ()) { if (File.Exists(projectLocation)) { if (Runtime.MessageService.AskQuestion(String.Format (GettextCatalog.GetString ("Project file {0} already exists, do you want to overwrite\nthe existing file ?"), projectLocation), GettextCatalog.GetString ("File already exists"))) { project.Save (projectLocation, monitor); } } else { project.Save (projectLocation, monitor); } } return projectLocation; }
public static ArrayList GenerateWebProxyCode(Project project, ServiceDescription desc) { ArrayList fileList = null; string serviceName = String.Empty; if(desc.Services.Count > 0) { serviceName = desc.Services[0].Name; } else { serviceName = "UnknownService"; } string webRefFolder = "Web References"; string nmspace = GetNamespaceFromUri(desc.RetrievalUrl); StringBuilder savedir = new StringBuilder(); savedir.Append(project.BaseDirectory); savedir.Append(Path.DirectorySeparatorChar); savedir.Append(webRefFolder); savedir.Append(Path.DirectorySeparatorChar); savedir.Append(GetDirectoryFromUri(desc.RetrievalUrl) + Path.DirectorySeparatorChar + serviceName); // second, create the path if it doesn't exist if(!Directory.Exists(savedir.ToString())) Directory.CreateDirectory(savedir.ToString()); // generate the assembly ServiceDescriptionImporter importer = new ServiceDescriptionImporter(); importer.AddServiceDescription(desc, null, null); CodeNamespace codeNamespace = new CodeNamespace(nmspace); CodeCompileUnit codeUnit = new CodeCompileUnit(); codeUnit.Namespaces.Add(codeNamespace); importer.Import(codeNamespace, codeUnit); CodeDomProvider provider; System.CodeDom.Compiler.ICodeGenerator generator; String ext = String.Empty; switch(project.ProjectType) { case "C#": provider = new Microsoft.CSharp.CSharpCodeProvider(); ext = "cs"; break; case "VBNET": provider = new Microsoft.VisualBasic.VBCodeProvider(); ext = "vb"; break; default: // project type not supported error provider = null; break; } string filename = savedir.ToString() + Path.DirectorySeparatorChar + serviceName + "WebProxy." + ext; string wsdlfilename = savedir.ToString() + Path.DirectorySeparatorChar + serviceName + ".wsdl"; if(provider != null) { StreamWriter sw = new StreamWriter(filename); generator = provider.CreateGenerator(); CodeGeneratorOptions options = new CodeGeneratorOptions(); options.BracingStyle = "C"; generator.GenerateCodeFromCompileUnit(codeUnit, sw, options); sw.Close(); if(File.Exists(filename)) { fileList = new ArrayList(); // add project files to the list ProjectFile pfile = new ProjectFile(); pfile.Name = project.BaseDirectory + Path.DirectorySeparatorChar + webRefFolder; pfile.BuildAction = BuildAction.Nothing; pfile.Subtype = Subtype.WebReferences; pfile.DependsOn = String.Empty; pfile.Data = String.Empty; fileList.Add(pfile); /* pfile = new ProjectFile(); pfile.Name = project.BaseDirectory + @"\Web References\" + nmspace; pfile.BuildAction = BuildAction.Nothing; pfile.Subtype = Subtype.Directory; pfile.DependsOn = project.BaseDirectory + @"\Web References\"; pfile.WebReferenceUrl = String.Empty; fileList.Add(pfile); */ /* pfile = new ProjectFile(); pfile.Name = project.BaseDirectory + @"\Web References\" + nmspace + @"\" + serviceName; pfile.BuildAction = BuildAction.Nothing; pfile.Subtype = Subtype.Directory; pfile.DependsOn = project.BaseDirectory + @"\Web References\" + nmspace + @"\"; pfile.WebReferenceUrl = desc.RetrievalUrl; fileList.Add(pfile); */ // the Web Reference Proxy pfile = new ProjectFile(); pfile.Name = filename; pfile.BuildAction = BuildAction.Compile; pfile.Subtype = Subtype.Code; pfile.DependsOn = project.BaseDirectory + Path.DirectorySeparatorChar + webRefFolder; pfile.Data = desc.RetrievalUrl; fileList.Add(pfile); // the WSDL File used to generate the Proxy desc.Write(wsdlfilename); pfile = new ProjectFile(); pfile.Name = wsdlfilename; pfile.BuildAction = BuildAction.Nothing; pfile.Subtype = Subtype.Code; pfile.DependsOn = project.BaseDirectory + Path.DirectorySeparatorChar + webRefFolder; pfile.Data = desc.RetrievalUrl; fileList.Add(pfile); } } return fileList; }