Пример #1
0
        public CheckoutDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();

            var inputs = new IUserInputSource[]
            {
                _revisionInput = new TextBoxInputSource(_txtRevision),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            Text = Resources.StrCheckoutRevision;

            _lblRevision.Text = Resources.StrRevision.AddColon();

            _lstReferences.Style = GitterApplication.DefaultStyle;
            _lstReferences.LoadData(_repository, ReferenceType.Reference, GlobalBehavior.GroupReferences, GlobalBehavior.GroupRemoteBranches);
            _lstReferences.Items[0].IsExpanded = true;
            _lstReferences.ItemActivated      += OnReferencesItemActivated;

            GlobalBehavior.SetupAutoCompleteSource(_txtRevision, _repository, ReferenceType.Reference);
            GitterApplication.FontManager.InputFont.Apply(_txtRevision);

            _controller = new CheckoutController(repository)
            {
                View = this
            };
        }
Пример #2
0
        public RenameRemoteDialog(Remote remote)
        {
            Verify.Argument.IsNotNull(remote, "remote");
            Verify.Argument.IsFalse(remote.IsDeleted, "remote",
                Resources.ExcObjectIsDeleted.UseAsFormat("Remote"));

            _remote = remote;

            InitializeComponent();
            Localize();

            SetupReferenceNameInputBox(_txtNewName, ReferenceType.Remote);

            _txtOldName.Text = remote.Name;
            _txtNewName.Text = remote.Name;
            _txtNewName.SelectAll();

            var inputs = new IUserInputSource[]
            {
                _newNameInput = new TextBoxInputSource(_txtNewName),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            GitterApplication.FontManager.InputFont.Apply(_txtNewName, _txtOldName);

            _controller = new RenameRemoteController(remote);
        }
Пример #3
0
        /// <summary>Create <see cref="RenameBranchDialog"/>.</summary>
        /// <param name="branch">Branch to rename.</param>
        /// <exception cref="ArgumentNullException"><paramref name="branch"/> == <c>null</c>.</exception>
        public RenameBranchDialog(Branch branch)
        {
            Verify.Argument.IsNotNull(branch, "branch");
            Verify.Argument.IsFalse(branch.IsDeleted, "branch",
                                    Resources.ExcObjectIsDeleted.UseAsFormat("Branch"));

            _branch = branch;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _newNameInput = new TextBoxInputSource(_txtNewName),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtNewName, ReferenceType.LocalBranch);

            var branchName = branch.Name;

            _txtOldName.Text = branchName;
            _txtNewName.Text = branchName;
            _txtNewName.SelectAll();

            GitterApplication.FontManager.InputFont.Apply(_txtNewName, _txtOldName);

            _controller = new RenameBranchController(branch)
            {
                View = this
            };
        }
Пример #4
0
        /// <summary>Create <see cref="AddSubmoduleDialog"/>.</summary>
        public AddSubmoduleDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _pathInput            = new TextBoxInputSource(_txtPath),
                _urlInput             = new TextBoxInputSource(_txtRepository),
                _useCustomBranchInput = new CheckBoxInputSource(_chkBranch),
                _branchNameInput      = new TextBoxInputSource(_txtBranch),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            GitterApplication.FontManager.InputFont.Apply(_txtBranch, _txtRepository, _txtPath);

            _controller = new AddSubmoduleController(repository)
            {
                View = this
            };
        }
Пример #5
0
        /// <summary>Create <see cref="RenameBranchDialog"/>.</summary>
        /// <param name="branch">Branch to rename.</param>
        /// <exception cref="ArgumentNullException"><paramref name="branch"/> == <c>null</c>.</exception>
        public RenameBranchDialog(Branch branch)
        {
            Verify.Argument.IsNotNull(branch, "branch");
            Verify.Argument.IsFalse(branch.IsDeleted, "branch",
                Resources.ExcObjectIsDeleted.UseAsFormat("Branch"));

            _branch = branch;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _newNameInput = new TextBoxInputSource(_txtNewName),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtNewName, ReferenceType.LocalBranch);

            var branchName = branch.Name;
            _txtOldName.Text = branchName;
            _txtNewName.Text = branchName;
            _txtNewName.SelectAll();

            GitterApplication.FontManager.InputFont.Apply(_txtNewName, _txtOldName);

            _controller = new RenameBranchController(branch) { View = this };
        }
Пример #6
0
        public StashToBranchDialog(StashedState stashedState)
        {
            Verify.Argument.IsNotNull(stashedState, "stashedState");
            Verify.Argument.IsFalse(stashedState.IsDeleted, "stashedState",
                                    Resources.ExcObjectIsDeleted.UseAsFormat(stashedState.GetType().Name));

            _stashedState = stashedState;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _branchNameInput = new TextBoxInputSource(_txtBranchName),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtBranchName, ReferenceType.LocalBranch);

            _txtStashName.Text = ((IRevisionPointer)_stashedState).Pointer;

            GitterApplication.FontManager.InputFont.Apply(_txtBranchName, _txtStashName);

            _controller = new StashToBranchController(stashedState)
            {
                View = this
            };
        }
