public override void OnMultipleNodeDrop(object[] dataObjects, DragOperation operation, DropPosition pos)
        {
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            ExtensionNodeInfo en = (ExtensionNodeInfo)CurrentNode.DataItem;

            foreach (ExtensionNodeInfo newNode in dataObjects)
            {
                if (newNode.Node.Parent is ExtensionNodeDescription)
                {
                    ((ExtensionNodeDescription)newNode.Node.Parent).ChildNodes.Remove(en.Node);
                }
                else
                {
                    ((Extension)newNode.Node.Parent).ExtensionNodes.Remove(newNode.Node);
                }
                InsertNode(adata, en, pos, newNode.Node);

                // Add all other nodes after the first node
                en  = newNode;
                pos = DropPosition.After;
            }

            adata.CachedAddinManifest.Save();
            adata.NotifyChanged(false);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        public void OnAddExtensionPoint()
        {
            DotNetProject project = (DotNetProject)CurrentNode.DataItem;

            if (project == null)
            {
                return;
            }
            AddinData data = project.GetAddinData();

            if (project == null)
            {
                return;
            }

            ExtensionPoint          ep  = new ExtensionPoint();
            NewExtensionPointDialog dlg = new NewExtensionPointDialog(project, data.AddinRegistry, data.CachedAddinManifest, ep);

            try {
                if (dlg.Run() == (int)Gtk.ResponseType.Ok)
                {
                    data.CachedAddinManifest.ExtensionPoints.Add(ep);
                    data.SaveAddinManifest();
                    data.NotifyChanged(false);
                }
            } finally {
                dlg.Destroy();
            }
        }
        public override void ActivateItem()
        {
            DotNetProject project = (DotNetProject)CurrentNode.GetParentDataItem(typeof(DotNetProject), true);

            if (project == null)
            {
                return;
            }
            AddinData data = project.GetAddinData();

            if (data == null)
            {
                return;
            }

            ExtensionPoint ep  = (ExtensionPoint)CurrentNode.DataItem;
            ExtensionPoint epc = new ExtensionPoint();

            epc.CopyFrom(ep);
            NewExtensionPointDialog epdlg = new NewExtensionPointDialog(project, data.AddinRegistry, data.CachedAddinManifest, epc);

            if (epdlg.Run() == (int)Gtk.ResponseType.Ok)
            {
                ep.CopyFrom(epc);
                data.CachedAddinManifest.Save();
            }
            epdlg.Destroy();
        }
Ejemplo n.º 5
0
        public void OnAddExtension()
        {
            DotNetProject project = (DotNetProject)CurrentNode.DataItem;

            if (project == null)
            {
                return;
            }
            AddinData data = project.GetAddinData();

            if (project == null)
            {
                return;
            }

            AddinDescription adesc = data.CachedAddinManifest;

            ExtensionSelectorDialog dlg = new ExtensionSelectorDialog(data.AddinRegistry, adesc, adesc.IsRoot, false);

            if (dlg.Run() == (int)Gtk.ResponseType.Ok)
            {
                foreach (object ob in dlg.GetSelection())
                {
                    AddinDescription desc = null;
                    if (ob is ExtensionPoint)
                    {
                        ExtensionPoint ep  = (ExtensionPoint)ob;
                        Extension      ext = new Extension(ep.Path);
                        adesc.MainModule.Extensions.Add(ext);
                        desc = (AddinDescription)ep.Parent;
                    }
                    else if (ob is ExtensionNodeDescription)
                    {
                        ExtensionNodeDescription node = (ExtensionNodeDescription)ob;
                        desc = node.ParentAddinDescription;
                        string path = "";
                        while (node != null && !(node.Parent is Extension))
                        {
                            if (!node.IsCondition)
                            {
                                path = "/" + node.Id + path;
                            }
                            node = node.Parent as ExtensionNodeDescription;
                        }
                        Extension eext = (Extension)node.Parent;
                        Extension ext  = new Extension(eext.Path + "/" + node.Id + path);
                        adesc.MainModule.Extensions.Add(ext);
                    }
                    if (adesc.AddinId != desc.AddinId && !adesc.MainModule.DependsOnAddin(desc.AddinId))
                    {
                        adesc.MainModule.Dependencies.Add(new AddinDependency(desc.AddinId));
                    }
                }
                adesc.Save();
            }
            dlg.Destroy();
        }
Ejemplo n.º 6
0
        public AddinData GetAddinData(ITreeNavigator nav)
        {
            DotNetProject p = (DotNetProject)nav.GetParentDataItem(typeof(DotNetProject), true);

            if (p == null)
            {
                return(null);
            }
            return(p.GetAddinData());
        }
Ejemplo n.º 7
0
        public override void OnNodeRemoved(object dataObject)
        {
            DotNetProject project = (DotNetProject)dataObject;

            project.NameChanged -= projectNameChanged;

            AddinData data = project.GetAddinData();

            if (data != null)
            {
                data.Changed -= HandleDataChanged;
            }
        }
Ejemplo n.º 8
0
        public void UpdateImports(SolutionEntityItem item, List <string> imports)
        {
            DotNetProject project = item as DotNetProject;

            if (project != null && project.GetAddinData() != null)
            {
                imports.Add(import);
            }
            else
            {
                imports.Remove(import);
            }
        }
        public void AddNodeBefore(object data)
        {
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            ExtensionNodeInfo        en      = (ExtensionNodeInfo)CurrentNode.DataItem;
            ExtensionNodeType        ntype   = (ExtensionNodeType)data;
            ExtensionNodeDescription newNode = new ExtensionNodeDescription(ntype.NodeName);

            InsertNode(adata, en, DropPosition.Before, newNode);

            adata.CachedAddinManifest.Save();
            adata.NotifyChanged(false);
        }
 public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
 {
     base.GetNodeAttributes(parentNode, dataObject, ref attributes);
     if (dataObject is ProjectFile)
     {
         string fname = ((ProjectFile)dataObject).Name;
         if (fname.EndsWith(".addin.xml", StringComparison.Ordinal) || fname.EndsWith(".addin", StringComparison.Ordinal))
         {
             if (!(parentNode.DataItem is AddinData))
             {
                 DotNetProject dp = (DotNetProject)parentNode.GetParentDataItem(typeof(DotNetProject), true);
                 if (dp != null && dp.GetAddinData() != null)
                 {
                     // Hide the manifest
                     attributes |= NodeAttributes.Hidden;
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
        public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
        {
            DotNetProject project = (DotNetProject)dataObject;
            AddinData     data    = project.GetAddinData();

            if (data != null && data.CachedAddinManifest != null)
            {
                AddinDescription adesc       = data.CachedAddinManifest;
                HashSet <string> localPoints = new HashSet <string> ();
                foreach (ExtensionPoint ep in adesc.ExtensionPoints)
                {
                    builder.AddChild(ep);
                    localPoints.Add(ep.Path);
                }
                foreach (Extension ext in adesc.MainModule.Extensions)
                {
                    if (!localPoints.Contains(ext.Path))
                    {
                        builder.AddChild(ext);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 public static bool IsProjectIncludedByAddin(DotNetProject project, ProjectReference pref)
 {
     // Checks if the provided reference is implicitly included by an add-in reference in the project.
     foreach (ProjectReference p in project.References)
     {
         if (p.ReferenceType != ReferenceType.Project && p != pref)
         {
             continue;
         }
         DotNetProject rp = project.ParentSolution.FindProjectByName(p.Reference) as DotNetProject;
         if (rp != null && rp.GetAddinData() != null)
         {
             foreach (ProjectReference aref in rp.References)
             {
                 if (aref.ReferenceType == ReferenceType.Project && aref.Reference == pref.Reference)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
        public override void DeleteMultipleItems()
        {
            if (MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to delete the selected nodes?"), AlertButton.Delete))
            {
                foreach (var nav in CurrentNodes)
                {
                    ExtensionNodeInfo en = (ExtensionNodeInfo)nav.DataItem;
                    if (en.Node.Parent is Extension)
                    {
                        ((Extension)en.Node.Parent).ExtensionNodes.Remove(en.Node);
                    }
                    else if (en.Node.Parent is ExtensionNodeDescription)
                    {
                        ((ExtensionNodeDescription)en.Node.Parent).ChildNodes.Remove(en.Node);
                    }
                }
            }
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            adata.SaveAddinManifest();
            adata.NotifyChanged(false);
        }
Ejemplo n.º 14
0
        public override void GetNodeAttributes(ITreeNavigator parentNode, object dataObject, ref NodeAttributes attributes)
        {
            if (dataObject is AddinProjectReference)
            {
                attributes |= NodeAttributes.Hidden;
                return;
            }
            ProjectReference pr     = (ProjectReference)dataObject;
            DotNetProject    parent = pr.OwnerProject as DotNetProject;

            if (AddinAuthoringService.IsProjectIncludedByAddin(parent, pr))
            {
                attributes |= NodeAttributes.Hidden;
            }
            else if (parent.GetAddinData() != null && pr.ReferenceType == ReferenceType.Project)
            {
                DotNetProject tp = parent.ParentSolution.FindProjectByName(pr.Reference) as DotNetProject;
                if (tp != null && tp.GetAddinData() != null)
                {
                    attributes |= NodeAttributes.Hidden;
                }
            }
        }
        public override void DeleteMultipleItems()
        {
            string msg = GettextCatalog.GetString("The following extensions and all the nodes they contain will be deleted:") + "\n\n";

            foreach (var nav in CurrentNodes)
            {
                msg += Util.GetDisplayName((Extension)nav.DataItem) + "\n";
            }
            if (MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to delete the selected extensions?"), msg, AlertButton.Delete))
            {
                foreach (var nav in CurrentNodes)
                {
                    Extension         ex     = (Extension)nav.DataItem;
                    ModuleDescription module = (ModuleDescription)ex.Parent;
                    module.Extensions.Remove(ex);
                }
            }
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            adata.SaveAddinManifest();
            adata.NotifyChanged(false);
        }
        public override void DeleteMultipleItems()
        {
            string msg = GettextCatalog.GetString("The following extension points and all the nodes they contain will be deleted:") + "\n\n";

            foreach (var nav in CurrentNodes)
            {
                msg += Util.GetDisplayName((ExtensionPoint)nav.DataItem) + "\n";
            }
            if (MessageService.Confirm(GettextCatalog.GetString("Are you sure you want to delete the selected extension points?"), msg, AlertButton.Delete))
            {
                foreach (var nav in CurrentNodes)
                {
                    ExtensionPoint ep = (ExtensionPoint)nav.DataItem;
                    ep.ParentAddinDescription.ExtensionPoints.Remove(ep);
                    foreach (ModuleDescription module in ep.ParentAddinDescription.AllModules)
                    {
                        List <Extension> toDelete = new List <Extension> ();
                        foreach (Extension ext in module.Extensions)
                        {
                            if (ext.Path == ep.Path || ext.Path.StartsWith(ep.Path + "/"))
                            {
                                toDelete.Add(ext);
                            }
                        }
                        foreach (Extension ext in toDelete)
                        {
                            module.Extensions.Remove(ext);
                        }
                    }
                }
            }
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            adata.SaveAddinManifest();
            adata.NotifyChanged(false);
        }
        public void AddNodeBefore(object data)
        {
            DotNetProject p     = (DotNetProject)CurrentNode.GetParentDataItem(typeof(Project), false);
            AddinData     adata = p.GetAddinData();

            Extension         en    = GetExtension();
            ExtensionNodeType ntype = (ExtensionNodeType)data;

            ExtensionNodeDescription newNode = new ExtensionNodeDescription(ntype.NodeName);

            en.ExtensionNodes.Add(newNode);
            CurrentNode.Expanded = true;

            adata.SaveAddinManifest();
            adata.NotifyChanged(false);

            DispatchService.GuiDispatch(delegate {
                ITreeNavigator nav = Tree.GetNodeAtObject(new ExtensionNodeInfo(newNode, false));
                if (nav != null)
                {
                    nav.Selected = true;
                }
            });
        }
Ejemplo n.º 18
0
        ExecutionCommand CreateCommand(SolutionEntityItem item)
        {
            DotNetProject project = item as DotNetProject;

            if (project == null || project.CompileTarget != CompileTarget.Library || project.ParentSolution == null)
            {
                return(null);
            }

            SolutionAddinData sdata = project.ParentSolution.GetAddinData();

            if (sdata == null || project.GetAddinData() == null || project.GetAddinData().IsRoot)
            {
                return(null);
            }

            RegistryInfo ri = sdata.ExternalRegistryInfo;

            if (ri == null || string.IsNullOrEmpty(ri.TestCommand))
            {
                return(null);
            }

            FilePath cmd;
            string   args;

            if (ri.TestCommand [0] == '"')
            {
                // If the file name is quoted, unquote it
                int i = ri.TestCommand.IndexOf('"', 1);
                if (i == -1)
                {
                    throw new UserException("Invalid add-in test command: " + ri.TestCommand);
                }
                cmd  = ri.TestCommand.Substring(1, i - 1);
                args = ri.TestCommand.Substring(i + 1).Trim();
            }
            else
            {
                int i = ri.TestCommand.IndexOf(' ');
                if (i == -1)
                {
                    cmd  = ri.TestCommand;
                    args = string.Empty;
                }
                else
                {
                    cmd  = ri.TestCommand.Substring(0, i);
                    args = ri.TestCommand.Substring(i + 1).Trim();
                }
            }

            // If the command is an absolute file, take it
            // It not, consider it is a file relative to the startup path
            // If a relative file can't be found, use it as is

            if (!cmd.IsAbsolute)
            {
                FilePath absCmd = cmd.ToAbsolute(ri.ApplicationPath);
                if (System.IO.File.Exists(absCmd))
                {
                    cmd = absCmd;
                }
            }

            ProcessExecutionCommand pcmd = Runtime.ProcessService.CreateCommand(cmd) as ProcessExecutionCommand;

            if (pcmd == null)
            {
                return(null);
            }
            pcmd.Arguments = args;
            pcmd.EnvironmentVariables ["MONO_ADDINS_REGISTRY"] = sdata.TestRegistryPath;
            return(pcmd);
        }