public async void OnReload() { var solutions = new HashSet <Solution> (); Task task = Task.CompletedTask; using (ProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) { m.BeginTask(null, CurrentNodes.Length); foreach (ITreeNavigator node in CurrentNodes) { UnknownSolutionItem entry = (UnknownSolutionItem)node.DataItem; if (!entry.Enabled) { entry.Enabled = true; solutions.Add(entry.ParentSolution); } var am = m.BeginAsyncStep(1); var t = entry.ParentFolder.ReloadItem(am, entry).ContinueWith(ta => { am.Dispose(); }); task = Task.WhenAll(task, t); } m.EndTask(); } await task; await IdeApp.ProjectOperations.SaveAsync(solutions); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { UnknownSolutionItem entry = (UnknownSolutionItem)dataObject; if (entry.UnloadedEntry) { nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); Xwt.Drawing.Image gicon = Context.GetComposedIcon(nodeInfo.Icon, "fade"); if (gicon == null) { gicon = nodeInfo.Icon.WithAlpha(0.5); Context.CacheComposedIcon(nodeInfo.Icon, "fade", gicon); } nodeInfo.Icon = gicon; nodeInfo.Label = GettextCatalog.GetString("<span foreground='grey'>{0} <span size='small'>(Unavailable)</span></span>", GLib.Markup.EscapeText(entry.Name)); } else if (entry.LoadError.Length > 0) { nodeInfo.Icon = Context.GetIcon(Gtk.Stock.DialogError); nodeInfo.Label = GettextCatalog.GetString("{0} <span foreground='red' size='small'>(Load failed)</span>", GLib.Markup.EscapeText(entry.Name)); } else { nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); var gicon = Context.GetComposedIcon(nodeInfo.Icon, "fade"); if (gicon == null) { gicon = nodeInfo.Icon.WithAlpha(0.5); Context.CacheComposedIcon(nodeInfo.Icon, "fade", gicon); } nodeInfo.Icon = gicon; nodeInfo.Label = GLib.Markup.EscapeText(entry.Name); } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { UnknownSolutionItem entry = (UnknownSolutionItem)dataObject; if (entry.UnloadedEntry) { icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); Gdk.Pixbuf gicon = Context.GetComposedIcon(icon, "fade"); if (gicon == null) { gicon = ImageService.MakeTransparent(icon, 0.5); Context.CacheComposedIcon(icon, "fade", gicon); } icon = gicon; label = GettextCatalog.GetString("<span foreground='grey'>{0} <span size='small'>(Unavailable)</span></span>", GLib.Markup.EscapeText(entry.Name)); } else if (entry.LoadError.Length > 0) { icon = Context.GetIcon(Gtk.Stock.DialogError); label = GettextCatalog.GetString("{0} <span foreground='red' size='small'>(Load failed)</span>", GLib.Markup.EscapeText(entry.Name)); } else { icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); Gdk.Pixbuf gicon = Context.GetComposedIcon(icon, "fade"); if (gicon == null) { gicon = ImageService.MakeTransparent(icon, 0.5); Context.CacheComposedIcon(icon, "fade", gicon); } icon = gicon; label = GLib.Markup.EscapeText(entry.Name); } }
protected override DataNode ReadChild(XmlReader reader, DataItem parent) { if (reader.LocalName == "Entries") { if (reader.IsEmptyElement) { reader.Skip(); return(null); } string basePath = Path.GetDirectoryName(baseFile); reader.ReadStartElement(); ArrayList files = new ArrayList(); while (MoveToNextElement(reader)) { string nodefile = reader.GetAttribute("filename"); nodefile = FileService.RelativeToAbsolutePath(basePath, nodefile); files.Add(nodefile); reader.Skip(); } monitor.BeginTask(GettextCatalog.GetString("Loading solution: {0}", baseFile), files.Count); try { foreach (string nodefile in files) { try { if (Path.GetExtension(nodefile).ToLower() == ".mds") { entries.Add(ReadSolutionFolder(nodefile, monitor)); } else { SolutionEntityItem entry = (SolutionEntityItem)Services.ProjectService.ReadSolutionItem(monitor, nodefile); entries.Add(entry); } } catch (Exception ex) { UnknownSolutionItem entry = new UnknownSolutionItem(); entry.FileName = nodefile; entry.LoadError = ex.Message; entries.Add(entry); monitor.ReportError(GettextCatalog.GetString("Could not load item: {0}", nodefile), ex); } monitor.Step(1); } } finally { monitor.EndTask(); } reader.ReadEndElement(); return(null); } return(base.ReadChild(reader, parent)); }
public override void BuildChildNodes(ITreeBuilder treeBuilder, object dataObject) { UnknownSolutionItem entry = (UnknownSolutionItem)dataObject; if (entry.LoadError.Length > 0) { treeBuilder.AddChild(new TreeViewItem(GLib.Markup.EscapeText(entry.LoadError))); } }
public void OnUpdateReload(CommandInfo info) { foreach (ITreeNavigator node in CurrentNodes) { UnknownSolutionItem entry = (UnknownSolutionItem)node.DataItem; if (entry.ParentFolder == null) { info.Enabled = false; return; } } }
public void OnReload() { using (IProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) { m.BeginTask(null, CurrentNodes.Length); foreach (ITreeNavigator node in CurrentNodes) { UnknownSolutionItem entry = (UnknownSolutionItem)node.DataItem; entry.ParentFolder.ReloadItem(m, entry); m.Step(1); } m.EndTask(); } }
public void OnUnload() { HashSet <Solution> solutions = new HashSet <Solution> (); using (ProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) { m.BeginTask(null, CurrentNodes.Length); foreach (ITreeNavigator nav in CurrentNodes) { UnknownSolutionItem p = (UnknownSolutionItem)nav.DataItem; solutions.Add(p.ParentSolution); p.Enabled = false; p.ParentFolder.ReloadItem(m, p); m.Step(1); } m.EndTask(); } IdeApp.ProjectOperations.SaveAsync(solutions); }
public override void DeleteItem() { UnknownSolutionItem item = (UnknownSolutionItem)CurrentNode.DataItem; SolutionFolder cmb = item.ParentFolder; if (cmb == null) { return; } bool yes = MessageService.Confirm(GettextCatalog.GetString( "Do you really want to remove project '{0}' from solution '{1}'", item.FileName, cmb.Name), AlertButton.Remove); if (yes) { cmb.Items.Remove(item); item.Dispose(); IdeApp.ProjectOperations.Save(cmb.ParentSolution); } }
public void OnReload() { var solutions = new HashSet <Solution> (); using (ProgressMonitor m = IdeApp.Workbench.ProgressMonitors.GetProjectLoadProgressMonitor(true)) { m.BeginTask(null, CurrentNodes.Length); foreach (ITreeNavigator node in CurrentNodes) { UnknownSolutionItem entry = (UnknownSolutionItem)node.DataItem; if (!entry.Enabled) { entry.Enabled = true; solutions.Add(entry.ParentSolution); } entry.ParentFolder.ReloadItem(m, entry); m.Step(1); } m.EndTask(); } IdeApp.ProjectOperations.SaveAsync(solutions); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { UnknownSolutionItem entry = (UnknownSolutionItem)dataObject; if (entry is UnloadedSolutionItem) { nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); Xwt.Drawing.Image gicon = Context.GetComposedIcon(nodeInfo.Icon, "fade"); if (gicon == null) { gicon = nodeInfo.Icon.WithAlpha(0.5); Context.CacheComposedIcon(nodeInfo.Icon, "fade", gicon); } nodeInfo.Icon = gicon; nodeInfo.Label = GettextCatalog.GetString("{0} <span size='small'>(Unavailable)</span>", GLib.Markup.EscapeText(entry.Name)); nodeInfo.DisabledStyle = true; } else if (entry.LoadError.Length > 0) { nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project).WithAlpha(0.5); nodeInfo.Label = entry.Name; nodeInfo.StatusSeverity = TaskSeverity.Error; nodeInfo.StatusMessage = GettextCatalog.GetString("Load failed: ") + entry.LoadError; nodeInfo.DisabledStyle = true; } else { nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Project); var gicon = Context.GetComposedIcon(nodeInfo.Icon, "fade"); if (gicon == null) { gicon = nodeInfo.Icon.WithAlpha(0.5); Context.CacheComposedIcon(nodeInfo.Icon, "fade", gicon); } nodeInfo.Icon = gicon; nodeInfo.Label = GLib.Markup.EscapeText(entry.Name); } }
public override bool HasChildNodes(ITreeBuilder builder, object dataObject) { UnknownSolutionItem entry = (UnknownSolutionItem)dataObject; return(entry.LoadError.Length > 0); }
internal void LoadSolution(Solution sol, SlnFile sln, ProgressMonitor monitor, SolutionLoadContext ctx) { var version = sln.FormatVersion; //Parse the .sln file var folder = sol.RootFolder; sol.Version = "0.1"; //FIXME: monitor.BeginTask("Loading projects ..", sln.Projects.Count + 1); Dictionary <string, SolutionFolderItem> items = new Dictionary <string, SolutionFolderItem> (); List <string> sortedList = new List <string> (); List <Task> loadTasks = new List <Task> (); foreach (SlnProject sec in sln.Projects) { try { // Valid guid? new Guid(sec.TypeGuid); } catch (FormatException) { monitor.Step(1); //Use default guid as projectGuid LoggingService.LogDebug(GettextCatalog.GetString( "Invalid Project type guid '{0}' on line #{1}. Ignoring.", sec.Id, sec.Line)); continue; } string projTypeGuid = sec.TypeGuid.ToUpper(); string projectName = sec.Name; string projectPath = sec.FilePath; string projectGuid = sec.Id; lock (items) sortedList.Add(projectGuid); if (projTypeGuid == MSBuildProjectService.FolderTypeGuid) { //Solution folder SolutionFolder sfolder = new SolutionFolder(); sfolder.Name = projectName; sfolder.ItemId = projectGuid; DeserializeSolutionItem(monitor, sol, sfolder, sec); foreach (string f in ReadFolderFiles(sec)) { sfolder.Files.Add(MSBuildProjectService.FromMSBuildPath(Path.GetDirectoryName(sol.FileName), f)); } lock (items) items.Add(projectGuid, sfolder); monitor.Step(1); continue; } if (projectPath.StartsWith("http://")) { monitor.ReportWarning(GettextCatalog.GetString( "{0}({1}): Projects with non-local source (http://...) not supported. '{2}'.", sol.FileName, sec.Line, projectPath)); monitor.Step(1); continue; } string path = MSBuildProjectService.FromMSBuildPath(Path.GetDirectoryName(sol.FileName), projectPath); if (String.IsNullOrEmpty(path)) { monitor.ReportWarning(GettextCatalog.GetString( "Invalid project path found in {0} : {1}", sol.FileName, projectPath)); LoggingService.LogWarning(GettextCatalog.GetString( "Invalid project path found in {0} : {1}", sol.FileName, projectPath)); monitor.Step(1); continue; } projectPath = Path.GetFullPath(path); SolutionItem item = null; Task <SolutionItem> loadTask; DateTime ti = DateTime.Now; if (sol.IsSolutionItemEnabled(projectPath)) { loadTask = Services.ProjectService.ReadSolutionItem(monitor, projectPath, format, projTypeGuid, projectGuid, ctx); } else { loadTask = Task.FromResult <SolutionItem> (new UnloadedSolutionItem() { FileName = projectPath }); } var ft = loadTask.ContinueWith(ta => { try { item = ta.Result; if (item == null) { throw new UnknownSolutionItemTypeException(projTypeGuid); } } catch (Exception cex) { var e = UnwrapException(cex).First(); string unsupportedMessage = e.Message; if (e is UserException) { var ex = (UserException)e; LoggingService.LogError("{0}: {1}", ex.Message, ex.Details); monitor.ReportError(string.Format("{0}{1}{1}{2}", ex.Message, Environment.NewLine, ex.Details), null); } else { LoggingService.LogError(string.Format("Error while trying to load the project {0}", projectPath), e); monitor.ReportWarning(GettextCatalog.GetString( "Error while trying to load the project '{0}': {1}", projectPath, e.Message)); } SolutionItem uitem; uitem = new UnknownSolutionItem() { FileName = projectPath, LoadError = unsupportedMessage, }; item = uitem; item.ItemId = projectGuid; item.TypeGuid = projTypeGuid; } item.UnresolvedProjectDependencies = ReadSolutionItemDependencies(sec); // Deserialize the object DeserializeSolutionItem(monitor, sol, item, sec); lock (items) { if (!items.ContainsKey(projectGuid)) { items.Add(projectGuid, item); } else { monitor.ReportError(GettextCatalog.GetString("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null); } } monitor.Step(1); }); loadTasks.Add(ft); } Task.WaitAll(loadTasks.ToArray()); sol.LoadedProjects = new HashSet <string> (items.Keys); var nested = sln.Sections.GetSection("NestedProjects"); if (nested != null) { LoadNestedProjects(nested, items, monitor); } // Resolve project dependencies foreach (var it in items.Values.OfType <SolutionItem> ()) { if (it.UnresolvedProjectDependencies != null) { foreach (var id in it.UnresolvedProjectDependencies.ToArray()) { SolutionFolderItem dep; if (items.TryGetValue(id, out dep) && dep is SolutionItem) { it.UnresolvedProjectDependencies.Remove(id); it.ItemDependencies.Add((SolutionItem)dep); } } if (it.UnresolvedProjectDependencies.Count == 0) { it.UnresolvedProjectDependencies = null; } } } //Add top level folders and projects to the main folder foreach (string id in sortedList) { SolutionFolderItem ce; if (items.TryGetValue(id, out ce) && ce.ParentFolder == null) { folder.Items.Add(ce); } } //FIXME: This can be just SolutionConfiguration also! LoadSolutionConfigurations(sln.SolutionConfigurationsSection, sol, monitor); LoadProjectConfigurationMappings(sln.ProjectConfigurationsSection, sol, items, monitor); foreach (var e in sln.Sections) { string name = e.Id; if (name.StartsWith("MonoDevelopProperties.")) { int i = name.IndexOf('.'); LoadMonoDevelopConfigurationProperties(name.Substring(i + 1), e, sol, monitor); } } monitor.EndTask(); }
public static VersionControlItem CreateItem(object obj, bool projRecurse = true) { string path; bool isDir; IWorkspaceObject pentry; Repository repo; VersionInfo versionInfo = null; if (obj is ProjectFile) { ProjectFile file = (ProjectFile)obj; path = file.FilePath; isDir = false; pentry = file.Project; versionInfo = file.ExtendedProperties [typeof(VersionInfo)] as VersionInfo; } else if (obj is SystemFile) { SystemFile file = (SystemFile)obj; path = file.Path; isDir = false; pentry = file.ParentWorkspaceObject; } else if (obj is ProjectFolder) { ProjectFolder f = (ProjectFolder)obj; path = f.Path; isDir = true; pentry = f.ParentWorkspaceObject; } else if (!projRecurse && obj is Solution) { Solution sol = (Solution)obj; path = sol.FileName; isDir = false; pentry = sol; } else if (!projRecurse && obj is Project) { Project proj = (Project)obj; path = proj.FileName; isDir = false; pentry = proj; } else if (!projRecurse && obj is UnknownSolutionItem) { UnknownSolutionItem item = (UnknownSolutionItem)obj; path = item.FileName; isDir = false; pentry = item; } else if (obj is IWorkspaceObject) { pentry = ((IWorkspaceObject)obj); path = pentry.BaseDirectory; isDir = true; } else { return(null); } if (pentry == null) { return(null); } repo = VersionControlService.GetRepository(pentry); return(new VersionControlItem(repo, pentry, path, isDir, versionInfo)); }
public void OnEditUnknownSolutionItem() { UnknownSolutionItem si = (UnknownSolutionItem)CurrentNode.DataItem; IdeApp.Workbench.OpenDocument(si.FileName, project: null); }