/// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            // Get a reference to the model element that is being described.
            ModelEnum modelEnum = ModelElement as ModelEnum;

            //Add the descriptor for the tracking property.
            if (modelEnum != null)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #2
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> so that the <see cref="ORMNotesToolWindow"/>
        /// contents can be updated to reflect any model changes.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            if (Utility.ValidateStore(store) == null)
            {
                return;                 // Bail out
            }
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;

            // Track Note additions and deletions changes
            NoteRoleAndHandler[] owningRelationshipHandlers;
            if (null != (owningRelationshipHandlers = GetOwningRelationshipHandlers(store, action == EventHandlerAction.Add)))
            {
                for (int i = 0; i < owningRelationshipHandlers.Length; ++i)
                {
                    NoteRoleAndHandler handlerInfo          = owningRelationshipHandlers[i];
                    EventHandler <ElementEventArgs> handler = handlerInfo.AddDeleteHandler;
                    DomainClassInfo classInfo = handlerInfo.DomainRole.DomainRelationship;
                    eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(handler), action);
                    eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(handler), action);
                }

                // Track Note.Text changes
                eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(GetNoteTextPropertyId(store)), new EventHandler <ElementPropertyChangedEventArgs>(NoteAlteredEventHandler), action);
            }
        }
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            // Get a reference to the model element that is being described.
            Association association = ModelElement as Association;

            //Add the descriptor for the tracking property.
            if (association != null)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo collectionClassPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId);
                DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] collectionClassAttributes =
                {
                    new DisplayNameAttribute("Collection Class"),
                    new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #4
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="ORMBaseShape"/>s.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        public static void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;
            DomainPropertyInfo  propertyInfo  = dataDirectory.FindDomainProperty(ORMBaseBinaryLinkShape.UpdateCounterDomainPropertyId);

            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(UpdateRequiredEvent), action);
        }
 private Dictionary <Type, Type> ParseList(string list, Dictionary <Type, Type> cache)
 {
     if (list.Length != 0)
     {
         Dictionary <Type, Type> retVal = cache;
         if (retVal == null)
         {
             retVal = new Dictionary <Type, Type>();
         }
         if (retVal.Count == 0)
         {
             //synchronize the cache with the string
             DomainDataDirectory dataDir   = Store.DomainDataDirectory;
             string[]            typeNames = list.Split(new char[] { ListDelimiter }, StringSplitOptions.RemoveEmptyEntries);
             int typeCount = typeNames.Length;
             for (int i = 0; i < typeCount; ++i)
             {
                 DomainClassInfo classInfo;
                 if (null != (classInfo = dataDir.FindDomainClass(typeNames[i])))
                 {
                     retVal.Add(classInfo.ImplementationClass, null);
                 }
             }
         }
         return(retVal);
     }
     return(cache);
 }
        private static Dictionary <DomainClassInfo, object> BuildCustomSerializationOmissions(Store store)
        {
            Dictionary <DomainClassInfo, object> retVal = new Dictionary <DomainClassInfo, object>();
            DomainDataDirectory dataDir = store.DomainDataDirectory;

            retVal[dataDir.FindDomainRelationship(ExcludedORMModelElement.DomainClassId)] = null;
            return(retVal);
        }
        /// <summary>
        /// Manage events associated with the schema customization state.
        /// The primary function of schema customization is to reassociate
        /// schema customizations when a schema is deleted and recreated.
        /// Therefore, the data is maintained outside the transacted store
        /// and must be updated with events to remain consistent across
        /// undo and redo operations.
        /// </summary>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> to attach
        /// to. The assumption is that this is called for state change events on document
        /// loaded.</param>
        /// <param name="store">The <see cref="Store"/> used to retrieve type information.</param>
        /// <param name="action">The action to take (add or remove the handler)</param>
        public static void ManageModelingEventHandlers(ModelingEventManager eventManager, Store store, EventHandlerAction action)
        {
            DomainDataDirectory dataDir = store.DomainDataDirectory;

            eventManager.AddOrRemoveHandler(dataDir.FindDomainClass(Column.DomainClassId), new EventHandler <ElementPropertyChangedEventArgs>(ColumnPropertyChanged), action);
            eventManager.AddOrRemoveHandler(dataDir.FindDomainClass(Table.DomainClassId), new EventHandler <ElementPropertyChangedEventArgs>(TablePropertyChanged), action);
            eventManager.AddOrRemoveHandler(dataDir.FindDomainClass(Schema.DomainClassId), new EventHandler <ElementPropertyChangedEventArgs>(SchemaPropertyChanged), action);
            eventManager.AddOrRemoveHandler(dataDir.FindDomainRole(TableContainsColumn.ColumnDomainRoleId), new EventHandler <RolePlayerOrderChangedEventArgs>(ColumnOrderChanged), action);
        }
		private static Dictionary<DomainClassInfo, object> BuildCustomSerializationOmissions(Store store)
		{
			Dictionary<DomainClassInfo, object> retVal = new Dictionary<DomainClassInfo, object>();
			DomainDataDirectory dataDir = store.DomainDataDirectory;
			retVal[dataDir.FindDomainRelationship(ParentShapeContainsNestedChildShapes.DomainClassId)] = null;
			retVal[dataDir.FindDomainRelationship(PresentationViewsSubject.DomainClassId)] = null;
			retVal[dataDir.FindDomainClass(BarkerEntityShape.DomainClassId)] = null;
			return retVal;
		}
