Exemple #1
0
 public void RemoveGroup(RightsGroup group)
 {
     group.Changed       -= OnRightChange;
     group.Deleted       -= OnGroupDelete;
     group.ProfilChanged -= OnProfilChange;
     this.MainPanel.Children.Remove(group);
 }
Exemple #2
0
 public void AddGroup(RightsGroup group)
 {
     group.Changed       += OnRightChange;
     group.Deleted       += OnGroupDelete;
     group.ProfilChanged += OnProfilChange;
     group.Margin         = new Thickness(5, 10, 10, 20);
     this.MainPanel.Children.Add(group);
 }
Exemple #3
0
        private void AddDefaultGroup(List <Object> items)
        {
            RightsGroup group1 = new RightsGroup(this.ObjectType);

            group1.ProfilComboBox.ItemsSource = items;
            group1.IsExpanded = true;
            this.AddGroup(group1);
        }
Exemple #4
0
 public bool IsDuplicateProfil(RightsGroup group)
 {
     foreach (UIElement elt in this.MainPanel.Children)
     {
         if (elt is RightsGroup && elt != group)
         {
             Object item = ((RightsGroup)elt).ProfilComboBox.SelectedItem;
             if (item != null && item.Equals(group.ProfilComboBox.SelectedItem))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #5
0
        public void TryToAddDefaultGroup()
        {
            int count = this.MainPanel.Children.Count;

            if (count > 0)
            {
                UIElement elt = this.MainPanel.Children[count - 1];
                if (elt is RightsGroup)
                {
                    RightsGroup group = (RightsGroup)elt;
                    if (group.ProfilComboBox.SelectedItem != null)
                    {
                        AddDefaultGroup(GetProfilsAndUsers());
                    }
                }
            }
        }
Exemple #6
0
 private bool OnProfilChange(object item)
 {
     if (item != null && item is RightsGroup)
     {
         RightsGroup group     = (RightsGroup)item;
         bool        duplicate = IsDuplicateProfil(group);
         if (!duplicate)
         {
             if (this.EditedObject != null)
             {
                 Object elt      = group.ProfilComboBox.SelectedItem;
                 bool   isProfil = elt != null && elt is Domain.Profil;
                 foreach (Right right in group.GetCheckRights())
                 {
                     if (isProfil)
                     {
                         right.profil = (Domain.Profil)elt;
                     }
                     else
                     {
                         right.user = (Domain.User)elt;
                     }
                     this.EditedObject.rightsListChangeHandler.AddUpdated(right);
                 }
             }
             OnChange();
             TryToAddDefaultGroup();
         }
         else
         {
             Object elt        = group.ProfilComboBox.SelectedItem;
             bool   isProfil   = elt is Domain.Profil;
             string profilText = elt is Domain.Profil ? "Profil":"User";
             MessageDisplayer.DisplayWarning("Duplicate " + profilText, "Another group with " + profilText + " '" + group.ProfilComboBox.SelectedItem + "' already exits!");
         }
         return(!duplicate);
     }
     return(true);
 }
Exemple #7
0
        public void Display()
        {
            this.MainPanel.Children.Clear();
            if (this.EditedObject != null)
            {
                if (this.EditedObject.rightsListChangeHandler == null)
                {
                    this.EditedObject.rightsListChangeHandler = new PersistentListChangeHandler <Right>();
                }

                List <Object> items = GetProfilsAndUsers();
                Dictionary <String, RightsGroup> map = new Dictionary <String, RightsGroup>(0);
                foreach (Right right in this.EditedObject.rightsListChangeHandler.Items)
                {
                    Persistent profilOrUser = right.profil;
                    if (profilOrUser == null)
                    {
                        profilOrUser = right.user;
                    }
                    string name = right.profil != null ? "P-" + right.profil.name : right.user != null ? "U-" + right.user.name : null;
                    if (!map.ContainsKey(name))
                    {
                        RightsGroup group1 = new RightsGroup(right.objectType);
                        group1.ProfilComboBox.ItemsSource  = items;
                        group1.ProfilComboBox.SelectedItem = profilOrUser;
                        map.Add(name, group1);
                        this.AddGroup(group1);
                    }
                    RightsGroup group = null;
                    if (map.TryGetValue(name, out group))
                    {
                        group.Select(right);
                    }
                }
                AddDefaultGroup(items);
            }
        }
Exemple #8
0
 private void OnGroupDelete(object item)
 {
     if (item != null && item is RightsGroup)
     {
         RightsGroup group = (RightsGroup)item;
         if (this.EditedObject != null)
         {
             foreach (Right right in group.GetCheckRights())
             {
                 if (right.oid.HasValue)
                 {
                     this.EditedObject.rightsListChangeHandler.AddDeleted(right);
                 }
                 else
                 {
                     this.EditedObject.rightsListChangeHandler.forget(right);
                 }
             }
         }
         RemoveGroup(group);
     }
     OnChange();
     TryToAddDefaultGroup();
 }