/// <summary>
 /// Initializes a new instance of <seealso cref="ErrorFrameTooltipViewModel"/> class.
 /// </summary>
 /// <param name="errorItem">The error item the tooltip shows.</param>
 public ErrorFrameTooltipViewModel(ErrorGroupItem errorItem)
 {
     OnCloseButtonCommand          = new ProtectedCommand(ShowTooltipUtils.HideTooltip);
     OnBackToErrorReportingCommand = new ProtectedCommand(
         () => ToolWindowCommandUtils.ShowToolWindow <ErrorReportingDetailToolWindow>());
     Error = errorItem;
 }
        public UserPromptWindowViewModel(UserPromptWindow owner, UserPromptWindow.Options options)
        {
            _owner   = owner;
            _options = options;

            ActionCommand = new ProtectedCommand(OnActionCommand);
        }
Example #3
0
        public AnalyticsOptInWindowViewModel(AnalyticsOptInWindow owner)
        {
            _owner = owner.ThrowIfNull(nameof(owner));

            OptInCommand = new ProtectedCommand(OnOptInCommand);
            AnalyticsLearnMoreLinkCommand = new ProtectedCommand(() => AnalyticsLearnMoreUtils.OpenLearnMoreLink());
        }
 /// <summary>
 /// Initializes a new instance of <seealso cref="TitleBarViewModel"/> class.
 /// Make it private to enforce the singleton pattern.
 /// </summary>
 public TitleBarViewModel()
 {
     OnGotoAccountManagementCommand = new ProtectedCommand(
         () => GoogleCloudExtensionPackage.Instance.UserPromptService.PromptUser(
             new ManageAccountsWindowContent()));
     CredentialsStore.Default.CurrentProjectIdChanged += (sender, e) => OnAccountProjectIdChanged();
 }
 /// <summary>
 /// Initializes an instance of <seealso cref="LogsViewerViewModel"/> class.
 /// </summary>
 public LogsViewerViewModel()
 {
     _dataSource       = new Lazy <LoggingDataSource>(CreateDataSource);
     RefreshCommand    = new ProtectedCommand(OnRefreshCommand);
     LogItemCollection = new ListCollectionView(_logs);
     LogItemCollection.GroupDescriptions.Add(new PropertyGroupDescription(nameof(LogItem.Date)));
     CancelRequestCommand    = new ProtectedCommand(CancelRequest);
     SimpleTextSearchCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerSimpleTextSearchEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     FilterSwitchCommand         = new ProtectedCommand(SwapFilter);
     SubmitAdvancedFilterCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerAdvancedFilterEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     AdvancedFilterHelpCommand = new ProtectedCommand(ShowAdvancedFilterHelp);
     DateTimePickerModel       = new DateTimePickerViewModel(
         TimeZoneInfo.Local, DateTime.UtcNow, isDescendingOrder: true);
     DateTimePickerModel.DateTimeFilterChange += (sender, e) => ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     PropertyChanged     += OnPropertyChanged;
     ResourceTypeSelector = new ResourceTypeMenuViewModel(_dataSource);
     ResourceTypeSelector.PropertyChanged += OnPropertyChanged;
     OnDetailTreeNodeFilterCommand         = new ProtectedCommand <ObjectNodeTree>(FilterOnTreeNodeValue);
     OnAutoReloadCommand = new ProtectedCommand(AutoReload);
 }
Example #6
0
 /// <summary>
 /// Creates a new NewSubscriptionViewModel
 /// </summary>
 /// <param name="subscription">The subscription object to model</param>
 /// <param name="owner">The owner dialog.</param>
 public NewSubscriptionViewModel(Subscription subscription, CommonDialogWindowBase owner)
 {
     _owner        = owner;
     Subscription  = subscription;
     CreateCommand = new ProtectedCommand(OnCreateCommand);
     PushConfig    = subscription.PushConfig ?? new PushConfig();
 }
        public AddWindowsCredentialViewModel(AddWindowsCredentialWindow owner, Instance instance)
        {
            _owner    = owner;
            _instance = instance;

            SaveCommand = new ProtectedCommand(OnSaveCommand);
        }
 /// <summary>
 /// Initializes an instance of <seealso cref="MenuItemViewModel"/> class.
 /// </summary>
 /// <param name="parent">The parent menu item view model.</param>
 public MenuItemViewModel(MenuItemViewModel parent)
 {
     IsVisible            = true;
     MenuItemParent       = parent;
     MenuCommand          = new ProtectedCommand(() => CommandBubblingHandler(this));
     MenuItems            = new ObservableCollection <MenuItemViewModel>();
     OnSubmenuOpenCommand = new ProtectedAsyncCommand(AddItemsAsync);
 }
