Beispiel #1
0
        private void addListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("List Name", "New List Function"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                GetDesignDoc(_contextNode).Lists.Add(new CouchFunctionDefinition {
                    Name = dialog.EnteredName
                });
                var listNode = CreateGenericFunctionNode("list", _contextNode, dialog.EnteredName);

                listNode.EnsureVisible();
                _currentNode = listNode;
                PrepopulateByType("list");
            }
        }
Beispiel #2
0
        private void addLuceneIndexToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("Index name", "New Index"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var indexNode = CreateGenericFunctionNode("fti", _contextNode, dialog.EnteredName);

                indexNode.EnsureVisible();
                _currentNode = indexNode;
                PrepopulateByType("fti");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Handles the Click event of the addDesignToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void addDesignToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("Design name", "New Design"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var design = new GenericDesignDocument(dialog.EnteredName,
                                                       ((CouchDatabase)_contextNode.Tag));

                var designNode = CreateDesignNode(design, _contextNode);
                designNode.EnsureVisible();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the addViewToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void addViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("View name", "New View"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var view = GetDesignDoc(_contextNode).AddView(dialog.EnteredName, String.Empty);

                var viewNode = CreateViewNode(_contextNode, view);
                var mapNode  = CreateGenericFunctionNode("map", viewNode, "map");

                mapNode.EnsureVisible();
                _currentNode = mapNode;
                PrepopulateByType("map");
            }
        }
Beispiel #5
0
        private void cloneViewsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CouchDatabase sourceDb = (CouchDatabase)_contextNode.Tag;

            using (var dialog = new dlgName("Specify Target", "Target Server/database"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var dbParts  = dialog.EnteredName.Replace("//", "").Split('/');
                var svr      = CreateServer(dbParts[0].Split(':'));
                var targetDb = svr.GetDatabase(dbParts[1]);

                foreach (var view in sourceDb.QueryAllDocuments().StartKey("_design").EndKey("_designZZZZZZZZZZZZZZZZZ").GetResult().RowDocuments())
                {
                    var design = sourceDb.GetDocument <GenericDesignDocument>(view.Key);

                    // need to make sure to overwrite the target
                    if (targetDb.HasDocument(design.Id))
                    {
                        design.Rev = targetDb.GetDocument(design.Id).Rev;
                    }
                    else
                    {
                        design.Rev = null;
                    }

                    design.Owner = targetDb;
                    design.Synch();
                }
            }
        }
Beispiel #6
0
        private void addDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_contextNode == null)
            {
                return;
            }

            if (HasOnlyDummyNode(_contextNode))
            {
                _contextNode.Nodes.Clear();
            }

            using (var dialog = new dlgName("Database name", "New Database"))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                ((CouchServer)_contextNode.Tag).CreateDatabase(dialog.EnteredName);
                LoadServer(tstServer.Text);
            }
        }