コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
ファイル: AddinData.cs プロジェクト: miaojiang1/monodevelop-1
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
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();
         }
     }
 }
コード例 #5
0
		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);
		}
コード例 #6
0
        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();
        }
コード例 #7
0
        public IViewContent CreateContentForUri(string fileName)
        {
            DotNetProject p    = IdeApp.Workspace.GetProjectContainingFile(fileName) as DotNetProject;
            AddinData     data = AddinData.GetAddinData(p);

            return(new AddinDescriptionView(data));
        }
コード例 #8
0
        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");
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
        void OnProjectChanged(object s, EventArgs a)
        {
            AddinData    data = (AddinData)s;
            ITreeBuilder tb   = Context.GetTreeBuilder(data.Project);

            if (tb != null)
            {
                tb.UpdateAll();
            }
        }
コード例 #12
0
ファイル: AddinData.cs プロジェクト: miaojiang1/monodevelop-1
        public static void DisableAddinAuthoringSupport(DotNetProject project)
        {
            AddinData data = GetAddinData(project);

            project.ExtendedProperties.Remove("MonoDevelop.AddinAuthoring");
            if (data != null && AddinSupportChanged != null)
            {
                AddinSupportChanged(project, false);
            }
        }
コード例 #13
0
 public void NotifyChanged()
 {
     foreach (DotNetProject p in solution.GetAllSolutionItems <DotNetProject> ())
     {
         AddinData data = p.GetAddinData();
         if (data != null)
         {
             data.NotifyChanged(false);
         }
     }
 }
コード例 #14
0
 public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
 {
     if (dataObject is DotNetProject)
     {
         AddinData data = AddinData.GetAddinData((DotNetProject)dataObject);
         if (data != null)
         {
             builder.AddChild(data);
         }
     }
 }
コード例 #15
0
 public override void OnNodeAdded(object dataObject)
 {
     if (dataObject is DotNetProject)
     {
         AddinData data = AddinData.GetAddinData((DotNetProject)dataObject);
         if (data != null)
         {
             data.Changed += OnProjectChanged;
         }
     }
 }
コード例 #16
0
        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);
        }
コード例 #17
0
 public void Store()
 {
     if (checkEnable.Active)
     {
         AddinFeature f = new AddinFeature();
         f.ApplyFeature(project.ParentFolder, project, optionsWidget);
     }
     else
     {
         AddinData.DisableAddinAuthoringSupport(project);
     }
 }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
 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);
 }
コード例 #21
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);
 }
コード例 #22
0
 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);
 }
コード例 #23
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);
 }
コード例 #24
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 });
            }
        }
コード例 #25
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();
        }
コード例 #26
0
        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();
                }
            }
        }
コード例 #27
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);
        }
コード例 #28
0
		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 ();
		}
コード例 #29
0
ファイル: AddinData.cs プロジェクト: miaojiang1/monodevelop-1
 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);
 }
コード例 #30
0
        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();
        }
コード例 #31
0
        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();
        }
コード例 #32
0
		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 ();
		}
コード例 #33
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();
                    });
                }
            }
        }
コード例 #34
0
		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);
		}
コード例 #35
0
		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);
		}
コード例 #36
0
		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;
		}
コード例 #37
0
		public void Fill (AddinData data, AddinDescription pdesc, string path)
		{
			Fill (data.AddinRegistry, data.CachedAddinManifest, pdesc, path);
		}
コード例 #38
0
		public ExtensionEditorView (AddinDescription desc, AddinData data): base (desc, data)
		{
		}
コード例 #39
0
		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 ();
		}
コード例 #41
0
		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;
		}