private void OnOutdentClick(object sender, RoutedEventArgs e)
        {
            List <Domain.Attribute> attributes = GetSelectedValues();

            if (attributes.Count == 0)
            {
                return;
            }
            attributes.BubbleSort();
            foreach (Domain.Attribute attribute in attributes)
            {
                Domain.Attribute parent = attribute.parent;
                if (parent == null)
                {
                    parent = this.Root;
                }
                Domain.Attribute grandParent = parent.parent;
                if (grandParent == null)
                {
                    return;
                }

                ForgetDefaultAttributes(grandParent);
                parent.ForgetChild(attribute);
                parent.related = parent.childrenListChangeHandler.Items.Count > 0;
                grandParent.AddChild(attribute);
                grandParent.related = true;
                parent.IsExpanded   = true;

                int row = Source.IndexOf(grandParent);
                if (row >= 0)
                {
                    Source.Remove(grandParent);
                    Source.Insert(row, grandParent);
                }
                else
                {
                    row = Source.Count;
                    Source.Remove(attribute);
                    if (row - 2 >= 0)
                    {
                        Source.Insert(row - 2, attribute);
                    }
                    else
                    {
                        Source.Add(attribute);
                    }
                }
                AddDefaultAttributes(grandParent);
            }
            treeList.RefreshData();
            treeList.SelectedItems = attributes;
            if (Changed != null)
            {
                Changed();
            }
        }
        private void OnDeleteClick(object sender, RoutedEventArgs e)
        {
            List <Domain.Attribute> attributes = GetSelectedValues();

            if (attributes.Count == 0)
            {
                return;
            }
            String message = "Do you want to delete Attribute: '" + attributes[0] + "' ?";

            if (attributes.Count > 1)
            {
                message = "Do you want to delete the " + attributes.Count + " selected attributes ?";
            }
            MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete Attribute", message);

            if (result == MessageBoxResult.Yes)
            {
                foreach (Domain.Attribute attribute in attributes)
                {
                    if (IsUsedToGenerateUniverse(attribute))
                    {
                        return;
                    }
                    Domain.Attribute parent = attribute.parent;

                    ForgetDefaultAttributes(parent);
                    if (attribute.oid.HasValue)
                    {
                        parent.RemoveChild(attribute);
                    }
                    else
                    {
                        parent.ForgetChild(attribute);
                    }
                    parent.related = parent.childrenListChangeHandler.Items.Count > 0;
                    AddDefaultAttributes(parent);
                    removeFromSource(attribute);
                }
                if (Changed != null)
                {
                    Changed();
                }
            }
        }
        private void OnIndentClick(object sender, RoutedEventArgs e)
        {
            List <Domain.Attribute> attributes = GetSelectedValues();

            if (attributes.Count == 0)
            {
                return;
            }
            attributes.BubbleSort();
            foreach (Domain.Attribute attribute in attributes)
            {
                Domain.Attribute parent = attribute.parent;
                if (parent == null)
                {
                    parent = this.Root;
                }
                int position             = attribute.GetPosition();
                Domain.Attribute brother = (Domain.Attribute)parent.GetChildByPosition(position - 1);
                if (brother == null)
                {
                    return;
                }
                ForgetDefaultAttributes(parent);
                parent.ForgetChild(attribute);
                brother.AddChild(attribute);
                brother.related    = true;
                brother.IsExpanded = true;

                int row = Source.IndexOf(brother);
                Source.Remove(brother);
                Source.Insert(row, brother);
                AddDefaultAttributes(parent);
            }
            treeList.RefreshData();
            treeList.SelectedItems = attributes;
            if (Changed != null)
            {
                Changed();
            }
        }