/// <inheritdoc />
 public override void Populate(Contribution model)
 {
     if (model != null)
     {
         this.Id                   = model.Id;
         this.TypeName             = model.TypeName;
         this.Type                 = model.Type;
         this.Technology           = model.Technology.ToActivityTechnology();
         this.StartDate            = model.StartDate;
         this.Title                = model.Title;
         this.Description          = model.Description;
         this.AnnualQuantity       = model.AnnualQuantity;
         this.SecondAnnualQuantity = model.SecondAnnualQuantity;
         this.AnnualReach          = model.AnnualReach;
         this.ReferenceUrl         = model.ReferenceUrl;
         this.Visibility           = model.Visibility;
     }
     else
     {
         this.Id                   = 0;
         this.TypeName             = string.Empty;
         this.Type                 = null;
         this.Technology           = null;
         this.StartDate            = DateTime.UtcNow;
         this.Title                = string.Empty;
         this.Description          = string.Empty;
         this.AnnualQuantity       = null;
         this.SecondAnnualQuantity = null;
         this.AnnualReach          = null;
         this.ReferenceUrl         = string.Empty;
         this.Visibility           = ContributionVisibilities.Public;
     }
 }
Example #2
0
        public void Populate(Uri activationProtocolUri)
        {
            if (activationProtocolUri == null)
            {
                this.Populate(default(Contribution));
            }
            else
            {
                var date = ParseHelper.SafeParseDateTime(activationProtocolUri.ExtractQueryValue("date"));
                if (date.GreaterThan(DateTime.UtcNow) || date == DateTime.MinValue)
                {
                    date = DateTime.UtcNow;
                }

                this.Id                   = 0;
                this.TypeName             = string.Empty;
                this.Type                 = null;
                this.Technology           = null;
                this.StartDate            = date;
                this.Title                = activationProtocolUri.ExtractQueryValue("title");
                this.Description          = activationProtocolUri.ExtractQueryValue("description");
                this.AnnualQuantity       = ParseHelper.SafeParseInt(activationProtocolUri.ExtractQueryValue("quantity"));
                this.SecondAnnualQuantity = null;
                this.AnnualReach          = ParseHelper.SafeParseInt(activationProtocolUri.ExtractQueryValue("reach"));
                this.ReferenceUrl         = activationProtocolUri.ExtractQueryValue("url");
                this.Visibility           = ContributionVisibilities.Public;

                this.AnnualQuantityValue       = this.AnnualQuantity == null ? string.Empty : this.AnnualQuantity.ToString();
                this.SecondAnnualQuantityValue = this.SecondAnnualQuantity == null ? string.Empty : this.SecondAnnualQuantity.ToString();
                this.AnnualReachValue          = this.AnnualReach == null ? string.Empty : this.AnnualReach.ToString();
            }
        }
Example #3
0
        public void Populate(
            ContributionType contributionType,
            ActivityTechnology contributionTechnology,
            ItemVisibility visibility)
        {
            this.Populate(default(Contribution));

            this.Type            = contributionType;
            this.Technology      = contributionTechnology;
            this.VisibilityValue = visibility?.Description;
        }
        public void BuildModuleCompletionData(ModuleResult tr, ItemVisibility visMod,
                                              List <string> alreadyAddedModuleNames)
        {
            if (!tr.IsOnlyModuleNamePartTyped())
            {
                foreach (var i in tr.ResolvedModule)
                {
                    var di = i as DNode;
                    if (di == null)
                    {
                        if (i != null)
                        {
                            CompletionDataGenerator.Add(i);
                        }
                        continue;
                    }

                    if (di.IsPublic && CanItemBeShownGenerally(i))
                    {
                        CompletionDataGenerator.Add(i);
                    }
                }
            }
            else
            {
                var modNameParts = tr.ResolvedModule.ModuleName.Split('.');

                string packageDir = modNameParts[0];
                for (int i = 1; i <= tr.AlreadyTypedModuleNameParts; i++)
                {
                    packageDir += "." + modNameParts[i];
                }

                if (tr.AlreadyTypedModuleNameParts < modNameParts.Length - 1)
                {
                    // Don't add a package name that already has been added before.. so e.g. show only the first module of package "std.c."
                    if (alreadyAddedModuleNames.Contains(packageDir))
                    {
                        return;
                    }

                    alreadyAddedModuleNames.Add(packageDir);

                    CompletionDataGenerator.Add(modNameParts[tr.AlreadyTypedModuleNameParts], PathOverride: packageDir);
                }
                else
                {
                    CompletionDataGenerator.Add(modNameParts[modNameParts.Length - 1], tr.ResolvedModule);
                }
            }
        }
