Пример #1
0
        public void Export(object item, SnapinNode node)
        {
            try
            {
                // Show the form to select what goes in.

                var form = new CatalogueBrowserForm();
                form.DisplayCatalogue(_catalogue, true, CatalogueElements.All);
                form.Text = "Select Elements";

                // Select the appropriate element.

                SelectElements(form.Browser);

                // Show the dialog.

                if (form.ShowDialog() == DialogResult.OK)
                {
                    WriteElements(form.Browser);
                }
            }
            catch (System.Exception e)
            {
                new ExceptionDialog(e, "The following exception has occurred while trying to write the information:").ShowDialog();
            }
        }
Пример #2
0
        protected void MenuNewNamespaceHandler(object sender, SnapinNode node)
        {
            // Show the form.

            NewNamespaceWizard wizard = new NewNamespaceWizard(m_catalogue);

            if (wizard.Show() != DialogResult.OK)
            {
                return;
            }

            try
            {
                // Add the element.

                Namespace newNamespace = null;
                bool      cont         = true;
                while (cont)
                {
                    newNamespace = wizard.Namespace;
                    try
                    {
                        m_catalogue.Add(newNamespace);
                    }
                    catch (System.Exception e)
                    {
                        new ExceptionDialog(e, "Cannot add the namespace.").ShowDialog();

                        // Show it again.

                        if (wizard.Show(newNamespace) != DialogResult.OK)
                        {
                            return;
                        }
                        cont = true;
                        continue;
                    }

                    m_catalogue.Commit();
                    cont = false;
                }

                // Update the display.

                NamespaceNode newNode = new NamespaceNode(Snapin, newNamespace);
                InsertChildNode(newNode);
                newNode.Select();
                newNode.Refresh(false);
            }
            catch (System.Exception ex)
            {
                new ExceptionDialog(ex, "The following exception has occurred:").ShowDialog();
            }
        }
Пример #3
0
        protected override SnapinNode[] GetChildNodes()
        {
            // Iterate through namespaces.

            SnapinNode[] nodes = new SnapinNode[m_catalogue.Namespaces.Count];
            int          index = 0;

            foreach (Namespace ns in m_catalogue.Namespaces)
            {
                nodes[index++] = new NamespaceNode(Snapin, ns);
            }

            return(nodes);
        }
Пример #4
0
        public void Import(object item, SnapinNode node)
        {
            try
            {
                // Need to create a reader.

                IRepositoryReader fromReader = m_repositoryType.GetRepositoryConnection <IRepositoryReader>(true, m_parent);
                if (fromReader != null)
                {
                    // Save selection.

                    string selectedPath = ((SnapinNode)node.Snapin.CurrentScopeNode).GetPathRelativeTo(node);

                    // Run it.

                    IRepositoryWriter             toWriter = m_repositoryLink.GetConnection <IRepositoryWriter>();
                    ImportRepositoryResultsRunner runner   = new ImportRepositoryResultsRunner(fromReader, toWriter);
                    runner.Run();

                    using (new LongRunningMonitor(node.Snapin))
                    {
                        // Refresh the catalogue itself.

                        IRepositoryConnection repositoryConnection = m_repositoryLink as IRepositoryConnection;
                        if (repositoryConnection != null)
                        {
                            using (ConnectionState state = new ConnectionState())
                            {
                                repositoryConnection.Connect(state).Refresh();
                            }
                        }

                        // Refresh the node and selection.

                        node.Refresh(true);
                        SnapinNode selectedNode = node.FindNodeInTree(selectedPath);
                        if (selectedNode != null)
                        {
                            selectedNode.Select();
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                new ExceptionDialog(e, "The following exception has occurred while trying to read the information:").ShowDialog();
            }
        }
Пример #5
0
        protected override SnapinNode[] GetChildNodes()
        {
            // Iterate.

            SnapinNode[] nodes = new SnapinNode[m_namespace.Namespaces.Count + m_namespace.Sources.Count];
            int          index = 0;

            foreach (Namespace ns in m_namespace.Namespaces)
            {
                nodes[index++] = new NamespaceNode(Snapin, ns);
            }

            foreach (Source source in m_namespace.Sources)
            {
                nodes[index++] = new SourceNode(Snapin, source);
            }

            return(nodes);
        }
Пример #6
0
 protected void MenuDisableEventHandler(object sender, SnapinNode node)
 {
     SetIsEnabled(false);
 }
Пример #7
0
 protected void MenuEnableEventHandler(object sender, SnapinNode node)
 {
     SetIsEnabled(true);
 }
Пример #8
0
 private void MenuDeleteRepositoryHandler(object sender, SnapinNode node)
 {
     DeleteRepository();
 }
Пример #9
0
 private void MenuDisconnectHandler(object sender, SnapinNode node)
 {
     Disconnect();
 }
Пример #10
0
 private void MenuManageTypesHandler(object sender, SnapinNode arg)
 {
     ManageTypes();
 }