Пример #7
0
        public CheckoutDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();

            var inputs = new IUserInputSource[]
            {
                _revisionInput = new TextBoxInputSource(_txtRevision),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            Text = Resources.StrCheckoutRevision;

            _lblRevision.Text = Resources.StrRevision.AddColon();

            _lstReferences.Style = GitterApplication.DefaultStyle;
            _lstReferences.LoadData(_repository, ReferenceType.Reference, GlobalBehavior.GroupReferences, GlobalBehavior.GroupRemoteBranches);
            _lstReferences.Items[0].IsExpanded = true;
            _lstReferences.ItemActivated += OnReferencesItemActivated;

            GlobalBehavior.SetupAutoCompleteSource(_txtRevision, _repository, ReferenceType.Reference);
            GitterApplication.FontManager.InputFont.Apply(_txtRevision);

            _controller = new CheckoutController(repository) { View = this };
        }
Пример #8
0
        public RenameRemoteDialog(Remote remote)
        {
            Verify.Argument.IsNotNull(remote, "remote");
            Verify.Argument.IsFalse(remote.IsDeleted, "remote",
                                    Resources.ExcObjectIsDeleted.UseAsFormat("Remote"));

            _remote = remote;

            InitializeComponent();
            Localize();

            SetupReferenceNameInputBox(_txtNewName, ReferenceType.Remote);

            _txtOldName.Text = remote.Name;
            _txtNewName.Text = remote.Name;
            _txtNewName.SelectAll();

            var inputs = new IUserInputSource[]
            {
                _newNameInput = new TextBoxInputSource(_txtNewName),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            GitterApplication.FontManager.InputFont.Apply(_txtNewName, _txtOldName);

            _controller = new RenameRemoteController(remote);
        }
Пример #9
0
        public InitDialog(IGitRepositoryProvider gitRepositoryProvider)
        {
            Verify.Argument.IsNotNull(gitRepositoryProvider, "gitRepositoryProvider");

            _gitRepositoryProvider = gitRepositoryProvider;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _repositoryPathInput    = new TextBoxInputSource(_txtPath),
                _bareInput              = new CheckBoxInputSource(_chkBare),
                _useCustomTemplateInput = new CheckBoxInputSource(_chkUseTemplate),
                _templateInput          = new TextBoxInputSource(_txtTemplate),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            GitterApplication.FontManager.InputFont.Apply(_txtPath, _txtTemplate);

            _controller = new InitController(gitRepositoryProvider)
            {
                View = this
            };
        }
Пример #10
0
        public StashToBranchDialog(StashedState stashedState)
        {
            Verify.Argument.IsNotNull(stashedState, "stashedState");
            Verify.Argument.IsFalse(stashedState.IsDeleted, "stashedState",
                Resources.ExcObjectIsDeleted.UseAsFormat(stashedState.GetType().Name));

            _stashedState = stashedState;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _branchNameInput = new TextBoxInputSource(_txtBranchName),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtBranchName, ReferenceType.LocalBranch);

            _txtStashName.Text = ((IRevisionPointer)_stashedState).Pointer;

            GitterApplication.FontManager.InputFont.Apply(_txtBranchName, _txtStashName);

            _controller = new StashToBranchController(stashedState) { View = this };
        }
Пример #11
0
        /// <summary>Create <see cref="CreateBranchDialog"/>.</summary>
        /// <param name="repository"><see cref="Repository"/> to create <see cref="Branch"/> in.</param>
        /// <exception cref="ArgumentNullException"><paramref name="repository"/> == <c>null</c>.</exception>
        public CreateBranchDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _branchNameInput       = new TextBoxInputSource(_txtName),
                _startingRevisionInput = new ControlInputSource(_txtRevision),
                _checkoutInput         = new CheckBoxInputSource(_chkCheckoutAfterCreation),
                _orphanInput           = new CheckBoxInputSource(_chkOrphan),
                _createReflogInput     = new CheckBoxInputSource(_chkCreateReflog),
                _trackingModeInput     = new RadioButtonGroupInputSource <BranchTrackingMode>(
                    new[]
                {
                    Tuple.Create(_trackingDefault, BranchTrackingMode.Default),
                    Tuple.Create(_trackingTrack, BranchTrackingMode.Tracking),
                    Tuple.Create(_trackingDoNotTrack, BranchTrackingMode.NotTracking),
                }),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtName, ReferenceType.LocalBranch);

            var logallrefupdates = _repository.Configuration.TryGetParameterValue(GitConstants.CoreLogAllRefUpdatesParameter);

            if (logallrefupdates != null && logallrefupdates == "true")
            {
                _chkCreateReflog.Checked = true;
                _chkCreateReflog.Enabled = false;
            }

            ToolTipService.Register(_chkCheckoutAfterCreation, Resources.TipCheckoutAfterCreation);
            ToolTipService.Register(_chkOrphan, Resources.TipOrphan);
            ToolTipService.Register(_chkCreateReflog, Resources.TipReflog);
            ToolTipService.Register(_trackingTrack, Resources.TipTrack);

            _txtRevision.References.LoadData(
                _repository,
                ReferenceType.Reference,
                GlobalBehavior.GroupReferences,
                GlobalBehavior.GroupRemoteBranches);
            _txtRevision.References.Items[0].IsExpanded = true;

            GitterApplication.FontManager.InputFont.Apply(_txtName, _txtRevision);
            GlobalBehavior.SetupAutoCompleteSource(_txtRevision, _repository, ReferenceType.Branch);

            _controller = new CreateBranchController(repository)
            {
                View = this
            };
        }