Example #5
0
        /// <inheritdoc />
        public override void Populate(Contribution model)
        {
            var visibilities = ContributionVisibilities.GetItemVisibilities();

            if (model != null)
            {
                this.Id                   = model.Id;
                this.TypeName             = model.TypeName;
                this.Type                 = model.Type;
                this.Technology           = model.Technology.ToActivityTechnology();
                this.StartDate            = model.StartDate;
                this.Title                = model.Title;
                this.Description          = model.Description;
                this.AnnualQuantity       = model.AnnualQuantity;
                this.SecondAnnualQuantity = model.SecondAnnualQuantity;
                this.AnnualReach          = model.AnnualReach;
                this.ReferenceUrl         = model.ReferenceUrl;
                this.Visibility           = model.Visibility == null
                                      ? visibilities.FirstOrDefault()
                                      : visibilities.FirstOrDefault(x => x.Id.Equals(model.Visibility.Id));

                this.VisibilityValue = this.Visibility?.Description;

                this.AnnualQuantityValue       = model.AnnualQuantity == null ? string.Empty : model.AnnualQuantity.ToString();
                this.SecondAnnualQuantityValue = model.SecondAnnualQuantity == null
                                                     ? string.Empty
                                                     : model.SecondAnnualQuantity.ToString();
                this.AnnualReachValue = model.AnnualReach == null ? string.Empty : model.AnnualReach.ToString();
            }
            else
            {
                this.Id                   = 0;
                this.TypeName             = string.Empty;
                this.Type                 = null;
                this.Technology           = null;
                this.StartDate            = DateTime.UtcNow;
                this.Title                = string.Empty;
                this.Description          = string.Empty;
                this.AnnualQuantity       = null;
                this.SecondAnnualQuantity = null;
                this.AnnualReach          = null;
                this.ReferenceUrl         = string.Empty;
                this.Visibility           = visibilities.FirstOrDefault();
                this.VisibilityValue      = this.Visibility?.Description;

                this.AnnualQuantityValue       = string.Empty;
                this.SecondAnnualQuantityValue = string.Empty;
                this.AnnualReachValue          = string.Empty;
            }
        }
        public void BuildTypeCompletionData(TypeResult tr, ItemVisibility visMod)
        {
            var n = tr.ResolvedTypeDefinition;

            if (n is DClassLike)             // Add public static members of the class and including all base classes
            {
                var curlevel = tr;
                var tvisMod  = visMod;
                while (curlevel != null)
                {
                    foreach (var i in curlevel.ResolvedTypeDefinition)
                    {
                        var dn = i as DNode;

                        if (i != null && dn == null)
                        {
                            CompletionDataGenerator.Add(i);
                            continue;
                        }

                        bool add = false;

                        if (tvisMod.HasFlag(ItemVisibility.All))
                        {
                            add = true;
                        }
                        else
                        {
                            if (tvisMod.HasFlag(ItemVisibility.ProtectedMembers))
                            {
                                add = add || dn.ContainsAttribute(DTokens.Protected);
                            }
                            if (tvisMod.HasFlag(ItemVisibility.PublicMembers))
                            {
                                add = add || dn.IsPublic;
                            }
                            if (tvisMod.HasFlag(ItemVisibility.PublicStaticMembers))
                            {
                                add = add || (dn.IsPublic && dn.IsStatic);
                            }
                            if (tvisMod.HasFlag(ItemVisibility.StaticMembers))
                            {
                                add = add || dn.IsStatic;
                            }
                        }

                        if (add)
                        {
                            if (CanItemBeShownGenerally(dn))
                            {
                                CompletionDataGenerator.Add(dn);
                            }

                            // Add members of anonymous enums
                            else if (dn is DEnum && dn.Name == "")
                            {
                                foreach (var k in dn as DEnum)
                                {
                                    CompletionDataGenerator.Add(k);
                                }
                            }
                        }
                    }
                    curlevel = curlevel.BaseClass != null ? curlevel.BaseClass[0] : null;

                    // After having shown all items on the current node level,
                    // allow showing public (static) and/or protected items in the more basic levels then
                    if (tvisMod == ItemVisibility.All)
                    {
                        tvisMod = ItemVisibility.ProtectedMembers | ItemVisibility.PublicMembers;
                    }
                }
            }
            else if (n is DEnum)
            {
                var de = n as DEnum;

                foreach (var i in de)
                {
                    if (i is DEnumValue)
                    {
                        CompletionDataGenerator.Add(i);
                    }
                }
            }
        }
