/// <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> /// 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); }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { // UNDONE: If we delay attach user interface events (possible in the future for // external model scenarios), then we need to check ModelStateEvents here and // be more precise in which events are attached that affect model state such as // calculated shape size. Currently, this is only called without 'UserInterfaceEvents' // for unit-testing. if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents))) { Store store = Store; ORMDiagram.ManageEventHandlers(store, eventManager, action); ORMBaseShape.ManageEventHandlers(store, eventManager, action); ReadingShape.ManageEventHandlers(store, eventManager, action); ExternalConstraintShape.ManageEventHandlers(store, eventManager, action); RolePlayerLink.ManageEventHandlers(store, eventManager, action); ObjectTypeShape.ManageEventHandlers(store, eventManager, action); ORMBaseBinaryLinkShape.ManageEventHandlers(store, eventManager, action); FactTypeShape.ManageEventHandlers(store, eventManager, action); SubtypeLink.ManageEventHandlers(store, eventManager, action); } if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { IORMToolServices services; IORMExtendableElementService extendableElementService; if (null != (services = Store as IORMToolServices) && null != (extendableElementService = services.ExtendableElementService)) { extendableElementService.RegisterExtensionRoles(new Guid[] { ORMDiagramHasExtensionElement.ExtensionDomainRoleId, ORMBaseShapeHasExtensionElement.ExtensionDomainRoleId }); } } }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> so that the <see cref="ORMVerbalizationToolWindow"/> /// 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) { eventManager.AddOrRemoveHandler(new EventHandler <ElementEventsEndedEventArgs>(ModelStateChangedEvent), action); } }
/// <summary>See <see cref="DiagramDocView.Dispose"/>.</summary> protected override void Dispose(bool disposing) { try { if (disposing) { Store store; ModelingEventManager eventMgr; if (null != (store = Store) && DocData.IsLoaded && null != (eventMgr = ModelingEventManager.GetModelingEventManager(store))) { ManageModelingEventHandlers(eventMgr, EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.ModelStateEvents | EventSubscriberReasons.UserInterfaceEvents, EventHandlerAction.Remove); } if (myDocViewControl != null) { myDocViewControl.Parent.Dispose(); } } } finally { base.Dispose(disposing); } }
/// <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 } ModelingEventManager.GetModelingEventManager(store).AddOrRemoveHandler(store.DomainDataDirectory.FindDomainClass(ReferenceModeKind.DomainClassId), new EventHandler <ElementPropertyChangedEventArgs>(ReferenceModeKindChangeEvent), action); }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> during connect action activation and deactivation. /// The default implementation watches for new <see cref="UniquenessConstraint"/>s added to the <see cref="ORMModel"/>. /// </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> protected virtual void ManageStoreEvents(Store store, EventHandlerAction action) { if (store == null || store.Disposed) { return; // bail out } ModelingEventManager.GetModelingEventManager(store).AddOrRemoveHandler(store.DomainDataDirectory.FindDomainClass(UniquenessConstraint.DomainClassId), new EventHandler <ElementAddedEventArgs>(InternalConstraintAddedEvent), action); }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected new void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { base.ManageModelingEventHandlers(eventManager, reasons, action); if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents))) { eventManager.AddOrRemoveHandler(new EventHandler <ElementEventsEndedEventArgs>(OnElementEventsEnded), action); } }
/// <summary> /// Detach <see cref="EventHandler{TEventArgs}"/>s from the <see cref="Store"/> associated with the <see cref="ORMDesignerDocData"/>. Defers to <see cref="ManageEventHandlers"/>. /// </summary> protected void DetachEventHandlers(ORMDesignerDocData docData) { Store store = docData.Store; if (store != null) { ManageEventHandlers(store, ModelingEventManager.GetModelingEventManager(store), EventHandlerAction.Remove); } }
/// <summary> /// Attach <see cref="EventHandler{TEventArgs}"/>s to the <see cref="Store"/> associated with the <see cref="ORMDesignerDocData"/>. Defers to <see cref="ManageEventHandlers"/>. /// </summary> protected void AttachEventHandlers(ORMDesignerDocData docData) { Store store = docData.Store; if (null != store) { ManageEventHandlers(store, ModelingEventManager.GetModelingEventManager(store), EventHandlerAction.Add); } }
/// <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); }
/// <summary> /// Wires event handlers to the store. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { SamplePopulationEditor editor = myEditor; if (editor != null) { editor.ManageEventHandlers(store, eventManager, action); } }
/// <summary> /// Manages event handlers in the store so that the tool window /// contents can be updated to reflect any model changes. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { ReadingsViewForm form = myForm; ReadingEditor readingEditor = (form != null) ? form.ReadingEditor : null; if (readingEditor != null) { readingEditor.ManageEventHandlers(store, eventManager, action); } }
/// <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); }
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); } }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/> /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (0 == (reasons & EventSubscriberReasons.DocumentLoaded)) { return; } IPropertyProviderService propertyProvider = ((IFrameworkServices)Store).PropertyProviderService; propertyProvider.AddOrRemovePropertyProvider(typeof(FactType), AssimilationMapping.PopulateAssimilationMappingExtensionProperties, true, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ObjectType), AssimilationMapping.PopulateObjectTypeAbsorptionExtensionProperties, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ObjectType), ReferenceModeNaming.PopulateReferenceModeNamingExtensionProperties, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ORMModel), ReferenceModeNaming.PopulateDefaultReferenceModeNamingExtensionPropertiesOnORMModel, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(RelationalNameGenerator), ReferenceModeNaming.PopulateDefaultReferenceModeNamingExtensionPropertiesOnColumnNameGenerator, false, action); }
/// <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); }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="RelationalDiagram"/>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) { foreach (RelationalDiagram diagram in store.ElementDirectory.FindElements <RelationalDiagram>(false)) { switch (action) { case EventHandlerAction.Add: diagram.SubscribeCompartmentItemsEvents(); break; case EventHandlerAction.Remove: diagram.UnsubscribeCompartmentItemsEvents(); break; } } }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { Store store = Store; IPropertyProviderService propertyService = ((IFrameworkServices)store).PropertyProviderService; IExtensionVerbalizerService verbalizerService = ((IORMToolServices)store).ExtensionVerbalizerService; propertyService.AddOrRemovePropertyProvider(typeof(ORMModel), CustomPropertyProviders.CustomPropertiesEditor, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ORMModel), CustomPropertyProviders.Model, false, action); propertyService.AddOrRemovePropertyProvider(typeof(ORMDiagram), CustomPropertyProviders.ORMDiagram, false, action); propertyService.AddOrRemovePropertyProvider(typeof(ElementGrouping), CustomPropertyProviders.ElementGrouping, false, action); propertyService.AddOrRemovePropertyProvider(typeof(ObjectType), CustomPropertyProviders.ObjectType, true, action); propertyService.AddOrRemovePropertyProvider(typeof(SubtypeFact), CustomPropertyProviders.SubtypeFact, true, action); propertyService.AddOrRemovePropertyProvider(typeof(FactType), CustomPropertyProviders.FactType, false, action); propertyService.AddOrRemovePropertyProvider(typeof(Role), CustomPropertyProviders.Role, true, action); propertyService.AddOrRemovePropertyProvider(typeof(CardinalityConstraint), CustomPropertyProviders.CardinalityConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(FrequencyConstraint), CustomPropertyProviders.FrequencyConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(MandatoryConstraint), CustomPropertyProviders.MandatoryConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(RingConstraint), CustomPropertyProviders.RingConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(UniquenessConstraint), CustomPropertyProviders.UniquenessConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(EqualityConstraint), CustomPropertyProviders.EqualityConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ExclusionConstraint), CustomPropertyProviders.ExclusionConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(SubsetConstraint), CustomPropertyProviders.SubsetConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ValueComparisonConstraint), CustomPropertyProviders.ValueComparisonConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ValueConstraint), CustomPropertyProviders.ValueConstraint, true, action); if (verbalizerService != null) { verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ORMModel), DefaultVerbalizationProviders.Model, false, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ORMDiagram), DefaultVerbalizationProviders.ORMDiagram, false, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ElementGrouping), DefaultVerbalizationProviders.ElementGrouping, false, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ObjectType), DefaultVerbalizationProviders.ObjectType, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(SubtypeFact), DefaultVerbalizationProviders.SubtypeFact, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(FactType), DefaultVerbalizationProviders.FactType, false, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(Role), DefaultVerbalizationProviders.Role, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(CardinalityConstraint), DefaultVerbalizationProviders.CardinalityConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(FrequencyConstraint), DefaultVerbalizationProviders.FrequencyConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(MandatoryConstraint), DefaultVerbalizationProviders.MandatoryConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(RingConstraint), DefaultVerbalizationProviders.RingConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(UniquenessConstraint), DefaultVerbalizationProviders.UniquenessConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(EqualityConstraint), DefaultVerbalizationProviders.EqualityConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ExclusionConstraint), DefaultVerbalizationProviders.ExclusionConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(SubsetConstraint), DefaultVerbalizationProviders.SubsetConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ValueComparisonConstraint), DefaultVerbalizationProviders.ValueComparisonConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ValueConstraint), DefaultVerbalizationProviders.ValueConstraint, true, action); } } }
/// <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); }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/> /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { IPropertyProviderService propertyProvider = ((IFrameworkServices)Store).PropertyProviderService; propertyProvider.AddOrRemovePropertyProvider(typeof(FactType), AssimilationMapping.PopulateAssimilationMappingExtensionProperties, true, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ObjectType), AssimilationMapping.PopulateObjectTypeAbsorptionExtensionProperties, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ObjectType), ReferenceModeNaming.PopulateReferenceModeNamingExtensionProperties, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(ORMModel), ReferenceModeNaming.PopulateDefaultReferenceModeNamingExtensionPropertiesOnORMModel, false, action); propertyProvider.AddOrRemovePropertyProvider(typeof(RelationalNameGenerator), ReferenceModeNaming.PopulateDefaultReferenceModeNamingExtensionPropertiesOnColumnNameGenerator, false, action); if (0 != (reasons & EventSubscriberReasons.ModelStateEvents)) { SchemaCustomization.ManageModelingEventHandlers(eventManager, this.Store, action); } } }
/// <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); }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (action == EventHandlerAction.Add && 0 != (reasons & EventSubscriberReasons.DocumentLoading)) { // Hack implementation to turn on the FixupDiagram rules before the model loads. // Normally this would be done with a coordinated fixup listener. However, we // have no control over the DSL-generated FixupDiagram rule without jumping through // a lot of hoops, so we do it here, which fires after the rules are created and // before the model loads. Store.RuleManager.EnableRule(typeof(FixUpDiagram)); } if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { Store store = Store; BarkerEntityShape.ManageEventHandlers(store, eventManager, action); BarkerERDiagram.ManageEventHandlers(store, eventManager, action); } }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { // UNDONE: If we delay attach user interface events (possible in the future for // external model scenarios), then we need to check ModelStateEvents here and // be more precise in which events are attached that affect model state such as // calculated shape size. Currently, this is only called without 'UserInterfaceEvents' // for unit-testing. if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents))) { Store store = Store; ORMBaseShape.ManageEventHandlers(store, eventManager, action); ReadingShape.ManageEventHandlers(store, eventManager, action); ExternalConstraintShape.ManageEventHandlers(store, eventManager, action); RolePlayerLink.ManageEventHandlers(store, eventManager, action); ObjectTypeShape.ManageEventHandlers(store, eventManager, action); ORMBaseBinaryLinkShape.ManageEventHandlers(store, eventManager, action); FactTypeShape.ManageEventHandlers(store, eventManager, action); SubtypeLink.ManageEventHandlers(store, eventManager, action); } }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { // UNDONE: If we delay attach user interface events (possible in the future for // external model scenarios), then we need to check ModelStateEvents here and // be more precise in which events are attached that affect model state such as // calculated shape size. Currently, this is only called without 'UserInterfaceEvents' // for unit-testing. if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents))) { Store store = Store; ORMBaseShape.ManageEventHandlers(store, eventManager, action); ReadingShape.ManageEventHandlers(store, eventManager, action); ExternalConstraintShape.ManageEventHandlers(store, eventManager, action); RolePlayerLink.ManageEventHandlers(store, eventManager, action); ObjectTypeShape.ManageEventHandlers(store, eventManager, action); ORMBaseBinaryLinkShape.ManageEventHandlers(store, eventManager, action); FactTypeShape.ManageEventHandlers(store, eventManager, action); SubtypeLink.ManageEventHandlers(store, eventManager, action); } }
/// <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); } } }
/// <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 }
/// <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); }
/// <summary> /// Load a model from an input stream /// </summary> /// <param name="inputStream">The stream to input from.</param> /// <returns>A <see cref="Store"/> with the model loaded.</returns> public Store Load(Stream inputStream) { List <string> unrecognizedNamespaces = null; Stream namespaceStrippedStream = null; Store store = null; try { XmlReaderSettings readerSettings = new XmlReaderSettings(); ExtensionLoader extensionLoader = myExtensionLoader; readerSettings.CloseInput = false; Dictionary <string, ExtensionModelBinding> documentExtensions = null; using (XmlReader reader = XmlReader.Create(inputStream, readerSettings)) { reader.MoveToContent(); if (reader.NodeType == XmlNodeType.Element) { if (reader.MoveToFirstAttribute()) { do { if (reader.Prefix == "xmlns") { string URI = reader.Value; if (!string.Equals(URI, ORMCoreDomainModel.XmlNamespace, StringComparison.Ordinal) && !string.Equals(URI, ORMShapeDomainModel.XmlNamespace, StringComparison.Ordinal) && !string.Equals(URI, ORMSerializationEngine.RootXmlNamespace, StringComparison.Ordinal)) { ExtensionModelBinding?extensionType = extensionLoader.GetExtensionDomainModel(URI); if (extensionType.HasValue) { if (documentExtensions == null) { documentExtensions = new Dictionary <string, ExtensionModelBinding>(); } documentExtensions[URI] = extensionType.Value; } else { (unrecognizedNamespaces ?? (unrecognizedNamespaces = new List <string>())).Add(URI); } } } } while (reader.MoveToNextAttribute()); } } } extensionLoader.VerifyRequiredExtensions(ref documentExtensions); if (unrecognizedNamespaces != null) { inputStream.Position = 0; namespaceStrippedStream = ExtensionLoader.CleanupStream(inputStream, extensionLoader.StandardDomainModels, documentExtensions.Values, unrecognizedNamespaces); if (namespaceStrippedStream != null) { inputStream = namespaceStrippedStream; } else { unrecognizedNamespaces = null; } } inputStream.Position = 0; store = CreateStore(); store.UndoManager.UndoState = UndoState.Disabled; store.LoadDomainModels(extensionLoader.GetRequiredDomainModels(documentExtensions)); try { ModelingEventManager eventManager = ModelingEventManager.GetModelingEventManager(store); using (Transaction t = store.TransactionManager.BeginTransaction("File load and fixup")) { foreach (IModelingEventSubscriber subscriber in Utility.EnumerateDomainModels <IModelingEventSubscriber>(store.DomainModels)) { subscriber.ManageModelingEventHandlers(eventManager, EventSubscriberReasons.DocumentLoading | EventSubscriberReasons.ModelStateEvents, EventHandlerAction.Add); } if (inputStream.Length > 1) { (new ORMSerializationEngine(store)).Load(inputStream); } t.Commit(); } foreach (IModelingEventSubscriber subscriber in Utility.EnumerateDomainModels <IModelingEventSubscriber>(store.DomainModels)) { subscriber.ManageModelingEventHandlers(eventManager, EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.ModelStateEvents, EventHandlerAction.Add); } store.UndoManager.UndoState = UndoState.Enabled; } catch (TypeInitializationException ex) { // If the type that failed to load is an extensions, then remove it from // the list of available extensions and try again. if (documentExtensions != null) { string typeName = ex.TypeName; foreach (KeyValuePair <string, ExtensionModelBinding> pair in documentExtensions) { Type testType = pair.Value.Type; if (testType.FullName == typeName) { if (extensionLoader.CustomExtensionUnavailable(testType)) { return(Load(inputStream)); } break; } } } throw; } } finally { if (namespaceStrippedStream != null) { namespaceStrippedStream.Dispose(); } } return(store); }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="RelationalDiagram"/>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) { foreach (RelationalDiagram diagram in store.ElementDirectory.FindElements<RelationalDiagram>(false)) { switch (action) { case EventHandlerAction.Add: diagram.SubscribeCompartmentItemsEvents(); break; case EventHandlerAction.Remove: diagram.UnsubscribeCompartmentItemsEvents(); break; } } }
/// <summary> /// Wires event handlers to the store. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { SamplePopulationEditor editor = myEditor; if (editor != null) { editor.ManageEventHandlers(store, eventManager, action); } }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (action == EventHandlerAction.Add && 0 != (reasons & EventSubscriberReasons.DocumentLoading)) { // Hack implementation to turn on the FixupDiagram rules before the model loads. // Normally this would be done with a coordinated fixup listener. However, we // have no control over the DSL-generated FixupDiagram rule without jumping through // a lot of hoops, so we do it here, which fires after the rules are created and // before the model loads. Store.RuleManager.EnableRule(typeof(FixUpDiagram)); } if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { Store store = Store; TableShape.ManageEventHandlers(store, eventManager, action); RelationalDiagram.ManageEventHandlers(store, eventManager, action); } }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected new void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { base.ManageModelingEventHandlers(eventManager, reasons, action); if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents))) { eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsEndedEventArgs>(OnElementEventsEnded), action); } }
private void ManageTabRestoreEvents(ModelingEventManager eventManager, EventHandlerAction action) { // Add event handlers to cater for undo/redo and initial // add when multiple windows are open Store store = Store; DomainDataDirectory dataDirectory = store.DomainDataDirectory; DomainClassInfo classInfo = dataDirectory.FindDomainClass(Diagram.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(AddOrRemoveTabForEvent), action); }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { this.ManageModelingEventHandlers(eventManager, reasons, action); }
/// <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); }
/// <summary> /// NOT IMPLEMENTED: There are no event handlers to attach for this class. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="SubtypeLink"/>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) { eventManager.AddOrRemoveHandler(store.DomainDataDirectory.FindDomainProperty(SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId), new EventHandler <ElementPropertyChangedEventArgs>(ProvidesPreferredIdentifierChangedEvent), action); }
/// <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)) { 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); } } }
/// <summary> /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>. /// </summary> protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { Store store = Store; if (action == EventHandlerAction.Add && (EventSubscriberReasons.ModelStateEvents | EventSubscriberReasons.DocumentLoading) == (reasons & (EventSubscriberReasons.ModelStateEvents | EventSubscriberReasons.DocumentLoading))) { store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo[NamedElementDictionary.DefaultAllowDuplicateNamesKey] = null; } if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { if (0 != (reasons & EventSubscriberReasons.ModelStateEvents)) { NamedElementDictionary.ManageModelStateEventHandlers(store, eventManager, action); ORMModel.ManageModelStateEventHandlers(store, eventManager, action); } if (action == EventHandlerAction.Add && 0 == (reasons & EventSubscriberReasons.DocumentReloading) && 0 != (reasons & EventSubscriberReasons.UserInterfaceEvents)) { Design.ORMEditorUtility.RegisterModelErrorActivators(store); } } if (0 != (reasons & EventSubscriberReasons.SurveyQuestionEvents)) { DomainDataDirectory directory = store.DomainDataDirectory; EventHandler<ElementDeletedEventArgs> standardDeleteHandler = new EventHandler<ElementDeletedEventArgs>(ModelElementRemovedEvent); EventHandler<ElementPropertyChangedEventArgs> standardGlyphChangeHandler = new EventHandler<ElementPropertyChangedEventArgs>(SurveyGlyphChangedEvent); EventHandler<ElementDeletedEventArgs> standardErrorPathDeletedHandler = new EventHandler<ElementDeletedEventArgs>(ModelElementErrorStateChangedEvent); EventHandler<RolePlayerChangedEventArgs> standardErrorPathRolePlayedChangedHandler = new EventHandler<RolePlayerChangedEventArgs>(ModelElementErrorStateOwnerPathChangedEvent); //Object Type DomainClassInfo classInfo = directory.FindDomainClass(ObjectType.DomainClassId); DomainPropertyInfo propertyInfo = directory.FindDomainProperty(ObjectType.NameDomainPropertyId); eventManager.AddOrRemoveHandler(classInfo, propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ObjectTypeNameChangedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ObjectTypeAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardDeleteHandler, action); //Fact Type classInfo = directory.FindDomainClass(FactType.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(FactTypeAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardDeleteHandler, action); //Set Constraint classInfo = directory.FindDomainClass(SetConstraint.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(SetConstraintAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardDeleteHandler, action); //Set Comparison classInfo = directory.FindDomainClass(SetComparisonConstraint.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(SetComparisonConstraintAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardDeleteHandler, action); // External constraint expansion classInfo = directory.FindDomainRelationship(FactConstraint.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(FactConstraintAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(FactConstraintDeletedEvent), action); //Track name change EventHandler<ElementPropertyChangedEventArgs> standardNameChangedHandler = new EventHandler<ElementPropertyChangedEventArgs>(ModelElementNameChangedEvent); propertyInfo = directory.FindDomainProperty(ORMNamedElement.NameDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardNameChangedHandler , action); propertyInfo = directory.FindDomainProperty(FactType.NameChangedDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardNameChangedHandler, action); propertyInfo = directory.FindDomainProperty(ModelNote.TextDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardNameChangedHandler, action); // Derivation display (* after derived fact type and subtype names) classInfo = directory.FindDomainClass(FactTypeHasDerivationRule.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(FactTypeDerivationRuleAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(FactTypeDerivationRuleDeletedEvent), action); classInfo = directory.FindDomainClass(SubtypeHasDerivationRule.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(SubtypeDerivationRuleAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(SubtypeDerivationRuleDeletedEvent), action); //FactTypeHasRole classInfo = directory.FindDomainClass(FactTypeHasRole.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(FactTypeHasRoleAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(FactTypeHasRoleDeletedEvent), action); //Role propertyInfo = directory.FindDomainProperty(Role.NameDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(RoleNameChangedEvent), action); //ValueTypeHasDataType classInfo = directory.FindDomainClass(ValueTypeHasDataType.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ValueTypeHasDataTypeAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ValueTypeHasDataTypeDeletedEvent), action); //Objectification classInfo = directory.FindDomainClass(Objectification.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ObjectificationAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ObjectificationDeletedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<RolePlayerChangedEventArgs>(ObjectificationRolePlayerChangedEvent), action); propertyInfo = directory.FindDomainProperty(Objectification.IsImpliedDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ObjectificationChangedEvent), action); //Role player changes classInfo = directory.FindDomainClass(ObjectTypePlaysRole.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(RolePlayerAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(RolePlayerDeletedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<RolePlayerChangedEventArgs>(RolePlayerRolePlayerChangedEvent), action); //Error state changed classInfo = directory.FindDomainRelationship(ElementAssociatedWithModelError.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ModelElementErrorStateChangedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(FactTypeHasFactTypeInstance.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(ObjectTypeHasObjectTypeInstance.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(ValueConstraintHasValueRange.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(RolePathOwnerOwnsLeadRolePath.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathRolePlayedChangedHandler, action); classInfo = directory.FindDomainRelationship(RoleSubPathIsContinuationOfRolePath.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathRolePlayedChangedHandler, action); classInfo = directory.FindDomainRelationship(PathedRole.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(PathedRoleHasValueConstraint.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(LeadRolePathCalculatesCalculatedPathValue.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(FactTypeHasDerivationRule.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(SubtypeHasDerivationRule.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(ConstraintRoleSequenceHasJoinPath.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); classInfo = directory.FindDomainRelationship(SetComparisonConstraintHasRoleSequence.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); //ModalityChanged propertyInfo = directory.FindDomainProperty(SetConstraint.ModalityDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardGlyphChangeHandler, action); propertyInfo = directory.FindDomainProperty(SetComparisonConstraint.ModalityDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardGlyphChangeHandler, action); //RingType changed propertyInfo = directory.FindDomainProperty(RingConstraint.RingTypeDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardGlyphChangeHandler, action); //Preferred Identifier Changed propertyInfo = directory.FindDomainProperty(UniquenessConstraint.IsPreferredDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardGlyphChangeHandler, action); classInfo = directory.FindDomainClass(EntityTypeHasPreferredIdentifier.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, standardErrorPathDeletedHandler, action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<RolePlayerChangedEventArgs>(PreferredIdentifierRolePlayerChangedEvent), action); //ExclusiveOr added deleted classInfo = directory.FindDomainClass(ExclusiveOrConstraintCoupler.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ExclusiveOrAddedEvent), action); classInfo = directory.FindDomainClass(ExclusiveOrConstraintCoupler.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ExclusiveOrDeletedEvent), action); propertyInfo = directory.FindDomainProperty(ExclusionConstraint.NameDomainPropertyId); classInfo = directory.FindDomainClass(ExclusionConstraint.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ExclusiveOrNameChangedEvent), action); //SubType propertyInfo = directory.FindDomainProperty(SubtypeFact.ProvidesPreferredIdentifierDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardGlyphChangeHandler, action); //Grouping classInfo = directory.FindDomainClass(ElementGrouping.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(GroupingAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, standardDeleteHandler, action); propertyInfo = directory.FindDomainProperty(ElementGrouping.NameDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, standardNameChangedHandler, action); classInfo = directory.FindDomainRelationship(GroupingElementRelationship.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(GroupingElementAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(GroupingElementDeletedEvent), action); classInfo = directory.FindDomainRelationship(ElementGroupingContainsElementGrouping.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(NestedGroupingAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(NestedGroupingDeletedEvent), action); classInfo = directory.FindDomainRelationship(ElementGroupingIsOfElementGroupingType.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(GroupingTypeAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(GroupingTypeDeletedEvent), action); classInfo = directory.FindDomainRelationship(GroupingMembershipContradictionErrorIsForElement.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(GroupingContradictionErrorAddedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(GroupingContradictionErrorDeletedEvent), action); } }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> for <see cref="RolePlayerLink"/>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.FindDomainProperty(MandatoryConstraint.ModalityDomainPropertyId), new EventHandler<ElementPropertyChangedEventArgs>(InternalConstraintModalityChangedEvent), action); eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRelationship(FactSetConstraint.DomainClassId), new EventHandler<ElementAddedEventArgs>(InternalConstraintRoleSequenceAddedEvent), action); eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRelationship(ConstraintRoleSequenceHasRole.DomainClassId), new EventHandler<ElementDeletedEventArgs>(InternalConstraintRoleSequenceRoleRemovedEvent), action); }
/// <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); }
private void ManageErrorReportingEvents(ModelingEventManager eventManager, EventHandlerAction action) { Store store = Store; DomainDataDirectory dataDirectory = store.DomainDataDirectory; DomainClassInfo classInfo = dataDirectory.FindDomainRelationship(ModelHasError.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ErrorAddedEvent), action); classInfo = dataDirectory.FindDomainClass(ModelError.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ErrorRemovedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementPropertyChangedEventArgs>(ErrorChangedEvent), action); classInfo = dataDirectory.FindDomainRelationship(ModelHasModelErrorDisplayFilter.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementAddedEventArgs>(ErrorDisplayChangedEvent), action); classInfo = dataDirectory.FindDomainClass(ModelErrorDisplayFilter.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ErrorDisplayChangedEvent), action); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementPropertyChangedEventArgs>(ErrorDisplayChangedEvent), action); DomainPropertyInfo propertyInfo = dataDirectory.FindDomainProperty(ModelErrorDisplayFilter.ExcludedCategoriesDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ErrorDisplayChangedEvent), action); propertyInfo = dataDirectory.FindDomainProperty(ModelErrorDisplayFilter.ExcludedErrorsDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ErrorDisplayChangedEvent), action); propertyInfo = dataDirectory.FindDomainProperty(ModelErrorDisplayFilter.IncludedErrorsDomainPropertyId); eventManager.AddOrRemoveHandler(propertyInfo, new EventHandler<ElementPropertyChangedEventArgs>(ErrorDisplayChangedEvent), action); eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsEndedEventArgs>(ErrorEventsEnded), action); }
/// <summary> /// Manages event handlers in the store. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { }
/// <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); }
/// <summary> /// Manages <see cref="EventHandler{TEventArgs}"/>s in the <see cref="Store"/> so that the <see cref="ORMVerbalizationToolWindow"/> /// 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) { eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsEndedEventArgs>(ModelStateChangedEvent), action); } }
/// <summary> /// Manages event handlers in the store so that the tool window /// contents can be updated to reflect any model changes. /// </summary> protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action) { ReadingsViewForm form = myForm; ReadingEditor readingEditor = (form != null) ? form.ReadingEditor : null; if (readingEditor != null) { readingEditor.ManageEventHandlers(store, eventManager, action); } }
/// <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); }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { ManageModelingEventHandlers(eventManager, reasons, action); }
void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action) { if (0 != (reasons & EventSubscriberReasons.DocumentLoaded)) { Store store = Store; IPropertyProviderService propertyService = ((IFrameworkServices)store).PropertyProviderService; IExtensionVerbalizerService verbalizerService = ((IORMToolServices)store).ExtensionVerbalizerService; propertyService.AddOrRemovePropertyProvider(typeof(ORMModel), CustomPropertyProviders.CustomPropertiesEditor, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ORMModel), CustomPropertyProviders.Model, false, action); propertyService.AddOrRemovePropertyProvider(typeof(ObjectType), CustomPropertyProviders.ObjectType, true, action); propertyService.AddOrRemovePropertyProvider(typeof(SubtypeFact), CustomPropertyProviders.SubtypeFact, true, action); propertyService.AddOrRemovePropertyProvider(typeof(FactType), CustomPropertyProviders.FactType, false, action); propertyService.AddOrRemovePropertyProvider(typeof(Role), CustomPropertyProviders.Role, true, action); propertyService.AddOrRemovePropertyProvider(typeof(FrequencyConstraint), CustomPropertyProviders.FrequencyConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(MandatoryConstraint), CustomPropertyProviders.MandatoryConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(RingConstraint), CustomPropertyProviders.RingConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(UniquenessConstraint), CustomPropertyProviders.UniquenessConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(EqualityConstraint), CustomPropertyProviders.EqualityConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ExclusionConstraint), CustomPropertyProviders.ExclusionConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(SubsetConstraint), CustomPropertyProviders.SubsetConstraint, true, action); propertyService.AddOrRemovePropertyProvider(typeof(ValueConstraint), CustomPropertyProviders.ValueConstraint, true, action); if (verbalizerService != null) { verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ORMModel), DefaultVerbalizationProviders.Model, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ObjectType), DefaultVerbalizationProviders.ObjectType, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(SubtypeFact), DefaultVerbalizationProviders.SubtypeFact, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(FactType), DefaultVerbalizationProviders.FactType, false, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(Role), DefaultVerbalizationProviders.Role, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(FrequencyConstraint), DefaultVerbalizationProviders.FrequencyConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(MandatoryConstraint), DefaultVerbalizationProviders.MandatoryConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(RingConstraint), DefaultVerbalizationProviders.RingConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(UniquenessConstraint), DefaultVerbalizationProviders.UniquenessConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(EqualityConstraint), DefaultVerbalizationProviders.EqualityConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ExclusionConstraint), DefaultVerbalizationProviders.ExclusionConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(SubsetConstraint), DefaultVerbalizationProviders.SubsetConstraint, true, action); verbalizerService.AddOrRemoveExtensionVerbalizer(typeof(ValueConstraint), DefaultVerbalizationProviders.ValueConstraint, true, action); } } }