Пример #12
0
        public static bool ValidateUrl(string url, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if (string.IsNullOrWhiteSpace(url))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidUrl,
                                                   Resources.ErrUrlCannotBeEmpty));
                return(false);
            }
            return(true);
        }
Пример #13
0
        public CommitDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _messageInput     = new TextBoxInputSource(_txtMessage),
                _amendInput       = new CheckBoxInputSource(_chkAmend),
                _stagedItemsInput = new ControlInputSource(_lstStaged),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            for (int i = 0; i < _lstStaged.Columns.Count; ++i)
            {
                var col = _lstStaged.Columns[i];
                col.IsVisible = col.Id == (int)ColumnId.Name;
            }

            _lstStaged.Columns[0].SizeMode = ColumnSizeMode.Auto;
            _lstStaged.Style = GitterApplication.DefaultStyle;
            _lstStaged.SetTree(repository.Status.StagedRoot, TreeListBoxMode.ShowFullTree);
            _lstStaged.ExpandAll();

            _chkAmend.Enabled = !repository.Head.IsEmpty;

            GitterApplication.FontManager.InputFont.Apply(_txtMessage);
            if (SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }

            _txtMessage.Text   = repository.Status.LoadCommitMessage();
            _txtMessage.Height = _chkAmend.Top - _txtMessage.Top - 2;

            _controller = new CommitController(repository)
            {
                View = this
            };
        }
Пример #14
0
        /// <summary>Create <see cref="CreateTagDialog"/>.</summary>
        /// <param name="repository"><see cref="Repository"/> to create <see cref="Tag"/> in.</param>
        /// <exception cref="ArgumentNullException"><paramref name="repository"/> == <c>null</c>.</exception>
        public CreateTagDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _tagNameInput   = new TextBoxInputSource(_txtName),
                _revisionInput  = new ControlInputSource(_txtRevision),
                _messageInput   = new TextBoxInputSource(_txtMessage),
                _annotatedInput = new RadioButtonInputSource(_radAnnotated),
                _signedInput    = new RadioButtonInputSource(_radSigned),
                _useKeyIdInput  = new RadioButtonInputSource(_radUseKeyId),
                _keyIdInput     = new TextBoxInputSource(_txtKeyId),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtName, ReferenceType.Tag);

            _txtRevision.References.LoadData(
                _repository,
                ReferenceType.Reference,
                GlobalBehavior.GroupReferences,
                GlobalBehavior.GroupRemoteBranches);
            _txtRevision.References.Items[0].IsExpanded = true;

            GitterApplication.FontManager.InputFont.Apply(_txtKeyId, _txtMessage, _txtName, _txtRevision);
            GlobalBehavior.SetupAutoCompleteSource(_txtRevision, _repository, ReferenceType.Branch);
            if (SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }

            _controller = new CreateTagController(repository)
            {
                View = this
            };
        }
Пример #15
0
        public CommitDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _messageInput     = new TextBoxInputSource(_txtMessage),
                _amendInput       = new CheckBoxInputSource(_chkAmend),
                _stagedItemsInput = new ControlInputSource(_lstStaged),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            for(int i = 0; i < _lstStaged.Columns.Count; ++i)
            {
                var col = _lstStaged.Columns[i];
                col.IsVisible = col.Id == (int)ColumnId.Name;
            }

            _lstStaged.Columns[0].SizeMode = ColumnSizeMode.Auto;
            _lstStaged.Style = GitterApplication.DefaultStyle;
            _lstStaged.SetTree(repository.Status.StagedRoot, TreeListBoxMode.ShowFullTree);
            _lstStaged.ExpandAll();

            _chkAmend.Enabled = !repository.Head.IsEmpty;

            GitterApplication.FontManager.InputFont.Apply(_txtMessage);
            if(SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }

            _txtMessage.Text = repository.Status.LoadCommitMessage();
            _txtMessage.Height = _chkAmend.Top - _txtMessage.Top - 2;

            _controller = new CommitController(repository) { View = this };
        }
Пример #16
0
        public MergeDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();
            SetupTooltips();

            var inputs = new IUserInputSource[]
            {
                _revisionsInput     = new RevisionsInput(_references),
                _messageInput       = new TextBoxInputSource(_txtMessage),
                _noFastForwardInput = new CheckBoxInputSource(_chkNoFF),
                _noCommitInput      = new CheckBoxInputSource(_chkNoCommit),
                _squashInput        = new CheckBoxInputSource(_chkSquash),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            if (SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }

            GitterApplication.FontManager.InputFont.Apply(_txtMessage);

            _unmergedBranches = _repository.Refs.GetUnmergedBranches();
            _references.DisableContextMenus = true;
            _references.Style = GitterApplication.DefaultStyle;
            _references.LoadData(_repository, ReferenceType.Branch, false, GlobalBehavior.GroupRemoteBranches,
                                 reference => _unmergedBranches.Contains(reference as BranchBase));

            _txtMessage.Height = _pnlOptions.Top - _txtMessage.Top - 6;

            _controller = new MergeController(repository)
            {
                View = this
            };
        }