Пример #9
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="ORMBaseShape"/>s.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        public static void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;
            DomainClassInfo     classInfo     = dataDirectory.FindDomainClass(ORMBaseShape.DomainClassId);
            DomainPropertyInfo  propertyInfo  = dataDirectory.FindDomainProperty(UpdateCounterDomainPropertyId);

            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(UpdateRequiredEvent), action);
            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(ShapeAddedEvent), action);
            classInfo = dataDirectory.FindDomainClass(PresentationViewsSubject.DomainClassId);
            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(ShapeDeletedEvent), action);
        }
Пример #10
0
 void IORMModelErrorActivationService.RegisterErrorActivator(Type elementType, bool registerDerivedTypes, ORMModelErrorActivator activator)
 {
     if (registerDerivedTypes)
     {
         DomainDataDirectory dataDirectory = myStore.DomainDataDirectory;
         RegisterErrorActivator(elementType.IsSubclassOf(typeof(ElementLink)) ? dataDirectory.GetDomainRelationship(elementType) : dataDirectory.GetDomainClass(elementType), activator);
     }
     else
     {
         myActivators[elementType] = activator;
     }
 }
Пример #11
0
        /// <summary>
        /// Gets the target proto role player.
        /// </summary>
        /// <param name="partition">Partition.</param>
        /// <returns>Target proto role player.</returns>
        public ModelProtoRolePlayer GetTargetRolePlayer(Partition partition)
        {
            DomainDataDirectory  domainDataDirectory = partition.Store.DomainDataDirectory;
            ModelProtoRolePlayer protoRolePlayer     = rolePlayers[1];
            DomainRoleInfo       domainRoleInfo      = domainDataDirectory.GetDomainRole(protoRolePlayer.DomainRoleId);

            if (domainRoleInfo.IsSource)
            {
                protoRolePlayer = rolePlayers[0];
            }
            return(protoRolePlayer);
        }
Пример #12
0
 private static Guid[] myNoteTextPropertyId;         // Defined as an array so we can statically initialize without locking
 private Guid GetNoteTextPropertyId(Store store)
 {
     Guid[] propertyId = myNoteTextPropertyId;
     if (propertyId == null)
     {
         DomainDataDirectory dataDirectory = store.DomainDataDirectory;
         propertyId = new Guid[] { store.DomainDataDirectory.GetDomainClass(typeof(NoteType)).FindDomainProperty("Text", false).Id };
         System.Threading.Interlocked.CompareExchange <Guid[]>(ref myNoteTextPropertyId, propertyId, null);
         propertyId = myNoteTextPropertyId;
     }
     return(propertyId[0]);
 }
Пример #13
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is Association association)
            {
                storeDomainDataDirectory = association.Store.DomainDataDirectory;

                // only display roles for 1..1 and 0-1..0-1 associations
                if (((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) &&
                     (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne)))
                {
                    PropertyDescriptor sourceRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceRole");
                    propertyDescriptors.Remove(sourceRoleTypeDescriptor);

                    PropertyDescriptor targetRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetRole");
                    propertyDescriptors.Remove(targetRoleTypeDescriptor);
                }

                // only display delete behavior on the principal end
                if (association.SourceRole != EndpointRole.Principal)
                {
                    PropertyDescriptor sourceDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceDeleteAction");
                    propertyDescriptors.Remove(sourceDeleteActionTypeDescriptor);
                }

                if (association.TargetRole != EndpointRole.Principal)
                {
                    PropertyDescriptor targetDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetDeleteAction");
                    propertyDescriptors.Remove(targetDeleteActionTypeDescriptor);
                }

                /********************************************************************************/

                DomainPropertyInfo collectionClassPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId);
                DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] collectionClassAttributes =
                {
                    new DisplayNameAttribute("Collection Class"),
                    new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #14
0
 void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action)
 {
     if (0 != (reasons & EventSubscriberReasons.SurveyQuestionEvents))
     {
         Store store = Store;
         DomainDataDirectory dataDirectory = store.DomainDataDirectory;
         DomainClassInfo     classInfo     = dataDirectory.FindDomainClass(Diagram.DomainClassId);
         eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(DiagramAddedEvent), action);
         eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(DiagramRemovedEvent), action);
         DomainPropertyInfo propertyInfo = dataDirectory.FindDomainProperty(Diagram.NameDomainPropertyId);
         eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(DiagramRenamedEvent), action);
     }
 }
