Ejemplo n.º 1
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     // OnPackageLoadCompleted(selectedNode), which calls this method, is called by QueryExecutionCompleted
     // QueryExecutionCompleted is called when an asynchronous query execution completes
     // And, queries are executed from several places including SortSelectionChanged on the node which is always
     // called by default on the first node, not necessarily, the selected node by VsExtensionsProvider
     // This means the selectedNode, here, may not actually be THE selectedNode at this point
     // So, check if it is indeed selected before doing anything. Note that similar check is performed on QueryExecutionCompleted too
     if (selectedNode != null && selectedNode.IsSelected)
     {
         if (!selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
         {
             // After performing Update All, if user switches to another page, we don't want to show
             // the Update All button again. Here we check to make sure there's at least one enabled package.
             if (selectedNode.Extensions.OfType <PackageItem>().Any(p => p.IsEnabled))
             {
                 _updateAllUIService.Show();
             }
             else
             {
                 _updateAllUIService.Hide();
             }
         }
         else
         {
             _updateAllUIService.Hide();
         }
     }
 }
Ejemplo n.º 2
0
        private void AddSearchNode()
        {
            if (_searchNode != null && !RootNode.Nodes.Contains(_searchNode))
            {
                // remember the currently selected node so that when search term is cleared, we can restore it.
                _lastSelectedNode = SelectedNode;

                RootNode.Nodes.Add(_searchNode);
                SelectNode(_searchNode);
            }
        }
Ejemplo n.º 3
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     if (selectedNode != null && !selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
     {
         _updateAllUIService.Show();
     }
     else
     {
         _updateAllUIService.Hide();
     }
 }
Ejemplo n.º 4
0
        public PackagesSearchNode(PackagesProviderBase provider, IVsExtensionsTreeNode parent, PackagesTreeNodeBase baseNode, string searchText)
            : base(parent, provider)
        {
            if (baseNode == null) {
                throw new ArgumentNullException("baseNode");
            }

            _searchText = searchText;
            _baseNode = baseNode;

            // Mark this node as a SearchResults node to assist navigation in ExtensionsExplorer
            IsSearchResultsNode = true;
        }
Ejemplo n.º 5
0
        public PackagesSearchNode(PackagesProviderBase provider, IVsExtensionsTreeNode parent, PackagesTreeNodeBase baseNode, string searchText) :
            base(parent, provider, baseNode.CollapseVersions)
        {
            if (baseNode == null)
            {
                throw new ArgumentNullException("baseNode");
            }

            _searchText = searchText;
            _baseNode   = baseNode;

            // Mark this node as a SearchResults node to assist navigation in ExtensionsExplorer
            IsSearchResultsNode = true;
        }
Ejemplo n.º 6
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     if (selectedNode != null && !selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
     {
         // After performing Update All, if user switches to another page, we don't want to show
         // the Update All button again. Here we check to make sure there's at least one enabled package.
         if (selectedNode.Extensions.OfType <PackageItem>().Any(p => p.IsEnabled))
         {
             _updateAllUIService.Show();
         }
         else
         {
             _updateAllUIService.Hide();
         }
     }
     else
     {
         _updateAllUIService.Hide();
     }
 }
Ejemplo n.º 7
0
        protected override void FillRootNodes()
        {
            var packageSources = _packageSourceProvider.GetPackageSources();

            // create one tree node per package source
            foreach (var source in packageSources)
            {
                PackagesTreeNodeBase node = null;
                try {
                    var repository = new LazyRepository(_packageRepositoryFactory, source);
                    node = CreateTreeNodeForPackageSource(source, repository);
                }
                catch (Exception exception) {
                    // exception occurs if the Source value is invalid. In which case, adds an empty tree node in place.
                    node = new EmptyTreeNode(this, source.Name, RootNode);
                    ExceptionHelper.WriteToActivityLog(exception);
                }

                RootNode.Nodes.Add(node);
            }
        }
Ejemplo n.º 8
0
 protected void SelectNode(PackagesTreeNodeBase node)
 {
     node.IsSelected = true;
     SelectedNode = node;
 }