Пример #17
0
        /// <summary>Create <see cref="CreateTagDialog"/>.</summary>
        /// <param name="repository"><see cref="Repository"/> to create <see cref="Tag"/> in.</param>
        /// <exception cref="ArgumentNullException"><paramref name="repository"/> == <c>null</c>.</exception>
        public CreateTagDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _tagNameInput   = new TextBoxInputSource(_txtName),
                _revisionInput  = new ControlInputSource(_txtRevision),
                _messageInput   = new TextBoxInputSource(_txtMessage),
                _annotatedInput = new RadioButtonInputSource(_radAnnotated),
                _signedInput    = new RadioButtonInputSource(_radSigned),
                _useKeyIdInput  = new RadioButtonInputSource(_radUseKeyId),
                _keyIdInput     = new TextBoxInputSource(_txtKeyId),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtName, ReferenceType.Tag);

            _txtRevision.References.LoadData(
                _repository,
                ReferenceType.Reference,
                GlobalBehavior.GroupReferences,
                GlobalBehavior.GroupRemoteBranches);
            _txtRevision.References.Items[0].IsExpanded = true;

            GitterApplication.FontManager.InputFont.Apply(_txtKeyId, _txtMessage, _txtName, _txtRevision);
            GlobalBehavior.SetupAutoCompleteSource(_txtRevision, _repository, ReferenceType.Branch);
            if(SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }

            _controller = new CreateTagController(repository) { View = this };
        }
Пример #18
0
        /// <summary>Create <see cref="AddNoteDialog"/>.</summary>
        /// <param name="repository">Repository to create note in.</param>
        public AddNoteDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();

            var inputs = new IUserInputSource[]
            {
                _revisionInput = new ControlInputSource(_txtRevision),
                _messageInput  = new TextBoxInputSource(_txtMessage),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            Text = Resources.StrAddNote;

            _txtRevision.References.LoadData(
                _repository,
                ReferenceType.Reference,
                GlobalBehavior.GroupReferences,
                GlobalBehavior.GroupRemoteBranches);
            _txtRevision.References.Items[0].IsExpanded = true;

            _txtRevision.Text = GitConstants.HEAD;

            _lblRevision.Text = Resources.StrRevision.AddColon();
            _lblMessage.Text  = Resources.StrMessage.AddColon();

            GitterApplication.FontManager.InputFont.Apply(_txtRevision, _txtMessage);
            if (SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }
            _controller = new AddNoteController(repository)
            {
                View = this
            };
        }
Пример #19
0
        public AddRemoteDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _remoteNameInput   = new TextBoxInputSource(_txtName),
                _urlInput          = new TextBoxInputSource(_txtUrl),
                _fetchInput        = new CheckBoxInputSource(_chkFetch),
                _mirrorInput       = new CheckBoxInputSource(_chkMirror),
                _tagFetchModeInput = new RadioButtonGroupInputSource <TagFetchMode>(
                    new[]
                {
                    Tuple.Create(_tagFetchDefault, gitter.Git.TagFetchMode.Default),
                    Tuple.Create(_tagFetchNone, gitter.Git.TagFetchMode.NoTags),
                    Tuple.Create(_tagFetchAll, gitter.Git.TagFetchMode.AllTags),
                }),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtName, ReferenceType.Remote);

            if (_repository.Remotes.Count == 0)
            {
                _txtName.Text = GitConstants.DefaultRemoteName;
            }

            GitterApplication.FontManager.InputFont.Apply(_txtName, _txtUrl);

            _controller = new AddRemoteController(repository)
            {
                View = this
            };
        }
Пример #20
0
        public InitDialog(IGitRepositoryProvider gitRepositoryProvider)
        {
            Verify.Argument.IsNotNull(gitRepositoryProvider, "gitRepositoryProvider");

            _gitRepositoryProvider = gitRepositoryProvider;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _repositoryPathInput    = new TextBoxInputSource(_txtPath),
                _bareInput              = new CheckBoxInputSource(_chkBare),
                _useCustomTemplateInput = new CheckBoxInputSource(_chkUseTemplate),
                _templateInput          = new TextBoxInputSource(_txtTemplate),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            GitterApplication.FontManager.InputFont.Apply(_txtPath, _txtTemplate);

            _controller = new InitController(gitRepositoryProvider) { View = this };
        }
Пример #21
0
        public CloneDialog(IGitRepositoryProvider gitRepositoryProvider)
        {
            Verify.Argument.IsNotNull(gitRepositoryProvider, "gitRepositoryProvider");

            _gitRepositoryProvider = gitRepositoryProvider;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _urlInput            = new TextBoxInputSource(_txtUrl),
                _repositoryPathInput = new RepositoryPathInput(_txtPath, _txtUrl, _chkAppendRepositoryNameFromUrl),
                _remoteNameInput     = new TextBoxInputSource(_txtRemoteName),
                _shallowCloneInput   = new CheckBoxInputSource(_chkShallowClone),
                _depthInput          = new NumericUpDownInputSource <int>(_numDepth, value => (int)value, value => value),
                _useTemplateInput    = new CheckBoxInputSource(_chkUseTemplate),
                _templatePathInput   = new TextBoxInputSource(_txtTemplate),
                _bareInput           = new CheckBoxInputSource(_chkBare),
                _mirrorInput         = new CheckBoxInputSource(_chkMirror),
                _noCheckoutInput     = new CheckBoxInputSource(_chkNoCheckout),
                _recursiveInput      = new CheckBoxInputSource(_chkRecursive),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);
            _repositoryPathInput.ValueChanged += (s, e) => UpdateTargetPathText();

            UpdateTargetPathText();

            GitterApplication.FontManager.InputFont.Apply(_txtUrl, _txtPath, _txtRemoteName);

            _controller = new CloneController(gitRepositoryProvider)
            {
                View = this
            };
        }
