void emptyChild_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedParent = null;
            SelectedChild = null;

            List<Entity> unavailableEntities = new List<Entity>();
            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select child entity", false, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Child);
            form.ShowDialog();

            if (form.SelectedEntity != null)
            {
                Entity.AddChild(form.SelectedEntity);
                Populate();
            }
        }
示例#2
0
        void emptyParent_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select or create parent entity", false, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Parent);
            form.ShowDialog();

            if (form.SelectedEntity != null)
            {
                Entity.Parent = form.SelectedEntity;
                Populate();
            }
        }
        private void ShowSelectParent(bool onlyCreateAbstractParent)
        {
            SelectedParent = null;
            SelectedChild = null;

            List<Entity> unavailableEntities = new List<Entity>();
            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance.RequestorTypes requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Parent;

            if (onlyCreateAbstractParent)
                requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Create_Abstract_Parent;

            EntityImpl originalEntity = Entity;
            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select or create parent entity", false, requestType);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            Entity = originalEntity;

            if (form.SelectedEntity != null)
            {
                Entity.Parent = form.SelectedEntity;
                form.SelectedEntity.AddChild(Entity);

                foreach (var directedReference in Entity.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity.Parent)
                    {
                        Entity.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                foreach (var directedReference in Entity.Parent.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity)
                    {
                        Entity.Parent.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                // Remove the ID property from the child entity because it should share the parent entity's ID instead
                if (!form.SelectedEntity.IsAbstract)
                    for (int i = Entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                        Entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;

                Populate();
                this.Refresh();
                RaiseInheritanceUpdatedEvent();
            }
            form.EntityDeleted -= form_EntityDeleted;
            Populate();
        }
        void emptyChild_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != System.Windows.Forms.MouseButtons.Left)
                return;

            EntityImpl.InheritanceType inheritanceTypeWithChildren = EntityImpl.DetermineInheritanceTypeWithChildren(Entity);

            if (inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)
            {
                ShowHierarchyEditor();
                return;
            }
            //if ((Entity.Children.Count > 0 && inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerSubClass) ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerConcreteClass ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)// ||
            //{
            SelectedParent = null;
            SelectedChild = null;

            List<Entity> unavailableEntities = new List<Entity>();
            unavailableEntities.AddRange(Entity.Children);

            if (Entity.Parent != null)
                unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select child entities", true, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Child);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            if (form.SelectedEntities != null && form.SelectedEntities.Count > 0)
            {
                foreach (var entity in form.SelectedEntities)
                {
                    Entity.AddChild(entity);
                    entity.Parent = Entity;

                    foreach (var directedReference in Entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == entity)
                        {
                            Entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    foreach (var directedReference in entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == Entity)
                        {
                            entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    // Remove the ID property from the child entity because it should share the parent entity's ID instead
                    for (int i = entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                    {
                        if (Entity.IsAbstract)
                            entity.Key.Properties.ElementAt(i).IsHiddenByAbstractParent = true;
                        else
                            entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;
                    }
                    if (Entity.IsAbstract)
                    {
                        foreach (Property parentProp in Entity.Properties)
                        {
                            Property childProp = entity.ConcreteProperties.SingleOrDefault(p => p.Name == parentProp.Name);

                            if (childProp != null)
                                childProp.IsHiddenByAbstractParent = true;
                        }
                    }
                }
                form.EntityDeleted -= form_EntityDeleted;
                Populate();

                RaiseInheritanceUpdatedEvent();
            }
            //}
            //else if (!HasOneToOne)
            //{
            //UserControls.FormInheritanceHierarchy form = new UserControls.FormInheritanceHierarchy(Entity);
            //form.ShowDialog(this);
            //}
        }
示例#5
0
        private void ShowSelectParent(bool onlyCreateAbstractParent)
        {
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance.RequestorTypes requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Parent;

            if (onlyCreateAbstractParent)
            {
                requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Create_Abstract_Parent;
            }

            EntityImpl originalEntity = Entity;

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select or create parent entity", false, requestType);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            Entity = originalEntity;

            if (form.SelectedEntity != null)
            {
                Entity.Parent = form.SelectedEntity;
                form.SelectedEntity.AddChild(Entity);

                foreach (var directedReference in Entity.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity.Parent)
                    {
                        Entity.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                foreach (var directedReference in Entity.Parent.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity)
                    {
                        Entity.Parent.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                // Remove the ID property from the child entity because it should share the parent entity's ID instead
                if (!form.SelectedEntity.IsAbstract)
                {
                    for (int i = Entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                    {
                        Entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;
                    }
                }

                Populate();
                this.Refresh();
                RaiseInheritanceUpdatedEvent();
            }
            form.EntityDeleted -= form_EntityDeleted;
            Populate();
        }
示例#6
0
        void emptyChild_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            EntityImpl.InheritanceType inheritanceTypeWithChildren = EntityImpl.DetermineInheritanceTypeWithChildren(Entity);

            if (inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)
            {
                ShowHierarchyEditor();
                return;
            }
            //if ((Entity.Children.Count > 0 && inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerSubClass) ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerConcreteClass ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)// ||
            //{
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);

            if (Entity.Parent != null)
            {
                unavailableEntities.Add(Entity.Parent);
            }

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select child entities", true, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Child);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            if (form.SelectedEntities != null && form.SelectedEntities.Count > 0)
            {
                foreach (var entity in form.SelectedEntities)
                {
                    Entity.AddChild(entity);
                    entity.Parent = Entity;

                    foreach (var directedReference in Entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == entity)
                        {
                            Entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    foreach (var directedReference in entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == Entity)
                        {
                            entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    // Remove the ID property from the child entity because it should share the parent entity's ID instead
                    for (int i = entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                    {
                        if (Entity.IsAbstract)
                        {
                            entity.Key.Properties.ElementAt(i).IsHiddenByAbstractParent = true;
                        }
                        else
                        {
                            entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;
                        }
                    }
                    if (Entity.IsAbstract)
                    {
                        foreach (Property parentProp in Entity.Properties)
                        {
                            Property childProp = entity.ConcreteProperties.SingleOrDefault(p => p.Name == parentProp.Name);

                            if (childProp != null)
                            {
                                childProp.IsHiddenByAbstractParent = true;
                            }
                        }
                    }
                }
                form.EntityDeleted -= form_EntityDeleted;
                Populate();

                RaiseInheritanceUpdatedEvent();
            }
            //}
            //else if (!HasOneToOne)
            //{
            //UserControls.FormInheritanceHierarchy form = new UserControls.FormInheritanceHierarchy(Entity);
            //form.ShowDialog(this);
            //}
        }