Ejemplo n.º 9
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     // OnPackageLoadCompleted(selectedNode), which calls this method, is called by QueryExecutionCompleted
     // QueryExecutionCompleted is called when an asynchronous query execution completes
     // And, queries are executed from several places including SortSelectionChanged on the node which is always 
     // called by default on the first node, not necessarily, the selected node by VsExtensionsProvider
     // This means the selectedNode, here, may not actually be THE selectedNode at this point
     // So, check if it is indeed selected before doing anything. Note that similar check is performed on QueryExecutionCompleted too
     if (selectedNode != null && selectedNode.IsSelected)
     {
         if (!selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
         {
             // After performing Update All, if user switches to another page, we don't want to show 
             // the Update All button again. Here we check to make sure there's at least one enabled package.
             if (selectedNode.Extensions.OfType<PackageItem>().Any(p => p.IsEnabled))
             {
                 _updateAllUIService.Show();
             }
             else
             {
                 _updateAllUIService.Hide();
             }
         }
         else
         {
             _updateAllUIService.Hide();
         }
     }
 }
Ejemplo n.º 10
0
 public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
     base.OnPackageLoadCompleted(selectedNode);
     UpdateNumberOfPackages(selectedNode);
 }
 public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
     _baseProvider.OnPackageLoadCompleted(selectedNode);
 }
Ejemplo n.º 12
0
 protected void SelectNode(PackagesTreeNodeBase node)
 {
     node.IsSelected = true;
     SelectedNode    = node;
 }
Ejemplo n.º 13
0
 public virtual void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
 }
Ejemplo n.º 14
0
 public PagedPackagesSearchNode(PackagesProviderBase provider, IVsExtensionsTreeNode parent, PackagesTreeNodeBase baseNode, string searchText) :
     base(provider, parent, baseNode, searchText)
 {
 }
Ejemplo n.º 15
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     if (selectedNode != null && !selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
     {
         _updateAllUIService.Show();
     }
     else
     {
         _updateAllUIService.Hide();
     }
 }
Ejemplo n.º 16
0
        private void AddSearchNode()
        {
            if (_searchNode != null && !RootNode.Nodes.Contains(_searchNode)) {
                // remember the currently selected node so that when search term is cleared, we can restore it.
                _lastSelectedNode = SelectedNode;

                RootNode.Nodes.Add(_searchNode);
                SelectNode(_searchNode);
            }
        }
Ejemplo n.º 17
0
 public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
     base.OnPackageLoadCompleted(selectedNode);
     UpdateNumberOfPackages(selectedNode);
 }
Ejemplo n.º 18
0
 public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
     _baseProvider.OnPackageLoadCompleted(selectedNode);
 }
Ejemplo n.º 19
0
        private static PackagesSearchNode CreatePackagesSearchNode(string searchTerm, int numberOfPackages = 1, bool collapseVersions = true, PackagesTreeNodeBase baseNode = null)
        {
            PackagesProviderBase provider = new MockPackagesProvider();

            IVsExtensionsTreeNode parentTreeNode = new Mock<IVsExtensionsTreeNode>().Object;
            PackagesTreeNodeBase baseTreeNode;
            if (baseNode != null)
            {
                baseTreeNode = baseNode;
            }
            else
            {
                baseTreeNode = new MockTreeNode(parentTreeNode, provider, numberOfPackages, collapseVersions);
            }
            return new PackagesSearchNode(provider, parentTreeNode, baseTreeNode, searchTerm);
        }
Ejemplo n.º 20
0
 private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
 {
     if (selectedNode != null && !selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
     {
         // After performing Update All, if user switches to another page, we don't want to show 
         // the Update All button again. Here we check to make sure there's at least one enabled package.
         if (selectedNode.Extensions.OfType<PackageItem>().Any(p => p.IsEnabled))
         {
             _updateAllUIService.Show();
         }
         else
         {
             _updateAllUIService.Hide();
         }
     }
     else
     {
         _updateAllUIService.Hide();
     }
 }
        private static void TreeNodeActionTest(PackagesTreeNodeBase node,
                                               Action<PackagesTreeNodeBase> treeNodeAction,
                                               Action<PackagesTreeNodeBase> callback,
                                               int? pageSize = null)
        {
            // Arrange
            ManualResetEventSlim resetEvent = new ManualResetEventSlim(initialState: false);
            node.PageSize = pageSize ?? node.PageSize;

            Exception exception = null;

            node.PackageLoadCompleted += delegate
            {
                try
                {
                    // Callback for assertion
                    callback(node);
                }
                catch (Exception e)
                {
                    // There was an exception when running the callback async, so record the exception
                    exception = e;
                }
                finally
                {
                    // If there is an exception we don't want to freeze the unit test forever
                    resetEvent.Set();
                }
            };

            // Act
            treeNodeAction(node);

            // Wait for the event to get signaled
            resetEvent.Wait();

            // Make sure there was no exception
            Assert.Null(exception);
        }
Ejemplo n.º 22
0
 public virtual void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
 {
 }