Example #7
0
        protected override void ModuleShown()
        {
            base.ModuleShown();
            ControlService.LibraryTree.Controller.Type = LibraryGroup.EditorFilter;
            ItemVisibility visibility = ItemVisibility.Never;
            //ControlService.BarButton.Caption = "asdfadsf";
            bool insertEnabled = TabControl.Current != null;
            bool canCopy       = insertEnabled && CopyAction.CanCopy;
            bool canPast       = insertEnabled && CopyAction.CanPaste;

            if (insertEnabled)
            {
                visibility = ItemVisibility.Always;
            }
            bool sendToEnabled = HasInLibrary && (TabControl.Current != null && !TabControl.Current.ChangedService.HasChanged);
            bool canOpen       = CommonHelper.IsShowOpenDialog(LibraryType.Message);


            LocalMessageBus.Send(null, new MenuMessage(new MenuCommand[] {
                new MenuCommand {
                    Command = MenuCommands.Insert, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Open, Enabled = canOpen
                }
                , new MenuCommand {
                    Command = MenuCommands.InsertMessage, Enabled = insertEnabled, Visibility = ItemVisibility.Never
                }
                , new MenuCommand {
                    Command = MenuCommands.InsertPlaylist, Enabled = insertEnabled, Visibility = ItemVisibility.Never
                }
                , new MenuCommand {
                    Command = MenuCommands.InsertTimeSlice, Enabled = insertEnabled, Visibility = ItemVisibility.Never
                }
                , new MenuCommand {
                    Command = MenuCommands.Text, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Image, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Video, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.DynamicText, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                //, new MenuCommand{Command= MenuCommands.DynamicVideo, Enabled = insertEnabled, Visibility = ItemVisibility.Always}
                , new MenuCommand {
                    Command = MenuCommands.Time, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Temperature, Enabled = insertEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Copy, Enabled = canCopy, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Paste, Enabled = canPast, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SendToLiveStorage, Enabled = sendToEnabled, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SendToSign, Enabled = TabControl.Current != null, Visibility = ItemVisibility.Never
                }
                , new MenuCommand {
                    Command = MenuCommands.SendToPlaylist, Enabled = TabControl.Current != null, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SendToScheduler, Enabled = TabControl.Current != null, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SendMessageOrPlaylistToSign, Enabled = TabControl.Current != null, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SendPlayListToSign, Enabled = TabControl.Current != null, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.Save, Enabled = TabControl.Current != null &&
                                                           TabControl.Current.Model != null &&
                                                           TabControl.Current.ChangedService.HasChanged, Visibility = ItemVisibility.Always
                }
                , new MenuCommand {
                    Command = MenuCommands.SaveAs, Enabled = TabControl.Current != null &&
                                                             TabControl.Current.Model != null &&
                                                             TabControl.Current.Model.Items.Length > 0, Visibility = ItemVisibility.Always
                }
            }));


            //if (TabControl.Current == null || TabControl.Current.Model == null)
            //    LocalMessageBus.Send(this, new PWMessage<MenuCommands>(MenuCommands.NewMessage));
        }
        void BuildCompletionData(UserDefinedType tr, ItemVisibility visMod)
        {
            var n = tr.Definition;
            if (n is DClassLike) // Add public static members of the class and including all base classes
            {
                var propertyMethodsToIgnore = new List<string>();

                var curlevel = tr;
                var tvisMod = visMod;
                while (curlevel != null)
                {
                    foreach (var i in curlevel.Definition as DBlockNode)
                    {
                        var dn = i as DNode;

                        if (i != null && dn == null)
                        {
                            CompletionDataGenerator.Add(i);
                            continue;
                        }

                        bool add = false;

                        if (tvisMod.HasFlag(ItemVisibility.All))
                            add = true;
                        else
                        {
                            if (tvisMod.HasFlag(ItemVisibility.ProtectedMembers))
                                add |= dn.ContainsAttribute(DTokens.Protected);
                            if (tvisMod.HasFlag(ItemVisibility.ProtectedStaticMembers))
                                add |= dn.ContainsAttribute(DTokens.Protected) && (dn.IsStatic || IsTypeNode(i));
                            if (tvisMod.HasFlag(ItemVisibility.PublicMembers))
                                add |= dn.IsPublic;
                            if (tvisMod.HasFlag(ItemVisibility.PublicStaticMembers))
                                add |= dn.IsPublic && (dn.IsStatic || IsTypeNode(i));
                            if (tvisMod.HasFlag(ItemVisibility.StaticMembers))
                                add |= dn.IsStatic || IsTypeNode(i);
                        }

                        if (add)
                        {
                            if (CanItemBeShownGenerally(dn))
                            {
                                // Convert @property getters&setters to one unique property
                                if (dn is DMethod && dn.ContainsPropertyAttribute())
                                {
                                    if (!propertyMethodsToIgnore.Contains(dn.Name))
                                    {
                                        var dm = dn as DMethod;
                                        bool isGetter = dm.Parameters.Count < 1;

                                        var virtPropNode = new DVariable();

                                        virtPropNode.AssignFrom(dn);

                                        if (!isGetter)
                                            virtPropNode.Type = dm.Parameters[0].Type;

                                        CompletionDataGenerator.Add(virtPropNode);

                                        propertyMethodsToIgnore.Add(dn.Name);
                                    }
                                }
                                else
                                    CompletionDataGenerator.Add(dn);
                            }

                            // Add members of anonymous enums
                            else if (dn is DEnum && string.IsNullOrEmpty(dn.Name))
                            {
                                foreach (var k in dn as DEnum)
                                    CompletionDataGenerator.Add(k);
                            }
                        }
                    }
                    curlevel = curlevel.Base as UserDefinedType;

                    // After having shown all items on the current node level,
                    // allow showing public (static) and/or protected items in the more basic levels then
                    if (tvisMod.HasFlag(ItemVisibility.All))
                    {
                        if ((n as DClassLike).ContainsAttribute(DTokens.Static))
                            tvisMod = ItemVisibility.ProtectedStaticMembers | ItemVisibility.PublicStaticMembers;
                        else
                            tvisMod = ItemVisibility.ProtectedMembers | ItemVisibility.PublicMembers;
                    }
                }
            }
            else if (n is DEnum)
            {
                var de = n as DEnum;

                foreach (var i in de)
                    if (i is DEnumValue)
                        CompletionDataGenerator.Add(i);
            }
        }
Example #9
0
        void BuildCompletionData(UserDefinedType tr, ItemVisibility visMod)
        {
            var n = tr.Definition;

            if (n is DClassLike)             // Add public static members of the class and including all base classes
            {
                var propertyMethodsToIgnore = new List <string>();

                var curlevel = tr;
                var tvisMod  = visMod;
                while (curlevel != null)
                {
                    foreach (var i in curlevel.Definition as DBlockNode)
                    {
                        var dn = i as DNode;

                        if (i != null && dn == null)
                        {
                            CompletionDataGenerator.Add(i);
                            continue;
                        }

                        bool add = false;

                        if (tvisMod.HasFlag(ItemVisibility.All))
                        {
                            add = true;
                        }
                        else
                        {
                            if (tvisMod.HasFlag(ItemVisibility.ProtectedMembers))
                            {
                                add |= dn.ContainsAttribute(DTokens.Protected);
                            }
                            if (tvisMod.HasFlag(ItemVisibility.ProtectedStaticMembers))
                            {
                                add |= dn.ContainsAttribute(DTokens.Protected) && (dn.IsStatic || IsTypeNode(i));
                            }
                            if (tvisMod.HasFlag(ItemVisibility.PublicMembers))
                            {
                                add |= dn.IsPublic;
                            }
                            if (tvisMod.HasFlag(ItemVisibility.PublicStaticMembers))
                            {
                                add |= dn.IsPublic && (dn.IsStatic || IsTypeNode(i));
                            }
                            if (tvisMod.HasFlag(ItemVisibility.StaticMembers))
                            {
                                add |= dn.IsStatic || IsTypeNode(i);
                            }
                        }

                        if (add)
                        {
                            if (CanItemBeShownGenerally(dn))
                            {
                                // Convert @property getters&setters to one unique property
                                if (dn is DMethod && dn.ContainsPropertyAttribute())
                                {
                                    if (!propertyMethodsToIgnore.Contains(dn.Name))
                                    {
                                        var  dm       = dn as DMethod;
                                        bool isGetter = dm.Parameters.Count < 1;

                                        var virtPropNode = new DVariable();

                                        virtPropNode.AssignFrom(dn);

                                        if (!isGetter)
                                        {
                                            virtPropNode.Type = dm.Parameters[0].Type;
                                        }

                                        CompletionDataGenerator.Add(virtPropNode);

                                        propertyMethodsToIgnore.Add(dn.Name);
                                    }
                                }
                                else
                                {
                                    CompletionDataGenerator.Add(dn);
                                }
                            }

                            // Add members of anonymous enums
                            else if (dn is DEnum && string.IsNullOrEmpty(dn.Name))
                            {
                                foreach (var k in dn as DEnum)
                                {
                                    CompletionDataGenerator.Add(k);
                                }
                            }
                        }
                    }
                    curlevel = curlevel.Base as UserDefinedType;

                    // After having shown all items on the current node level,
                    // allow showing public (static) and/or protected items in the more basic levels then
                    if (tvisMod.HasFlag(ItemVisibility.All))
                    {
                        if ((n as DClassLike).ContainsAttribute(DTokens.Static))
                        {
                            tvisMod = ItemVisibility.ProtectedStaticMembers | ItemVisibility.PublicStaticMembers;
                        }
                        else
                        {
                            tvisMod = ItemVisibility.ProtectedMembers | ItemVisibility.PublicMembers;
                        }
                    }
                }
            }
            else if (n is DEnum)
            {
                var de = n as DEnum;

                foreach (var i in de)
                {
                    if (i is DEnumValue)
                    {
                        CompletionDataGenerator.Add(i);
                    }
                }
            }
        }