Пример #1
0
        public void ProcessEditEntity(EntityDTO entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var databaseID = new ProjectTreeHelper().GetFirstAncestorID <DatabaseDTO>();

            if (databaseID == Guid.Empty)
            {
                throw new InvalidOperationException("No database selected.");
            }

            var view = new EntityDetailsView();

            view.Object = entity;

            var popup = new PopupWindow();

            popup.Title    = "Edit Entity";
            popup.Validate = () => { return(new Validator().Validate(entity)); };
            popup.ViewPanel.Children.Add(view);

            if (popup.ShowDialog() == true)
            {
                new ObjectDataSource().SaveObject(entity);
                // Do not refresh node, since can be called from RelationDetailsView
            }
        }
Пример #2
0
        public EntityDTO ProcessCreateNewEntity()
        {
            var databaseID = new ProjectTreeHelper().GetFirstAncestorID <DatabaseDTO>();

            if (databaseID == Guid.Empty)
            {
                throw new InvalidOperationException("No database selected.");
            }
            var newEntity = new EntityDTO()
            {
                EntityName = "<Enter name>", SchemaName = "dbo", DatabaseID = databaseID
            };

            var view = new EntityDetailsView();

            view.Object = newEntity;

            var popup = new PopupWindow();

            popup.Title    = "New Entity";
            popup.Validate = () => { return(new Validator().Validate(newEntity)); };
            popup.ViewPanel.Children.Add(view);

            if (popup.ShowDialog() != true)
            {
                return(null);
            }

            new ObjectDataSource().SaveObject(newEntity);
            ServiceLocator serviceLocator = ServiceLocator.GetActive();

            serviceLocator.BasicController.ProcessProjectTreeRefresh();
            return(newEntity);
        }
Пример #3
0
        public void ProcessEditDiagramObject(PersistentObjectDTO obj)
        {
            UIElement view             = null;
            var       persistentObject = obj as PersistentObjectDTO;

            if (persistentObject != null)
            {
                if (persistentObject.PersistentType == typeof(Entity))
                {
                    view = new EntityDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(Diagram))
                {
                    view = new DiagramDetailsView();
                }

                if (view != null)
                {
                    ((IDetailsView)view).Object = persistentObject;
                }
            }

            if (view != null)
            {
                var popup = new PopupWindow();
                popup.Title    = "Edit " + persistentObject.PersistentType.Name;
                popup.Validate = () => { return(new Validator().Validate(persistentObject)); };
                popup.ViewPanel.Children.Add(view);

                if (popup.ShowDialog() == true)
                {
                    new ObjectDataSource().SaveObject(obj);
                    ServiceLocator serviceLocator = ServiceLocator.GetActive();
                    serviceLocator.BasicController.ProcessProjectTreeRefresh();
                }
            }
        }
Пример #4
0
        public void ProcessShowProjectTreeNodeDetails()
        {
            var serviceLocator = ServiceLocator.GetActive();

            serviceLocator.SessionState.ValidationErrors.Clear();
            serviceLocator.SessionState.ObjectInEditor = null;

            var node = new ProjectTreeHelper().GetCurrentNode();

            if (node == null)
            {
                serviceLocator.SessionState.DetailsPanel.Children.Clear();
                serviceLocator.SessionState.DetailsView = null;
                return;
            }

            IDetailsView view             = null;
            var          persistentObject = node.Object as PersistentObjectDTO;

            if (persistentObject != null)
            {
                if (persistentObject.PersistentType == typeof(Entity))
                {
                    view = new EntityDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(Project))
                {
                    view = new ProjectDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(Database))
                {
                    view = new DatabaseDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(ERModel.Attribute))
                {
                    view = new AttributeDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(DataType))
                {
                    view = new DataTypeDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(Relation))
                {
                    view = new RelationDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(RelationItem))
                {
                    view = new RelationItemDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(Diagram))
                {
                    view = new DiagramChartView();
                }
                else if (persistentObject.PersistentType == typeof(DiagramEntity))
                {
                    view = new DiagramEntityDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(BaseEnum))
                {
                    view = new BaseEnumDetailsView();
                }
                else if (persistentObject.PersistentType == typeof(BaseEnumValue))
                {
                    view = new BaseEnumValueDetailsView();
                }

                if (view != null)
                {
                    view.Object = persistentObject;
                }
            }

            serviceLocator.SessionState.DetailsPanel.Children.Clear();
            serviceLocator.SessionState.DetailsView    = view;
            serviceLocator.SessionState.ObjectInEditor = persistentObject;

            if (view != null)
            {
                serviceLocator.SessionState.DetailsPanel.Children.Add(view as UIElement);
            }
        }