public SettingsPanelViewModel(
            IConfigProvider <SourceControlSettings> configService,
            IFolderBrowserFactory folderBrowserFactory,
            IOpenFileDialog openFileDialog)
        {
            _configService        = configService;
            _folderBrowserFactory = folderBrowserFactory;
            _config = _configService.Create();

            _openFileDialog                 = openFileDialog;
            _openFileDialog.Filter          = "Executables (*.exe)|*.exe|All files (*.*)|*.*";
            _openFileDialog.Multiselect     = false;
            _openFileDialog.ReadOnlyChecked = true;
            _openFileDialog.CheckFileExists = true;

            UserName     = _config.UserName;
            EmailAddress = _config.EmailAddress;
            DefaultRepositoryLocation = _config.DefaultRepositoryLocation;
            CommandPromptLocation     = _config.CommandPromptLocation;

            _showDefaultRepoFolderPickerCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowDefaultRepoFolderPicker());
            _showCommandPromptExePickerCommand  = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowCommandPromptExePicker());
            _cancelSettingsChangesCommand       = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CancelSettingsChanges());
            _updateSettingsCommand    = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => UpdateSettings());
            _showGitIgnoreCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowGitIgnore(), _ => Provider != null);
            _showGitAttributesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowGitAttributes(), _ => Provider != null);
        }
Beispiel #2
0
        private void ViewModel_ErrorThrown(object sender, ErrorEventArgs e)
        {
            const string unauthorizedMessage = "Request failed with status code: 401";

            if (e.InnerMessage == unauthorizedMessage)
            {
                Logger.Trace("Requesting login");
                DisplayLoginGrid = true;
            }
            else
            {
                Logger.Trace("Displaying {0} with title '{1}' and message '{2}'", e.NotificationType, e.Title, e.InnerMessage);

                ErrorTitle   = e.Title;
                ErrorMessage = e.InnerMessage;

                IconMappings.TryGetValue(e.NotificationType, out _errorIcon);
                OnPropertyChanged("ErrorIcon");

                DisplayErrorMessageGrid = true;
            }

            if (e.InnerMessage == RubberduckUI.SourceControl_UpdateSettingsMessage)
            {
                _config = _configService.Create();
            }
        }
        private void HandleViewModelError(object sender, ErrorEventArgs e)
        {
            // smell: relies on implementation detail of 3rd-party library
            const string unauthorizedMessage = "Request failed with status code: 401";

            if (e.InnerMessage == unauthorizedMessage)
            {
                Logger.Trace("Requesting login");
                DisplayLoginGrid = true;
            }
            else
            {
                Logger.Trace($"Displaying {e.NotificationType} notification with title '{e.Title}' and message '{e.InnerMessage}'");
                ErrorTitle   = e.Title;
                ErrorMessage = e.InnerMessage;

                IconMappings.TryGetValue(e.NotificationType, out _errorIcon);
                OnPropertyChanged("ErrorIcon");

                DisplayErrorMessageGrid = true;
            }

            if (e.InnerMessage == RubberduckUI.SourceControl_UpdateSettingsMessage)
            {
                _config = _configService.Create();
            }
        }
Beispiel #4
0
        public SourceControlViewViewModel(
            VBE vbe,
            RubberduckParserState state,
            ISourceControlProviderFactory providerFactory,
            IFolderBrowserFactory folderBrowserFactory,
            ISourceControlConfigProvider configService,
            [Named("changesView")] IControlView changesView,
            [Named("branchesView")] IControlView branchesView,
            [Named("unsyncedCommitsView")] IControlView unsyncedCommitsView,
            [Named("settingsView")] IControlView settingsView,
            ICodePaneWrapperFactory wrapperFactory,
            IMessageBox messageBox)
        {
            _vbe                  = vbe;
            _state                = state;
            _providerFactory      = providerFactory;
            _folderBrowserFactory = folderBrowserFactory;

            _state.StateChanged += _state_StateChanged;

            _configService  = configService;
            _config         = _configService.Create();
            _wrapperFactory = wrapperFactory;
            _messageBox     = messageBox;

            _initRepoCommand            = new DelegateCommand(_ => InitRepo());
            _openRepoCommand            = new DelegateCommand(_ => OpenRepo());
            _cloneRepoCommand           = new DelegateCommand(_ => ShowCloneRepoGrid());
            _publishRepoCommand         = new DelegateCommand(_ => ShowPublishRepoGrid());
            _refreshCommand             = new DelegateCommand(_ => Refresh());
            _dismissErrorMessageCommand = new DelegateCommand(_ => DismissErrorMessage());
            _showFilePickerCommand      = new DelegateCommand(_ => ShowFilePicker());
            _loginGridOkCommand         = new DelegateCommand(_ => CloseLoginGrid(), text => !string.IsNullOrEmpty((string)text));
            _loginGridCancelCommand     = new DelegateCommand(_ => CloseLoginGrid());

            _cloneRepoOkButtonCommand     = new DelegateCommand(_ => CloneRepo(), _ => !IsNotValidCloneRemotePath);
            _cloneRepoCancelButtonCommand = new DelegateCommand(_ => CloseCloneRepoGrid());

            _publishRepoOkButtonCommand     = new DelegateCommand(_ => PublishRepo(), _ => !IsNotValidPublishRemotePath);
            _publishRepoCancelButtonCommand = new DelegateCommand(_ => ClosePublishRepoGrid());

            TabItems = new ObservableCollection <IControlView>
            {
                changesView,
                branchesView,
                unsyncedCommitsView,
                settingsView
            };
            SetTab(SourceControlTab.Changes);

            Status = RubberduckUI.Offline;

            ListenForErrors();

            _fileSystemWatcher = new FileSystemWatcher();
        }
