Esempio n. 1
0
        /// <summary>
        /// Return current values from the input fields
        /// </summary>
        /// <returns>Structure with values</returns>
        public ClassRemotes.Remote Get()
        {
            ClassRemotes.Remote repo = new ClassRemotes.Remote();
            repo.Name     = textName.Text.Trim();
            repo.PushCmd  = textPushCmd.Text.Trim();
            repo.Password = textPassword.Text.Trim();

            // For SSH, make sure the URL string follows the strict format
            if (_fetchUrl.Type == ClassUrl.UrlType.Ssh)
            {
                repo.UrlFetch = ClassUrl.ToCanonical(textUrlFetch.Text.Trim());
            }
            else
            {
                repo.UrlFetch = textUrlFetch.Text.Trim();
            }

            if (_pushUrl.Type == ClassUrl.UrlType.Ssh)
            {
                repo.UrlPush = ClassUrl.ToCanonical(textUrlPush.Text.Trim());
            }
            else
            {
                repo.UrlPush = textUrlPush.Text.Trim();
            }

            return(repo);
        }
Esempio n. 2
0
        public void Prepare(Function fn, ClassRemotes.Remote remote)
        {
            remoteDisplay.Clear();
            remoteDisplay.AnyTextChanged += SomeTextChanged;

            // Do things differently basen on whether we are using this
            // form to add a new remote repo, rename it or we are editing
            // an existing remote repo

            switch (fn)
            {
            case Function.Add:
                remoteDisplay.Enable(true, true);
                remote.Name    = "origin";
                remote.PushCmd = "";
                remoteDisplay.Set(remote);
                Text         = "Add a new remote repository";
                btOK.Enabled = false;
                break;

            case Function.Edit:
                Text = "Edit remote repository '" + remote.Name + "'";
                remoteDisplay.Enable(false, true);
                remoteDisplay.Set(remote);
                break;

            case Function.Rename:
                Text = "Rename remote repository '" + remote.Name + "'";
                remoteDisplay.Enable(true, false);
                remoteDisplay.Set(remote);
                break;
            }
        }
Esempio n. 3
0
        private void ListRemotesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (listRemotes.SelectedIndex >= 0)
            {
                string name = listRemotes.SelectedItem.ToString();
                _current = _repo.Remotes.Get(name);
                userControlRemoteDisplay.Set(_current);

                btEdit.Enabled = btRename.Enabled = btDelete.Enabled = true;
            }
            else
                btEdit.Enabled = btRename.Enabled = btDelete.Enabled = false;
        }
