public void OnDisable()
        {
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            PackageManagerPrefs.instance.lastUsedPackageFilter = PackageFiltering.instance.currentFilterTab;

            PageManager.instance.onRefreshOperationFinish -= OnRefreshOperationFinish;
            PageManager.instance.onRefreshOperationStart  -= OnRefreshOperationStart;
            PageManager.instance.onRefreshOperationError  -= OnRefreshOperationError;
            PackageFiltering.instance.onFilterTabChanged  -= OnFilterChanged;

            packageDetails.OnDisable();
            packageList.OnDisable();
            packageLoadBar.OnDisable();
            packageManagerToolbar.OnDisable();
            packageStatusbar.OnDisable();

            EditorApplication.focusChanged -= OnFocusChanged;
            Selection.selectionChanged     -= OnEditorSelectionChanged;
        }
Пример #2
0
        internal static void SelectPackageAndFilter(string packageIdOrDisplayName, PackageFilterTab?filterTab = null, bool refresh = false, string searchText = "")
        {
            instance         = GetWindow <PackageManagerWindow>();
            instance.minSize = new Vector2(700, 250);
            if (!string.IsNullOrEmpty(packageIdOrDisplayName) || filterTab != null)
            {
                if (filterTab == null)
                {
                    filterTab = PageManager.instance.FindTab(packageIdOrDisplayName);
                }

                instance.m_FilterToSelectAfterLoad = filterTab;
                instance.m_PackageToSelectOnLoaded = packageIdOrDisplayName;
                instance.packageManagerToolbar.SetCurrentSearch(searchText);

                if (refresh || PackageDatabase.instance.isEmpty)
                {
                    PageManager.instance.Refresh(filterTab);
                }
                else
                {
                    instance.SelectPackageAndFilter();
                }
            }
            instance.Show();
        }
 internal static void SelectPackageAndFilterStatic(string packageToSelect, PackageFilterTab?filterTab = null, bool refresh = false, string searchText = "")
 {
     instance         = GetWindow <PackageManagerWindow>();
     instance.minSize = new Vector2(800, 250);
     instance.m_Root.SelectPackageAndFilter(packageToSelect, filterTab, refresh, searchText);
     instance.Show();
 }
        public void OnDisable()
        {
            if (s_Window == null)
            {
                s_Window = this;
            }
            if (s_Window != this)
            {
                return;
            }

            PackageManagerPrefs.instance.lastUsedPackageFilter = PackageFiltering.instance.currentFilterTab;

            PackageDatabase.instance.onRefreshOperationFinish -= OnRefreshOperationFinish;
            PackageDatabase.instance.onRefreshOperationStart  -= OnRefreshOperationStart;
            PackageDatabase.instance.onRefreshOperationError  -= OnRefreshOperationError;

            packageDetails.OnDisable();
            packageList.OnDisable();
            packageManagerToolbar.OnDisable();
            packageStatusbar.OnDisable();

            PageManager.instance.Clear();

            EditorApplication.focusChanged -= OnFocusChanged;
        }