Example #9
0
 /// <summary>
 /// Creates a new Console Link tree leaf node.
 /// </summary>
 /// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
 /// <param name="linkFormatInfo">
 /// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
 /// </param>
 public ConsoleLink(ICloudSourceContext context, LinkInfo linkFormatInfo)
 {
     _context            = context;
     _linkFormatInfo     = linkFormatInfo;
     Caption             = _linkFormatInfo.Caption;
     NavigateCommand     = new ProtectedCommand(OnNavigateCommand);
     NavigateInfoCommand = new ProtectedCommand(OnNavigateHelpCommand, false);
 }
Example #10
0
        public AnalyticsOptInWindowViewModel()
        {
            _browserService = GoogleCloudExtensionPackage.Instance.GetMefServiceLazy <IBrowserService>();

            OptInCommand = new ProtectedCommand(OnOptInCommand);
            AnalyticsLearnMoreLinkCommand = new ProtectedCommand(
                () => BrowserService.OpenBrowser(AnalyticsLearnMoreConstants.AnalyticsLearnMoreLink));
        }
Example #11
0
 /// <summary>
 /// Create a instance of <seealso cref="DateTimePickerViewModel"/> class.
 /// </summary>
 /// <param name="timeZone">Current selected time zone.</param>
 /// <param name="dateTimeUtc">Initial UTC date time.</param>
 /// <param name="isDescendingOrder">Initial time stamp sort order.</param>
 public DateTimePickerViewModel(TimeZoneInfo timeZone, DateTime dateTimeUtc, bool isDescendingOrder)
 {
     _timeZone         = timeZone;
     DateTimeUtc       = dateTimeUtc;
     IsDescendingOrder = isDescendingOrder;
     GoCommand         = new ProtectedCommand(OnGoButtonCommand);
     CancelCommand     = new ProtectedCommand(() => IsDropDownOpen = false);
 }
 public CsrAddRepoWindowViewModel(CsrAddRepoWindow owner, IList <Repo> repos, Project project)
 {
     _owner         = owner.ThrowIfNull(nameof(owner));
     _repos         = repos.ThrowIfNull(nameof(repos));
     _project       = project.ThrowIfNull(nameof(project));
     OkCommand      = new ProtectedAsyncCommand(CreateRepoAsync, canExecuteCommand: false);
     CsrLinkCommand = new ProtectedCommand(() => Process.Start(CsrConsoleLink));
 }
Example #13
0
        public PortManagerViewModel(PortManagerWindow owner, Instance instance)
        {
            _owner    = owner;
            _instance = instance;

            Ports     = CreatePortModels();
            OkCommand = new ProtectedCommand(OnOkCommand);
        }
        private GceStepViewModel(GceStepContent content)
        {
            _content = content;

            Instances = AsyncPropertyValueUtils.CreateAsyncProperty(GetAllWindowsInstances());

            ManageCredentialsCommand = new ProtectedCommand(OnManageCredentialsCommand, canExecuteCommand: false);
        }
Example #15
0
        private GkeStepViewModel(GkeStepContent content)
        {
            _content = content;

            Clusters                   = new AsyncPropertyValue <IList <Cluster> >(GetAllClustersAsync());
            CreateClusterCommand       = new ProtectedCommand(OnCreateClusterCommand);
            RefreshClustersListCommand = new ProtectedCommand(OnRefreshClustersListCommand);
        }
