Exemple #1
0
 private void SetupPackageList()
 {
     PackageList.OnLoaded      += OnPackagesLoaded;
     PackageList.OnFocusChange += OnListFocusChange;
     PackageList.SetSearchFilter(SearchFilter);
     Collection.OnLatestPackageInfoFetched += PackageList.OnLatestPackageInfoFetched;
 }
Exemple #2
0
        public void OnEnable()
        {
            PackageCollection.InitInstance(ref Collection);
            PackageSearchFilter.InitInstance(ref SearchFilter);

            this.GetRootVisualContainer().AddStyleSheetPath(EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath);

            var windowResource = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(TemplatePath);

            if (windowResource != null)
            {
                var template = windowResource.CloneTree(null);
                this.GetRootVisualContainer().Add(template);
                template.StretchToParentSize();

                PackageList.OnSelected    += OnPackageSelected;
                PackageList.OnLoaded      += OnPackagesLoaded;
                PackageList.OnFocusChange += OnListFocusChange;

                PackageManagerToolbar.SearchToolbar.OnSearchChange += OnSearchChange;
                PackageManagerToolbar.SearchToolbar.OnFocusChange  += OnToolbarFocusChange;

                // Disable filter while fetching first results
                if (!PackageCollection.Instance.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }
                else
                {
                    PackageList.SelectLastSelection();
                }
            }
        }
Exemple #3
0
        public void OnEnable()
        {
            var collectionWasNull = Collection == null;

            if (Collection == null)
            {
                Collection = new PackageCollection();
            }

            if (SearchFilter == null)
            {
                SearchFilter = new PackageSearchFilter();
            }

            this.GetRootVisualContainer().AddStyleSheetPath(EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath);
            // Temporarly fix for case 1075335 (UIElements)
            this.GetRootVisualContainer().style.positionLeft   = 2;
            this.GetRootVisualContainer().style.positionTop    = 22;
            this.GetRootVisualContainer().style.positionRight  = 2;
            this.GetRootVisualContainer().style.positionBottom = 2;
            this.GetRootVisualContainer().style.flexGrow       = 1;

            var windowResource = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(TemplatePath);

            if (windowResource != null)
            {
                root = windowResource.CloneTree(null);
                this.GetRootVisualContainer().Add(root);
                root.StretchToParentSize();

                Collection.SetFilter(PackageManagerPrefs.GetLastUsedPackageFilter(Directory.GetCurrentDirectory()));

                SetupPackageDetails();
                SetupPackageList();
                SetupSearchToolbar();
                SetupToolbar();
                SetupStatusbar();
                SetupCollection();

                // Disable filter while fetching first results
                if (!Collection.LatestListPackages.Any())
                {
                    PackageManagerToolbar.SetEnabled(false);
                }
                else
                {
                    PackageList.SelectLastSelection(Collection.SelectedPackage);
                }

                Collection.FetchListOfflineCache(Collection.listOperationOfflineOngoing);
                Collection.FetchListCache(Collection.listOperationOngoing);
                Collection.FetchSearchCache(Collection.searchOperationOngoing);

                if (!collectionWasNull)
                {
                    Collection.UpdatePackageCollection(true);
                }
            }
        }
Exemple #4
0
 private void SetupPackageList()
 {
     PackageList.OnSelected    += OnPackageSelected;
     PackageList.OnLoaded      += OnPackagesLoaded;
     PackageList.OnFocusChange += OnListFocusChange;
     PackageList.OnReload      += OnReload;
     PackageList.SetSearchFilter(SearchFilter);
 }
Exemple #5
0
 private void SetupCollection()
 {
     Collection.OnPackagesChanged += (filter, packages) =>
     {
         PackageList.SetPackages(filter, packages);
         SelectionManager.Selection.TriggerNewSelection();
     };
     Collection.OnUpdateTimeChange += PackageStatusbar.SetUpdateTimeMessage;
     Collection.ListSignal.WhenOperation(PackageStatusbar.OnListOrSearchOperation);
     Collection.SearchSignal.WhenOperation(PackageStatusbar.OnListOrSearchOperation);
 }
        public static void FilterPackageList(PackageList packageList)
        {
            PackageItem firstItem            = null;
            PackageItem lastItem             = null;
            var         selectedItemInFilter = false;
            var         selectedItem         = packageList.selectedItem;
            var         packageItems         = packageList.Query <PackageItem>().ToList();

            foreach (var item in packageItems)
            {
                if (FilterByText(item, PackageSearchFilter.Instance.SearchText))
                {
                    if (firstItem == null)
                    {
                        firstItem = item;
                    }
                    if (item == selectedItem)
                    {
                        selectedItemInFilter = true;
                    }

                    UIUtils.SetElementDisplay(item, true);

                    if (lastItem != null)
                    {
                        lastItem.nextItem = item;
                    }

                    item.previousItem = lastItem;
                    item.nextItem     = null;

                    lastItem = item;
                }
                else
                {
                    UIUtils.SetElementDisplay(item, false);
                }
            }

            if (firstItem == null)
            {
                packageList.ShowNoResults();
            }
            else
            {
                packageList.ShowResults(selectedItemInFilter ? selectedItem : firstItem);
            }
        }
        public static void FilterPackageList(PackageList packageList)
        {
            var packageItems = packageList.Query <PackageItem>().ToList();

            if (!packageItems.Any())
            {
                return;
            }

            PackageItem firstItem            = null;
            var         selectedItemInFilter = false;
            var         selectedItem         = packageList.SelectedItem;

            foreach (var item in packageItems)
            {
                if (FilterByText(item, packageList.searchFilter.SearchText))
                {
                    if (firstItem == null)
                    {
                        firstItem = item;
                    }
                    if (item == selectedItem)
                    {
                        selectedItemInFilter = true;
                    }

                    UIUtils.SetElementDisplay(item, true);
                }
                else
                {
                    UIUtils.SetElementDisplay(item, false);
                }
            }

            if (firstItem == null)
            {
                packageList.ShowNoResults();
            }
            else
            {
                packageList.ShowResults(selectedItemInFilter ? selectedItem : firstItem);
            }
        }
Exemple #8
0
 private void OnSearchChange(string searchText)
 {
     SearchFilter.SearchText = searchText;
     PackageList.SetSearchFilter(SearchFilter);
     PackageFiltering.FilterPackageList(PackageList);
 }
Exemple #9
0
 private void OnToolbarFocusChange()
 {
     PackageList.GrabFocus();
 }
Exemple #10
0
 private void SetupSelection()
 {
     PackageList.SetSelection(SelectionManager.Selection);
     PackageDetails.SetSelection(SelectionManager.Selection);
 }
Exemple #11
0
 private void OnReload()
 {
     // Force a re-init to initial condition
     Collection.UpdatePackageCollection();
     PackageList.SelectLastSelection(Collection.SelectedPackage);
 }