Пример #5
0
        internal static void SelectPackageAndFilter(string packageIdOrDisplayName, PackageFilterTab?filterTab = null, bool refresh = false, string searchText = "")
        {
            instance         = GetWindow <PackageManagerWindow>(typeof(SceneView));
            instance.minSize = new Vector2(700, 250);
            if (!string.IsNullOrEmpty(packageIdOrDisplayName) || filterTab != null)
            {
                if (filterTab == null)
                {
                    IPackageVersion version;
                    IPackage        package;
                    PackageDatabase.instance.GetPackageAndVersionByIdOrName(packageIdOrDisplayName, out package, out version);
                    filterTab = PageManager.instance.FindTab(package, version);
                }

                instance.m_FilterToSelectAfterLoad = filterTab;
                instance.m_PackageToSelectOnLoaded = packageIdOrDisplayName;
                instance.packageManagerToolbar.SetCurrentSearch(searchText);

                if (refresh || PackageDatabase.instance.isEmpty)
                {
                    instance.DelayRefresh((PackageFilterTab)filterTab);
                }
                else
                {
                    instance.SelectPackageAndFilter();
                }
            }
            instance.Show();
        }
        void OnEnable()
        {
            this.SetAntiAliasing(4);
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            titleContent = GetLocalizedTitleContent();

            var container           = ServicesContainer.instance;
            var resourceLoader      = container.Resolve <ResourceLoader>();
            var selection           = container.Resolve <SelectionProxy>();
            var packageFiltering    = container.Resolve <PackageFiltering>();
            var packageManagerPrefs = container.Resolve <PackageManagerPrefs>();
            var packageDatabase     = container.Resolve <PackageDatabase>();
            var pageManager         = container.Resolve <PageManager>();
            var settingsProxy       = container.Resolve <PackageManagerProjectSettingsProxy>();

            m_Root = new PackageManagerWindowRoot(resourceLoader, selection, packageFiltering, packageManagerPrefs, packageDatabase, pageManager, settingsProxy);
            rootVisualElement.Add(m_Root);

            m_Root.OnEnable();
        }
 internal static void SelectFilterSubPageStatic(string filterTabOrSubPage = "")
 {
     instance         = GetWindow <PackageManagerWindow>();
     instance.minSize = new Vector2(800, 250);
     instance.m_Root.SelectFilterSubPage(filterTabOrSubPage);
     instance.Show();
 }
        public void OnDisable()
        {
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            m_PackageManagerPrefs.lastUsedPackageFilter = m_PackageFiltering.currentFilterTab;

            m_PageManager.onRefreshOperationFinish -= OnRefreshOperationFinish;
            m_PageManager.onRefreshOperationStart  -= OnRefreshOperationStart;
            m_PageManager.onRefreshOperationError  -= OnRefreshOperationError;
            m_PackageFiltering.onFilterTabChanged  -= OnFilterChanged;

            packageDetails.OnDisable();
            packageList.OnDisable();
            packageLoadBar.OnDisable();
            packageManagerToolbar.OnDisable();
            packageStatusbar.OnDisable();

            EditorApplication.focusChanged -= OnFocusChanged;
            m_Selection.onSelectionChanged -= RefreshSelectedInInspectorClass;
        }
Пример #9
0
        public void OnDestroy()
        {
            foreach (var extension in PackageManagerExtensions.ToolbarExtensions)
            {
                extension.OnWindowDestroy();
            }

            instance = null;
        }
Пример #10
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (!importedAssets.Any(IsPackageJsonAsset) && !deletedAssets.Any(IsPackageJsonAsset) && !movedAssets.Any(IsPackageJsonAsset))
            {
                return;
            }

            PackageManagerWindow.FetchListOfflineCacheForAllWindows();
        }
        private void SetupAddMenu()
        {
            AddMenu.menu.AppendAction("Add package from disk...", a =>
            {
                var path = EditorUtility.OpenFilePanelWithFilters("Select package on disk", "", new[] { "package.json file", "json" });
                if (!string.IsNullOrEmpty(path) && !Package.PackageOperationInProgress)
                {
                    Package.AddFromLocalDisk(path);
                }
            }, a => DropdownMenuAction.Status.Normal);

            AddMenu.menu.AppendAction("Add package from git URL...", a =>
            {
                var addFromGitUrl            = new PackagesAction("Add");
                addFromGitUrl.actionClicked += url =>
                {
                    addFromGitUrl.Hide();
                    if (!Package.PackageOperationInProgress)
                    {
                        Package.AddFromUrl(url);
                    }
                };

                parent.Add(addFromGitUrl);
                addFromGitUrl.Show();
            }, a => DropdownMenuAction.Status.Normal);

            AddMenu.menu.AppendSeparator("");

            AddMenu.menu.AppendAction("Create Package...", a =>
            {
                var defaultName              = PackageCreator.GenerateUniquePackageDisplayName("New Package");
                var createPackage            = new PackagesAction("Create", defaultName);
                createPackage.actionClicked += displayName =>
                {
                    createPackage.Hide();
                    var packagePath = PackageCreator.CreatePackage("Packages/" + displayName);
                    AssetDatabase.Refresh();
                    EditorApplication.delayCall += () =>
                    {
                        var path = Path.Combine(packagePath, "package.json");
                        var o    = AssetDatabase.LoadMainAssetAtPath(path);
                        if (o != null)
                        {
                            UnityEditor.Selection.activeObject = o;
                        }

                        PackageManagerWindow.SelectPackageAndFilter(displayName, PackageFilter.InDevelopment, true);
                    };
                };

                parent.Add(createPackage);
                createPackage.Show();
            }, a => DropdownMenuAction.Status.Normal);
        }
        public void OnEnable()
        {
            this.SetAntiAliasing(4);
            if (s_Window == null)
            {
                s_Window = this;
            }
            if (s_Window != this)
            {
                return;
            }

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

            if (windowResource != null)
            {
                var root = windowResource.CloneTree();
                root.styleSheets.Add(Resources.GetStyleSheet());
                cache = new VisualElementCache(root);

                PageManager.instance.Setup();

                packageDetails.OnEnable();
                packageList.OnEnable();
                packageManagerToolbar.OnEnable();
                packageStatusbar.OnEnable();

                packageManagerToolbar.SetEnabled(!PackageDatabase.instance.isEmpty);
                packageDetails.packageToolbarContainer.SetEnabled(!PackageDatabase.instance.isEmpty);

                PackageDatabase.instance.onRefreshOperationFinish += OnRefreshOperationFinish;
                PackageDatabase.instance.onRefreshOperationStart  += OnRefreshOperationStart;
                PackageDatabase.instance.onRefreshOperationError  += OnRefreshOperationError;

                PackageManagerWindowAnalytics.Setup();

                rootVisualElement.Add(root);
                root.StretchToParentSize();

                PackageFiltering.instance.currentFilterTab = PackageManagerPrefs.instance.lastUsedPackageFilter ?? PackageFilterTab.All;

                if (!PageManager.instance.HasFetchedPageForFilterTab(PackageFiltering.instance.currentFilterTab))
                {
                    PageManager.instance.Refresh(RefreshOptions.CurrentFilter);
                }

                if (PackageFiltering.instance.currentFilterTab != PackageFilterTab.All && !PageManager.instance.HasFetchedPageForFilterTab(PackageFilterTab.All))
                {
                    PageManager.instance.Refresh(RefreshOptions.All);
                }

                EditorApplication.focusChanged += OnFocusChanged;
            }
        }
        void OnDisable()
        {
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            m_Root?.OnDisable();
        }
