private static void TablePropertyChanged(object sender, ElementPropertyChangedEventArgs e)
        {
            // Transitions:
            // Name changed, CustomName set->update schema customization
            // CustomName changed: add or remove customization
            ModelElement        element = e.ModelElement;
            Table               table   = null;
            Schema              schema;
            SchemaCustomization customization;
            string              updatedName = null;
            bool customNameChanged          = false;

            if (!element.IsDeleted)
            {
                Guid propertyId = e.DomainProperty.Id;
                if (propertyId == Table.NameDomainPropertyId)
                {
                    table = (Table)element;
                    if (table.CustomName)
                    {
                        updatedName       = table.Name;
                        customNameChanged = true;
                    }
                }
                else if (propertyId == Table.CustomNameDomainPropertyId)
                {
                    table = (Table)element;
                    if (table.CustomName)
                    {
                        updatedName = table.Name;
                    }
                    customNameChanged = true;
                }
                else if (propertyId == Table.ColumnOrderDomainPropertyId)
                {
                    table = (Table)element;
                    bool isCustom = (ColumnOrdering)e.NewValue == ColumnOrdering.Custom;
                    if ((isCustom ^ ((ColumnOrdering)e.OldValue == ColumnOrdering.Custom)) &&
                        null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        // UNDONE: Consider batching this into an 'element events ended'
                        customization.CustomizeColumnPositions(table, isCustom);
                    }
                }
                if (customNameChanged &&
                    null != (schema = table.Schema) &&
                    null != (customization = SchemaCustomization.GetCustomization(schema)))
                {
                    customization.CustomizeTableName(table, updatedName);
                }
            }
        }
Beispiel #2
0
 private static void DelayValidateCustomizeColumnPositions(ModelElement element)
 {
     if (!element.IsDeleted)
     {
         Table  table = (Table)element;
         Schema schema;
         SchemaCustomization customization;
         if (null != (schema = table.Schema) &&
             null != (customization = SchemaCustomization.GetCustomization(schema)))
         {
             customization.CustomizeColumnPositions(table, table.ColumnOrder == ColumnOrdering.Custom);
         }
     }
 }
        private static void ColumnOrderChanged(object sender, RolePlayerOrderChangedEventArgs e)
        {
            ModelElement element = e.SourceElement;

            if (!element.IsDeleted)
            {
                Table  table = (Table)element;
                Schema schema;
                SchemaCustomization customization;
                if (table.ColumnOrder == ColumnOrdering.Custom &&
                    null != (schema = table.Schema) &&
                    null != (customization = SchemaCustomization.GetCustomization(schema)))
                {
                    // UNDONE: Consider batching this into an 'element events ended'
                    customization.CustomizeColumnPositions(table, true);
                }
            }
        }
        private static void ColumnPropertyChanged(object sender, ElementPropertyChangedEventArgs e)
        {
            // Transitions:
            // Name changed, CustomName set->update schema customization
            // CustomName changed: add or remove customization
            ModelElement element = e.ModelElement;

            if (!element.IsDeleted)
            {
                Column column = null;
                Table  table;
                Schema schema;
                SchemaCustomization customization;
                string updatedName       = null;
                bool   customNameChanged = false;
                Guid   propertyId        = e.DomainProperty.Id;
                if (propertyId == Column.NameDomainPropertyId)
                {
                    column = (Column)element;
                    if (column.CustomName)
                    {
                        updatedName       = column.Name;
                        customNameChanged = true;
                    }
                }
                else if (propertyId == Column.CustomNameDomainPropertyId)
                {
                    column = (Column)element;
                    if (column.CustomName)
                    {
                        updatedName = column.Name;
                    }
                    customNameChanged = true;
                }
                if (customNameChanged &&
                    null != (table = column.Table) &&
                    null != (schema = table.Schema) &&
                    null != (customization = SchemaCustomization.GetCustomization(schema)))
                {
                    customization.CustomizeColumnName(column, updatedName);
                }
            }
        }
Beispiel #5
0
            /// <summary>
            /// ChangeRule: typeof(ORMSolutions.ORMArchitect.RelationalModels.ConceptualDatabase.Table)
            /// </summary>
            private static void TableChangedRule(ElementPropertyChangedEventArgs e)
            {
                Guid   propertyId = e.DomainProperty.Id;
                Table  table;
                Schema schema;
                SchemaCustomization customization;

                if (propertyId == Table.CustomNameDomainPropertyId)
                {
                    table = (Table)e.ModelElement;
                    if (null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeTableName(table, (bool)e.NewValue ? table.Name : null);
                        ValidateSchemaNamesChanged(schema);
                    }
                }
                else if (propertyId == Table.NameDomainPropertyId)
                {
                    table = (Table)e.ModelElement;
                    if (table.CustomName &&
                        null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeTableName(table, (string)e.NewValue);
                        ValidateSchemaNamesChanged(schema);
                    }
                }
                else if (propertyId == Table.ColumnOrderDomainPropertyId)
                {
                    table = (Table)e.ModelElement;
                    if (null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        if (((ColumnOrdering)e.NewValue == ColumnOrdering.Custom) ^ ((ColumnOrdering)e.OldValue == ColumnOrdering.Custom))
                        {
                            FrameworkDomainModel.DelayValidateElement(table, DelayValidateCustomizeColumnPositions);
                        }
                        ValidateSchemaNamesChanged(schema);
                    }
                }
            }
