示例#1
0
 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 IViewContent CreateContentForUri(string fileName)
        {
            DotNetProject p    = IdeApp.Workspace.GetProjectContainingFile(fileName) as DotNetProject;
            AddinData     data = AddinData.GetAddinData(p);

            return(new AddinDescriptionView(data));
        }
 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;
     }
 }
 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)
 {
     if (dataObject is DotNetProject)
     {
         AddinData data = AddinData.GetAddinData((DotNetProject)dataObject);
         if (data != null)
         {
             builder.AddChild(data);
         }
     }
 }
 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);
 }
示例#7
0
 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);
 }
示例#8
0
 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);
 }
示例#9
0
        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 });
            }
        }
示例#10
0
        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();
        }
示例#11
0
        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);
        }
示例#12
0
 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 void OnAddExtension()
        {
            DotNetProject p    = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject;
            AddinData     data = AddinData.GetAddinData(p);

            AddinDescription        desc = data.LoadAddinManifest();
            ExtensionSelectorDialog dlg  = new ExtensionSelectorDialog(data.AddinRegistry, null, desc.IsRoot, false);

            if (dlg.Run() == (int)ResponseType.Ok)
            {
                foreach (object ob in dlg.GetSelection())
                {
                    Console.WriteLine("pp s: " + ob);
                }
            }
            dlg.Destroy();
        }
示例#14
0
        public override void BuildChildNodes(ITreeBuilder treeBuilder, object dataObject)
        {
            base.BuildChildNodes(treeBuilder, dataObject);
            DotNetProject p = (DotNetProject)treeBuilder.GetParentDataItem(typeof(DotNetProject), false);

            if (p != null)
            {
                AddinData data = AddinData.GetAddinData(p);
                if (data != null)
                {
                    foreach (Dependency adep in data.CachedAddinManifest.MainModule.Dependencies)
                    {
                        treeBuilder.AddChild(adep);
                    }
                }
            }
        }
示例#15
0
        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();
                    });
                }
            }
        }
示例#16
0
        public override bool HasChildNodes(ITreeBuilder builder, object dataObject)
        {
            if (base.HasChildNodes(builder, dataObject))
            {
                return(true);
            }
            DotNetProject p = (DotNetProject)builder.GetParentDataItem(typeof(DotNetProject), false);

            if (p != null)
            {
                AddinData data = AddinData.GetAddinData(p);
                if (data != null)
                {
                    return(data.CachedAddinManifest.MainModule.Dependencies.Count > 0);
                }
            }
            return(false);
        }
        public AddinOptionPanelWidget(DotNetProject project)
        {
            this.Build();
            this.project = project;
            optionsWidget.Load(project.ParentSolution, project, true);

            AddinData data = AddinData.GetAddinData(project);

            if (data != null)
            {
                checkEnable.Active = true;
            }
            else
            {
                checkEnable.Active      = false;
                optionsWidget.Sensitive = false;
            }
        }
示例#18
0
 public FeatureSupportLevel GetSupportLevel(SolutionFolder parentCombine, SolutionItem entry)
 {
     if (entry is DotNetProject)
     {
         if (AddinData.GetAddinData((DotNetProject)entry) != null)
         {
             return(FeatureSupportLevel.Enabled);
         }
         else
         {
             return(FeatureSupportLevel.Supported);
         }
     }
     else
     {
         return(FeatureSupportLevel.NotSupported);
     }
 }
