Esempio n. 1
0
        public override void OnExecute(CommandEventArgs e)
        {
            ISvnRepositoryItem selected = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>());

            string directoryName = "";

            using (CreateDirectoryDialog dlg = new CreateDirectoryDialog())
            {
                DialogResult result = dlg.ShowDialog(e.Context);

                directoryName = dlg.NewDirectoryName;

                if (result != DialogResult.OK || string.IsNullOrEmpty(directoryName))
                    return;

                string log = dlg.LogMessage;

                // Handle special characters like on local path
                Uri uri = SvnTools.AppendPathSuffix(selected.Uri, directoryName);

                ProgressRunnerResult prResult =
                    e.GetService<IProgressRunner>().RunModal(
                    CommandStrings.CreatingDirectories,
                    delegate(object sender, ProgressWorkerArgs ee)
                    {
                        SvnCreateDirectoryArgs args = new SvnCreateDirectoryArgs();
                        args.ThrowOnError = false;
                        args.CreateParents = true;
                        args.LogMessage = log;
                        ee.Client.RemoteCreateDirectory(uri, args);
                    }
                    );

                if (prResult.Succeeded)
                {
                    selected.RefreshItem(false);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the directory specified by <see cref="uri"/>
        /// Returns false if the user cancelled creating the directory, true otherwise
        /// </summary>
        /// <param name="e"></param>
        /// <param name="title">The title of the Create dialog</param>
        /// <param name="uri">The directory to be created</param>
        /// <param name="cl"></param>
        /// <returns></returns>
        static bool RemoteCreateDirectory(CommandEventArgs e, string title, Uri uri, SvnClient cl)
        {
            using (CreateDirectoryDialog createDialog = new CreateDirectoryDialog())
            {
                createDialog.Text = title; // Override dialog title with text from other dialog

                createDialog.NewDirectoryName = uri.ToString();
                createDialog.NewDirectoryReadonly = true;
                if (createDialog.ShowDialog(e.Context) == DialogResult.OK)
                {
                    // Create uri (including optional /trunk if required)
                    SvnCreateDirectoryArgs cdArg = new SvnCreateDirectoryArgs();
                    cdArg.CreateParents = true;
                    cdArg.LogMessage = createDialog.LogMessage;

                    cl.RemoteCreateDirectory(uri, cdArg);
                    return true;
                }

                return false; // bail out, we cannot continue without directory in the repository
            }
        }