Пример #14
0
        internal override void OnHeaderControlsGUI()
        {
            base.OnHeaderControlsGUI();

            // We want to have this button enabled even for immutable package
            var previousEnabled = GUI.enabled;

            GUI.enabled = packageState != null && packageState.isValidFile && targets.Length == 1;
            if (GUILayout.Button(Styles.viewInPackageManager, EditorStyles.miniButton))
            {
                PackageManagerWindow.SelectPackageAndFilterStatic(packageState.info.packageName.completeName);
            }
            GUI.enabled = previousEnabled;
        }
        void OnDisable()
        {
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            m_Root?.OnDisable();

            Events.registeredPackages -= OnRegisteredPackages;
        }
        internal static void CloseAll()
        {
            var windows = Resources.FindObjectsOfTypeAll <PackageManagerWindow>();

            if (windows == null)
            {
                return;
            }

            foreach (var window in windows)
            {
                window.Close();
            }

            instance = null;
        }
        public void OnDestroy()
        {
            if (s_Window == null)
            {
                s_Window = this;
            }
            if (s_Window != this)
            {
                return;
            }

            foreach (var extension in PackageManagerExtensions.ToolbarExtensions)
            {
                extension.OnWindowDestroy();
            }

            s_Window = null;
        }
        void OnEnable()
        {
            this.SetAntiAliasing(4);
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            titleContent = GetLocalizedTitleContent();

            BuildGUI();

            Events.registeredPackages += OnRegisteredPackages;
        }
Пример #19
0
 internal static void SelectPackageAndFilter(string packageIdOrDisplayName, PackageFilterTab?filterTab = null, bool refresh = false, string searchText = "")
 {
     s_Window         = GetWindow <PackageManagerWindow>();
     s_Window.minSize = new Vector2(700, 250);
     if (!string.IsNullOrEmpty(packageIdOrDisplayName))
     {
         s_Window.packageManagerToolbar.SetCurrentSearch(searchText);
         s_Window.m_PackageToSelectOnLoaded = packageIdOrDisplayName;
         s_Window.m_FilterToSelectAfterLoad = filterTab;
         if (refresh)
         {
             PageManager.instance.Refresh(filterTab ?? PackageFilterTab.All);
         }
         else if (!PackageDatabase.instance.isEmpty)
         {
             s_Window.SelectPackageAndFilter();
         }
     }
     s_Window.Show();
 }