Example #16
0
 private ListProcessStepViewModel(
     ListProcessStepContent content,
     AttachDebuggerContext context)
     : base(context)
 {
     Content        = content;
     RefreshCommand = new ProtectedCommand(() => GetAllProcessesList());
 }
 /// <summary>
 /// Internal constructor for testing.
 /// </summary>
 /// <param name="linkFormatInfo">
 /// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
 /// </param>
 /// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
 /// <param name="startProcess">
 /// Dependency injecion of the static function <see cref="Process.Start(string)"/>.
 /// </param>
 internal ConsoleLink(LinkInfo linkFormatInfo, ICloudSourceContext context, Func <string, Process> startProcess)
 {
     _startProcess   = startProcess;
     _context        = context;
     _linkFormatInfo = linkFormatInfo;
     Caption         = _linkFormatInfo.Caption;
     NavigateCommand = new ProtectedCommand(OnNavigateCommand);
 }
        public AddTrafficSplitViewModel(AddTrafficSplitWindow owner, IEnumerable <string> versions)
        {
            _owner = owner;

            Versions        = versions;
            SelectedVersion = Versions.FirstOrDefault();
            AddSplitCommand = new ProtectedCommand(OnAddSplitCommand);
        }
Example #19
0
 public RepoItemViewModel(Repo cloudRepo, string localGitRoot)
 {
     cloudRepo.ThrowIfNull(nameof(cloudRepo));
     LocalPath       = localGitRoot.ThrowIfNullOrEmpty(nameof(localGitRoot));
     Name            = cloudRepo.Name?.Split('/').LastOrDefault();
     RepoFullName    = cloudRepo.Name;
     VisitUrlCommand = new ProtectedCommand(() => Process.Start(cloudRepo.Url));
 }
Example #20
0
 private HelpStepViewModel(
     HelpStepContent content,
     AttachDebuggerContext context)
     : base(context)
 {
     Content         = content;
     HelpLinkCommand = new ProtectedCommand(() => Process.Start(HelpLink));
 }
Example #21
0
        private void UpdateContextMenu()
        {
            var getPublishSettingsCommand = new ProtectedCommand(OnSavePublishSettingsCommand, canExecuteCommand: Instance.IsAspnetInstance());
            var openWebSite = new ProtectedCommand(OnOpenWebsite, canExecuteCommand: Instance.IsAspnetInstance() && Instance.IsRunning());
            var openTerminalServerSessionCommand = new ProtectedCommand(
                OnOpenTerminalServerSessionCommand,
                canExecuteCommand: Instance.IsWindowsInstance() && Instance.IsRunning());
            var startInstanceCommand     = new ProtectedCommand(OnStartInstanceCommand);
            var stopInstanceCommand      = new ProtectedCommand(OnStopInstanceCommand);
            var manageFirewallPorts      = new ProtectedCommand(OnManageFirewallPortsCommand);
            var manageWindowsCredentials = new ProtectedCommand(OnManageWindowsCredentialsCommand, canExecuteCommand: Instance.IsWindowsInstance());

            var menuItems = new List <MenuItem>
            {
                new MenuItem {
                    Header = Resources.CloudExplorerGceSavePublishSettingsMenuHeader, Command = getPublishSettingsCommand
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceOpenTerminalSessionMenuHeader, Command = openTerminalServerSessionCommand
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceOpenWebSiteMenuHeader, Command = openWebSite
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceManageFirewallPortsMenuHeader, Command = manageFirewallPorts
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceManageWindowsCredentialsMenuHeader, Command = manageWindowsCredentials
                }
            };

            if (Instance.IsRunning())
            {
                menuItems.Add(new MenuItem {
                    Header = Resources.CloudExplorerGceStopInstanceMenuHeader, Command = stopInstanceCommand
                });
            }
            else
            {
                menuItems.Add(new MenuItem {
                    Header = Resources.CloudExplorerGceStartInstanceMenuHeader, Command = startInstanceCommand
                });
            }

            menuItems.Add(new MenuItem {
                Header = Resources.UiOpenOnCloudConsoleMenuHeader, Command = new ProtectedCommand(OnOpenOnCloudConsoleCommand)
            });
            menuItems.Add(new MenuItem {
                Header = Resources.UiPropertiesMenuHeader, Command = new ProtectedCommand(OnPropertiesWindowCommand)
            });

            ContextMenu = new ContextMenu {
                ItemsSource = menuItems
            };

            SyncContextMenuState();
        }
        private GceStepViewModel(GceStepContent content, IGceDataSource dataSource, IApiManager apiManager)
            : base(apiManager)
        {
            _content    = content;
            _dataSource = dataSource;

            ManageCredentialsCommand = new ProtectedCommand(OnManageCredentialsCommand, canExecuteCommand: false);
            EnableApiCommand         = new ProtectedAsyncCommand(OnEnableApiCommandAsync);
        }