Пример #22
0
        /// <summary>Create <see cref="AddNoteDialog"/>.</summary>
        /// <param name="repository">Repository to create note in.</param>
        public AddNoteDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();

            var inputs = new IUserInputSource[]
            {
                _revisionInput = new ControlInputSource(_txtRevision),
                _messageInput  = new TextBoxInputSource(_txtMessage),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            Text = Resources.StrAddNote;

            _txtRevision.References.LoadData(
                _repository,
                ReferenceType.Reference,
                GlobalBehavior.GroupReferences,
                GlobalBehavior.GroupRemoteBranches);
            _txtRevision.References.Items[0].IsExpanded = true;

            _txtRevision.Text = GitConstants.HEAD;

            _lblRevision.Text = Resources.StrRevision.AddColon();
            _lblMessage.Text = Resources.StrMessage.AddColon();

            GitterApplication.FontManager.InputFont.Apply(_txtRevision, _txtMessage);
            if(SpellingService.Enabled)
            {
                _speller = new TextBoxSpellChecker(_txtMessage, true);
            }
            _controller = new AddNoteController(repository) { View = this };
        }
Пример #23
0
        public AddRemoteDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _remoteNameInput   = new TextBoxInputSource(_txtName),
                _urlInput          = new TextBoxInputSource(_txtUrl),
                _fetchInput        = new CheckBoxInputSource(_chkFetch),
                _mirrorInput       = new CheckBoxInputSource(_chkMirror),
                _tagFetchModeInput = new RadioButtonGroupInputSource<TagFetchMode>(
                    new[]
                    {
                        Tuple.Create(_tagFetchDefault, gitter.Git.TagFetchMode.Default),
                        Tuple.Create(_tagFetchNone,    gitter.Git.TagFetchMode.NoTags),
                        Tuple.Create(_tagFetchAll,     gitter.Git.TagFetchMode.AllTags),
                    }),
            };
            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);

            SetupReferenceNameInputBox(_txtName, ReferenceType.Remote);

            if(_repository.Remotes.Count == 0)
            {
                _txtName.Text = GitConstants.DefaultRemoteName;
            }

            GitterApplication.FontManager.InputFont.Apply(_txtName, _txtUrl);

            _controller = new AddRemoteController(repository) { View = this };
        }
Пример #24
0
        public static bool ValidateRelativePath(string path, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            int start = -1;
            int end   = -1;

            for (int i = 0; i < path.Length; ++i)
            {
                if (!char.IsWhiteSpace(path[i]))
                {
                    start = i;
                    break;
                }
            }
            if (start == -1)
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrNoPathSpecified,
                                                   Resources.ErrPathCannotBeEmpty));
                return(false);
            }
            for (int i = path.Length - 1; i >= 0; --i)
            {
                if (!char.IsWhiteSpace(path[i]))
                {
                    end = i;
                    break;
                }
            }
            if (!ValidatePartialPath(path, start, end, userInputSource, inputErrorNotifier))
            {
                return(false);
            }
            return(true);
        }
Пример #25
0
        public static bool ValidateNewBranchName(string branchName, Repository repository, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(!ValidateBranchName(branchName, userInputSource, inputErrorNotifier))
            {
                return false;
            }
            if(repository.Refs.Heads.Contains(branchName) ||
                repository.Refs.Remotes.Contains(branchName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidBranchName,
                        Resources.ErrBranchAlreadyExists));
                return false;
            }
            return true;
        }
Пример #26
0
        public static bool ValidateNewTagName(string tagName, Repository repository, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));
            Verify.Argument.IsNotNull(userInputSource, nameof(userInputSource));
            Verify.Argument.IsNotNull(inputErrorNotifier, nameof(inputErrorNotifier));

            if (!ValidateTagName(tagName, userInputSource, inputErrorNotifier))
            {
                return(false);
            }
            if (repository.Refs.Tags.Contains(tagName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidTagName,
                                                   Resources.ErrTagAlreadyExists));
                return(false);
            }
            return(true);
        }
Пример #27
0
        public static bool ValidateTagName(string tagName, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(string.IsNullOrWhiteSpace(tagName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrNoTagNameSpecified,
                        Resources.ErrTagNameCannotBeEmpty));
                return false;
            }
            string errmsg;
            if(!Tag.ValidateName(tagName, out errmsg))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidTagName,
                        errmsg));
                return false;
            }
            return true;
        }