示例#19
0
 void ProjectReferenceAddedToProject(object sender, ProjectReferenceEventArgs e)
 {
     if (updating)
     {
         return;
     }
     if (e.ProjectReference.ReferenceType == ReferenceType.Project)
     {
         DotNetProject rp = project.ParentSolution.FindProjectByName(e.ProjectReference.Reference) as DotNetProject;
         if (rp != null)
         {
             AddinData adata = AddinData.GetAddinData(rp);
             if (adata != null)
             {
                 CachedAddinManifest.MainModule.Dependencies.Add(new AddinDependency(adata.CachedAddinManifest.AddinId));
                 CachedAddinManifest.Save();
                 NotifyChanged(false);
             }
         }
     }
 }
 public override string[] GetReferencedFileNames(ConfigurationSelector configuration)
 {
     if (OwnerProject != null)
     {
         AddinData data = AddinData.GetAddinData((DotNetProject)OwnerProject);
         if (data != null)
         {
             Addin addin = data.AddinRegistry.GetAddin(Reference);
             if (addin != null)
             {
                 List <string> list = new List <string> ();
                 foreach (string asm in addin.Description.MainModule.Assemblies)
                 {
                     string afile = Path.Combine(Path.GetDirectoryName(addin.Description.AddinFile), asm);
                     list.Add(afile);
                 }
                 return(list.ToArray());
             }
         }
     }
     return(new string [0]);
 }
示例#21
0
        void HandleDocumentOpened(object sender, DocumentEventArgs e)
        {
            if (!(e.Document.Project is DotNetProject) || !e.Document.IsFile)
            {
                return;
            }
            string ext = e.Document.FileName;

            if (!ext.EndsWith(".addin.xml") && !ext.EndsWith(".addin"))
            {
                return;
            }

            var data = AddinData.GetAddinData((DotNetProject)e.Document.Project);

            if (data != null)
            {
                IWorkbenchWindow window = e.Document.Window;
                var adesc = data.AddinRegistry.ReadAddinManifestFile(e.Document.FileName);

                window.AttachViewContent(new ExtensionEditorView(adesc, data));
                window.AttachViewContent(new ExtensionPointsEditorView(adesc, data));
            }
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            DotNetProject project = entry as DotNetProject;
            AddinData     data    = project != null?AddinData.GetAddinData(project) : null;

            if (data != null)
            {
                monitor.BeginTask(null, buildingSolution ? 2 : 3);
            }

            BuildResult res = base.Build(monitor, entry, configuration);

            if (res.ErrorCount > 0 || data == null)
            {
                return(res);
            }

            monitor.Step(1);

            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);
            }

            if (!buildingSolution && project.ParentSolution != null)
            {
                monitor.Step(1);
                SolutionAddinData sdata = project.ParentSolution.GetAddinData();
                if (sdata != null && sdata.Registry != null)
                {
                    sdata.Registry.Update(new ProgressStatusMonitor(monitor));
                    DispatchService.GuiDispatch(delegate {
                        sdata.NotifyChanged();
                    });
                }
            }

            monitor.EndTask();

            return(res);
        }
