Ejemplo n.º 1
0
        protected override void UpdateEditorInternal(IEditableObject item, Control editor)
        {
            CheckBoxList cbl = (CheckBoxList) editor;
            cbl.Items.AddRange(GetListItems(item));

            PropertyCollection dc = item.GetDetailCollection(Name, false);
            if (dc != null)
            {
                foreach (object detail in dc)
                {
                    string value = GetValue(detail);
                    ListItem li = cbl.Items.FindByValue(value);
                    if (li != null)
                    {
                        li.Selected = true;
                    }
                    else
                    {
                        li = new ListItem(value);
                        li.Selected = true;
                        li.Attributes["style"] = "color:silver";
                        cbl.Items.Add(li);
                    }
                }
            }
        }
        public override bool UpdateItem(IEditableObject item, Control editor)
        {
            PropertyCollection detailCollection = item.GetDetailCollection(Name, true);
            BaseDetailCollectionEditor detailCollectionEditor = (BaseDetailCollectionEditor) editor;

            List<PropertyData> propertyDataToDelete = new List<PropertyData>();

            // First pass saves or creates items.
            for (int i = 0; i < detailCollectionEditor.Editors.Count; i++)
            {
                if (!detailCollectionEditor.DeletedIndexes.Contains(i))
                {
                    PropertyData existingDetail = (detailCollection.Count > i) ? detailCollection.Details[i] : null;
                    object newDetail;
                    CreateOrUpdateDetailCollectionItem((ContentItem) item, existingDetail, detailCollectionEditor.Editors[i], out newDetail);
                    if (newDetail != null)
                        if (existingDetail != null)
                            existingDetail.Value = newDetail;
                        else
                            detailCollection.Add(newDetail);
                }
                else
                {
                    propertyDataToDelete.Add(detailCollection.Details[i]);
                }
            }

            // Do a second pass to delete the items, this is so we don't mess with the indices on the first pass.
            foreach (PropertyData propertyData in propertyDataToDelete)
                detailCollection.Remove(propertyData);

            return detailCollectionEditor.DeletedIndexes.Count > 0 || detailCollectionEditor.AddedEditors;
        }
Ejemplo n.º 3
0
 public override bool UpdateItem(IEditableObject item, Control editor)
 {
     CheckBoxList cbl = (CheckBoxList) editor;
     IEnumerable selected = GetSelectedItems(cbl.Items.Cast<ListItem>().Where(li => li.Selected));
     PropertyCollection dc = item.GetDetailCollection(Name, true);
     dc.Replace(selected);
     return true;
 }
 protected override void UpdateEditorInternal(IEditableObject item, Control editor)
 {
     BaseDetailCollectionEditor detailCollectionEditor = (BaseDetailCollectionEditor) editor;
     PropertyCollection detailCollection = item.GetDetailCollection(Name, true);
     PropertyData[] details = new PropertyData[detailCollection.Count];
     detailCollection.CopyTo(details, 0);
     detailCollectionEditor.Initialize(details);
 }
Ejemplo n.º 5
0
        public override bool UpdateItem(IEditableObject item, Control editor)
        {
            CheckBoxList cbl = editor as CheckBoxList;
            List<Items.Role> roles = new List<Items.Role>();
            foreach (ListItem li in cbl.Items)
                if (li.Selected)
                {
                    Items.Role role = Context.Current.Resolve<IWebSecurityManager>().GetRole(li.Value);
                    roles.Add(role);
                }

            PropertyCollection dc = item.GetDetailCollection(Name, true);
            dc.Replace(roles);

            return true;
        }
Ejemplo n.º 6
0
 protected override void UpdateEditorInternal(IEditableObject item, Control editor)
 {
     CheckBoxList cbl = editor as CheckBoxList;
     PropertyCollection dc = item.GetDetailCollection(Name, false);
     if (dc != null)
     {
         foreach (Items.Role role in dc)
         {
             ListItem li = cbl.Items.FindByValue(role.Name);
             if (li != null)
             {
                 li.Selected = true;
             }
             else
             {
                 li = new ListItem(role.Name);
                 li.Selected = true;
                 li.Attributes["style"] = "color:silver";
                 cbl.Items.Add(li);
             }
         }
     }
 }