Пример #28
0
        public static bool ValidateAbsolutePath(string path, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            int start = -1;
            int end   = -1;

            for (int i = 0; i < path.Length; ++i)
            {
                if (!char.IsWhiteSpace(path[i]))
                {
                    start = i;
                    break;
                }
            }
            if (start == -1)
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrNoPathSpecified,
                                                   Resources.ErrPathCannotBeEmpty));
                return(false);
            }
            for (int i = path.Length - 1; i >= 0; --i)
            {
                if (!char.IsWhiteSpace(path[i]))
                {
                    end = i;
                    break;
                }
            }
            int length = end - start + 1;

            if (length >= 3)
            {
                var c0 = path[start + 0];
                var c1 = path[start + 1];
                var c2 = path[start + 2];
                if (c1 == Path.VolumeSeparatorChar)
                {
                    if (!((c0 >= 'a' && c0 <= 'z') || (c0 >= 'A' && c0 <= 'Z')))
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidPath,
                                                           Resources.ErrPathUnknownSchema));
                        return(false);
                    }
                    if (c2 != Path.DirectorySeparatorChar && c2 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidPath,
                                                           Resources.ErrPathUnknownSchema));
                        return(false);
                    }
                    start  += 3;
                    length -= 3;
                }
                else
                {
                    if (c0 != Path.DirectorySeparatorChar && c0 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidPath,
                                                           Resources.ErrPathUnknownSchema));
                        return(false);
                    }
                    if (c1 != Path.DirectorySeparatorChar && c1 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidPath,
                                                           Resources.ErrPathUnknownSchema));
                        return(false);
                    }
                    start  += 2;
                    length += 2;
                }
            }
            else
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidPath,
                                                   Resources.ErrPathIsTooShort));
                return(false);
            }
            if (!ValidatePartialPath(path, start, end, userInputSource, inputErrorNotifier))
            {
                return(false);
            }
            return(true);
        }
Пример #29
0
        public static bool ValidateRemoteName(string remoteName, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if (string.IsNullOrWhiteSpace(remoteName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrNoRemoteNameSpecified,
                                                   Resources.ErrRemoteNameCannotBeEmpty));
                return(false);
            }
            string errorMessage;

            if (!Reference.ValidateName(remoteName, ReferenceType.Remote, out errorMessage))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidRemoteName,
                                                   errorMessage));
                return(false);
            }
            return(true);
        }
Пример #30
0
        public static bool ValidateRefspec(string refspec, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if (string.IsNullOrEmpty(refspec))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidRevisionExpression,
                                                   Resources.ErrStartingRevisionCannotBeEmpty));
                return(false);
            }
            bool encounteredNonWhitespace      = false;
            bool encounteredTrailingWhitespace = false;

            for (int i = 0; i < refspec.Length; ++i)
            {
                if (char.IsWhiteSpace(refspec[i]))
                {
                    if (encounteredNonWhitespace)
                    {
                        encounteredTrailingWhitespace = true;
                    }
                }
                else
                {
                    if (encounteredTrailingWhitespace)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidRevisionExpression,
                                                           Resources.ErrRefspecCannotContainSpaces));
                    }
                    encounteredNonWhitespace = true;
                }
            }
            if (!encounteredNonWhitespace)
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidRevisionExpression,
                                                   Resources.ErrStartingRevisionCannotBeEmpty));
                return(false);
            }
            return(true);
        }
Пример #31
0
        public static bool ValidateRefspec(string refspec, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(string.IsNullOrEmpty(refspec))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidRevisionExpression,
                        Resources.ErrStartingRevisionCannotBeEmpty));
                return false;
            }
            bool encounteredNonWhitespace = false;
            bool encounteredTrailingWhitespace = false;
            for(int i = 0; i < refspec.Length; ++i)
            {
                if(char.IsWhiteSpace(refspec[i]))
                {
                    if(encounteredNonWhitespace)
                    {
                        encounteredTrailingWhitespace = true;
                    }
                }
                else
                {
                    if(encounteredTrailingWhitespace)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidRevisionExpression,
                                Resources.ErrRefspecCannotContainSpaces));
                    }
                    encounteredNonWhitespace = true;
                }
            }
            if(!encounteredNonWhitespace)
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidRevisionExpression,
                        Resources.ErrStartingRevisionCannotBeEmpty));
                return false;
            }
            return true;
        }
