コード例 #1
0
        private void RefreshLabel()
        {
            versionLabel.text = version.version?.ToString() ?? version.versionString;
            var   primary    = package.versions.primary;
            Label stateLabel = null;

            if (version == primary)
            {
                if (version.isInstalled)
                {
                    stateLabel = new Label(L10n.Tr("Currently Installed"));
                }
                else if (version.HasTag(PackageTag.Downloadable) && version.isAvailableOnDisk)
                {
                    stateLabel = new Label(L10n.Tr("Currently Downloaded"));
                }
            }
            else if (version == package.versions.recommended)
            {
                stateLabel = new Label(L10n.Tr("Update Available"));
            }
            if (stateLabel != null)
            {
                stateLabel.tooltip = stateLabel.text;
                stateContainer.Add(stateLabel);
            }

            var tagLabel = PackageTagLabel.CreateTagLabel(version, true);

            if (tagLabel != null)
            {
                stateContainer.Add(tagLabel);
            }
        }
コード例 #2
0
        internal void SetPackage(IPackage package)
        {
            var displayVersion = package?.versions.primary;

            if (displayVersion == null)
            {
                return;
            }

            // changing the package assigned to an item is not supported
            if (this.package != null && this.package.uniqueId != package.uniqueId)
            {
                return;
            }

            var oldDisplayVersion = this.package?.versions.primary;

            this.package = package;

            // if the package gets updated while it's selected, we need to do some special handling
            if (!string.IsNullOrEmpty(visualState?.selectedVersionId))
            {
                // if the primary version was selected but there is a new primary version
                // select the new primary version to keep the main item selected
                if (visualState.selectedVersionId == oldDisplayVersion?.uniqueId && oldDisplayVersion?.uniqueId != displayVersion.uniqueId)
                {
                    m_PageManager.SetSelected(package, displayVersion);
                }
            }

            nameLabel.text = displayVersion.displayName;

            var expandable = !package.Is(PackageType.BuiltIn);

            UIUtils.SetElementDisplay(arrowExpander, expandable);
            UIUtils.SetElementDisplay(expanderHidden, !expandable);
            if (!expandable && UIUtils.IsElementVisible(versionsContainer))
            {
                UpdateExpanderUI(false);
            }

            var showVersionList = !displayVersion.HasTag(PackageTag.BuiltIn) && !string.IsNullOrEmpty(package.displayName);

            UIUtils.SetElementDisplay(versionList, showVersionList);

            tagContainer.Clear();
            var tagLabel = PackageTagLabel.CreateTagLabel(displayVersion);

            if (tagLabel != null)
            {
                tagContainer.Add(tagLabel);
            }

            RefreshState();
            RefreshVersions();
            RefreshSelection();
        }