Beispiel #5
0
        public SourceControlViewViewModel(
            VBE vbe,
            RubberduckParserState state,
            ISinks sinks,
            ISourceControlProviderFactory providerFactory,
            IFolderBrowserFactory folderBrowserFactory,
            IConfigProvider <SourceControlSettings> configService,
            IEnumerable <IControlView> views,
            ICodePaneWrapperFactory wrapperFactory,
            IMessageBox messageBox)
        {
            _vbe                  = vbe;
            _state                = state;
            _sinks                = sinks;
            _providerFactory      = providerFactory;
            _folderBrowserFactory = folderBrowserFactory;

            _state.StateChanged += _state_StateChanged;

            _configService  = configService;
            _config         = _configService.Create();
            _wrapperFactory = wrapperFactory;
            _messageBox     = messageBox;

            _initRepoCommand            = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => InitRepo(), _ => _vbe.VBProjects.Count != 0);
            _openRepoCommand            = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => OpenRepo(), _ => _vbe.VBProjects.Count != 0);
            _cloneRepoCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowCloneRepoGrid(), _ => _vbe.VBProjects.Count != 0);
            _publishRepoCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowPublishRepoGrid(), _ => _vbe.VBProjects.Count != 0 && Provider != null);
            _refreshCommand             = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => Refresh());
            _dismissErrorMessageCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => DismissErrorMessage());
            _showFilePickerCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowFilePicker());
            _loginGridOkCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseLoginGrid(), text => !string.IsNullOrEmpty((string)text));
            _loginGridCancelCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseLoginGrid());

            _cloneRepoOkButtonCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloneRepo(), _ => !IsNotValidCloneRemotePath);
            _cloneRepoCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseCloneRepoGrid());

            _publishRepoOkButtonCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => PublishRepo(), _ => !IsNotValidPublishRemotePath);
            _publishRepoCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ClosePublishRepoGrid());

            _openCommandPromptCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => OpenCommandPrompt());

            _sinks.ComponentAdded   += ComponentAdded;
            _sinks.ComponentRemoved += ComponentRemoved;
            _sinks.ComponentRenamed += ComponentRenamed;
            _sinks.ProjectRemoved   += ProjectRemoved;

            TabItems = new ObservableCollection <IControlView>(views);
            SetTab(SourceControlTab.Changes);

            Status = RubberduckUI.Offline;

            ListenForErrors();

            _fileSystemWatcher = new FileSystemWatcher();
        }
        public void Initialize()
        {
            _config = new SourceControlSettings(Name, Email, RepoLocation, new List <Repository>());

            _configService = new Mock <ISourceControlConfigProvider>();
            _configService.Setup(s => s.Create()).Returns(_config);

            _folderBrowser        = new Mock <IFolderBrowser>();
            _folderBrowserFactory = new Mock <IFolderBrowserFactory>();
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>())).Returns(_folderBrowser.Object);
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>(), false)).Returns(_folderBrowser.Object);
        }
        public SourceControlViewViewModel(
            IVBE vbe,
            RubberduckParserState state,
            ISourceControlProviderFactory providerFactory,
            IFolderBrowserFactory folderBrowserFactory,
            IConfigProvider <SourceControlSettings> configService,
            IEnumerable <IControlView> views,
            IMessageBox messageBox,
            IEnvironmentProvider environment)
        {
            _vbe                  = vbe;
            _state                = state;
            _providerFactory      = providerFactory;
            _folderBrowserFactory = folderBrowserFactory;

            _configService = configService;
            _config        = _configService.Create();
            _messageBox    = messageBox;
            _environment   = environment;

            InitRepoCommand            = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => InitRepo(), _ => _vbe.VBProjects.Count != 0);
            OpenRepoCommand            = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => OpenRepo(), _ => _vbe.VBProjects.Count != 0);
            CloneRepoCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowCloneRepoGrid(), _ => _vbe.VBProjects.Count != 0);
            PublishRepoCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowPublishRepoGrid(), _ => _vbe.VBProjects.Count != 0 && Provider != null);
            RefreshCommand             = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => Refresh());
            DismissErrorMessageCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => DismissErrorMessage());
            ShowFilePickerCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowFilePicker());
            LoginGridOkCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseLoginGrid(), text => !string.IsNullOrEmpty((string)text));
            LoginGridCancelCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseLoginGrid());

            CloneRepoOkButtonCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloneRepo(), _ => !IsNotValidCloneRemotePath);
            CloneRepoCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CloseCloneRepoGrid());

            PublishRepoOkButtonCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => PublishRepo(), _ => !IsNotValidPublishRemotePath);
            PublishRepoCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ClosePublishRepoGrid());

            OpenCommandPromptCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => OpenCommandPrompt());

            AddComponentEventHandlers();

            TabItems = new ObservableCollection <IControlView>(views);
            SetTab(SourceControlTab.Changes);

            Status = RubberduckUI.Offline;

            ListenForErrors();

            _fileSystemWatcher = new FileSystemWatcher();
        }
        public SettingsViewViewModel(
            ISourceControlConfigProvider configService,
            IFolderBrowserFactory folderBrowserFactory)
        {
            _configService        = configService;
            _folderBrowserFactory = folderBrowserFactory;
            _config = _configService.Create();

            UserName     = _config.UserName;
            EmailAddress = _config.EmailAddress;
            DefaultRepositoryLocation = _config.DefaultRepositoryLocation;

            _showFilePickerCommand        = new DelegateCommand(_ => ShowFilePicker());
            _cancelSettingsChangesCommand = new DelegateCommand(_ => CancelSettingsChanges());
            _updateSettingsCommand        = new DelegateCommand(_ => UpdateSettings());
            _showGitIgnoreCommand         = new DelegateCommand(_ => ShowGitIgnore(), _ => Provider != null);
            _showGitAttributesCommand     = new DelegateCommand(_ => ShowGitAttributes(), _ => Provider != null);
        }
 /// <remarks/>
 public void GetRepositoryFileSystemLayerAsync(string SessionID, string Path, SourceControlSettings SourceControlSettings, object userState) {
     if ((this.GetRepositoryFileSystemLayerOperationCompleted == null)) {
         this.GetRepositoryFileSystemLayerOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetRepositoryFileSystemLayerOperationCompleted);
     }
     this.InvokeAsync("GetRepositoryFileSystemLayer", new object[] {
                 SessionID,
                 Path,
                 SourceControlSettings}, this.GetRepositoryFileSystemLayerOperationCompleted, userState);
 }
 /// <remarks/>
 public void GetRepositoryFileSystemLayerAsync(string SessionID, string Path, SourceControlSettings SourceControlSettings) {
     this.GetRepositoryFileSystemLayerAsync(SessionID, Path, SourceControlSettings, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginGetRepositoryFileSystemLayer(string SessionID, string Path, SourceControlSettings SourceControlSettings, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("GetRepositoryFileSystemLayer", new object[] {
                 SessionID,
                 Path,
                 SourceControlSettings}, callback, asyncState);
 }
 public CxWSResponseFileSystemLayer GetRepositoryFileSystemLayer(string SessionID, string Path, SourceControlSettings SourceControlSettings) {
     object[] results = this.Invoke("GetRepositoryFileSystemLayer", new object[] {
                 SessionID,
                 Path,
                 SourceControlSettings});
     return ((CxWSResponseFileSystemLayer)(results[0]));
 }
Beispiel #13
0
    public CxWSResponseFileSystemLayer GetRepositoryFileSystemLayer(string SessionID, string Path, SourceControlSettings SourceControlSettings)
    {
        CxWSResponseFileSystemLayer result = _web_Service.GetRepositoryFileSystemLayer(SessionID, Path, SourceControlSettings);

        return(result);
    }
 public CxWSResponseFileSystemLayer GetRepositoryFileSystemLayer(string SessionID, string Path, SourceControlSettings SourceControlSettings)
 {
     CxWSResponseFileSystemLayer result = _web_Service.GetRepositoryFileSystemLayer(SessionID, Path, SourceControlSettings);
     return result;
 }