Пример #15
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelClass modelClass)
            {
                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelClass);

                storeDomainDataDirectory = modelClass.Store.DomainDataDirectory;



                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.DatabaseSchemaDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDatabaseSchemaTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Database Schema")
                    , new DescriptionAttribute("The schema to use for table creation. Overrides default schema for model if present.")
                    , new CategoryAttribute("Database")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.NamespaceDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsNamespaceTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Namespace")
                    , new DescriptionAttribute("Overrides default namespace")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.OutputDirectoryDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelClass.IsOutputDirectoryTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Output Directory")
                    , new DescriptionAttribute("Overrides default output directory")
                    , new CategoryAttribute("Code Generation")
                    , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #16
0
        /// <summary>
        /// Iterates through the domain and finds the specific name usage using it's <see cref="NameUsageIdentifierAttribute"/>
        /// </summary>
        /// <param name="store"></param>
        /// <param name="identifier">String representing the <see cref="NameUsageIdentifierAttribute"/> of the desired NameUsage</param>
        /// <returns></returns>
        public static DomainClassInfo TranslateFromNameUsageIdentifier(Store store, string identifier)
        {
            DomainDataDirectory dataDir   = store.DomainDataDirectory;
            DomainClassInfo     classInfo = dataDir.FindDomainClass(NameUsage.DomainClassId);
            DomainClassInfo     retVal    = null;

            string[] identifierPieces = identifier.Split(new char[] { '.', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < identifierPieces.Length; ++i)
            {
                IList <DomainClassInfo> childInfos = classInfo.LocalDescendants;
                int count = childInfos.Count;
                int j     = 0;

                string identifierPiece = identifierPieces[i];


                for (; j < count; ++j)
                {
                    bool match = false;

                    DomainClassInfo childInfo = childInfos[j];
                    if (childInfo.Name == identifierPiece)
                    {
                        match = true;
                    }
                    else
                    {
                        object[] customAttributes = childInfo.ImplementationClass.GetCustomAttributes(typeof(NameUsageIdentifierAttribute), false);
                        if (customAttributes != null && customAttributes.Length != 0)
                        {
                            match = ((NameUsageIdentifierAttribute)customAttributes[0]).Name == identifierPiece;
                        }
                    }

                    if (match)
                    {
                        classInfo = childInfo;
                        retVal    = classInfo;
                        break;
                    }
                }
                if (j == count)
                {
                    return(null);
                }
            }
            return(retVal);
        }
Пример #17
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="ExternalConstraintShape"/>s.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        public static new void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;

            eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRole(SetComparisonConstraintHasRoleSequence.RoleSequenceDomainRoleId), new EventHandler <RolePlayerOrderChangedEventArgs>(RolePlayerOrderChangedEvent), action);

            eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(SetComparisonConstraint.ModalityDomainPropertyId), new EventHandler <ElementPropertyChangedEventArgs>(SetComparisonConstraintChangedEvent), action);
            eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(SetConstraint.ModalityDomainPropertyId), new EventHandler <ElementPropertyChangedEventArgs>(SetConstraintChangedEvent), action);

            DomainClassInfo classInfo = dataDirectory.FindDomainRelationship(EntityTypeHasPreferredIdentifier.DomainClassId);

            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(PreferredIdentifierAddedEvent), action);
            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(PreferredIdentifierRemovedEvent), action);
            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <RolePlayerChangedEventArgs>(PreferredIdentifierRolePlayerChangedEvent), action);
        }