Пример #32
0
 public static bool ValidateRelativePath(string path, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
 {
     int start = -1;
     int end = -1;
     for(int i = 0; i < path.Length; ++i)
     {
         if(!char.IsWhiteSpace(path[i]))
         {
             start = i;
             break;
         }
     }
     if(start == -1)
     {
         inputErrorNotifier.NotifyError(userInputSource,
             new UserInputError(
                 Resources.ErrNoPathSpecified,
                 Resources.ErrPathCannotBeEmpty));
         return false;
     }
     for(int i = path.Length - 1; i >= 0; --i)
     {
         if(!char.IsWhiteSpace(path[i]))
         {
             end = i;
             break;
         }
     }
     if(!ValidatePartialPath(path, start, end, userInputSource, inputErrorNotifier))
     {
         return false;
     }
     return true;
 }
Пример #33
0
        public static bool ValidateAbsolutePath(string path, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            int start = -1;
            int end = -1;
            for(int i = 0; i < path.Length; ++i)
            {
                if(!char.IsWhiteSpace(path[i]))
                {
                    start = i;
                    break;
                }
            }
            if(start == -1)
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrNoPathSpecified,
                        Resources.ErrPathCannotBeEmpty));
                return false;
            }
            for(int i = path.Length - 1; i >= 0; --i)
            {
                if(!char.IsWhiteSpace(path[i]))
                {
                    end = i;
                    break;
                }
            }
            int length = end - start + 1;

            if(length >= 3)
            {
                var c0 = path[start + 0];
                var c1 = path[start + 1];
                var c2 = path[start + 2];
                if(c1 == Path.VolumeSeparatorChar)
                {
                    if(!((c0 >= 'a' && c0 <= 'z') || (c0 >= 'A' && c0 <= 'Z')))
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidPath,
                                Resources.ErrPathUnknownSchema));
                        return false;
                    }
                    if(c2 != Path.DirectorySeparatorChar && c2 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidPath,
                                Resources.ErrPathUnknownSchema));
                        return false;
                    }
                    start += 3;
                    length -= 3;
                }
                else
                {
                    if(c0 != Path.DirectorySeparatorChar && c0 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidPath,
                                Resources.ErrPathUnknownSchema));
                        return false;
                    }
                    if(c1 != Path.DirectorySeparatorChar && c1 != Path.AltDirectorySeparatorChar)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidPath,
                                Resources.ErrPathUnknownSchema));
                        return false;
                    }
                    start += 2;
                    length += 2;
                }
            }
            else
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidPath,
                        Resources.ErrPathIsTooShort));
                return false;
            }
            if(!ValidatePartialPath(path, start, end, userInputSource, inputErrorNotifier))
            {
                return false;
            }
            return true;
        }
Пример #34
0
        public static bool ValidateRemoteName(string remoteName, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(string.IsNullOrWhiteSpace(remoteName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrNoRemoteNameSpecified,
                        Resources.ErrRemoteNameCannotBeEmpty));
                return false;
            }
            string errorMessage;
            if(!Reference.ValidateName(remoteName, ReferenceType.Remote, out errorMessage))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidRemoteName,
                        errorMessage));
                return false;
            }
            return true;
        }
Пример #35
0
        public static bool ValidateTagName(string tagName, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if (string.IsNullOrWhiteSpace(tagName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrNoTagNameSpecified,
                                                   Resources.ErrTagNameCannotBeEmpty));
                return(false);
            }
            string errmsg;

            if (!Tag.ValidateName(tagName, out errmsg))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidTagName,
                                                   errmsg));
                return(false);
            }
            return(true);
        }
Пример #36
0
        private static bool ValidatePartialPath(string path, int start, int end, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Assert.IsNotNull(path);
            Assert.IsNotNull(userInputSource);
            Assert.IsNotNull(inputErrorNotifier);

            var  invalidPathChars   = Path.GetInvalidFileNameChars();
            bool endsWithWhitespace = false;
            bool isPartStart        = true;

            for (int i = start; i <= end; ++i)
            {
                char c = path[i];
                if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar)
                {
                    if (i != start)
                    {
                        if (isPartStart)
                        {
                            inputErrorNotifier.NotifyError(userInputSource,
                                                           new UserInputError(
                                                               Resources.ErrInvalidPath,
                                                               Resources.ErrPathCannotContainEmptyDirectoryName));
                            return(false);
                        }
                        if (endsWithWhitespace)
                        {
                            inputErrorNotifier.NotifyError(userInputSource,
                                                           new UserInputError(
                                                               Resources.ErrInvalidPath,
                                                               Resources.ErrDirectoryNameCannotEndWithWhitespace));
                            return(false);
                        }
                        isPartStart = true;
                    }
                    continue;
                }
                if (Array.IndexOf(invalidPathChars, c) != -1)
                {
                    inputErrorNotifier.NotifyError(userInputSource,
                                                   new UserInputError(
                                                       Resources.ErrInvalidPath,
                                                       Resources.ErrPathCannotContainCharacter.UseAsFormat(c)));
                    return(false);
                }
                endsWithWhitespace = char.IsWhiteSpace(c);
                if (isPartStart)
                {
                    if (endsWithWhitespace)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                                                       new UserInputError(
                                                           Resources.ErrInvalidPath,
                                                           Resources.ErrDirectoryNameCannotStartWithWhitespace));
                        return(false);
                    }
                    isPartStart = false;
                }
            }
            return(true);
        }
Пример #37
0
        public static bool ValidateUrl(string url, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(string.IsNullOrWhiteSpace(url))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidUrl,
                        Resources.ErrUrlCannotBeEmpty));
                return false;
            }
            return true;
        }
Пример #38
0
        public static bool ValidateNewTagName(string tagName, Repository repository, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if(!ValidateTagName(tagName, userInputSource, inputErrorNotifier))
            {
                return false;
            }
            if(repository.Refs.Tags.Contains(tagName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                    new UserInputError(
                        Resources.ErrInvalidTagName,
                        Resources.ErrTagAlreadyExists));
                return false;
            }
            return true;
        }
Пример #39
0
        public static bool ValidateBranchName(string branchName, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(userInputSource, nameof(userInputSource));
            Verify.Argument.IsNotNull(inputErrorNotifier, nameof(inputErrorNotifier));

            if (string.IsNullOrWhiteSpace(branchName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrNoBranchNameSpecified,
                                                   Resources.ErrBranchNameCannotBeEmpty));
                return(false);
            }
            string errmsg;

            if (!Branch.ValidateName(branchName, out errmsg))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidBranchName,
                                                   errmsg));
                return(false);
            }
            return(true);
        }
