private void SetStatusMessage(StatusType status, string message)
        {
            currentStatus = status;

            if (currentStatus == StatusType.Loading)
            {
                LoadingSpinner.Start();
            }
            else
            {
                LoadingSpinner.Stop();
            }

            UIUtils.SetElementDisplay(LoadingIcon, currentStatus == StatusType.Error);
            if (currentStatus == StatusType.Error)
            {
                LoadingText.AddToClassList("icon");
            }
            else
            {
                LoadingText.RemoveFromClassList("icon");
            }

            LoadingText.text    = message;
            LoadingText.tooltip = currentStatus != StatusType.Loading ? "Click to refresh packages" : string.Empty;
        }
 private void OnFilterChanged(PackageFilter filter)
 {
     ClearAll();
     if (!LoadingSpinner.Started)
     {
         root.Q <VisualElement>(loadingId).visible = true;
         LoadingSpinner.Start();
     }
 }
        private void SetLoading(bool state)
        {
            LoadingContainer.visible = state;

            if (state)
            {
                LoadingSpinner.Start();
            }
            else
            {
                LoadingSpinner.Stop();
            }
        }
        private void ClearAll()
        {
            List.Clear();
            Groups.Clear();
            ClearSelection();

            root.Q <VisualElement>(emptyId).visible = false;
            if (LoadingSpinner.Started)
            {
                root.Q <VisualElement>(loadingId).visible = false;
                LoadingSpinner.Stop();
            }
        }
        private void SetStatusMessage(StatusType status, string message)
        {
            if (status == StatusType.Loading)
            {
                LoadingSpinner.Start();
            }
            else
            {
                LoadingSpinner.Stop();
            }


            UIUtils.SetElementDisplay(ErrorIcon, status == StatusType.Error);
            StatusLabel.text = message;
        }
        private void SetPackages(IEnumerable <Package> packages)
        {
            if (PackageCollection.Instance.Filter == PackageFilter.Local)
            {
                packages = packages.Where(pkg => pkg.Current != null);
            }

            var previousSelection = selectedItem != null ? selectedItem.package : null;

            OnLoaded();
            ClearAll();

            var packagesGroup = new PackageGroup(PackageGroupOrigins.Packages.ToString());

            Groups.Add(packagesGroup);
            List.Add(packagesGroup);

            var builtInGroup = new PackageGroup(PackageGroupOrigins.BuiltInPackages.ToString());

            Groups.Add(builtInGroup);
            List.Add(builtInGroup);

            packagesGroup.previousGroup = null;
#if UNITY_2018_2_OR_NEWER
            packagesGroup.nextGroup    = builtInGroup;
            builtInGroup.previousGroup = packagesGroup;
            builtInGroup.nextGroup     = null;
#else
            packagesGroup.nextGroup = null;
            UIUtils.SetElementDisplay(builtInGroup, false);
#endif

            root.Q <VisualElement>(loadingId).visible = false;
            LoadingSpinner.Stop();

            foreach (var package in packages.OrderBy(pkg => pkg.Versions.FirstOrDefault() == null ? pkg.Name : pkg.Versions.FirstOrDefault().DisplayName))
            {
                var item = AddPackage(package);

                if (previousSelection != null && package.Name == previousSelection.Name)
                {
                    Select(item);
                }
            }

            root.Q <VisualElement>(emptyId).visible = !packages.Any();
        }
        private void SetStatusMessage(StatusType status, string message)
        {
            if (status == StatusType.Loading)
            {
                LoadingSpinnerContainer.AddToClassList("loading");
                LoadingSpinner.Start();
            }
            else
            {
                LoadingSpinner.Stop();
                LoadingSpinnerContainer.RemoveFromClassList("loading");
            }


            UIUtils.SetElementDisplay(ErrorIcon, status == StatusType.Error);
            StatusLabel.text = message;
        }
        public PackageList()
        {
            Groups = new List <PackageGroup>();

            root = Resources.Load <VisualTreeAsset>("Templates/PackageList").CloneTree(null);
            Add(root);
            root.StretchToParentSize();

            root.Q <VisualElement>(emptyId).visible   = false;
            root.Q <VisualElement>(loadingId).visible = true;
            root.Q <VisualElement>(loadingId).StretchToParentSize();
            root.Q <VisualElement>(loadingSpinnerId).clippingOptions = ClippingOptions.NoClipping;
            LoadingSpinner.Start();

            PackageCollection.Instance.OnPackagesChanged += SetPackages;
            PackageCollection.Instance.OnFilterChanged   += OnFilterChanged;

            RegisterCallback <AttachToPanelEvent>(OnEnterPanel);
            RegisterCallback <DetachFromPanelEvent>(OnLeavePanel);

            Reload();
        }
示例#9
0
        private void SetStatusMessage(StatusType status, string message)
        {
            if (status == StatusType.Loading)
            {
                LoadingSpinner.Start();
            }
            else
            {
                LoadingSpinner.Stop();
            }

            UIUtils.SetElementDisplay(LoadingIcon, status == StatusType.Error);
            if (status == StatusType.Error)
            {
                LoadingText.AddToClassList("icon");
            }
            else
            {
                LoadingText.RemoveFromClassList("icon");
            }

            LoadingText.text = message;
        }