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);
        }
Esempio n. 2
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 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 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()
        {
            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);
        }
        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;
                }
            });
        }