示例#23
0
        public void Load(Solution solution, DotNetProject project, bool forOptionsPanel)
        {
            AddinData data = AddinData.GetAddinData(project);

            if (data != null && !forOptionsPanel)
            {
                boxLibraryType.Visible = false;
                AddinDescription desc = data.CachedAddinManifest;
                if (project.CompileTarget != CompileTarget.Library || desc.IsRoot || solution.HasAddinRoot())
                {
                    boxRepo.Visible    = false;
                    hseparator.Visible = false;
                    isRoot             = true;
                }
                else
                {
                    if (solution.HasAddinRoot())
                    {
                        boxRepo.Visible = false;
                    }
                    else if (solution.GetAddinData() != null)
                    {
                        string app = solution.GetAddinData().ApplicationName;
                        if (app != null)
                        {
                            regSelector.ApplicationName = app;
                            regSelector.Sensitive       = false;
                        }
                    }
                    isRoot = false;
                }
                entryName.Text = project.Name;
                entryId.Text   = project.Name;
            }
            else
            {
                if (project.CompileTarget != CompileTarget.Library)
                {
                    // Editing options of an exe
                    labelExtensibleApp.Visible = data == null;
                    boxRepo.Visible            = false;
                    boxLibraryType.Visible     = false;
                    hseparator.Visible         = false;
                    isRoot = true;
                }
                else
                {
                    // Editing options of an add-in or extensible library
                    labelExtensibleApp.Visible = false;
                    if (data != null && data.CachedAddinManifest != null && data.CachedAddinManifest.IsRoot)
                    {
                        radiobuttonLibrary.Active = true;
                    }
                    else
                    {
                        radiobuttonAddin.Active = true;
                    }
                    isRoot = radiobuttonLibrary.Active;

                    // There is a root in the solution. The target registry can't be selected.
                    if (solution.HasAddinRoot())
                    {
                        boxRepo.Visible = false;
                    }
                }
                if (data != null)
                {
                    regSelector.ApplicationName = data.ApplicationName;
                    ((Gtk.Container)tableNames.Parent).Remove(tableNames);
                    ((Gtk.Container)labelAddinInfo.Parent).Remove(labelAddinInfo);
                }
                else
                {
                    entryName.Text = project.Name;
                    entryId.Text   = project.Name;
                }
            }
            if (project.CompileTarget == CompileTarget.Library)
            {
                if (radiobuttonLibrary.Active)
                {
                    labelAddinInfo.Text = AddinManager.CurrentLocalizer.GetString("Library information:");
                }
                else
                {
                    labelAddinInfo.Text = AddinManager.CurrentLocalizer.GetString("Add-in information:");
                }
            }
            else
            {
                labelAddinInfo.Text = AddinManager.CurrentLocalizer.GetString("Application information:");
            }

            UpdateControls();
        }
示例#24
0
 public static AddinData GetAddinData(this DotNetProject p)
 {
     return(AddinData.GetAddinData(p));
 }
示例#25
0
        void SyncReferences()
        {
            bool      changed   = false;
            Hashtable addinRefs = new Hashtable();

            foreach (AddinDependency adep in CachedAddinManifest.MainModule.Dependencies)
            {
                bool found = false;
                foreach (ProjectReference pr in Project.References)
                {
                    if ((pr is AddinProjectReference) && ((AddinProjectReference)pr).AddinId == adep.FullAddinId)
                    {
                        found = true;
                        break;
                    }
                    else if (pr.ReferenceType == ReferenceType.Project)
                    {
                        DotNetProject rp = Project.ParentSolution.FindProjectByName(pr.Reference) as DotNetProject;
                        if (rp != null)
                        {
                            AddinData ad = AddinData.GetAddinData(rp);
                            if (ad != null && ad.CachedAddinManifest.AddinId == adep.FullAddinId)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                }
                if (!found)
                {
                    try {
                        updating = true;
                        DotNetProject p = FindProjectImplementingAddin(adep.FullAddinId);
                        if (p != null)
                        {
                            Project.References.Add(new ProjectReference(p)
                            {
                                LocalCopy = false
                            });
                        }
                        else
                        {
                            Project.References.Add(new AddinProjectReference(adep.FullAddinId));
                        }
                    } finally {
                        updating = false;
                    }
                    changed = true;
                }
                addinRefs [adep.FullAddinId] = adep;
            }

            ArrayList toDelete = new ArrayList();

            foreach (ProjectReference pr in Project.References)
            {
                if ((pr is AddinProjectReference) && !addinRefs.ContainsKey(((AddinProjectReference)pr).AddinId))
                {
                    toDelete.Add(pr);
                }
            }
            foreach (ProjectReference pr in toDelete)
            {
                Project.References.Remove(pr);
            }

            if (changed || toDelete.Count > 0)
            {
                Project.Save(new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor());
            }
        }
示例#26
0
        public void OnUpdateAddAddinDependency(CommandInfo cinfo)
        {
            DotNetProject p = CurrentNode.GetParentDataItem(typeof(Project), true) as DotNetProject;

            cinfo.Visible = p != null && AddinData.GetAddinData(p) != null;
        }