Пример #18
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="BarkerEntityShape"/>s.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        public static void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;
            DomainPropertyInfo  propertyInfo  = dataDirectory.FindDomainProperty(BarkerEntityShape.UpdateCounterDomainPropertyId);

            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(UpdateShapeEvent), action);

            if (action == EventHandlerAction.Add)
            {
                // We don't want this rule on. This forces a full repopulation of the compartment,
                // which makes it impossible to determine the old index of a selected item. If this is
                // on, then the ColumnRenamedEvent does not work for the initial transaction.
                store.RuleManager.DisableRule(typeof(CompartmentItemChangeRule));
            }
            propertyInfo = dataDirectory.FindDomainProperty(Barker.Attribute.NameDomainPropertyId);
            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(AttributeRenamedEvent), action);
        }
Пример #19
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is ModelEnum modelEnum)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));

                /********************************************************************************/

                DomainPropertyInfo outputDirectoryPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelEnum.OutputDirectoryDomainPropertyId);
                DomainPropertyInfo isOutputDirectoryTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsOutputDirectoryTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] outputDirectoryAttributes =
                {
                    new DisplayNameAttribute("Output Directory"),
                    new DescriptionAttribute("Overrides default output directory"),
                    new CategoryAttribute("Code Generation"),
                    new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum, outputDirectoryPropertyInfo, isOutputDirectoryTrackingPropertyInfo, outputDirectoryAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #20
0
        /// <summary>
        /// Creates a <see cref="PropertyDescriptor"/> for the <see cref="DomainPropertyInfo"/> or
        /// <see cref="DomainRoleInfo"/> with a <see cref="DomainObjectInfo.Id"/> equal to
        /// <paramref name="domainPropertyOrRoleId"/>.
        /// </summary>
        /// <param name="element">
        /// The instance of <see cref="ModelElement"/> containing the property for which a
        /// <see cref="PropertyDescriptor"/> should be created.
        /// </param>
        /// <param name="domainPropertyOrRoleId">
        /// The <see cref="DomainObjectInfo.Id"/> of the <see cref="DomainPropertyInfo"/> or
        /// <see cref="DomainRoleInfo"/> for which a <see cref="PropertyDescriptor"/> should
        /// be created.
        /// </param>
        /// <returns>
        /// A <see cref="PropertyDescriptor"/> for the <see cref="DomainPropertyInfo"/> or
        /// <see cref="DomainRoleInfo"/> with a <see cref="DomainObjectInfo.Id"/> equal to
        /// <paramref name="domainPropertyOrRoleId"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="element"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="DomainDataNotFoundException">
        /// Neither a <see cref="DomainPropertyInfo"/> nor a <see cref="DomainRoleInfo"/>
        /// with a <see cref="DomainObjectInfo.Id"/> equal to
        /// <paramref name="domainPropertyOrRoleId"/> could be found.
        /// </exception>
        public static PropertyDescriptor CreatePropertyDescriptor(ModelElement element, Guid domainPropertyOrRoleId)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            DomainDataDirectory domainDataDirectory = element.Store.DomainDataDirectory;
            DomainPropertyInfo  domainPropertyInfo  = domainDataDirectory.FindDomainProperty(domainPropertyOrRoleId);

            if (domainPropertyInfo != null)
            {
                return(DomainTypeDescriptor.CreatePropertyDescriptor(element, domainPropertyInfo));
            }
            else
            {
                return(DomainTypeDescriptor.CreatePropertyDescriptor(element, domainDataDirectory.GetDomainRole(domainPropertyOrRoleId)));
            }
        }
Пример #21
0
        /// <summary>
        /// Required override. Attach handlers for tracking the current diagram.
        /// </summary>
        protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            store = Utility.ValidateStore(store);
            if (store == null)
            {
                return;
            }
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;
            DomainClassInfo     classInfo     = dataDirectory.FindDomainClass(typeof(Diagram));

            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(DiagramAddedEvent), action);
            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(DiagramRemovedEvent), action);
            eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(Diagram.NameDomainPropertyId), new EventHandler <ElementPropertyChangedEventArgs>(DiagramNameChangedEvent), action);
            eventManager.AddOrRemoveHandler(new EventHandler <ElementEventsEndedEventArgs>(ElementEventsEnded), action);
            myStore             = (action == EventHandlerAction.Add) ? store : null;
            myDiagramSetChanged = true;
            AdjustVisibility(false, false);
        }
