/// <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);
        }
Exemple #2
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);
        }
Exemple #3
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);
            }
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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
        }
Exemple #7
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);
     }
 }
Exemple #8
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)));
            }
        }
Exemple #9
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);
        }
 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;
             }
         }
     }
 }
        /// <summary>
        /// Show selected properties from the <see cref="FactType.NestingType"/> and the
        /// <see cref="Objectification.NestedFactType"/> for an objectified <see cref="FactType"/>,
        /// as well as expandable nodes for each of the underlying instances.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            FactType factType = ModelElement;

            if (FactTypeShape.ShouldDrawObjectification(factType))
            {
                FactTypeShape       factTypeShape              = PresentationElement;
                Objectification     objectification            = factType.Objectification;
                ObjectType          nestingType                = objectification.NestingType;
                bool                nestingTypeHasRelatedTypes = nestingType.IsSubtypeOrSupertype;
                DomainDataDirectory domainDataDirectory        = factType.Store.DomainDataDirectory;
                EnsureDomainAttributesInitialized(domainDataDirectory);

                PropertyDescriptorCollection retVal;
                if (factTypeShape.DisplayAsObjectType)
                {
                    retVal = new PropertyDescriptorCollection(null);
                    Type componentType = typeof(FactTypeShape);
                    foreach (PropertyDescriptor nestingTypeDescriptor in TypeDescriptor.GetProperties(nestingType))
                    {
                        if (nestingTypeDescriptor.Name == "NestedFactType")
                        {
                            continue;
                        }
                        retVal.Add(EditorUtility.RedirectPropertyDescriptor(nestingType, nestingTypeDescriptor, componentType));
                    }
                    retVal.Add(CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayAsObjectTypeDomainPropertyId), DisplayAsObjectTypeDomainPropertyAttributes));
                    retVal.Add(CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.ExpandRefModeDomainPropertyId), ExpandRefModeDomainPropertyAttributes));
                    retVal.Add(new ObjectifyingEntityTypePropertyDescriptor(factType, domainDataDirectory.FindDomainRole(Objectification.NestingTypeDomainRoleId), NestedFactTypeDomainRoleAttributes));
                    retVal.Add(new ObjectifiedFactTypePropertyDescriptor(nestingType, domainDataDirectory.FindDomainRole(Objectification.NestedFactTypeDomainRoleId), NestingTypeDomainRoleAttributes));
                    if (nestingTypeHasRelatedTypes)
                    {
                        retVal.Add(CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayRelatedTypesDomainPropertyId), DisplayRelatedTypesDomainPropertyAttributes));
                    }
                }
                else
                {
                    PropertyDescriptor[] descriptors = new PropertyDescriptor[nestingTypeHasRelatedTypes ? 9 : 8];
                    descriptors[0] = CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.ConstraintDisplayPositionDomainPropertyId), ConstraintDisplayPositionDomainPropertyAttributes);
                    descriptors[1] = CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayOrientationDomainPropertyId), DisplayOrientationDomainPropertyAttributes);
                    descriptors[2] = CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayRoleNamesDomainPropertyId), DisplayRoleNamesDomainPropertyAttributes);
                    descriptors[3] = CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayAsObjectTypeDomainPropertyId), DisplayAsObjectTypeDomainPropertyAttributes);
                    descriptors[4] = CreatePropertyDescriptor(nestingType, domainDataDirectory.FindDomainProperty(ORMNamedElement.NameDomainPropertyId), NameDomainPropertyAttributes);
                    descriptors[5] = CreatePropertyDescriptor(nestingType, domainDataDirectory.FindDomainProperty(ObjectType.IsIndependentDomainPropertyId), IsIndependentDomainPropertyAttributes);
                    descriptors[6] = new ObjectifyingEntityTypePropertyDescriptor(factType, domainDataDirectory.FindDomainRole(Objectification.NestingTypeDomainRoleId), NestedFactTypeDomainRoleAttributes);
                    descriptors[7] = new ObjectifiedFactTypePropertyDescriptor(nestingType, domainDataDirectory.FindDomainRole(Objectification.NestedFactTypeDomainRoleId), NestingTypeDomainRoleAttributes);
                    if (nestingTypeHasRelatedTypes)
                    {
                        descriptors[8] = CreatePropertyDescriptor(factTypeShape, domainDataDirectory.FindDomainProperty(FactTypeShape.DisplayRelatedTypesDomainPropertyId), DisplayRelatedTypesDomainPropertyAttributes);
                    }
                    retVal = new PropertyDescriptorCollection(descriptors);
                }

                // This mockup of important properties means that extension providers cannot add properties
                // here by adding to the objecttype or facttype. Use an extension on the Objectification type
                // itself to add extension properties.
                ((IFrameworkServices)factType.Store).PropertyProviderService.GetProvidedProperties(objectification, retVal);
                return(retVal);
            }
            return(base.GetProperties(attributes));
        }