Пример #40
0
        public static bool ValidateNewRemoteName(string remoteName, Repository repository, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(userInputSource, "userInputSource");
            Verify.Argument.IsNotNull(inputErrorNotifier, "inputErrorNotifier");

            if (!ValidateRemoteName(remoteName, userInputSource, inputErrorNotifier))
            {
                return(false);
            }
            if (repository.Remotes.Contains(remoteName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidRemoteName,
                                                   Resources.ErrRemoteAlreadyExists));
                return(false);
            }
            return(true);
        }
Пример #41
0
        public static bool ValidateNewBranchName(string branchName, Repository repository, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));
            Verify.Argument.IsNotNull(userInputSource, nameof(userInputSource));
            Verify.Argument.IsNotNull(inputErrorNotifier, nameof(inputErrorNotifier));

            if (!ValidateBranchName(branchName, userInputSource, inputErrorNotifier))
            {
                return(false);
            }
            if (repository.Refs.Heads.Contains(branchName) ||
                repository.Refs.Remotes.Contains(branchName))
            {
                inputErrorNotifier.NotifyError(userInputSource,
                                               new UserInputError(
                                                   Resources.ErrInvalidBranchName,
                                                   Resources.ErrBranchAlreadyExists));
                return(false);
            }
            return(true);
        }
Пример #42
0
        private static bool ValidatePartialPath(string path, int start, int end, IUserInputSource userInputSource, IUserInputErrorNotifier inputErrorNotifier)
        {
            Assert.IsNotNull(path);
            Assert.IsNotNull(userInputSource);
            Assert.IsNotNull(inputErrorNotifier);

            var invalidPathChars = Path.GetInvalidFileNameChars();
            bool endsWithWhitespace = false;
            bool isPartStart = true;
            for(int i = start; i <= end; ++i)
            {
                char c = path[i];
                if(c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar)
                {
                    if(i != start)
                    {
                        if(isPartStart)
                        {
                            inputErrorNotifier.NotifyError(userInputSource,
                                new UserInputError(
                                    Resources.ErrInvalidPath,
                                    Resources.ErrPathCannotContainEmptyDirectoryName));
                            return false;
                        }
                        if(endsWithWhitespace)
                        {
                            inputErrorNotifier.NotifyError(userInputSource,
                                new UserInputError(
                                    Resources.ErrInvalidPath,
                                    Resources.ErrDirectoryNameCannotEndWithWhitespace));
                            return false;
                        }
                        isPartStart = true;
                    }
                    continue;
                }
                if(Array.IndexOf(invalidPathChars, c) != -1)
                {
                    inputErrorNotifier.NotifyError(userInputSource,
                        new UserInputError(
                            Resources.ErrInvalidPath,
                            Resources.ErrPathCannotContainCharacter.UseAsFormat(c)));
                    return false;
                }
                endsWithWhitespace = char.IsWhiteSpace(c);
                if(isPartStart)
                {
                    if(endsWithWhitespace)
                    {
                        inputErrorNotifier.NotifyError(userInputSource,
                            new UserInputError(
                                Resources.ErrInvalidPath,
                                Resources.ErrDirectoryNameCannotStartWithWhitespace));
                        return false;
                    }
                    isPartStart = false;
                }
            }
            return true;
        }
Пример #43
0
        public PushDialog(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            InitializeComponent();
            Localize();

            var inputs = new IUserInputSource[]
            {
                _pushToInput = new RadioButtonGroupInputSource <PushTo>(
                    new[]
                {
                    Tuple.Create(_radRemote, gitter.Git.Gui.Interfaces.PushTo.Remote),
                    Tuple.Create(_radUrl, gitter.Git.Gui.Interfaces.PushTo.Url),
                }),
                _remoteInput         = PickerInputSource.Create(_remotePicker),
                _urlInput            = new TextBoxInputSource(_txtUrl),
                _referencesInput     = new BranchesInputSource(_lstReferences),
                _forceOverwriteInput = new CheckBoxInputSource(_chkForceOverwriteBranches),
                _thinPackInput       = new CheckBoxInputSource(_chkUseThinPack),
                _sendTagsInput       = new CheckBoxInputSource(_chkSendTags),
            };

            _errorNotifier = new UserInputErrorNotifier(NotificationService, inputs);


            _picWarning.Image = CachedResources.Bitmaps["ImgWarning"];

            _lstReferences.LoadData(_repository, ReferenceType.LocalBranch, false, false, null);
            _lstReferences.EnableCheckboxes();

            if (!_repository.Head.IsDetached)
            {
                foreach (BranchListItem item in _lstReferences.Items)
                {
                    if (item.DataContext == _repository.Head.Pointer)
                    {
                        item.CheckedState = CheckedState.Checked;
                        break;
                    }
                }
            }

            _remotePicker.LoadData(repository);
            Remote remote = null;

            lock (repository.Remotes.SyncRoot)
            {
                foreach (var r in repository.Remotes)
                {
                    remote = r;
                    break;
                }
            }
            _remotePicker.SelectedValue = remote;

            _controller = new PushController(repository)
            {
                View = this
            };
        }