Пример #22
0
        /// <summary>
        /// We cannot use anonymous delegates in ManageEventHandlers to respond to add/remove
        /// of relationships because the instance would change each time, making it impossible
        /// to remove the event handler from the watch list on a store. These are built once
        /// for each store, which can theoretically have different sets of note owners from
        /// other stores, depending on the loaded extensions. This finds all embedding relationships
        /// that contain an element of the <typeparamref name="NoteType"/> or any descendants of
        /// this type.
        /// </summary>
        private NoteRoleAndHandler[] GetOwningRelationshipHandlers(Store store, bool forceCreate)
        {
            Dictionary <object, object> storeBag = store.PropertyBag;
            object key = typeof(NoteType);
            object handlersAsObject;

            NoteRoleAndHandler[] handlers;
            if (storeBag.TryGetValue(key, out handlersAsObject) &&
                null != (handlers = handlersAsObject as NoteRoleAndHandler[]))
            {
                return(handlers);
            }
            else if (!forceCreate)
            {
                return(null);
            }
            List <NoteRoleAndHandler>            handlersList = new List <NoteRoleAndHandler>();
            DomainDataDirectory                  dataDir      = store.DomainDataDirectory;
            DomainClassInfo                      classInfo    = dataDir.FindDomainClass(typeof(NoteType));
            ReadOnlyCollection <DomainClassInfo> descendants  = classInfo.AllDescendants;
            int descendantCount = descendants.Count;

            for (int descendantIndex = -1; descendantIndex < descendantCount;)
            {
                foreach (DomainRoleInfo noteRole in classInfo.LocalDomainRolesPlayed)
                {
                    if (noteRole.DomainRelationship.IsEmbedding)
                    {
                        handlersList.Add(new NoteRoleAndHandler(this, noteRole));
                    }
                }
                ++descendantIndex;
                if (descendantIndex == descendantCount)
                {
                    break;
                }
                classInfo = descendants[descendantIndex];
            }
            handlers      = handlersList.ToArray();
            storeBag[key] = handlers;
            return(handlers);
        }
Пример #23
0
 private IEnumerable <ModelElement> ExtractElements(IDataObject data)
 {
     if (data != null)
     {
         if (data.GetDataPresent(typeof(ElementGroupPrototype)))
         {
             ElementGroupPrototype groupPrototype = (ElementGroupPrototype)data.GetData(typeof(ElementGroupPrototype));
             if (groupPrototype != null)
             {
                 IElementDirectory elementDir = Store.ElementDirectory;
                 foreach (ProtoElement proto in groupPrototype.RootProtoElements)
                 {
                     ModelElement element;
                     if (null != (element = elementDir.FindElement(proto.ElementId)))
                     {
                         yield return(element);
                     }
                 }
             }
         }
         else
         {
             Store store = Store;
             DomainDataDirectory dataDirectory = store.DomainDataDirectory;
             foreach (string possibleClassName in data.GetFormats(false))
             {
                 DomainClassInfo classInfo;
                 DomainClassInfo elementClassInfo;
                 ModelElement    element;
                 if (null != (classInfo = dataDirectory.FindDomainClass(possibleClassName)) &&
                     null != (element = data.GetData(possibleClassName) as ModelElement) &&
                     element.Store == store &&
                     ((elementClassInfo = element.GetDomainClass()) == classInfo ||
                      elementClassInfo.IsDerivedFrom(classInfo)))
                 {
                     yield return(element);
                 }
             }
         }
     }
 }
Пример #24
0
        /// <summary>
        /// Implement <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>
        /// </summary>
        protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action)
        {
            if (0 != (reasons & EventSubscriberReasons.DocumentLoaded))
            {
                // Force toolbox refresh on next selection change
                myLastToolboxDiagramType = null;

                // Attach extra properties and events if we're tracking diagram order and position
                Store store = this.Store;
                if (null != store.FindDomainModel(DiagramDisplayDomainModel.DomainModelId))
                {
                    if (0 != (reasons & EventSubscriberReasons.ModelStateEvents))
                    {
                        IPropertyProviderService providerService = ((IFrameworkServices)store).PropertyProviderService;
                        if (providerService != null)
                        {
                            providerService.AddOrRemovePropertyProvider(typeof(Diagram), DiagramDisplay.ProvideDiagramProperties, true, action);
                        }
                    }
                    if (0 != (reasons & EventSubscriberReasons.UserInterfaceEvents))
                    {
                        DomainDataDirectory dataDirectory = store.DomainDataDirectory;
                        DomainClassInfo     classInfo;
                        classInfo = dataDirectory.FindDomainRelationship(DiagramDisplayHasDiagramOrder.DomainClassId);
                        if (classInfo != null)
                        {
                            // DiagramDisplay is an optional domain model, it may not be loaded in the store
                            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(VerifyPageOrderEvent), action);
                            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(VerifyPageOrderEvent), action);
                            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <RolePlayerOrderChangedEventArgs>(VerifyPageOrderEvent), action);
                            eventManager.AddOrRemoveHandler(classInfo, new EventHandler <RolePlayerChangedEventArgs>(VerifyPageOrderEvent), action);
                        }
                    }
                }
                if (0 != (reasons & EventSubscriberReasons.UserInterfaceEvents))
                {
                    eventManager.AddOrRemoveHandler(new EventHandler <ElementEventsBegunEventArgs>(ElementEventsBegunEvent), action);
                    eventManager.AddOrRemoveHandler(new EventHandler <ElementEventsEndedEventArgs>(ElementEventsEndedEvent), action);
                }
            }
        }
