internal static void RemoveReferences(AddinData data, string[] fullIds) { AddinDescription desc = data.LoadAddinManifest(); AddinDescriptionView view = FindLoadedDescription(data); foreach (string ad in fullIds) { RemoveReference(desc, ad); if (view != null) { RemoveReference(view.AddinDescription, ad); } } if (view != null) { view.Update(); view.BeginInternalUpdate(); } try { desc.Save(); data.NotifyChanged(true); } finally { if (view != null) { view.EndInternalUpdate(); } } }
public static AddinData GetAddinData(DotNetProject project) { AddinData data = project.ExtendedProperties ["MonoDevelop.AddinAuthoring"] as AddinData; if (data != null) { return(data); } if (data == null) { foreach (ProjectFile pfile in project.Files) { if (pfile.Name.EndsWith(".addin.xml") || pfile.Name.EndsWith(".addin")) { return(new AddinData(project)); } } ProjectDom dom = ProjectDomService.GetProjectDom(project); if (dom != null && dom.Attributes.Any( a => a.AttributeType.FullName == "Mono.Addins.AddinAttribute" || a.AttributeType.FullName == "Mono.Addins.AddinRootAttribute" )) { return(new AddinData(project)); } } return(null); }
public static AddinData GetAddinData(DotNetProject project) { // Extensibility options are only available when a project belongs to a solution if (project.ParentSolution == null) { return(null); } AddinData data = project.ExtendedProperties ["MonoDevelop.AddinAuthoring"] as AddinData; if (data != null) { return(data); } if (data == null) { foreach (ProjectFile pfile in project.Files) { if (pfile.Name.EndsWith(".addin.xml") || pfile.Name.EndsWith(".addin")) { return(new AddinData(project)); } } } return(null); }
static void OnEndBuild(object s, BuildEventArgs args) { if (args.Success && IdeApp.Workspace.IsOpen) { Dictionary <string, AddinRegistry> regs = new Dictionary <string, AddinRegistry> (); foreach (DotNetProject p in IdeApp.Workspace.GetAllSolutionItems <DotNetProject> ()) { AddinData data = AddinData.GetAddinData(p); if (data != null) { if (!regs.ContainsKey(data.AddinRegistry.RegistryPath)) { regs [data.AddinRegistry.RegistryPath] = data.AddinRegistry; } } } if (regs.Count > 0) { args.ProgressMonitor.BeginTask(AddinManager.CurrentLocalizer.GetString("Updating add-in registry"), regs.Count); foreach (AddinRegistry reg in regs.Values) { reg.Update(new ProgressStatusMonitor(args.ProgressMonitor, 2)); args.ProgressMonitor.Step(1); } args.ProgressMonitor.EndTask(); } } }
public void Fill (AddinDescription desc, AddinData data) { adesc = desc; comboNs.Entry.Text = desc.Namespace; entryVersion.Text = desc.Version; entryCompatVersion.Text = desc.CompatVersion; textviewDesc.Buffer.Text = desc.Description; entryAuthor.Text = desc.Author; entryLicense.Text = desc.Copyright; entryUrl.Text = desc.Url; checkIsRoot.Active = desc.IsRoot; notebook.ShowTabs = false; notebook.ShowBorder = false; if (desc.LocalId.Length == 0) { defaultId = System.IO.Path.GetFileNameWithoutExtension (data.Project.GetOutputFileName (ConfigurationSelector.Default)); entryIdentifier.Text = defaultId; } else entryIdentifier.Text = desc.LocalId; if (desc.Name.Length == 0) { defaultName = entryIdentifier.Text; entryName.Text = defaultName; } else entryName.Text = desc.Name; extensionEditor.SetData (adesc, data); extensionPointsEditor.SetData (adesc, data); }
public void ApplyFeature(SolutionFolder parentCombine, SolutionItem entry, Widget ed) { AddinFeatureWidget editor = (AddinFeatureWidget)ed; AddinData data = AddinData.EnableAddinAuthoringSupport((DotNetProject)entry); DotNetProject project = (DotNetProject)entry; if (editor.HasRegistryInfo) { project.GetAddinData().ApplicationName = editor.ApplicationName; } AddinDescription desc = data.LoadAddinManifest(); if (editor.AddinId.Length > 0) { desc.LocalId = editor.AddinId; } if (editor.AddinName.Length > 0) { desc.Name = editor.AddinName; } desc.Namespace = editor.AddinNamespace; desc.IsRoot = project.CompileTarget != CompileTarget.Library || editor.IsRoot; desc.Version = "1.0"; desc.Save(); data.NotifyChanged(); }
public IViewContent CreateContentForUri(string fileName) { DotNetProject p = IdeApp.Workspace.GetProjectContainingFile(fileName) as DotNetProject; AddinData data = AddinData.GetAddinData(p); return(new AddinDescriptionView(data)); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Pixbuf icon, ref Pixbuf closedIcon) { AddinData data = (AddinData)treeBuilder.GetParentDataItem(typeof(AddinData), false); label = AddinManager.CurrentLocalizer.GetString("Extensions ({0})", data.CachedAddinManifest.MainModule.Extensions.Count); icon = Context.GetIcon("md-extension-node"); }
public override bool AddToProject(SolutionItem parent, Project project, string language, string directory, string name) { // Replace template variables string cname = Path.GetFileNameWithoutExtension(name); string[,] tags = { { "Name", cname }, }; string content = addinTemplate.OuterXml; content = StringParserService.Parse(content, tags); // Create the manifest XmlDocument doc = new XmlDocument(); doc.LoadXml(content); string file = Path.Combine(directory, "manifest.addin.xml"); doc.Save(file); project.AddFile(file, BuildAction.EmbeddedResource); AddinData.EnableAddinAuthoringSupport((DotNetProject)project); return(true); }
public void OnUpdateAddExtension(CommandInfo cinfo) { if (CurrentNode.DataItem is ProjectFolder || CurrentNode.DataItem is DotNetProject) { DotNetProject p = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject; cinfo.Visible = p != null && AddinData.GetAddinData(p) != null; } }
void OnProjectChanged(object s, EventArgs a) { AddinData data = (AddinData)s; ITreeBuilder tb = Context.GetTreeBuilder(data.Project); if (tb != null) { tb.UpdateAll(); } }
public static void DisableAddinAuthoringSupport(DotNetProject project) { AddinData data = GetAddinData(project); project.ExtendedProperties.Remove("MonoDevelop.AddinAuthoring"); if (data != null && AddinSupportChanged != null) { AddinSupportChanged(project, false); } }
public void NotifyChanged() { foreach (DotNetProject p in solution.GetAllSolutionItems <DotNetProject> ()) { AddinData data = p.GetAddinData(); if (data != null) { data.NotifyChanged(false); } } }
public override void BuildChildNodes(ITreeBuilder builder, object dataObject) { if (dataObject is DotNetProject) { AddinData data = AddinData.GetAddinData((DotNetProject)dataObject); if (data != null) { builder.AddChild(data); } } }
public override void OnNodeAdded(object dataObject) { if (dataObject is DotNetProject) { AddinData data = AddinData.GetAddinData((DotNetProject)dataObject); if (data != null) { data.Changed += OnProjectChanged; } } }
public override void BuildChildNodes(ITreeBuilder builder, object dataObject) { AddinData data = (AddinData)dataObject; ProjectFile file = data.Project.GetProjectFile(data.AddinManifestFileName); if (file != null) { builder.AddChild(file); } builder.AddChild(data.CachedAddinManifest.ExtensionPoints); builder.AddChild(data.CachedAddinManifest.MainModule.Extensions); }
public void Store() { if (checkEnable.Active) { AddinFeature f = new AddinFeature(); f.ApplyFeature(project.ParentFolder, project, optionsWidget); } else { AddinData.DisableAddinAuthoringSupport(project); } }
internal static void AddReferences(AddinData data, object[] addins) { AddinDescription desc = data.CachedAddinManifest; foreach (Addin ad in addins) { AddReference(desc, ad); } data.SaveAddinManifest(); data.NotifyChanged(false); }
internal static void RemoveReferences(AddinData data, string[] fullIds) { AddinDescription desc = data.CachedAddinManifest; foreach (string ad in fullIds) { RemoveReference(desc, ad); } data.SaveAddinManifest(); data.NotifyChanged(false); }
static AddinDescriptionView FindLoadedDescription(AddinData data) { foreach (Document doc in IdeApp.Workbench.Documents) { AddinDescriptionView view = doc.GetContent <AddinDescriptionView> (); if (view != null && view.Data == data) { return(view); } } return(null); }
public static string GetAddinApplication(this Solution sol) { foreach (DotNetProject dnp in sol.GetAllSolutionItems <DotNetProject> ()) { AddinData data = AddinData.GetAddinData(dnp); if (data != null && data.ApplicationName != null) { return(data.ApplicationName); } } return(null); }
public bool CanCreateContentForUri(string fileName) { if (fileName.EndsWith(".addin.xml") || fileName.EndsWith(".xml")) { if (IdeApp.Workspace.IsOpen) { DotNetProject p = IdeApp.Workspace.GetProjectContainingFile(fileName) as DotNetProject; return(p != null && AddinData.GetAddinData(p) != null); } } return(false); }
public static bool HasAddinRoot(this Solution sol) { foreach (DotNetProject dnp in sol.GetAllSolutionItems <DotNetProject> ()) { AddinData data = AddinData.GetAddinData(dnp); if (data != null && data.IsRoot) { return(true); } } return(false); }
public override void DeleteItem() { DotNetProject p = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject; AddinData data = AddinData.GetAddinData(p); AddinDependency adep = (AddinDependency)CurrentNode.DataItem; string q = AddinManager.CurrentLocalizer.GetString("Are you sure you want to remove the reference to add-in '{0}'?", Addin.GetIdName(adep.AddinId)); if (MessageService.Confirm(q, AlertButton.Remove)) { AddinAuthoringService.RemoveReferences(data, new string[] { adep.FullAddinId }); } }
public void AddAddinDependency() { DotNetProject p = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject; AddinData data = AddinData.GetAddinData(p); ExtensionSelectorDialog dlg = new ExtensionSelectorDialog(data.AddinRegistry, null, data.CachedAddinManifest.IsRoot, true); if (dlg.Run() == (int)Gtk.ResponseType.Ok) { AddinAuthoringService.AddReferences(data, dlg.GetSelection()); } dlg.Destroy(); }
public override void ActivateItem() { AddinData data = (AddinData)CurrentNode.GetParentDataItem(typeof(AddinData), false); Document doc = IdeApp.Workbench.OpenDocument(data.AddinManifestFileName); if (doc != null) { AddinDescriptionView view = doc.GetContent <AddinDescriptionView> (); if (view != null) { view.ShowExtensions(); } } }
protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration) { BuildResult res = base.Build(monitor, entry, configuration); if (res.ErrorCount > 0 || !(entry is DotNetProject)) { return(res); } DotNetProject project = (DotNetProject)entry; AddinData data = AddinData.GetAddinData(project); if (data == null) { return(res); } monitor.Log.WriteLine(AddinManager.CurrentLocalizer.GetString("Verifying add-in description...")); string fileName = data.AddinManifestFileName; ProjectFile file = data.Project.Files.GetFile(fileName); if (file == null) { return(res); } string addinFile; if (file.BuildAction == BuildAction.EmbeddedResource) { addinFile = project.GetOutputFileName(ConfigurationSelector.Default); } else { addinFile = file.FilePath; } AddinDescription desc = data.AddinRegistry.GetAddinDescription(new ProgressStatusMonitor(monitor), addinFile); StringCollection errors = desc.Verify(); foreach (string err in errors) { res.AddError(data.AddinManifestFileName, 0, 0, "", err); monitor.Log.WriteLine("ERROR: " + err); } return(res); }
public AddinDescriptionView (AddinData data) { this.data = data; ContentName = data.Project.Name + " Extension Model"; //ContentName = data.AddinManifestFileName; Project = data.Project; descWidget = new AddinDescriptionWidget (); descWidget.Changed += delegate { IsDirty = true; }; data.Changed += OnDataChanged; Reload (); }
DotNetProject FindProjectImplementingAddin(string fullId) { if (Project.ParentSolution == null) { return(null); } foreach (DotNetProject p in Project.ParentSolution.GetAllSolutionItems <DotNetProject> ()) { AddinData adata = AddinData.GetAddinData(p); if (adata != null && adata.CachedAddinManifest.AddinId == fullId) { return(p); } } return(null); }
public AddinDescriptionView(AddinData data) { this.data = data; ContentName = data.Project.Name + " Extension Model"; //ContentName = data.AddinManifestFileName; Project = data.Project; descWidget = new AddinDescriptionWidget(); descWidget.Changed += delegate { IsDirty = true; }; data.Changed += OnDataChanged; Reload(); }
public AddinDescriptionView(AddinData data, string manifestFile) { this.data = data; this.manifestFile = manifestFile; ContentName = manifestFile; Project = data.Project; descWidget = new AddinDescriptionWidget(); descWidget.Changed += delegate { IsDirty = true; }; data.Changed += OnDataChanged; Reload(); }
public AddinDescriptionView (AddinData data, string manifestFile) { this.data = data; this.manifestFile = manifestFile; ContentName = manifestFile; Project = data.Project; descWidget = new AddinDescriptionWidget (); descWidget.Changed += delegate { IsDirty = true; }; data.Changed += OnDataChanged; Reload (); }
public override void Save(IProgressMonitor monitor, SolutionEntityItem entry) { base.Save(monitor, entry); DotNetProject project = entry as DotNetProject; if (project != null) { AddinData data = AddinData.GetAddinData(project); if (data != null) { Gtk.Application.Invoke(delegate { data.CheckOutputPath(); }); } } }
internal static void AddReferences (AddinData data, object[] addins) { AddinDescription desc = data.CachedAddinManifest; foreach (Addin ad in addins) AddReference (desc, ad); data.SaveAddinManifest (); data.NotifyChanged (false); }
internal static void RemoveReferences (AddinData data, string[] fullIds) { AddinDescription desc = data.CachedAddinManifest; foreach (string ad in fullIds) RemoveReference (desc, ad); data.SaveAddinManifest (); data.NotifyChanged (false); }
public static AddinData EnableAddinAuthoringSupport (DotNetProject project) { AddinData data = GetAddinData (project); if (data != null) return data; data = new AddinData (project); project.ExtendedProperties ["MonoDevelop.AddinAuthoring"] = data; if (AddinSupportChanged != null) AddinSupportChanged (project, true); return data; }
public void Fill (AddinData data, AddinDescription pdesc, string path) { Fill (data.AddinRegistry, data.CachedAddinManifest, pdesc, path); }
public ExtensionEditorView (AddinDescription desc, AddinData data): base (desc, data) { }
internal static void RemoveReferences (AddinData data, string[] fullIds) { AddinDescription desc = data.LoadAddinManifest (); AddinDescriptionView view = FindLoadedDescription (data); foreach (string ad in fullIds) { RemoveReference (desc, ad); if (view != null) RemoveReference (view.AddinDescription, ad); } if (view != null) { view.Update (); view.BeginInternalUpdate (); } try { desc.Save (); data.NotifyChanged (true); } finally { if (view != null) view.EndInternalUpdate (); } }
public void SetData (AddinDescription desc, AddinData data) { this.data = data; this.adesc = desc; Fill (); }
static AddinDescriptionView FindLoadedDescription (AddinData data) { foreach (Document doc in IdeApp.Workbench.Documents) { AddinDescriptionView view = doc.GetContent <AddinDescriptionView> (); if (view != null && view.Data == data) return view; } return null; }