Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPMModelController"/> class.
        /// </summary>
        /// <param name="topLevelElement">
        /// The top level element.
        /// </param>
        public UPMModelController(ITopLevelElement topLevelElement)
        {
            if (topLevelElement == null)
            {
                return;
            }

            this.TopLevelElement = topLevelElement;
            this.pendingChanges  = new List <IIdentifier>();
        }
 /// <summary>
 /// Informs the about did fail top level element.
 /// </summary>
 /// <param name="failedTopLevelElement">The failed top level element.</param>
 public override void InformAboutDidFailTopLevelElement(ITopLevelElement failedTopLevelElement)
 {
     if (this.TestDelegate != null)
     {
         this.TestDelegate.ModelControllerDidFailWithError(this, new Exception("error"));
     }
     else
     {
         base.InformAboutDidFailTopLevelElement(failedTopLevelElement);
     }
 }
 /// <summary>
 /// Informs about change of top level element.
 /// </summary>
 /// <param name="oldTopLevelElement">The old top level element.</param>
 /// <param name="newTopLevelElement">The new top level element.</param>
 /// <param name="changedIdentifiers">The changed identifiers.</param>
 /// <param name="changeHints">The change hints.</param>
 public override void InformAboutDidChangeTopLevelElement(ITopLevelElement oldTopLevelElement,
                                                          ITopLevelElement newTopLevelElement, List <IIdentifier> changedIdentifiers, UPChangeHints changeHints)
 {
     if (this.TestDelegate != null)
     {
         this.TestDelegate.ModelControllerDidFinishWithSuccess(this, (MDetailPage)newTopLevelElement);
     }
     else
     {
         base.InformAboutDidChangeTopLevelElement(oldTopLevelElement, newTopLevelElement, changedIdentifiers,
                                                  changeHints);
     }
 }
Exemplo n.º 4
0
        private void FillPage()
        {
            UPMCharacteristicsPage newPage = (UPMCharacteristicsPage)this.InstantiatePage();

            newPage.IsReadOnly = this.IsReadOnly;
            foreach (UPCharacteristicsGroup crmGroup in this.Characteristics.Groups)
            {
                UPMCharacteristicsItemGroup group = new UPMCharacteristicsItemGroup(StringIdentifier.IdentifierWithStringId(crmGroup.CatalogValue))
                {
                    GroupNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmGroup.Label))
                    {
                        StringValue = crmGroup.Label
                    },
                    ShowExpanded = crmGroup.ShowExpanded,
                    GroupType    = crmGroup.SingleSelection ? UPMCharacteristicsItemGroupType.SingleSelect : UPMCharacteristicsItemGroupType.MultiSelect
                };

                foreach (UPCharacteristicsItem crmItem in crmGroup.Items)
                {
                    UPMCharacteristicsItem item = new UPMCharacteristicsItem(StringIdentifier.IdentifierWithStringId(crmItem.CatalogValue))
                    {
                        ItemNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmItem.Label))
                        {
                            StringValue = crmItem.Label
                        },
                        SelectedField = new UPMBooleanEditField(StringIdentifier.IdentifierWithStringId(crmItem.Label))
                        {
                            BoolValue = crmItem.Record != null
                        }
                    };
                    group.AddChild(item);

                    List <UPMField> additionalEditFields = new List <UPMField>();
                    if (crmItem.ShowAdditionalFields)
                    {
                        for (int additionalFieldIndex = 0; additionalFieldIndex < crmItem.AdditionalFields.Count; additionalFieldIndex++)
                        {
                            UPConfigFieldControlField configField     = crmItem.AdditionalFields[additionalFieldIndex];
                            FieldIdentifier           fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(this.CharacteristicsRootRecordIdentification, configField.Identification);
                            UPEditFieldContext        fieldContext    = UPEditFieldContext.FieldContextFor(configField, fieldIdentifier, crmItem.Values[additionalFieldIndex], (List <UPEditFieldContext>)null);
                            if (fieldContext != null)
                            {
                                additionalEditFields.Add(fieldContext.EditField);
                                this.editPageContext.EditFields.SetObjectForKey(fieldContext, $"{configField.Identification}-{crmItem.CatalogValue}-{crmGroup.CatalogValue}");
                            }
                        }
                    }

                    item.EditFields = additionalEditFields;
                }

                if (group.Children.Count > 0)
                {
                    newPage.AddChild(group);
                }
            }

            if (this.IsReadOnly)
            {
                newPage = this.PageForOverview(newPage);
            }

            ITopLevelElement oldPage = this.TopLevelElement;

            this.TopLevelElement = newPage;
            newPage.Invalid      = false;
            this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null);
        }