Пример #25
0
        /// <summary>
        /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="TableShape"/>s.
        /// </summary>
        /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
        /// <param name="eventManager">The <see cref="ModelingEventManager"/> used to manage the <see cref="EventHandler{TEventArgs}"/>s.</param>
        /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
        public static void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            DomainDataDirectory dataDirectory = store.DomainDataDirectory;
            DomainPropertyInfo  propertyInfo  = dataDirectory.FindDomainProperty(TableShape.UpdateCounterDomainPropertyId);

            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(UpdateShapeEvent), action);

            if (action == EventHandlerAction.Add)
            {
                // We don't want this rule on. This forces a full repopulation of the compartment,
                // which makes it impossible to determine the old index of a selected item. If this is
                // on, then the ColumnRenamedEvent does not work for the initial transaction.
                store.RuleManager.DisableRule(typeof(CompartmentItemChangeRule));
            }
#if CUSTOMSORT
            propertyInfo = dataDirectory.FindDomainProperty(Column.NameDomainPropertyId);
            eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler <ElementPropertyChangedEventArgs>(ColumnRenamedEvent), action);
#else // CUSTOMSORT
            eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRole(TableContainsColumn.ColumnDomainRoleId), new EventHandler <RolePlayerOrderChangedEventArgs>(ColumnOrderChanged), action);
#endif // CUSTOMSORT
        }
Пример #26
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelAttribute domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            ModelAttribute modelAttribute = ModelElement as ModelAttribute;

            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (modelAttribute != null)
            {
                storeDomainDataDirectory = modelAttribute.Store.DomainDataDirectory;

                EFCoreValidator.RemoveHiddenProperties(propertyDescriptors, modelAttribute);

                // dono't display IdentityType unless the IsIdentity is true
                if (!modelAttribute.IsIdentity)
                {
                    PropertyDescriptor identityTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "IdentityType");
                    propertyDescriptors.Remove(identityTypeDescriptor);
                }

                /********************************************************************************/

                DomainPropertyInfo columnNamePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.ColumnNameDomainPropertyId);
                DomainPropertyInfo isColumnNameTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelAttribute.IsColumnNameTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] columnNameAttributes =
                {
                    new DisplayNameAttribute("Column Name"),
                    new DescriptionAttribute("Overrides default column name"),
                    new CategoryAttribute("Database")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelAttribute, columnNamePropertyInfo, isColumnNameTrackingPropertyInfo, columnNameAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #27
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelEnum domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            //Add the descriptor for the tracking property.
            if (ModelElement is ModelEnum modelEnum)
            {
                storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory;

                EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelEnum);

                //Add the descriptors for the tracking properties

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Namespace")
                    , new DescriptionAttribute("Overrides default namespace")
                    , new CategoryAttribute("Code Generation")
                }));

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.OutputDirectoryDomainPropertyId)
                                                                       , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsOutputDirectoryTrackingDomainPropertyId)
                                                                       , new Attribute[]
                {
                    new DisplayNameAttribute("Output Directory")
                    , new DescriptionAttribute("Overrides default output directory")
                    , new CategoryAttribute("Code Generation")
                    , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                }));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #28