Beispiel #6
0
            /// <summary>
            /// ChangeRule: typeof(ORMSolutions.ORMArchitect.RelationalModels.ConceptualDatabase.Column)
            /// </summary>
            private static void ColumnChangedRule(ElementPropertyChangedEventArgs e)
            {
                Guid   propertyId = e.DomainProperty.Id;
                Column column;
                Table  table;
                Schema schema;
                SchemaCustomization customization;

                if (propertyId == Column.IsNullableDomainPropertyId)
                {
                    column = (Column)e.ModelElement;
                    if (null != (table = column.Table) &&
                        table.ColumnOrder != ColumnOrdering.Custom)
                    {
                        ValidateTableNameChanged(table);
                    }
                }
                else if (propertyId == Column.CustomNameDomainPropertyId)
                {
                    column = (Column)e.ModelElement;
                    if (null != (table = column.Table) &&
                        null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeColumnName(column, (bool)e.NewValue ? column.Name : null);
                        ValidateSchemaNamesChanged(schema);
                    }
                }
                else if (propertyId == Column.NameDomainPropertyId)
                {
                    column = (Column)e.ModelElement;
                    if (column.CustomName &&
                        null != (table = column.Table) &&
                        null != (schema = table.Schema) &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeColumnName(column, (string)e.NewValue);
                        ValidateSchemaNamesChanged(schema);
                    }
                }
            }
        private static void SchemaPropertyChanged(object sender, ElementPropertyChangedEventArgs e)
        {
            // Transitions:
            // Name changed, CustomName set->update schema customization
            // CustomName changed: add or remove customization
            ModelElement element = e.ModelElement;

            if (!element.IsDeleted)
            {
                Schema schema = null;
                SchemaCustomization customization;
                string updatedName       = null;
                bool   customNameChanged = false;
                Guid   propertyId        = e.DomainProperty.Id;
                if (propertyId == Schema.NameDomainPropertyId)
                {
                    schema = (Schema)element;
                    if (schema.CustomName)
                    {
                        updatedName       = schema.Name;
                        customNameChanged = true;
                    }
                }
                else if (propertyId == Schema.CustomNameDomainPropertyId)
                {
                    schema = (Schema)element;
                    if (schema.CustomName)
                    {
                        updatedName = schema.Name;
                    }
                    customNameChanged = true;
                }
                if (customNameChanged &&
                    null != (customization = SchemaCustomization.GetCustomization(schema)))
                {
                    customization.CustomizeSchemaName(schema, updatedName);
                }
            }
        }
Beispiel #8
0
            /// <summary>
            /// ChangeRule: typeof(ORMSolutions.ORMArchitect.RelationalModels.ConceptualDatabase.Schema)
            /// </summary>
            private static void SchemaChangedRule(ElementPropertyChangedEventArgs e)
            {
                Guid   propertyId = e.DomainProperty.Id;
                Schema schema;
                SchemaCustomization customization;

                if (propertyId == Schema.DefaultColumnOrderDomainPropertyId)
                {
                    // Note that this does not affect custom ordering, so there is nothing to
                    // record in the schema customizations
                    ValidateSchemaNamesChanged((Schema)e.ModelElement);
                }
                else if (propertyId == Schema.CustomNameDomainPropertyId)
                {
                    schema = (Schema)e.ModelElement;
                    if (null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeSchemaName(schema, (bool)e.NewValue ? schema.Name : null);
                        // Don't use the full ValidateSchemaNamesChanged, which rebuilds the customization
                        // object and regenerates all names.
                        FrameworkDomainModel.DelayValidateElement(schema, DelayValidateSchemaNameChanged);
                    }
                }
                else if (propertyId == Schema.NameDomainPropertyId)
                {
                    schema = (Schema)e.ModelElement;
                    if (schema.CustomName &&
                        null != (customization = SchemaCustomization.GetCustomization(schema)))
                    {
                        customization.CustomizeSchemaName(schema, (string)e.NewValue);
                        // Don't use the full ValidateSchemaNamesChanged, which rebuilds the customization
                        // object and regenerates all names.
                        FrameworkDomainModel.DelayValidateElement(schema, DelayValidateSchemaNameChanged);
                    }
                }
            }