Exemplo n.º 1
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();
                }
            }
        }
Exemplo n.º 2
0
 private void OnPackagesLoaded()
 {
     PackageManagerToolbar.SetEnabled(true);
     SelectionManager.SetSelection(PackageToSelectAfterLoad);
     PackageManagerToolbar.SetFilter(Collection.Filter);
     PackageToSelectAfterLoad = null;
 }
 private void SetupToolbar()
 {
     PackageManagerToolbar.OnFilterChange        += OnFilterChange;
     PackageManagerToolbar.OnTogglePreviewChange += OnTogglePreviewChange;
     PackageManagerToolbar.SetFilter(Collection.Filter);
     PackageManagerToolbar.SetCollection(Collection);
 }
Exemplo n.º 4
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);
                }
            }
        }
 private void SetupCollection()
 {
     Collection.OnPackagesChanged += (filter, packages) =>
     {
         PackageList.SetPackages(filter, packages);
         SelectionManager.Selection.TriggerNewSelection();
         PackageManagerToolbar.OnPackagesChanged();
     };
     Collection.OnUpdateTimeChange += PackageStatusbar.SetUpdateTimeMessage;
     Collection.ListSignal.WhenOperation(PackageStatusbar.OnListOrSearchOperation);
     Collection.SearchSignal.WhenOperation(PackageStatusbar.OnListOrSearchOperation);
 }
Exemplo n.º 6
0
        private void OnPackagesLoaded()
        {
            PackageManagerToolbar.SetEnabled(true);

            if (!string.IsNullOrEmpty(PackageToSelectAfterLoad) || FilterToSelectAfterLoad != null)
            {
                if (FilterToSelectAfterLoad != null)
                {
                    PackageManagerToolbar.SetFilter(FilterToSelectAfterLoad);
                }
                SelectionManager.SetSelection(PackageToSelectAfterLoad, FilterToSelectAfterLoad, true);
            }

            PackageToSelectAfterLoad = null;
            FilterToSelectAfterLoad  = null;
        }
Exemplo n.º 7
0
        public void OnEnable()
        {
            var rootElement = GetRootElement();
            var path        = EditorGUIUtility.isProSkin ? DarkStylePath : LightStylePath;
            var styleSheet  = EditorGUIUtility.LoadRequired(path) as StyleSheet;

            rootElement.styleSheets.Add(styleSheet);

            var collectionWasNull = Collection == null;

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

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

            if (SelectionManager == null)
            {
                SelectionManager = new SelectionManager();
            }

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

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

                Cache = new VisualElementCache(root);

                SelectionManager.SetCollection(Collection);
                Collection.OnFilterChanged += filter => SetupSelection();
                Collection.SetFilter(PackageManagerPrefs.LastUsedPackageFilter);

                if (!collectionWasNull)
                {
                    Collection.UpdatePackageCollection(true);
                }

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

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

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

                Collection.TriggerPackagesChanged();
            }
        }
Exemplo n.º 8
0
 private void OnListFocusChange()
 {
     PackageManagerToolbar.GrabFocus();
 }
Exemplo n.º 9
0
        public void OnEnable()
        {
            var styleSheet = Resources.GetStyleSheet();

            rootVisualElement.styleSheets.Add(styleSheet);

            var collectionWasNull = Collection == null;

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

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

            if (SelectionManager == null)
            {
                SelectionManager = new SelectionManager();
            }

            var windowResource = Resources.GetVisualTreeAsset("PackageManagerWindow.uxml");

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

                Cache = new VisualElementCache(root);

                SelectionManager.SetCollection(Collection);
                Collection.OnFilterChanged += filter => SetupSelection();
                if (collectionWasNull)
                {
                    LastUsedPackageFilter = PackageManagerPrefs.LastUsedPackageFilter;
                }

                Collection.SetFilter(LastUsedPackageFilter);
                Collection.UpdatePackageCollection(true);

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

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

                if (!EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    Collection.FetchListOfflineCache(true);
                    Collection.FetchListCache(collectionWasNull);
                    Collection.FetchSearchCache(collectionWasNull);
                }
                Collection.TriggerPackagesChanged();
            }
        }
Exemplo n.º 10
0
 private void OnPackagesLoaded()
 {
     PackageManagerToolbar.SetEnabled(true);
 }