0
                    /// <summary>
                    /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> during activation and
                    /// deactivation.
                    /// </summary>
                    /// <param name="store">The <see cref="Store"/> for which the <see cref="EventHandler{TEventArgs}"/>s should be managed.</param>
                    /// <param name="action">The <see cref="EventHandlerAction"/> that should be taken for the <see cref="EventHandler{TEventArgs}"/>s.</param>
                    private void ManageStoreEvents(Store store, EventHandlerAction action)
                    {
                        if (store == null || store.Disposed)
                        {
                            return;                             // bail out
                        }
                        DomainDataDirectory  dataDirectory = store.DomainDataDirectory;
                        ModelingEventManager eventManager  = ModelingEventManager.GetModelingEventManager(store);

                        DomainClassInfo classInfo = dataDirectory.FindDomainClass(ReferenceModeKind.DomainClassId);

                        eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementPropertyChangedEventArgs>(ReferenceModeKindChangeEvent), action);

                        classInfo = dataDirectory.FindDomainClass(CustomReferenceMode.DomainClassId);
                        eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementPropertyChangedEventArgs>(CustomReferenceModeChangeEvent), action);

                        classInfo = dataDirectory.FindDomainRelationship(ModelHasReferenceMode.DomainClassId);
                        eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementAddedEventArgs>(CustomReferenceModeAddEvent), action);
                        eventManager.AddOrRemoveHandler(classInfo, new EventHandler <ElementDeletedEventArgs>(CustomReferenceModeRemoveEvent), action);

                        classInfo = dataDirectory.FindDomainRelationship(ReferenceModeHasReferenceModeKind.DomainClassId);
                        eventManager.AddOrRemoveHandler(classInfo, new EventHandler <RolePlayerChangedEventArgs>(ReferenceModeHasKindChangeEvent), action);
                    }
 private void EnsureDomainAttributesInitialized(DomainDataDirectory domainDataDirectory)
 {
     if (!myCustomPropertyAttributesInitialized)
     {
         lock (LockObject)
         {
             if (!myCustomPropertyAttributesInitialized)
             {
                 ConstraintDisplayPositionDomainPropertyAttributes = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.ConstraintDisplayPositionDomainPropertyId));
                 DisplayOrientationDomainPropertyAttributes        = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayOrientationDomainPropertyId));
                 DisplayRelatedTypesDomainPropertyAttributes       = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayRelatedTypesDomainPropertyId));
                 DisplayRoleNamesDomainPropertyAttributes          = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayRoleNamesDomainPropertyId));
                 DisplayAsObjectTypeDomainPropertyAttributes       = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayAsObjectTypeDomainPropertyId));
                 ExpandRefModeDomainPropertyAttributes             = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(FactTypeShape.ExpandRefModeDomainPropertyId));
                 NameDomainPropertyAttributes          = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(ORMNamedElement.NameDomainPropertyId));
                 IsIndependentDomainPropertyAttributes = GetDomainPropertyAttributes(domainDataDirectory.FindDomainProperty(ObjectType.IsIndependentDomainPropertyId));
                 NestedFactTypeDomainRoleAttributes    = AddExpandableElementTypeConverterAttribute(GetRolePlayerPropertyAttributes(domainDataDirectory.FindDomainRole(Objectification.NestedFactTypeDomainRoleId)));
                 NestingTypeDomainRoleAttributes       = AddExpandableElementTypeConverterAttribute(GetRolePlayerPropertyAttributes(domainDataDirectory.FindDomainRole(Objectification.NestingTypeDomainRoleId)));
                 myCustomPropertyAttributesInitialized = true;
             }
         }
     }
 }
Пример #30
0
        /// <summary>
        ///    Returns the property descriptors for the described ModelClass domain class, adding tracking property
        ///    descriptor(s).
        /// </summary>
        private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
        {
            // Get the default property descriptors from the base class
            PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes);

            if (ModelElement is ModelClass modelClass)
            {
                EFCoreValidator.RemoveHiddenProperties(propertyDescriptors, modelClass);

                storeDomainDataDirectory = modelClass.Store.DomainDataDirectory;

                //Add the descriptors for the tracking properties
                /********************************************************************************/

                DomainPropertyInfo databaseSchemaPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.DatabaseSchemaDomainPropertyId);
                DomainPropertyInfo isDatabaseSchemaTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsDatabaseSchemaTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] databaseSchemaAttributes =
                {
                    new DisplayNameAttribute("Database Schema"),
                    new DescriptionAttribute("The schema to use for table creation. Overrides default schema for model if present."),
                    new CategoryAttribute("Database")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, databaseSchemaPropertyInfo, isDatabaseSchemaTrackingPropertyInfo, databaseSchemaAttributes));

                /********************************************************************************/

                DomainPropertyInfo namespacePropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.NamespaceDomainPropertyId);
                DomainPropertyInfo isNamespaceTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsNamespaceTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] namespaceAttributes =
                {
                    new DisplayNameAttribute("Namespace"),
                    new DescriptionAttribute("Overrides default namespace"),
                    new CategoryAttribute("Code Generation")
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, namespacePropertyInfo, isNamespaceTrackingPropertyInfo, namespaceAttributes));

                /********************************************************************************/

                DomainPropertyInfo outputDirectoryPropertyInfo           = storeDomainDataDirectory.GetDomainProperty(ModelClass.OutputDirectoryDomainPropertyId);
                DomainPropertyInfo isOutputDirectoryTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(ModelClass.IsOutputDirectoryTrackingDomainPropertyId);

                // Define attributes for the tracking property/properties so that the Properties window displays them correctly.
                Attribute[] outputDirectoryAttributes =
                {
                    new DisplayNameAttribute("Output Directory"),
                    new DescriptionAttribute("Overrides default output directory"),
                    new CategoryAttribute("Code Generation"),
                    new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter))
                };

                propertyDescriptors.Add(new TrackingPropertyDescriptor(modelClass, outputDirectoryPropertyInfo, isOutputDirectoryTrackingPropertyInfo, outputDirectoryAttributes));
            }

            // Return the property descriptors for this element
            return(propertyDescriptors);
        }