Пример #20
0
        internal void Add(PackageInfo packageInfo)
        {
            if (packageInfo == Current || AddRemoveOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateAddOperation();

            addRemoveOperationInstance   = operation;
            OnAddOperationFinalizedEvent = () =>
            {
                AddSignal.Operation             = null;
                operation.OnOperationFinalized -= OnAddOperationFinalizedEvent;
                PackageManagerWindow.FetchListOfflineCacheForAllWindows();
            };

            operation.OnOperationFinalized += OnAddOperationFinalizedEvent;

            AddSignal.SetOperation(operation);
            operation.AddPackageAsync(packageInfo);
        }
Пример #21
0
        public void Remove()
        {
            if (Current == null || AddRemoveOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateRemoveOperation();

            addRemoveOperationInstance      = operation;
            OnRemoveOperationFinalizedEvent = () =>
            {
                RemoveSignal.Operation          = null;
                operation.OnOperationFinalized -= OnRemoveOperationFinalizedEvent;
                PackageManagerWindow.FetchListOfflineCacheForAllWindows();
            };

            operation.OnOperationFinalized += OnRemoveOperationFinalizedEvent;
            RemoveSignal.SetOperation(operation);

            operation.RemovePackageAsync(Current);
        }
Пример #22
0
        internal override void OnHeaderControlsGUI()
        {
            base.OnHeaderControlsGUI();

            var previousEnabled = GUI.enabled;

            GUI.enabled = targets.Length == 1 && m_Package?.state == PackageState.InDevelopment && (m_Version?.isInstalled ?? false);
            if (GUILayout.Button(Styles.editPackage, EditorStyles.miniButton))
            {
                var path     = m_Version.packageInfo.assetPath;
                var manifest = AssetDatabase.LoadAssetAtPath <PackageManifest>($"{path}/package.json");
                if (manifest != null)
                {
                    Selection.activeObject = manifest;
                }
            }
            GUI.enabled = targets.Length == 1 && m_Package != null && m_Version != null;
            if (GUILayout.Button(Styles.viewInPackageManager, EditorStyles.miniButton))
            {
                PackageManagerWindow.SelectPackageAndFilter(m_Version.uniqueId);
            }
            GUI.enabled = previousEnabled;
        }
Пример #23
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            var allUpdatedAssets    = importedAssets.Concat(deletedAssets).Concat(movedAssets).Concat(movedFromAssetPaths);
            var packageJsonsUpdated = false;

            foreach (var asset in allUpdatedAssets)
            {
                var pathComponents = asset.Split('/');
                if (pathComponents[0] != "Packages")
                {
                    continue;
                }
                if (!packageJsonsUpdated && pathComponents.Length == 3 && pathComponents[2] == "package.json")
                {
                    packageJsonsUpdated = true;
                    break;
                }
            }

            if (packageJsonsUpdated)
            {
                PackageManagerWindow.FetchListOfflineCacheForAllWindows();
            }
        }
Пример #24
0
        private void RemoveClick()
        {
            var roots = PackageDatabase.instance.GetDependentVersions(displayVersion).Where(p => p.isDirectDependency && p.isInstalled).ToList();
            // Only show this message on a package if it is installed by dependency only. This allows it to still be removed from the installed list.
            var showDialog = roots.Any() && !(!displayVersion.HasTag(PackageTag.BuiltIn) && displayVersion.isDirectDependency);

            if (showDialog)
            {
                if (roots.Count > MaxDependentList)
                {
                    Debug.Log(GetDependentMessage(displayVersion, roots, int.MaxValue));
                }

                var message = GetDependentMessage(displayVersion, roots);
                var title   = displayVersion.HasTag(PackageTag.BuiltIn) ? "Cannot disable built-in package" : "Cannot remove dependent package";
                EditorUtility.DisplayDialog(title, message, "Ok");

                return;
            }

            if (displayVersion.HasTag(PackageTag.InDevelopment))
            {
                if (!EditorUtility.DisplayDialog("Unity Package Manager", "You will loose all your changes (if any) if you delete a package in development. Are you sure?", "Yes", "No"))
                {
                    return;
                }

                detailError.ClearError();
                PackageDatabase.instance.RemoveEmbedded(package);
                RefreshPackageActionButtons();

                EditorApplication.delayCall += () =>
                {
                    PackageFilterTab?newFilterTab = null;
                    if (PackageFiltering.instance.currentFilterTab == PackageFilterTab.InDevelopment)
                    {
                        var hasOtherInDevelopment = PackageDatabase.instance.allPackages.Any(p =>
                        {
                            var installed = p.installedVersion;
                            return(installed != null && installed.HasTag(PackageTag.InDevelopment) && p.uniqueId != package.uniqueId);
                        });
                        newFilterTab = hasOtherInDevelopment ? PackageFilterTab.InDevelopment : PackageFilterTab.Local;
                    }
                    PackageManagerWindow.SelectPackageAndFilter(displayVersion.uniqueId, newFilterTab, true);
                };
                return;
            }

            var result = 0;

            if (displayVersion.HasTag(PackageTag.BuiltIn))
            {
                if (!PackageManagerPrefs.instance.skipDisableConfirmation)
                {
                    result = EditorUtility.DisplayDialogComplex("Disable Built-In Package",
                                                                "Are you sure you want to disable this built-in package?",
                                                                "Disable", "Cancel", "Never ask");
                }
            }
            else
            {
                if (!PackageManagerPrefs.instance.skipRemoveConfirmation)
                {
                    result = EditorUtility.DisplayDialogComplex("Removing Package",
                                                                "Are you sure you want to remove this package?",
                                                                "Remove", "Cancel", "Never ask");
                }
            }

            // Cancel
            if (result == 1)
            {
                return;
            }

            // Do not ask again
            if (result == 2)
            {
                if (displayVersion.HasTag(PackageTag.BuiltIn))
                {
                    PackageManagerPrefs.instance.skipDisableConfirmation = true;
                }
                else
                {
                    PackageManagerPrefs.instance.skipRemoveConfirmation = true;
                }
            }

            // Remove
            detailError.ClearError();
            PackageDatabase.instance.Uninstall(package);
            RefreshPackageActionButtons();
        }
 /// <summary>
 /// Open Package Manager Window and select specified filter.
 /// The string used to identify the filter can be any of the following:
 /// <list type="bullet">
 /// <item><description>filterTab (e.g. "InProject")</description></item>
 /// <item><description>filterTab/subPage (e.g. "InProject/Services")</description></item>
 /// <item><description>null (no specific filterTab to focus)</description></item>
 /// </list>
 /// </summary>
 /// <param name="filterAndSubPageToSelect">Filter tab and subpage (optional) to select. If filter tab cannot be found, last select tab will be selected, if subpage cannot be found, first subpage will be selected</param>
 internal static void OpenFilter(string filterAndSubPageToSelect)
 {
     PackageManagerWindow.OpenPackageManagerOnFilter(filterAndSubPageToSelect);
 }
 /// <summary>
 /// Open Package Manager Window and select specified package(if any).
 /// The string used to identify the package can be any of the following:
 /// <list type="bullet">
 /// <item><description>productId (e.g. 12345)</description></item>
 /// <item><description>packageName (e.g. com.unity.x)</description></item>
 /// <item><description>packageId (e.g. [email protected])</description></item>
 /// <item><description>displayName (e.g. 2D Common)</description></item>
 /// <item><description>null (no specific package to focus)</description></item>
 /// </list>
 /// </summary>
 /// <param name="packageToSelect">packageToSelect can be identified by packageName, displayName, packageId, productId or null</param>
 public static void Open(string packageToSelect)
 {
     PackageManagerWindow.OpenPackageManager(packageToSelect);
 }
        public void OnEnable()
        {
            this.SetAntiAliasing(4);
            if (instance == null)
            {
                instance = this;
            }
            if (instance != this)
            {
                return;
            }

            instance.titleContent = GetLocalizedTitleContent();

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

            if (windowResource != null)
            {
                var root = windowResource.Instantiate();
                root.styleSheets.Add(Resources.GetMainWindowStyleSheet());
                cache = new VisualElementCache(root);

                rootVisualElement.Add(root);
                LocalizeVisualElementAndAllChildrenText(rootVisualElement);

                PageManager.instance.Setup();

                packageDetails.OnEnable();
                packageList.OnEnable();
                packageLoadBar.OnEnable();
                packageManagerToolbar.OnEnable();
                packageStatusbar.OnEnable();

                packageManagerToolbar.SetEnabled(!PackageDatabase.instance.isEmpty);
                packageDetails.packageToolbarContainer.SetEnabled(!PackageDatabase.instance.isEmpty);

                PageManager.instance.onRefreshOperationFinish += OnRefreshOperationFinish;
                PageManager.instance.onRefreshOperationStart  += OnRefreshOperationStart;
                PageManager.instance.onRefreshOperationError  += OnRefreshOperationError;
                PackageFiltering.instance.onFilterTabChanged  += OnFilterChanged;

                PackageManagerWindowAnalytics.Setup();

                root.StretchToParentSize();

                var newTab = PackageManagerPrefs.instance.lastUsedPackageFilter ?? PackageFiltering.instance.defaultFilterTab;
                PackageFiltering.instance.SetCurrentFilterTabWithoutNotify(newTab);
                packageManagerToolbar.SetFilter(newTab);

                if (newTab != PackageFilterTab.AssetStore)
                {
                    UIUtils.SetElementDisplay(packageLoadBar, false);
                }

                if (PageManager.instance.GetRefreshTimestamp(newTab) == 0)
                {
                    DelayRefresh(newTab);
                }

                if (newTab != PackageFilterTab.All && PageManager.instance.GetRefreshTimestamp(PackageFilterTab.All) == 0)
                {
                    DelayRefresh(PackageFilterTab.All);
                }

                mainContainer.leftWidth      = m_SplitPaneLeftWidth;
                mainContainer.onSizeChanged += width => { m_SplitPaneLeftWidth = width; };

                EditorApplication.focusChanged += OnFocusChanged;
                Selection.selectionChanged     += OnEditorSelectionChanged;

                rootVisualElement.focusable = true;
                rootVisualElement.RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
                rootVisualElement.RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
            }
        }
 /// <summary>
 /// Open Package Manager Window and select specified package (if any)
 /// </summary>
 /// <param name="packageNameOrDisplayName">Id or display name of package to select, can be null</param>
 public static void Open(string packageNameOrDisplayName)
 {
     PackageManagerWindow.OpenPackageManager(packageNameOrDisplayName);
 }
        void OnDestroy()
        {
            m_Root?.OnDestroy();

            instance = null;
        }
        public void OnEnable()
        {
            this.SetAntiAliasing(4);
            if (s_Window == null)
            {
                s_Window = this;
            }
            if (s_Window != this)
            {
                return;
            }

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

            if (windowResource != null)
            {
                var root = windowResource.Instantiate();
                root.styleSheets.Add(Resources.GetStyleSheet());
                cache = new VisualElementCache(root);

                PageManager.instance.Setup();

                packageDetails.OnEnable();
                packageList.OnEnable();
                packageManagerToolbar.OnEnable();
                packageStatusbar.OnEnable();

                packageManagerToolbar.SetEnabled(!PackageDatabase.instance.isEmpty);
                packageDetails.packageToolbarContainer.SetEnabled(!PackageDatabase.instance.isEmpty);

                PageManager.instance.onRefreshOperationFinish += OnRefreshOperationFinish;
                PageManager.instance.onRefreshOperationStart  += OnRefreshOperationStart;
                PageManager.instance.onRefreshOperationError  += OnRefreshOperationError;

                PackageManagerWindowAnalytics.Setup();

                rootVisualElement.Add(root);
                root.StretchToParentSize();

                var newTab = PackageManagerPrefs.instance.lastUsedPackageFilter ?? PackageFilterTab.All;
                PackageFiltering.instance.currentFilterTab = newTab;

                if (PageManager.instance.GetRefreshTimestamp(newTab) == 0)
                {
                    PageManager.instance.Refresh(newTab);
                }

                if (newTab != PackageFilterTab.All && PageManager.instance.GetRefreshTimestamp(PackageFilterTab.All) == 0)
                {
                    PageManager.instance.Refresh(PackageFilterTab.All);
                }

                mainContainer.leftWidth      = m_SplitPaneLeftWidth;
                mainContainer.onSizeChanged += width => { m_SplitPaneLeftWidth = width; };

                EditorApplication.focusChanged += OnFocusChanged;

                rootVisualElement.focusable = true;
                rootVisualElement.RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
                rootVisualElement.RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
            }
        }