Example #23
0
        public AuthorizedNetworkModel(AclEntry acl, bool newNetwork = false)
        {
            _acl         = acl;
            _newNetwork  = newNetwork;
            _toBeDeleted = false;

            DeleteCommand     = new ProtectedCommand(OnDeleteCommand);
            UndoDeleteCommand = new ProtectedCommand(OnUndoDeleteCommand);
        }
            public void TestExecute_InvokesProvidedAction()
            {
                var actionMock      = new Mock <Action>();
                var objectUnderTest = new ProtectedCommand(actionMock.Object);

                objectUnderTest.Execute(null);

                actionMock.Verify(f => f(), Times.Once);
            }
Example #25
0
        /// <summary>
        /// Constructor used for testing.
        /// </summary>
        internal AppEngineManagementViewModel(ICloseable owner, string projectId, IGaeDataSource dataSource)
        {
            _owner      = owner;
            _dataSource = dataSource;

            Locations        = new AsyncProperty <IEnumerable <string> >(ListAllLocationsAsync(), s_loadingPlaceholder);
            SelectedLocation = s_loadingPlaceholder.First();
            ActionCommand    = new ProtectedCommand(OnActionCommand);
            ProjectId        = projectId;
        }
 /// <param name="closeWindow">The action that closes the related dialog.</param>
 protected TemplateChooserViewModelBase(Action closeWindow)
 {
     GcpProjectId = CredentialsStore.Default.CurrentProjectId ?? "";
     OkCommand    = new ProtectedCommand(
         () =>
     {
         Result = CreateResult();
         closeWindow();
     });
 }
        public NamePromptViewModel(NamePromptWindow owner, NamePromptWindow.Options options)
        {
            _owner = owner;

            Name    = options?.InitialName;
            Message = options?.Message ?? Resources.EnterNameDialogNameMessage;

            OkCommand     = new ProtectedCommand(OnOkCommand);
            CancelCommand = new ProtectedCommand(OnCancelCommand);
        }
        public AttachDebuggerWindowViewModel(Instance gceInstance, AttachDebuggerWindow dialogWindow)
        {
            OKCommand     = new ProtectedAsyncCommand(() => ExceuteAsync(OnOKCommand), canExecuteCommand: false);
            CancelCommand = new ProtectedCommand(OnCancelCommand, canExecuteCommand: false);

            var context   = new AttachDebuggerContext(gceInstance, dialogWindow);
            var firstStep = SetCredentialStepViewModel.CreateStep(context);

            ErrorHandlerUtils.HandleExceptionsAsync(() => ExceuteAsync(() => GotoStep(firstStep)));
        }
Example #29
0
        public PickProjectIdViewModel(string helpText, bool allowAccountChange)
        {
            AllowAccountChange = allowAccountChange;
            HelpText           = helpText;

            ChangeUserCommand = new ProtectedCommand(OnChangeUserCommand);
            OkCommand         = new ProtectedCommand(OnOkCommand, canExecuteCommand: false);
            RefreshCommand    = new ProtectedCommand(OnRefreshCommand, canExecuteCommand: false);
            StartLoadProjects();
        }
        /// <inheritdoc />
        protected PublishDialogStepBase(IApiManager apiManager)
        {
            _apiManager = apiManager;

            SelectProjectCommand = new ProtectedCommand(OnSelectProjectCommand);
            CredentialsStore.Default.CurrentProjectIdChanged += (sender, args) =>
            {
                RaisePropertyChanged(nameof(GcpProjectId));
            };
        }