Пример #31
0
					public InitialPropertyExpansionBranch(Store store, PropertyAssignment[] assignments)
					{
						myDirectory = store.DomainDataDirectory;
						myAssignments = assignments;
					}
Пример #32
0
		private static void InvalidateIndirectErrorOwnerDisplay(ModelElement element, DomainDataDirectory domainDataDirectory, Predicate<ModelElement> filter)
		{
			IHasIndirectModelErrorOwner indirectOwner = element as IHasIndirectModelErrorOwner;
			if (indirectOwner != null)
			{
				Guid[] metaRoles = indirectOwner.GetIndirectModelErrorOwnerLinkRoles();
				int roleCount;
				if (metaRoles != null &&
					0 != (roleCount = metaRoles.Length))
				{
					if (domainDataDirectory == null)
					{
						domainDataDirectory = element.Store.DomainDataDirectory;
					}
					for (int i = 0; i < roleCount; ++i)
					{
						Debug.Assert(metaRoles[i] != Guid.Empty);
						DomainRoleInfo metaRole = domainDataDirectory.FindDomainRole(metaRoles[i]);
						if (metaRole != null)
						{
							LinkedElementCollection<ModelElement> counterparts = metaRole.GetLinkedElements(element);
							int counterpartCount = counterparts.Count;
							for (int j = 0; j < counterpartCount; ++j)
							{
								ModelElement counterpart = counterparts[j];
								if (filter != null && filter(counterpart))
								{
									continue;
								}
								if (counterpart is IModelErrorOwner)
								{
									InvalidateErrorOwnerDisplay(counterpart);
								}
								InvalidateIndirectErrorOwnerDisplay(
									counterpart,
									domainDataDirectory,
									delegate(ModelElement testElement)
									{
										return testElement == element ||
											(filter != null && filter(testElement));
									});
							}
						}
					}
				}
			}
			ElementLink elementLink;
			IElementLinkRoleHasIndirectModelErrorOwner indirectLinkRoleOwner;
			if (null != (indirectLinkRoleOwner = element as IElementLinkRoleHasIndirectModelErrorOwner) &&
				null != (elementLink = element as ElementLink))
			{
				Guid[] metaRoles = indirectLinkRoleOwner.GetIndirectModelErrorOwnerElementLinkRoles();
				int roleCount;
				if (metaRoles != null &&
					0 != (roleCount = metaRoles.Length))
				{
					if (domainDataDirectory == null)
					{
						domainDataDirectory = element.Store.DomainDataDirectory;
					}
					for (int i = 0; i < roleCount; ++i)
					{
						Debug.Assert(metaRoles[i] != Guid.Empty);
						DomainRoleInfo metaRole = domainDataDirectory.FindDomainRole(metaRoles[i]);
						if (metaRole != null)
						{
							ModelElement rolePlayer = metaRole.GetRolePlayer(elementLink);
							if (filter != null && filter(rolePlayer))
							{
								continue;
							}
							if (rolePlayer is IModelErrorOwner)
							{
								InvalidateErrorOwnerDisplay(rolePlayer);
							}
							InvalidateIndirectErrorOwnerDisplay(
								rolePlayer,
								domainDataDirectory,
								delegate(ModelElement testElement)
								{
									return testElement == element ||
										(filter != null && filter(testElement));
								});
						}
					}
				}
			}
		}