public void ResetLoadTimes() { lastSaveTime.Clear(); foreach (FilePath file in item.GetItemFiles(false)) { lastSaveTime [file] = GetLastWriteTime(file); } needsReload = false; }
public void ResetLoadTimes() { lastSaveTime.Clear(); reloadCheckTime.Clear(); foreach (FilePath file in item.GetItemFiles(false)) { lastSaveTime [file] = reloadCheckTime [file] = GetLastWriteTime(file); } // needsReload = false; if (reloadRequired != null) { InternalNeedsReload(); } }
public List <FilePath> GetFilesToDelete() { List <FilePath> files = new List <FilePath> (); if (radioDeleteAll.Active) { files.Add(item.BaseDirectory); if (item.BaseDirectory != item.ItemDirectory) { foreach (FilePath f in item.GetItemFiles(false)) { if (!f.IsChildPathOf(item.BaseDirectory)) { files.Add(f); } } } return(files); } foreach (Gtk.TreeIter it in paths.Values) { if ((bool)store.GetValue(it, 0)) { files.Add((string)store.GetValue(it, 3)); } } // If a directory is selected, remove all files of that directory, // since the dir will be deleted as a whole List <FilePath> cleaned = new List <FilePath> (files); foreach (FilePath path in files) { if (Directory.Exists(path)) { for (int n = 0; n < cleaned.Count; n++) { if (cleaned [n].IsChildPathOf(path)) { cleaned.RemoveAt(n); n--; } } } } return(cleaned); }
string Export(IProgressMonitor monitor, IWorkspaceFileObject obj, string[] includedChildIds, string targetPath, FileFormat format) { string rootSourceFile = obj.FileName; string sourcePath = Path.GetFullPath(Path.GetDirectoryName(rootSourceFile)); targetPath = Path.GetFullPath(targetPath); if (sourcePath != targetPath) { if (!CopyFiles(monitor, obj, obj.GetItemFiles(true), targetPath, true)) { return(null); } string newFile = Path.Combine(targetPath, Path.GetFileName(rootSourceFile)); if (IsWorkspaceItemFile(rootSourceFile)) { obj = ReadWorkspaceItem(monitor, newFile); } else { obj = (SolutionEntityItem)ReadSolutionItem(monitor, newFile); } using (obj) { List <FilePath> oldFiles = obj.GetItemFiles(true); ExcludeEntries(obj, includedChildIds); if (format != null) { obj.ConvertToFormat(format, true); } obj.Save(monitor); List <FilePath> newFiles = obj.GetItemFiles(true); foreach (FilePath f in newFiles) { if (!f.IsChildPathOf(targetPath)) { if (obj is Solution) { monitor.ReportError("The solution '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the root solution directory.", null); } else { monitor.ReportError("The project '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the project directory.", null); } } oldFiles.Remove(f); } // Remove old files foreach (FilePath file in oldFiles) { if (File.Exists(file)) { File.Delete(file); // Exclude empty directories FilePath dir = file.ParentDirectory; if (Directory.GetFiles(dir).Length == 0 && Directory.GetDirectories(dir).Length == 0) { try { Directory.Delete(dir); } catch (Exception ex) { monitor.ReportError(null, ex); } } } } return(obj.FileName); } } else { using (obj) { ExcludeEntries(obj, includedChildIds); if (format != null) { obj.ConvertToFormat(format, true); } obj.Save(monitor); return(obj.FileName); } } }
string Export (IProgressMonitor monitor, IWorkspaceFileObject obj, string[] includedChildIds, string targetPath, FileFormat format) { string rootSourceFile = obj.FileName; string sourcePath = Path.GetFullPath (Path.GetDirectoryName (rootSourceFile)); targetPath = Path.GetFullPath (targetPath); if (sourcePath != targetPath) { if (!CopyFiles (monitor, obj, obj.GetItemFiles (true), targetPath, true)) return null; string newFile = Path.Combine (targetPath, Path.GetFileName (rootSourceFile)); if (IsWorkspaceItemFile (rootSourceFile)) obj = ReadWorkspaceItem (monitor, newFile); else obj = (SolutionEntityItem) ReadSolutionItem (monitor, newFile); using (obj) { List<FilePath> oldFiles = obj.GetItemFiles (true); ExcludeEntries (obj, includedChildIds); if (format != null) obj.ConvertToFormat (format, true); obj.Save (monitor); List<FilePath> newFiles = obj.GetItemFiles (true); foreach (FilePath f in newFiles) { if (!f.IsChildPathOf (targetPath)) { if (obj is Solution) monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the root solution directory.", null); else monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the project directory.", null); } oldFiles.Remove (f); } // Remove old files foreach (FilePath file in oldFiles) { if (File.Exists (file)) { File.Delete (file); // Exclude empty directories FilePath dir = file.ParentDirectory; if (Directory.GetFiles (dir).Length == 0 && Directory.GetDirectories (dir).Length == 0) { try { Directory.Delete (dir); } catch (Exception ex) { monitor.ReportError (null, ex); } } } } return obj.FileName; } } else { using (obj) { ExcludeEntries (obj, includedChildIds); if (format != null) obj.ConvertToFormat (format, true); obj.Save (monitor); return obj.FileName; } } }
public ConfirmProjectDeleteDialog(IWorkspaceFileObject item) { this.Build(); this.item = item; store = new TreeStore(typeof(bool), typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string)); fileList.Model = store; TreeViewColumn col = new TreeViewColumn(); CellRendererToggle crt = new CellRendererToggle(); crt.Toggled += CrtToggled; col.PackStart(crt, false); col.AddAttribute(crt, "active", 0); CellRendererPixbuf crp = new CellRendererPixbuf(); col.PackStart(crp, false); col.AddAttribute(crp, "pixbuf", 1); CellRendererText cre = new CellRendererText(); col.PackStart(cre, true); col.AddAttribute(cre, "text", 2); col.AddAttribute(cre, "foreground", 4); fileList.AppendColumn(col); store.SetSortColumnId(2, SortType.Ascending); labelProjectDir.Text = item.BaseDirectory.FullPath; HashSet <string> itemFiles = new HashSet <string> (); HashSet <string> knownPaths = new HashSet <string> (); foreach (FilePath file in item.GetItemFiles(true)) { itemFiles.Add(file.FullPath); knownPaths.Add(file.FullPath + "~"); } foreach (string ext in knownExtensions) { knownPaths.Add(item.FileName.ChangeExtension(ext)); } FillDirRec(TreeIter.Zero, item, itemFiles, knownPaths, item.BaseDirectory, false); if (item.BaseDirectory != item.ItemDirectory) { // If the project has a custom base directory, make sure the project files // from the item directory are shown in the list foreach (FilePath f in item.GetItemFiles(false)) { if (!f.IsChildPathOf(item.BaseDirectory)) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile(f, IconSize.Menu); paths [f] = store.AppendValues(true, pix, f.FileName, f.ToString()); } } } if (item is SolutionItem) { var sol = ((SolutionItem)item).ParentSolution; var bdir = item.BaseDirectory; if (sol.GetItemFiles(false).Any(f => f.IsChildPathOf(bdir)) || sol.GetAllSolutionItems <SolutionEntityItem> ().Any(it => it != item && it.GetItemFiles(true).Any(f => f.IsChildPathOf(bdir)))) { radioDeleteAll.Sensitive = false; labelProjectDir.Text = GettextCatalog.GetString("Project directory can't be deleted since it contains files from other projects or solutions"); } } if (item.BaseDirectory.FileName == item.Name && radioDeleteAll.Sensitive) { radioDeleteAll.Active = true; fileList.Sensitive = false; } else { radioDeleteSel.Active = true; Focus = radioDeleteSel; } }
public ConfirmProjectDeleteDialog (IWorkspaceFileObject item) { this.Build (); this.item = item; store = new TreeStore (typeof(bool), typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string)); fileList.Model = store; TreeViewColumn col = new TreeViewColumn (); CellRendererToggle crt = new CellRendererToggle (); crt.Toggled += CrtToggled; col.PackStart (crt, false); col.AddAttribute (crt, "active", 0); CellRendererPixbuf crp = new CellRendererPixbuf (); col.PackStart (crp, false); col.AddAttribute (crp, "pixbuf", 1); CellRendererText cre = new CellRendererText (); col.PackStart (cre, true); col.AddAttribute (cre, "text", 2); col.AddAttribute (cre, "foreground", 4); fileList.AppendColumn (col); store.SetSortColumnId (2, SortType.Ascending); labelProjectDir.Text = item.BaseDirectory.FullPath; HashSet<string> itemFiles = new HashSet<string> (); HashSet<string> knownPaths = new HashSet<string> (); foreach (FilePath file in item.GetItemFiles (true)) { itemFiles.Add (file.FullPath); knownPaths.Add (file.FullPath + "~"); } foreach (string ext in knownExtensions) knownPaths.Add (item.FileName.ChangeExtension (ext)); FillDirRec (TreeIter.Zero, item, itemFiles, knownPaths, item.BaseDirectory, false); if (item.BaseDirectory != item.ItemDirectory) { // If the project has a custom base directory, make sure the project files // from the item directory are shown in the list foreach (FilePath f in item.GetItemFiles (false)) { if (!f.IsChildPathOf (item.BaseDirectory)) { Gdk.Pixbuf pix = DesktopService.GetPixbufForFile (f, IconSize.Menu); paths [f] = store.AppendValues (true, pix, f.FileName, f.ToString ()); } } } if (item is SolutionItem) { var sol = ((SolutionItem)item).ParentSolution; var bdir = item.BaseDirectory; if (sol.GetItemFiles (false).Any (f => f.IsChildPathOf (bdir)) || sol.GetAllSolutionItems<SolutionEntityItem> ().Any (it => it != item && it.GetItemFiles (true).Any (f => f.IsChildPathOf (bdir)))) { radioDeleteAll.Sensitive = false; labelProjectDir.Text = GettextCatalog.GetString ("Project directory can't be deleted since it contains files from other projects or solutions"); } } if (item.BaseDirectory.FileName == item.Name && radioDeleteAll.Sensitive) { radioDeleteAll.Active = true; fileList.Sensitive = false; } else { radioDeleteSel.Active = true; Focus = radioDeleteSel; } }