Esempio n. 4
0
        /// <summary>
        /// Set all input fields to parameter values
        /// </summary>
        /// <param name="repo">Values to set</param>
        public void Set(ClassRemotes.Remote repo)
        {
            textName.Text     = repo.Name;
            textUrlFetch.Text = repo.UrlFetch;
            textUrlPush.Text  = repo.UrlPush;
            textPushCmd.Text  = repo.PushCmd;
            btWWW1.Enabled    = isValidUrl(textUrlFetch.Text);
            btWWW2.Enabled    = isValidUrl(textUrlPush.Text);
            textPassword.Text = repo.Password;

            // Rebuild the state variables _after_ all the URLs have been inserted
            SomeTextChanged(null, null);
        }
        private void ListRemotesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (listRemotes.SelectedIndex >= 0)
            {
                string name = listRemotes.SelectedItem.ToString();
                _current = _repo.Remotes.Get(name);
                userControlRemoteEdit.Set(_current);

                btEdit.Enabled = btRename.Enabled = btDelete.Enabled = true;
            }
            else
            {
                btEdit.Enabled = btRename.Enabled = btDelete.Enabled = false;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Add new remote repository
        /// </summary>
        private void BtAddClick(object sender, EventArgs e)
        {
            ClassRemotes.Remote remote = new ClassRemotes.Remote();
            FormRemoteAddEdit remoteAddEdit = new FormRemoteAddEdit();
            remoteAddEdit.Prepare(FormRemoteAddEdit.Function.Add, remote);

            if (remoteAddEdit.ShowDialog() == DialogResult.OK)
            {
                remote = remoteAddEdit.Get();
                _repo.Run("remote add " + remote.Name + " " + remote.UrlFetch);
                _repo.Remotes.SetPassword(remote.Name, remote.Password);
                _repo.Remotes.SetPushCmd(remote.Name, remote.PushCmd);

                SetRepo(_repo);
            }
        }
        /// <summary>
        /// Return current values from the input fields
        /// </summary>
        /// <returns>Structure with values</returns>
        public ClassRemotes.Remote Get()
        {
            ClassRemotes.Remote repo = new ClassRemotes.Remote();
            repo.Name = textName.Text;
            repo.PushCmd = textPushCmd.Text;
            repo.Password = textPassword.Text;

            // For SSH, make sure the URL string follows the strict format
            if (_fetchUrl.Type == ClassUrl.UrlType.Ssh)
                repo.UrlFetch = ClassUrl.ToCanonical(textUrlFetch.Text);
            else
                repo.UrlFetch = textUrlFetch.Text;

            if (_pushUrl.Type == ClassUrl.UrlType.Ssh)
                repo.UrlPush = ClassUrl.ToCanonical(textUrlPush.Text);
            else
                repo.UrlPush = textUrlPush.Text;

            return repo;
        }
Esempio n. 8
0
        /// <summary>
        /// Add new remote repository
        /// </summary>
        private void BtAddClick(object sender, EventArgs e)
        {
            ClassRemotes.Remote remote = new ClassRemotes.Remote();
            FormRemoteAddEdit remoteAddEdit = new FormRemoteAddEdit();
            remoteAddEdit.Prepare(FormRemoteAddEdit.Function.Add, remote);

            if (remoteAddEdit.ShowDialog() == DialogResult.OK)
            {
                remote = remoteAddEdit.Get();
                ExecResult result = _repo.Run("remote add " + remote.Name + " " + remote.UrlFetch);
                if (result.Success())
                {
                    _repo.Remotes.SetPassword(remote.Name, remote.Password);
                    _repo.Remotes.SetPushCmd(remote.Name, remote.PushCmd);
                    SetRepo(_repo);
                }
                else
                {
                    MessageBox.Show("Git is unable to add this remote repository.", "Add remote repository", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    App.PrintStatusMessage(result.stderr, MessageType.Error);
                }
            }
        }
        /// <summary>
        /// Add new remote repository
        /// </summary>
        private void BtAddClick(object sender, EventArgs e)
        {
            ClassRemotes.Remote remote        = new ClassRemotes.Remote();
            FormRemoteAddEdit   remoteAddEdit = new FormRemoteAddEdit();

            remoteAddEdit.Prepare(FormRemoteAddEdit.Function.Add, remote);

            if (remoteAddEdit.ShowDialog() == DialogResult.OK)
            {
                remote = remoteAddEdit.Get();
                ExecResult result = _repo.Run("remote add " + remote.Name + " " + remote.UrlFetch);
                if (result.Success())
                {
                    _repo.Remotes.SetPassword(remote.Name, remote.Password);
                    _repo.Remotes.SetPushCmd(remote.Name, remote.PushCmd);
                    SetRepo(_repo);
                }
                else
                {
                    MessageBox.Show("Git is unable to add this remote repository.", "Add remote repository", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    App.PrintStatusMessage(result.stderr, MessageType.Error);
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Call this method to properly set the remote structure that is going to be used by this dialog
 /// </summary>
 public void SetRemote(ClassRemotes.Remote remote)
 {
     Remote = remote;
     remoteDisplay.Set(Remote);
 }
Esempio n. 11
0
 /// <summary>
 /// Callback function called when text in the remote repo editing has changed.
 /// </summary>
 private void SomeTextChanged(bool valid)
 {
     btNext.Enabled = valid;
     Remote         = remoteDisplay.Get();
 }
Esempio n. 12
0
 /// <summary>
 /// Callback function called when text in the remote repo editing has changed.
 /// </summary>
 private void SomeTextChanged(bool valid)
 {
     btNext.Enabled = valid;
     Remote = remoteDisplay.Get();
 }
Esempio n. 13
0
 /// <summary>
 /// Call this method to properly set the remote structure that is going to be used by this dialog
 /// </summary>
 public void SetRemote(ClassRemotes.Remote remote)
 {
     Remote = remote;
     remoteEdit.Set(Remote);
 }
Esempio n. 14
0
 /// <summary>
 /// Call this method to properly set the remote structure that is going to be used by this dialog
 /// </summary>
 public void SetRemote(ClassRemotes.Remote remote)
 {
     Remote = remote;
     remoteDisplay.Set(Remote);
 }