/// <summary> /// Retrieves all children of a specific parent element. This includes all model elements that are reachable /// from the parent element through the embedding relationship. /// </summary> /// <param name="parentElement">Parent element to retrieve children for.</param> /// <param name="bOnlyLocal">Specifies if children of the found children of the given element should be processed too.</param> /// <returns>List of model elements that are embedded under the parent element. May be empty.</returns> public virtual List <ModelElement> GetChildren(ModelElement parentElement, bool bOnlyLocal) { List <ModelElement> allChildren = new List <ModelElement>(); DomainClassInfo info = parentElement.GetDomainClass(); ReadOnlyCollection <DomainRoleInfo> roleInfoCol = info.AllDomainRolesPlayed; foreach (DomainRoleInfo roleInfo in roleInfoCol) { if (roleInfo.IsSource) { if ((parentElement as IDomainModelOwnable).Store.DomainDataAdvDirectory.IsEmbeddingRelationship(roleInfo.DomainRelationship.Id)) { global::System.Collections.Generic.IList <ElementLink> links = DomainRoleInfo.GetElementLinks <ElementLink>(parentElement, roleInfo.Id); foreach (ElementLink link in links) { ModelElement child = DomainRoleInfo.GetTargetRolePlayer(link); allChildren.Add(child); if (!bOnlyLocal) { allChildren.AddRange( (child as IDomainModelOwnable).GetDomainModelServices().ElementChildrenProvider.GetChildren(child, bOnlyLocal)); } } } } } return(allChildren); }
public void DeleteShapesForElement(DomainModelLink element) { if (element == null) { return; } DomainModelLink link = element; DiagramDomainDataDirectory data = link.Store.DomainDataAdvDirectory.ResolveExtensionDirectory <DiagramDomainDataDirectory>(); DomainModelElement m = DomainRoleInfo.GetSourceRolePlayer(link) as DomainModelElement; List <Guid> shapes = data.GetShapeTypesForElement(m.GetDomainClassId()); if (shapes == null) { return; } foreach (Guid g in shapes) { if (data.MappingRelationshipShapeInfos.ContainsKey(g)) { this.DeleteShapesForElement(m.Store, m.Id, g); return; } } }
private static ModelElement GetCompartmentElementFirstParent(ModelElement modelElement) { // Get the domain class associated with model element. DomainClassInfo domainClass = modelElement.GetDomainClass(); if (domainClass != null) { // A element is only considered to be in a compartment if it participates in only 1 embedding relationship // This might be wrong for some models if (domainClass.AllEmbeddedByDomainRoles.Count == 1) { // Get a collection of all the links to this model element // Since this is in a compartment there will only be one ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetAllElementLinks(modelElement); if (links.Count == 1) { // Get the model element participating in the link that isn't the current one // That will be the parent // Probably there is a better way to achieve the same result foreach (ModelElement linkedElement in links[0].LinkedElements) { if (!modelElement.Equals(linkedElement)) { return(linkedElement); } } } } } return(null); }
/// <summary> /// Gets the embedding domain element of a specific type for a given model element. /// </summary> /// <param name="modelElement">ModelElement to get the embedding domain element for.</param> /// <param name="parentTypeDomainClassId">Type of the embedding domain element to find.</param> /// <returns>Domain element as ModelElement if found. Null otherwise</returns> public virtual ModelElement GetEmbeddingParent(ModelElement modelElement, System.Guid parentTypeDomainClassId) { if (!(modelElement is DomainModelElement)) { return(null); } List <EmbeddingRelationshipAdvancedInfo> embeddings = (modelElement as DomainModelElement).Store.DomainDataAdvDirectory.FindDomainClassTargetEmbeddings((modelElement as DomainModelElement).GetDomainClassId()); if (embeddings != null) { foreach (EmbeddingRelationshipAdvancedInfo emb in embeddings) { IList <ElementLink> links = DomainRoleInfo.GetElementLinks <ElementLink>(modelElement, emb.TargetRoleId); if (links.Count == 1) { ModelElement m = DomainRoleInfo.GetSourceRolePlayer(links[0]); if (m.GetDomainClass().IsDerivedFrom(parentTypeDomainClassId)) { return(m); } return(GetEmbeddingParent(m, parentTypeDomainClassId)); } } } return(null); }
private static void ProcessModelErrorChange(ModelHasError errorLink) { ModelError error = errorLink.Error; // Give the error itself a chance to have an indirect owner. // A ModelError can own itself. InvalidateIndirectErrorOwnerDisplay(error, null, null); DomainClassInfo classInfo = error.GetDomainClass(); ReadOnlyCollection <DomainRoleInfo> playedMetaRoles = classInfo.AllDomainRolesPlayed; int playedMetaRoleCount = playedMetaRoles.Count; for (int i = 0; i < playedMetaRoleCount; ++i) { DomainRoleInfo roleInfo = playedMetaRoles[i]; if (roleInfo.Id != ModelHasError.ErrorDomainRoleId) { LinkedElementCollection <ModelElement> rolePlayers = roleInfo.GetLinkedElements(error); int rolePlayerCount = rolePlayers.Count; for (int j = 0; j < rolePlayerCount; ++j) { ModelElement rolePlayer = rolePlayers[j]; InvalidateErrorOwnerDisplay(rolePlayer); InvalidateIndirectErrorOwnerDisplay(rolePlayer, null, null); } } } }
/// <summary> /// This method is called when the rule is fired, that is when a compartment entry is deleting from the model. /// </summary> /// <param name="e">the ElementDeletingEventArgs</param> public override void ElementDeleting(ElementDeletingEventArgs e) { // it is not easy to find the compartment parent of a compartment entry if (e.ModelElement != null) { foreach (ElementLink link in DomainRoleInfo.GetAllElementLinks(e.ModelElement)) { // I have to find the ElementLink where the compartment entry is the target if (DomainRoleInfo.GetTargetRolePlayer(link) == e.ModelElement) { // and check if this ElementLink is annotated with the DomainRelationshipAttribute object[] attrs = link.GetType().GetCustomAttributes(typeof(DomainRelationshipAttribute), true); if (attrs.Length > 0) { DomainRelationshipAttribute attr = attrs[0] as DomainRelationshipAttribute; if (attr != null) { // and only if the DomainRelationshipAttribute is set to IsEmbedding == true if (attr.IsEmbedding) // follow only embedded links - there is only one embedded link with a concret class (the child) as target { // finally we found the parent of the compartment entry ModelElement parent = DomainRoleInfo.GetSourceRolePlayer(link); // check all links from parent if anyone uses this child as source or target DeleteReferencesFromParentToChild(parent, e.ModelElement); } } } } } } }
/// <summary> /// ChangeRule: typeof(ORMBaseBinaryLinkShape), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AutoLayoutShapesRulePriority; /// Keep relative child elements a fixed distance away from the fact /// when the shape changes. /// </summary> private static void LinkChangeRule(ElementPropertyChangedEventArgs e) { Guid attributeId = e.DomainProperty.Id; if (attributeId == ORMBaseBinaryLinkShape.EdgePointsDomainPropertyId) { ORMBaseBinaryLinkShape parentShape = e.ModelElement as ORMBaseBinaryLinkShape; LinkedElementCollection <ShapeElement> childShapes = parentShape.RelativeChildShapes; int childCount = childShapes.Count; for (int i = 0; i < childCount; ++i) { LinkConnectorShape linkConnector = childShapes[i] as LinkConnectorShape; if (linkConnector != null) { RectangleD bounds = parentShape.AbsoluteBoundingBox; linkConnector.Location = new PointD(bounds.Width / 2, bounds.Height / 2); ReadOnlyCollection <LinkConnectsToNode> links = DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(linkConnector, LinkConnectsToNode.NodesDomainRoleId); int linksCount = links.Count; for (int j = 0; j < linksCount; ++j) { LinkConnectsToNode link = links[j]; BinaryLinkShape linkShape = link.Link as BinaryLinkShape; if (linkShape != null) { // Changing the location is not reliably reconnecting all shapes, especially // during load. Force the link to reconnect with a RecalculateRoute call linkShape.RecalculateRoute(); } } break; } } } }
/// <summary> /// Update source and target dependency parts. /// </summary> protected virtual void UpdateParts() { if (this.MainElement == null) { return; } DomainClassInfo elementInfo = this.MainElement.GetDomainClass(); Dictionary <Guid, GraphicalDependencyShape> sParts = new Dictionary <Guid, GraphicalDependencyShape>(); Dictionary <Guid, GraphicalDependencyShape> tParts = new Dictionary <Guid, GraphicalDependencyShape>(); ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetAllElementLinks(this.MainElement); foreach (ElementLink link in links) { DomainRelationshipInfo info = link.GetDomainRelationship(); if (this.Store.DomainDataAdvDirectory.IsReferenceIncludedInModel(info.Id)) { if (DomainRoleInfo.GetSourceRolePlayer(link) == this.MainElement) { UpdatePart(elementInfo.Id, tParts, true, link, info); } else { UpdatePart(elementInfo.Id, sParts, false, link, info); } } } }
/// <summary> /// Gets the linked elements for the specified element. /// </summary> /// <param name="element">The element.</param> /// <param name="masterDictionary">A master dictionary of all elements</param> /// <param name="localDictionary">A local dictionary for this pass through. /// Allows us to track multiple passes while iterating through the elements of another dictionary.</param> /// <param name="generations">The generations.</param> private static void GetLinkedElements(IHierarchyContextEnabled element, Dictionary<IHierarchyContextEnabled, int> masterDictionary, ref Dictionary<IHierarchyContextEnabled, int> localDictionary, int generations) { ModelElement mel = (ModelElement)element; Type contextType = typeof(IHierarchyContextEnabled); foreach (DomainRoleInfo roleInfo in mel.GetDomainClass().AllDomainRolesPlayed) { DomainRoleInfo oppositeRole = roleInfo.OppositeDomainRole; Type oppositeType = oppositeRole.RolePlayer.ImplementationClass; if (!oppositeType.IsAbstract && contextType.IsAssignableFrom(oppositeType)) { foreach (ElementLink link in roleInfo.GetElementLinks(mel, true)) // Exclude derived, these will also be played roles and be picked up. { IHierarchyContextLinkFilter filter = link as IHierarchyContextLinkFilter; if (filter != null && !filter.ContinueHierachyWalking(roleInfo)) { continue; } ModelElement oppositeMel = oppositeRole.GetRolePlayer(link); if (oppositeMel == mel) { continue; } IHierarchyContextEnabled contextableElement = (IHierarchyContextEnabled)oppositeMel; // Cast must work, already checked at the type level int decrement = contextableElement.HierarchyContextDecrementCount; if (masterDictionary.Count == 1 && contextableElement.ForwardHierarchyContextTo != null) { decrement = 0; } GetRelatedContextableElementsHelper(contextableElement, masterDictionary, ref localDictionary, generations - decrement); } } } }
/// <summary> /// Test if null is allowed for the provided link. /// </summary> /// <param name="link">The current element link for /// the component associated with this role player</param> /// <returns></returns> public virtual bool CanAllowNull(ElementLink link) { if (link == null) { return(true); } DomainRoleInfo targetDomainRole = DomainRoleInfo; DomainRoleInfo sourceDomainRole = targetDomainRole.OppositeDomainRole; bool sourceIsOptional = sourceDomainRole.IsOptional; if (sourceIsOptional && targetDomainRole.IsOptional) { // We previously determined that we always allow null. return(true); } if (sourceIsOptional) { // The source role is optional, but the target role isn't. However, // we need to check/ for other instances of this type of relationship // that satisfy that. if (targetDomainRole.Multiplicity == Multiplicity.OneMany) { ModelElement targetPlayer = targetDomainRole.GetRolePlayer(link); if (targetDomainRole.GetElementLinks <ElementLink>(targetPlayer).Count > 1) { // There is at least one other instance of this type of relationship, // which means that the "mandatory" on the target role would still be // satisfied even if this link were to be deleted. return(true); } } } return(false); }
/// <summary> /// Looks for compartment connections of Type CONNECTION on the compartment parent that have the /// compartment element as source or target and deletes this compartment connection from the model. /// </summary> /// <param name="parent"></param> /// <param name="element"></param> private void DeleteReferencesFromParentToChild(ModelElement parent, ModelElement element) { // i don't want to change my list inside the foreach loop List <ElementLink> toDelete = new List <ElementLink>(); foreach (ElementLink link in DomainRoleInfo.GetAllElementLinks(parent)) { if (link is CONNECTION) { if ((DomainRoleInfo.GetSourceRolePlayer(link) == parent && element is SOURCE_COMPARTMENT_ENTRY && GetBuilderInstance().IsEntryConnectionSource(element as SOURCE_COMPARTMENT_ENTRY, (CONNECTION)link)) || (DomainRoleInfo.GetTargetRolePlayer(link) == parent && element is TARGET_COMPARTMENT_ENTRY && GetBuilderInstance().IsEntryConnectionTarget(element as TARGET_COMPARTMENT_ENTRY, (CONNECTION)link))) { toDelete.Add(link); } } } // now do the deleting foreach (ElementLink link in toDelete) { link.Delete(); } }
private static ModelElement GetCompartmentElementFirstParentElement(this ModelElement modelElement) { // Get the domain class associated with model element. DomainClassInfo domainClass = modelElement.GetDomainClass(); if (domainClass != null) { // A element is only considered to be in a compartment if it participates in only 1 embedding relationship // This might be wrong for some models if (domainClass.AllEmbeddedByDomainRoles.Count == 1) { DomainRoleInfo roleInfo = domainClass.AllEmbeddedByDomainRoles[0]; // Get a collection of all the links to this model element // Since this is in a compartment there should be at least one // There can be only one. if (roleInfo != null) { ElementLink link = roleInfo.GetElementLinks(modelElement).FirstOrDefault(); // Get the model element participating in the link that isn't the current one // That will be the parent // Probably there is a better way to achieve the same result return(link?.LinkedElements?.FirstOrDefault(linkedElement => !modelElement.Equals(linkedElement))); } } } return(null); }
/// <summary> /// Unsubscribes from a specific event. /// </summary> /// <param name="domainRoleInfo">Domain role info specifying when to unsubscribe.</param> /// <param name="elementLinkId">Link id specifying when to unsubscribe.</param> /// <param name="action">Action identifying what to unsubscribe.</param> public void Unsubscribe(DomainRoleInfo domainRoleInfo, Guid elementLinkId, Action <RolePlayerChangedEventArgs> action) { lock (dictionaryOnRoleInfoElementId) { if (dictionaryOnRoleInfoElementId.Keys.Contains(domainRoleInfo.Id)) { if (dictionaryOnRoleInfoElementId[domainRoleInfo.Id].Keys.Contains(elementLinkId)) { IEventSubscription eventSubscription = dictionaryOnRoleInfoElementId[domainRoleInfo.Id][elementLinkId].Cast <EventSubscription <RolePlayerChangedEventArgs> >().FirstOrDefault(evt => evt.Action == action); if (eventSubscription != null) { dictionaryOnRoleInfoElementId[domainRoleInfo.Id][elementLinkId].Remove(eventSubscription); if (dictionaryOnRoleInfoElementId[domainRoleInfo.Id][elementLinkId].Count == 0) { dictionaryOnRoleInfoElementId[domainRoleInfo.Id].Remove(elementLinkId); } if (dictionaryOnRoleInfoElementId[domainRoleInfo.Id].Count == 0) { dictionaryOnRoleInfoElementId.Remove(domainRoleInfo.Id); } } } } } }
/* * public override void AddCommandHandlers(System.ComponentModel.Design.IMenuCommandService menuCommandService) * { * // NB this removes the Add command for all nodes / domain classes. Haven't * // worked out how to be more selective than this yet! * * // Let the base class set up the command handlers * base.AddCommandHandlers(menuCommandService); * * * findDependencies = new MenuCommand(new EventHandler(ONFindDToImportedModels), * new CommandID(GuidSymbol, IDSymbol)); * findDependencies.Enabled = false; * findDependencies.Visible = false; * * menuCommandService.AddCommand(findDependencies); * / * } * * * private void ONFindDToImportedModels(object sender, EventArgs args) * { * if (this.SelectedElement is MetaModelLibrary) * { * List<ModelElement> classes = new List<ModelElement>(); * foreach (ModelContext m in (this.SelectedElement as MetaModelLibrary).MetaModel.ModelContexts) * { * foreach (DomainClass d in m.Classes) * { * classes.Add(d); * classes.AddRange(d.Properties); * classes.AddRange(d.RolesPlayed); * } * } * * DependenciesViewModel vm = new DependenciesViewModel(LanguageDSLDocData.ViewModelStore, false); * List<ModelElement> metaModels = new List<ModelElement>(); * metaModels.Add((this.SelectedElement as MetaModelLibrary).MetaModel); * vm.Set(classes, metaModels, LanguageDSLDependenciesItemsProvider.GetAllCategories()); * * bool bDelete = true; * if (vm.ActiveDependencies.Count > 0) * { * * DeleteElementsPopup popup = new DeleteElementsPopup(); * popup.DataContext = vm; * if (popup.ShowDialog().Value != true) * bDelete = false; * } * * if (bDelete) * (this.SelectedElement as MetaModelLibrary).UnloadLibrary(); * * vm.Dispose(); * GC.Collect(); * } * } */ /// <summary> /// Query whether the specified role should be considered a candidate for addition /// through the explorer add menus. /// </summary> /// <param name="element"></param> /// <param name="role"></param> /// <returns></returns> protected override bool IsAddableRoleForElement(ModelElement element, DomainRoleInfo role) { if (element is MetaModel) { /* * if (role.Id == MetaModelHasClasses.MetaModelDomainRoleId || * role.Id == MetaModelHasRelationships.MetaModelDomainRoleId || * role.Id == MetaModelHasDiagramClasses.MetaModelDomainRoleId) * return false; */ } if (element is DiagramClass) { if (role.Id == DiagramClassHasPresentationElements.DiagramClassDomainRoleId) { return(false); } } if (element is MetaModelLibrary) { if (role.Id == MetaModelLibraryHasImportedLibrary.MetaModelLibraryDomainRoleId) { return(false); } } return(base.IsAddableRoleForElement(element, role)); }
/// <summary> /// Delete element executed. /// </summary> protected virtual void DeleteElementCommand_Executed() { if (SelectedObject != null) { ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetElementLinks <ElementLink>(this.Elements[0] as ModelElement, this.SourceRoleId); foreach (ElementLink link in links) { ModelElement target = DomainRoleInfo.GetRolePlayer(link, this.TargetRoleId); if (SelectedObject.Element == target) { try { using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Delete relationship")) { link.Delete(); transaction.Commit(); } } catch (Exception ex) { System.Windows.MessageBox.Show("Error while deleting: " + ex.Message); } break; } } } }
public override RoleGroupTreeNode CreateRoleGroupTreeNode(DomainRoleInfo targetRoleInfo) { if (targetRoleInfo == null) { throw new ArgumentNullException(nameof(targetRoleInfo)); } Type representedType = targetRoleInfo.LinkPropertyInfo.PropertyType; if (!nodeEventHandlersAdded.Contains(representedType)) { DomainClassInfo domainClassInfo = ModelingDocData.Store.DomainDataDirectory.FindDomainClass(representedType); ModelingDocData.Store.EventManagerDirectory.ElementAdded.Add(domainClassInfo, new EventHandler <ElementAddedEventArgs>(AddedHandler)); ModelingDocData.Store.EventManagerDirectory.ElementDeleted.Add(domainClassInfo, new EventHandler <ElementDeletedEventArgs>(DeletedHandler)); ModelingDocData.Store.EventManagerDirectory.ElementPropertyChanged.Add(domainClassInfo, new EventHandler <ElementPropertyChangedEventArgs>(ChangedHandler)); nodeEventHandlersAdded.Add(representedType); } RoleGroupTreeNode roleGroupTreeNode = new EFModelRoleGroupTreeNode(targetRoleInfo); if (ObjectModelBrowser.ImageList != null) { roleGroupTreeNode.DefaultImageIndex = 1; } return(roleGroupTreeNode); }
/// <summary> /// Initializes the resources for each instance of the connector. /// </summary> protected override void InitializeInstanceResources() { base.InitializeInstanceResources(); // TODO: Need to find a better pattern for connectors, becuase this code never executes as a connector does not have a non-null MEL // to get to the target MEL from. // Set tailorable colors (based upon the target element) ElementLink link = this.Subject as ElementLink; if (link != null) { NamedElementSchema targetElement = DomainRoleInfo.GetTargetRolePlayer(link) as NamedElementSchema; if ((targetElement != null) && (targetElement.IsInheritedFromBase)) { // Set tailoring styles for this instance. this.SetShapeBrushColor(DiagramBrushes.ConnectionLineDecorator, this.TailoringColors.TextColor); this.SetShapePenColor(DiagramPens.ConnectionLine, this.TailoringColors.OutlineColor); this.SetShapePenColor(DiagramPens.ConnectionLineDecorator, this.TailoringColors.OutlineColor); this.SetShapeBrushColor(DiagramBrushes.ShapeText, this.TailoringColors.TextColor); } else { // Reset to orginally configured styles for this instance. this.InitializeResources(this.StyleSet); } } else { // Reset to orginally configured styles for this instance. this.InitializeResources(this.StyleSet); } }
/// <summary> /// Returns all non abstract derived classes of the given elements. /// </summary> private static List <AttributedDomainElement> GetNonAbstractDerivedElements(AttributedDomainElement child) { List <AttributedDomainElement> derivedClassesCollection = new List <AttributedDomainElement>(); if (child is DomainClass) { ReadOnlyCollection <DomainClassReferencesBaseClass> derivedClasses = DomainRoleInfo.GetElementLinks <DomainClassReferencesBaseClass>(child, DomainClassReferencesBaseClass.BaseClassDomainRoleId); foreach (DomainClassReferencesBaseClass c in derivedClasses) { if (c.DerivedClass.InheritanceModifier != InheritanceModifier.Abstract) { derivedClassesCollection.Add(c.DerivedClass); } derivedClassesCollection.AddRange(GetNonAbstractDerivedElements(c.DerivedClass)); } } else if (child is DomainRelationship) { ReadOnlyCollection <DomainRelationshipReferencesBaseRelationship> derivedClasses = DomainRoleInfo.GetElementLinks <DomainRelationshipReferencesBaseRelationship>(child, DomainRelationshipReferencesBaseRelationship.BaseRelationshipDomainRoleId); foreach (DomainRelationshipReferencesBaseRelationship c in derivedClasses) { if (c.DerivedRelationship.InheritanceModifier != InheritanceModifier.Abstract) { derivedClassesCollection.Add(c.DerivedRelationship); } derivedClassesCollection.AddRange(GetNonAbstractDerivedElements(c.DerivedRelationship)); } } return(derivedClassesCollection); }
/// <summary> /// ChangeRule: typeof(RingConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority; /// </summary> private static void RingConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == RingConstraint.RingTypeDomainPropertyId) { RingConstraint ringConstraint = (RingConstraint)e.ModelElement; if (!ringConstraint.IsDeleted) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(ringConstraint)) { RingConstraintShape ringConstraintShape = pel as RingConstraintShape; if (ringConstraintShape != null) { foreach (LinkConnectsToNode connection in DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(ringConstraintShape, LinkConnectsToNode.NodesDomainRoleId)) { BinaryLinkShape binaryLink = connection.Link as BinaryLinkShape; if (binaryLink != null) { binaryLink.RecalculateRoute(); } } SizeD oldSize = ringConstraintShape.Size; ringConstraintShape.AutoResize(); if (oldSize == ringConstraintShape.Size) { ringConstraintShape.InvalidateRequired(true); } } } } } }
public override RoleTreeNode CreateRoleTreeNode(DomainRoleInfo targetRoleInfo) { var roleNode = base.CreateRoleTreeNode(targetRoleInfo); roleNode.ImageIndex = -1; return(roleNode); }
public virtual void AddRSShapesForElement(DomainModelLink modelElement) { if (modelElement == null) { return; } DiagramDomainDataDirectory data = modelElement.Store.DomainDataAdvDirectory.ResolveExtensionDirectory <DiagramDomainDataDirectory>(); if (data == null) { throw new ArgumentNullException("DiagramDomainDataDirectory"); } List <Guid> shapes = data.GetShapeTypesForElement(modelElement.GetDomainClassId()); if (shapes != null) { if (shapes.Count > 0) { DomainModelElement source = DomainRoleInfo.GetSourceRolePlayer(modelElement) as DomainModelElement; DomainModelElement target = DomainRoleInfo.GetTargetRolePlayer(modelElement) as DomainModelElement; foreach (Guid shape in shapes) { AddRSShapesForElement(source, target, modelElement, shape); } } } }
/* * /// <summary> * /// Tries to find a free position on parent and update the location of the shape to that location. * /// </summary> * /// <returns> * /// Coordinates of a free position. * /// </returns> * /// <remarks> * /// Needs to be called within a modeling transaction. * /// </remarks> * public virtual void SetAtFreePositionOnParent() * { * IList<NodeShape> shapes; * if (this.Parent == null) * { * // free position on diagram * Diagram diagram = this.Diagram; * shapes = diagram.Children; * } * else * { * if (this.IsRelativeChildShape) * { * float width = (float)this.Bounds.Width; * float height = (float)this.Bounds.Height; * * float parentWidth = (float)this.Parent.Bounds.Width; * float parentHeight = (float)this.Parent.Bounds.Height; * * Dictionary<PortPlacement, int> dict = new Dictionary<PortPlacement, int>(); * dict.Add(PortPlacement.Left, 0); * dict.Add(PortPlacement.Top, 0); * dict.Add(PortPlacement.Bottom, 0); * dict.Add(PortPlacement.Right, 0); * for (int i = 0; i < this.Parent.RelativeChildren.Count; i++) * { * if (this.Parent.RelativeChildren[i] == this) * continue; * * dict[this.Parent.RelativeChildren[i].PlacementSide]++; * } * List<KeyValuePair<PortPlacement, int>> myList = new List<KeyValuePair<PortPlacement, int>>(dict); * myList.Sort((firstPair, nextPair) => * { * return firstPair.Value.CompareTo(nextPair.Value); * }); * * foreach (KeyValuePair<PortPlacement, int> p in myList) * { * RectangleF rectH; * switch (p.Key) * { * case PortPlacement.Left: * rectH = new RectangleF(-width / 2, 0, width, parentHeight); * break; * * case PortPlacement.Top: * rectH = new RectangleF(0, -height / 2, parentWidth, height); * break; * * case PortPlacement.Right: * rectH = new RectangleF(parentWidth - width / 2, 0, width, parentHeight); * break; * * case PortPlacement.Bottom: * rectH = new RectangleF(0, parentHeight - height / 2, parentWidth, height); * break; * * default: * throw new NotSupportedException(); * } * * if (SetPortAtFreePositionOnParent(p.Key, rectH)) * { * return; * } * } * * this.SetLocation(NodeShape.CorrectPortLocation(this.Parent, this, new PointD(0, 0))); * return; * } * * // free position on parent shape * shapes = this.Parent.NestedChildren; * } * * // trivial algo.. TODO: find something good * RectangleF rect = new RectangleF(0, 0, (float)this.Size.Width, (float)this.Size.Height); * * // find area that is already filled * RectangleF completeBounds = new RectangleF(0, 0, 0, 0); * for (int i = 0; i < shapes.Count; i++) * { * if (shapes[i] == this) * continue; * * if (i == 0) * completeBounds = shapes[i].Bounds.ToRectangleF(); * else * { * RectangleF f = shapes[i].Bounds.ToRectangleF(); * if (completeBounds.X > f.X) * completeBounds.X = f.X; * if (completeBounds.Y > f.Y) * completeBounds.Y = f.Y; * * if (completeBounds.Right < f.Right) * completeBounds.Width = f.Right - completeBounds.X; * * if (completeBounds.Bottom < f.Bottom) * completeBounds.Height = f.Bottom - completeBounds.Y; * } * } * * /* * // see if we can insert shape somewhere in that area * // if not, add shape right at the edge of that area * for (int i = 0; i < shapes.Count; i++) * { * if (shapes[i] == this) * continue; * * // TODO ... (not necessaraly required) * } * * // could not add shape in the completeBounds are, so add it outside of it */ /* * if( completeBounds.Width < completeBounds.Height ) * this.SetLocation(new PointD(completeBounds.Right + 5, 5)); * else * this.SetLocation(new PointD(5, completeBounds.Bottom + 5)); * this.UpdateAbsoluteLocation(); * } * * private bool SetPortAtFreePositionOnParent(PortPlacement side, RectangleF freeRectangle) * { * List<RectangleF> freeRectangles = new List<RectangleF>(); * freeRectangles.Add(freeRectangle); * * for (int i = 0; i < this.Parent.RelativeChildren.Count; i++) * { * if (this.Parent.RelativeChildren[i] == this) * continue; * * if (this.Parent.RelativeChildren[i].PlacementSide != side) * continue; * * RectangleF s = this.Parent.RelativeChildren[i].Bounds.ToRectangleF(); * for (int y = freeRectangles.Count - 1; y >= 0; y--) * { * RectangleF r = freeRectangles[y]; * RectangleF t = r; * r.Intersect(s); * * if (!r.IsEmpty) * { * // remove r from freeRectangley[y] --> yields <=2 rects * // add 2 rects to freeRectangles * freeRectangles.RemoveAt(y); * * switch (side) * { * case PortPlacement.Left: * case PortPlacement.Right: * if (t.Y < r.Y) * { * // first r * RectangleF r1 = new RectangleF(t.X, t.Y, t.Width, r.Y - t.Y); * freeRectangles.Add(r1); * } * * if (r.Bottom < t.Bottom) * { * // second r * RectangleF r2 = new RectangleF(t.X, r.Bottom, t.Width, t.Bottom - r.Bottom); * freeRectangles.Add(r2); * } * break; * * case PortPlacement.Top: * case PortPlacement.Bottom: * if (t.X < r.X) * { * // first r * RectangleF r1 = new RectangleF(t.X, t.Y, r.X-t.X, t.Height); * freeRectangles.Add(r1); * } * * if (r.Right < t.Right) * { * // second r * RectangleF r2 = new RectangleF(r.Right, t.Y, t.Right-r.Right, t.Height); * freeRectangles.Add(r2); * } * break; * } * * } * } * } * * // try to place at a fitting free rectangle * foreach (RectangleF r in freeRectangles) * { * if (r.Width >= this.Bounds.Width && r.Height >= this.Bounds.Height) * { * this.Location = new PointD(r.X, r.Y); * this.PlacementSide = side; * this.UpdateAbsoluteLocation(); * return true; * } * } * * return false; * } */ /// <summary> /// Create missing shapes. /// </summary> public virtual void FixUpMissingShapes() { if (this.Element == null) { return; } DomainModelElement e = this.Element as DomainModelElement; IDomainModelServices topMost = e.GetDomainModelServices().TopMostService; DiagramDomainDataDirectory data = this.Store.DomainDataAdvDirectory.ResolveExtensionDirectory <DiagramDomainDataDirectory>(); List <EmbeddingRelationshipAdvancedInfo> infos = this.Store.DomainDataAdvDirectory.FindDomainClassSourceEmbeddings(e.GetDomainClassId()); if (infos != null) { foreach (EmbeddingRelationshipAdvancedInfo info in infos) { List <Guid> shapes = data.GetShapeTypesForElement(info.TargetElementDomainClassId); if (shapes == null) { continue; } if (shapes.Count == 0) { continue; } ReadOnlyCollection <ElementLink> instances = DomainRoleInfo.GetElementLinks <ElementLink>(this.Element, info.SourceRoleId); foreach (ElementLink link in instances) { DomainModelElement child = DomainRoleInfo.GetTargetRolePlayer(link) as DomainModelElement; if (child == null) { continue; } // see if we need to add shape foreach (Guid elementShapeId in data.GetShapeTypesForElement(child.GetDomainClassId(), this.GetDomainClassId())) { if (!DiagramHelper.IsElementDisplayedOn(this, elementShapeId, child.Id)) { NodeShape shape = topMost.ShapeProvider.CreateShapeForElement(elementShapeId, child) as NodeShape; if (shape.IsRelativeChildShape) { this.AddRelativeChild(shape); } else { this.AddNestedChild(shape); } shape.FixUpMissingShapes(); } } } } } }
/// <summary> /// Gets the <see cref="IORMExtendableElement"/> that the extension <see cref="ModelElement"/> specified /// by <paramref name="extensionElement"/> is attached to. /// </summary> public static IORMExtendableElement GetExtendedElement(ModelElement extensionElement) { if (extensionElement == null) { throw new ArgumentNullException("extensionElement"); } return((IORMExtendableElement)DomainRoleInfo.GetLinkedElement(extensionElement, ORMModelElementHasExtensionElement.ExtensionDomainRoleId)); }
/// <summary> /// Gets the <see cref="IORMExtendableElement"/> that the extension <see cref="ModelError"/> specified /// by <paramref name="extensionError"/> is attached to. /// </summary> public static IORMExtendableElement GetExtendedErrorOwnerElement(ModelError extensionError) { if (extensionError == null) { throw new ArgumentNullException("extensionError"); } return((IORMExtendableElement)DomainRoleInfo.GetLinkedElement(extensionError, ORMModelElementHasExtensionModelError.ExtensionModelErrorDomainRoleId)); }
/// <summary> /// Replaces <see cref="ElementTypeDescriptor.GetRolePlayerPropertyAttributes"/>. /// </summary> /// <seealso cref="ElementTypeDescriptor.GetRolePlayerPropertyAttributes"/> protected new Attribute[] GetRolePlayerPropertyAttributes(DomainRoleInfo domainRole) { if (domainRole == null) { throw new ArgumentNullException("domainRole"); } return(EditorUtility.GetAttributeArray(DomainTypeDescriptor.GetRawAttributes(domainRole.LinkPropertyInfo))); }
/// <summary>Constructor</summary> /// <param name="metaRole">Role represented by this node</param> public EFModelRoleGroupTreeNode(DomainRoleInfo metaRole) : base(metaRole) { string propertyDisplayName = metaRole.OppositeDomainRole.PropertyDisplayName; displayTextBase = !string.IsNullOrEmpty(propertyDisplayName) ? propertyDisplayName : metaRole.OppositeDomainRole.PropertyName; }
private void OnChildElementAdded(ElementAddedEventArgs args) { ElementLink relationship = args.ModelElement as ElementLink; if (DomainRoleInfo.GetSourceRolePlayer(relationship) == Element) { AddChildElement(relationship, DomainRoleInfo.GetTargetRolePlayer(relationship), false); } }
private void OnChildElementDeleted(ElementDeletedEventArgs args) { ElementLink relationship = args.ModelElement as ElementLink; if (DomainRoleInfo.GetSourceRolePlayer(relationship) == Element) { RemoveChildElement(DomainRoleInfo.GetTargetRolePlayer(relationship)); } }
/// <summary> /// Initializes a new instance of <see cref="ObjectifyingEntityTypePropertyDescriptor"/>. /// </summary> public ObjectifyingEntityTypePropertyDescriptor(FactType sourcePlayer, DomainRoleInfo domainRole, Attribute[] sourceDomainRoleInfoAttributes) : base(sourcePlayer, domainRole, sourceDomainRoleInfoAttributes) { // The base class constructor has already checked domainRole for null. if (domainRole.Id != Objectification.NestingTypeDomainRoleId) { throw new ArgumentException(); } }
private ModelElement GetTargetOfRelationship(DomainRelationshipInfo info, ElementLink elementLink) { if (elementLink == null) { return(null); } return(DomainRoleInfo.GetTargetRolePlayer(elementLink)); }
/// <summary> /// Initializes a new instance of <see cref="ObjectifiedFactTypePropertyDescriptor"/>. /// </summary> public ObjectifiedFactTypePropertyDescriptor(ObjectType sourcePlayer, DomainRoleInfo domainRole, Attribute[] sourceDomainRoleInfoAttributes) : base(sourcePlayer, domainRole, sourceDomainRoleInfoAttributes) { // The base class constructor has already checked domainRole for null. if (domainRole.Id != Objectification.NestedFactTypeDomainRoleId) { throw new ArgumentException(); } Objectification objectification; myIsReadOnly = null != (objectification = sourcePlayer.Objectification) && objectification.IsImplied; }
public override void SetUniqueName(ModelElement element, ModelElement container, DomainRoleInfo embeddedDomainRole, string baseName) { if (element == null) { throw new ArgumentNullException("element"); } if (container == null) { throw new ArgumentNullException("container"); } if (baseName == null) { throw new ArgumentNullException("baseName"); } if (embeddedDomainRole == null) { throw new ArgumentNullException("embeddedDomainRole"); } Debug.Assert(DomainProperty.PropertyType == typeof(string), "Why isn't the inherent domain property type a string?"); // we want to make sure that we pick a unique name for the property that does not conflict with any other property name in the owning // entity type's inheritance tree (if there is one). var property = element as Property; if (property != null && property.EntityType != null) { var viewModel = property.EntityType.EntityDesignerViewModel; if (viewModel.ModelXRef != null) { // use the xref to obtain the EntityType EFObject that represents this view model element in order to query it var modelEntityType = viewModel.ModelXRef.GetExisting(property.EntityType) as ConceptualEntityType; Debug.Assert(modelEntityType != null, "Where is the model EFObject associated with this view model element?"); if (modelEntityType != null) { baseName = property is ScalarProperty ? Model.Entity.Property.DefaultPropertyName : ComplexConceptualProperty.DefaultComplexPropertyName; property.Name = ModelHelper.GetUniqueConceptualPropertyName( propertyNameCandidate: baseName, entityType: modelEntityType, alwaysAddSuffix: true); return; } } } base.SetUniqueName(element, container, embeddedDomainRole, baseName); }
public override void SetUniqueName(ModelElement element, ModelElement container, DomainRoleInfo embeddedDomainRole, string baseName) { Guard.NotNull(() => element, element); Guard.NotNull(() => embeddedDomainRole, embeddedDomainRole); Guard.NotNull(() => baseName, baseName); if (this.DomainProperty.PropertyType == typeof(string)) { // Ensure name is unique across whole model for this kind of element base.SetUniqueNameCore(element, baseName, GetElementNames(element)); } else { base.SetUniqueName(element, container, embeddedDomainRole, baseName); } }
public virtual VisitorFilterResult ShouldVisitRolePlayer( ElementWalker walker, ModelElement sourceElement, ElementLink elementLink, DomainRoleInfo targetDomainRole, ModelElement targetRolePlayer) { Guard.ArgumentNotNull(targetDomainRole, "targetDomainRole"); if(targetDomainRole.IsEmbedding) { return VisitorFilterResult.DoNotCare; } return VisitorFilterResult.Yes; }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="domainRelationshipInfo">Relationship domain class info.</param> /// <param name="sourceRoleId">RoleId of the source role player. </param> protected RoleEditorViewModel(ViewModelStore viewModelStore, DomainRelationshipInfo domainRelationshipInfo, Guid sourceRoleId) : base(viewModelStore) { this.domainRelationshipInfo = domainRelationshipInfo; if (domainRelationshipInfo.DomainRoles[0].Id == sourceRoleId) { sourceDomainRoleInfo = domainRelationshipInfo.DomainRoles[0]; targetDomainRoleInfo = domainRelationshipInfo.DomainRoles[1]; } else { sourceDomainRoleInfo = domainRelationshipInfo.DomainRoles[1]; targetDomainRoleInfo = domainRelationshipInfo.DomainRoles[0]; } this.isDefaultValuesSourceDynamic = true; this.Sort = SortByName; }
public virtual VisitorFilterResult ShouldVisitRelationship( ElementWalker walker, ModelElement sourceElement, DomainRoleInfo sourceRoleInfo, DomainRelationshipInfo domainRelationshipInfo, ElementLink targetRelationship) { Guard.ArgumentNotNull(sourceElement, "sourceElement"); Guard.ArgumentNotNull(domainRelationshipInfo, "domainRelationshipInfo"); Guard.ArgumentNotNull(targetRelationship, "targetRelationship"); if(!(sourceElement is ShapeElement)) { foreach(DomainRoleInfo info in domainRelationshipInfo.DomainRoles) { if(info.GetRolePlayer(targetRelationship) == sourceElement) { return VisitorFilterResult.Yes; } } } return VisitorFilterResult.DoNotCare; }
/// <summary> /// Constructor. /// </summary> /// <param name="elementLink">Relationship instance.</param> /// <param name="category">Category of the dependency item.</param> /// <param name="relationshipInfo">Relationship info.</param> /// <param name="roleInfo">Role info.</param> public DependencyItem(ElementLink elementLink, DependencyItemCategory category, DomainRelationshipInfo relationshipInfo, DomainRoleInfo roleInfo) : base(elementLink.Id, relationshipInfo, roleInfo) { this.elementLink = elementLink; this.itemCategory = category; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> protected CustomSerializedPropertyInfo GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { throw new NotSupportedException(); }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedLinkInfo</summary> protected CustomSerializedElementInfo GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { Guid roleId = rolePlayedInfo.Id; if (roleId == BinaryAssociationContainsRole.BinaryAssociationDomainRoleId) { return new CustomSerializedElementInfo(null, null, null, CustomSerializedElementWriteStyle.NotWritten, null); } if (roleId == EntityTypePlaysRole.EntityTypeDomainRoleId) { return new CustomSerializedElementInfo(null, null, null, CustomSerializedElementWriteStyle.NotWritten, null); } if (roleId == ExclusiveArcSpansOptionalRole.ExclusiveArcDomainRoleId) { return new CustomSerializedElementInfo(null, null, null, CustomSerializedElementWriteStyle.NotWritten, null); } return CustomSerializedElementInfo.Default; }
CustomSerializedElementInfo ICustomSerializedElement.GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { return this.GetCustomSerializedLinkInfo(rolePlayedInfo, elementLink); }
CustomSerializedPropertyInfo ICustomSerializedElement.GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { return this.GetCustomSerializedPropertyInfo(domainPropertyInfo, rolePlayedInfo); }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> CustomSerializedPropertyInfo ICustomSerializedElement.GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == CustomPropertyGroup.NameDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "name", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyGroup.DescriptionDomainPropertyId) { if (string.IsNullOrEmpty(this.Description)) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "description", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyGroup.IsDefaultDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "isDefault", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedLinkInfo</summary> protected new CustomSerializedElementInfo GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { Guid roleId = rolePlayedInfo.Id; if (roleId == ORMSolutions.ORMArchitect.Core.ObjectModel.ORMModelElementHasExtensionModelError.ExtendedElementDomainRoleId) { return new CustomSerializedElementInfo(null, "ObjectType", null, CustomSerializedElementWriteStyle.Element, null); } if (0 != (CustomSerializedElementSupportedOperations.LinkInfo & base.SupportedCustomSerializedOperations)) { return base.GetCustomSerializedLinkInfo(rolePlayedInfo, elementLink); } return CustomSerializedElementInfo.Default; }
/* public override void AddCommandHandlers(System.ComponentModel.Design.IMenuCommandService menuCommandService) { // NB this removes the Add command for all nodes / domain classes. Haven't // worked out how to be more selective than this yet! // Let the base class set up the command handlers base.AddCommandHandlers(menuCommandService); findDependencies = new MenuCommand(new EventHandler(ONFindDToImportedModels), new CommandID(GuidSymbol, IDSymbol)); findDependencies.Enabled = false; findDependencies.Visible = false; menuCommandService.AddCommand(findDependencies); / } private void ONFindDToImportedModels(object sender, EventArgs args) { if (this.SelectedElement is MetaModelLibrary) { List<ModelElement> classes = new List<ModelElement>(); foreach (ModelContext m in (this.SelectedElement as MetaModelLibrary).MetaModel.ModelContexts) { foreach (DomainClass d in m.Classes) { classes.Add(d); classes.AddRange(d.Properties); classes.AddRange(d.RolesPlayed); } } DependenciesViewModel vm = new DependenciesViewModel(LanguageDSLDocData.ViewModelStore, false); List<ModelElement> metaModels = new List<ModelElement>(); metaModels.Add((this.SelectedElement as MetaModelLibrary).MetaModel); vm.Set(classes, metaModels, LanguageDSLDependenciesItemsProvider.GetAllCategories()); bool bDelete = true; if (vm.ActiveDependencies.Count > 0) { DeleteElementsPopup popup = new DeleteElementsPopup(); popup.DataContext = vm; if (popup.ShowDialog().Value != true) bDelete = false; } if (bDelete) (this.SelectedElement as MetaModelLibrary).UnloadLibrary(); vm.Dispose(); GC.Collect(); } } */ /// <summary> /// Query whether the specified role should be considered a candidate for addition /// through the explorer add menus. /// </summary> /// <param name="element"></param> /// <param name="role"></param> /// <returns></returns> protected override bool IsAddableRoleForElement(ModelElement element, DomainRoleInfo role) { if (element is MetaModel) { /* if (role.Id == MetaModelHasClasses.MetaModelDomainRoleId || role.Id == MetaModelHasRelationships.MetaModelDomainRoleId || role.Id == MetaModelHasDiagramClasses.MetaModelDomainRoleId) return false; */ } if (element is DiagramClass) if (role.Id == DiagramClassHasPresentationElements.DiagramClassDomainRoleId) return false; if (element is MetaModelLibrary) if (role.Id == MetaModelLibraryHasImportedLibrary.MetaModelLibraryDomainRoleId) return false; return base.IsAddableRoleForElement(element, role); }
/// <summary> /// Calls <see cref="MultiShapeUtility.ShouldVisitOnDelete"/> to determine if the relationship should be visited /// and to reconfigure any links /// </summary> /// <param name="walker">The current <see cref="ElementWalker"/></param> /// <param name="sourceElement">The <see cref="ModelElement"/> being deleted</param> /// <param name="sourceRoleInfo">The role information</param> /// <param name="domainRelationshipInfo">The relationship information</param> /// <param name="targetRelationship">The other <see cref="ModelElement"/> in the relationship</param> /// <returns>Whether to visit the relationship</returns> public override VisitorFilterResult ShouldVisitRelationship(ElementWalker walker, ModelElement sourceElement, DomainRoleInfo sourceRoleInfo, DomainRelationshipInfo domainRelationshipInfo, ElementLink targetRelationship) { if (MultiShapeUtility.ShouldVisitOnDelete(walker, sourceElement, sourceRoleInfo, domainRelationshipInfo, targetRelationship)) { return base.ShouldVisitRelationship(walker, sourceElement, sourceRoleInfo, domainRelationshipInfo, targetRelationship); } else { return VisitorFilterResult.Never; } }
/// <summary> /// Initializes a new instance of the <see cref="CustomizationPolicyRolePlayerDescriptor"/> class. /// </summary> /// <param name="element">The element.</param> /// <param name="domainRoleInfo">The domain role info.</param> /// <param name="attributes">The attributes.</param> public CustomizationPolicyRolePlayerDescriptor(CustomizableElementSchema element, DomainRoleInfo domainRoleInfo, Attribute[] attributes) : base(element, domainRoleInfo, attributes) { }
/// <summary> /// Included relative and nested shapes in a default copy closure. /// The core design surface model does not do this in VS2010. /// </summary> public override VisitorFilterResult ShouldVisitRelationship(ElementWalker walker, ModelElement sourceElement, DomainRoleInfo sourceRoleInfo, DomainRelationshipInfo domainRelationshipInfo, ElementLink targetRelationship) { Guid roleId = sourceRoleInfo.Id; if (roleId == ParentShapeHasRelativeChildShapes.ParentShapeDomainRoleId || roleId == ParentShapeContainsNestedChildShapes.ParentShapeDomainRoleId) { return VisitorFilterResult.Yes; } return base.ShouldVisitRelationship(walker, sourceElement, sourceRoleInfo, domainRelationshipInfo, targetRelationship); }
/// <summary> /// Included relative and nested shapes in a default copy closure. /// The core design surface model does not do this in VS2010. /// </summary> public override VisitorFilterResult ShouldVisitRolePlayer(ElementWalker walker, ModelElement sourceElement, ElementLink elementLink, DomainRoleInfo targetDomainRole, ModelElement targetRolePlayer) { Guid roleId = targetDomainRole.Id; if (roleId == ParentShapeHasRelativeChildShapes.RelativeChildShapesDomainRoleId || roleId == ParentShapeContainsNestedChildShapes.NestedChildShapesDomainRoleId) { return VisitorFilterResult.Yes; } return base.ShouldVisitRolePlayer(walker, sourceElement, elementLink, targetDomainRole, targetRolePlayer); }
private static Attribute[] GetRolePlayerPropertyAttributes(DomainRoleInfo domainRole) { return domainRole.LinkPropertyInfo.GetCustomAttributes(false).OfType<Attribute>().ToArray(); }
private static RolePlayerPropertyDescriptor CreateRolePlayerPropertyDescriptor(ModelElement element, DomainRoleInfo targetRoleInfo, Attribute[] sourceDomainRoleInfoAttributes) { return new RolePlayerPropertyDescriptor(element, targetRoleInfo, sourceDomainRoleInfoAttributes); }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> protected CustomSerializedPropertyInfo GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == BarkerERDiagram.IsCompleteViewDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.NameDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.BaseFontNameDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.BaseFontSizeDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.DiagramIdDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.DoLineRoutingDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.DoResizeParentDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.DoShapeAnchoringDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.DoViewFixupDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } if (domainPropertyInfo.Id == BarkerERDiagram.PlaceUnplacedShapesDomainPropertyId) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary> /// Constructor. /// </summary> /// <param name="relationshipInfo">Relationship info.</param> /// <param name="roleInfo">Role info.</param> /// <param name="elementId">Element id.</param> public DependencyOriginItem(Guid elementId, DomainRelationshipInfo relationshipInfo, DomainRoleInfo roleInfo) { this.elementId = elementId; this.relationshipInfo = relationshipInfo; this.roleInfo = roleInfo; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedLinkInfo</summary> protected CustomSerializedElementInfo GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { throw new NotSupportedException(); }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedLinkInfo</summary> CustomSerializedElementInfo ICustomSerializedElement.GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { Guid roleId = rolePlayedInfo.Id; if (roleId == CustomPropertyHasCustomPropertyDefinition.CustomPropertyDefinitionDomainRoleId) { return new CustomSerializedElementInfo(null, "Definition", null, CustomSerializedElementWriteStyle.Element, null); } return CustomSerializedElementInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> CustomSerializedPropertyInfo ICustomSerializedElement.GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == CustomProperty.ValueDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "value", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> protected CustomSerializedPropertyInfo GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == Role.IsNonTransferableDomainPropertyId) { if (!this.IsNonTransferable) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == Role.IsMandatoryDomainPropertyId) { if (!this.IsMandatory) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == Role.IsPrimaryIdComponentDomainPropertyId) { if (!this.IsPrimaryIdComponent) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == Role.IsMultiValuedDomainPropertyId) { if (!this.IsMultiValued) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> CustomSerializedPropertyInfo ICustomSerializedElement.GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == CustomPropertyDefinition.NameDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "name", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.DescriptionDomainPropertyId) { if (string.IsNullOrEmpty(this.Description)) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "description", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.CategoryDomainPropertyId) { if (string.IsNullOrEmpty(this.Category)) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "category", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.DataTypeDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "dataType", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.DefaultValueDomainPropertyId) { if (this.DefaultValue == null) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "defaultValue", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.VerbalizeDefaultValueDomainPropertyId) { if (this.VerbalizeDefaultValue || this.DefaultValue == null) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "verbalizeDefaultValue", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.CustomEnumValueDomainPropertyId) { if (string.IsNullOrEmpty(this.CustomEnumValue)) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, "customEnumValues", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == CustomPropertyDefinition.ORMTypesDomainPropertyId) { return new CustomSerializedPropertyInfo(null, "ORMTypes", null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedPropertyInfo</summary> protected CustomSerializedPropertyInfo GetCustomSerializedPropertyInfo(DomainPropertyInfo domainPropertyInfo, DomainRoleInfo rolePlayedInfo) { if (domainPropertyInfo.Id == FactTypeMapsTowardsRole.MandatoryPatternDomainPropertyId) { if (MappingMandatoryPattern.None == this.MandatoryPattern) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } if (domainPropertyInfo.Id == FactTypeMapsTowardsRole.UniquenessPatternDomainPropertyId) { if (MappingUniquenessPattern.None == this.UniquenessPattern) { return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.NotWritten, null); } return new CustomSerializedPropertyInfo(null, null, null, false, CustomSerializedAttributeWriteStyle.Attribute, null); } return CustomSerializedPropertyInfo.Default; }
/// <summary>Implements ICustomSerializedElement.GetCustomSerializedLinkInfo</summary> protected CustomSerializedElementInfo GetCustomSerializedLinkInfo(DomainRoleInfo rolePlayedInfo, ElementLink elementLink) { Guid roleId = rolePlayedInfo.Id; if (roleId == GenerationSettingTargetsAbstractionModel.GeneratedAbstractionModelDomainRoleId) { return new CustomSerializedElementInfo(null, "AbstractionModel", null, CustomSerializedElementWriteStyle.Element, null); } return CustomSerializedElementInfo.Default; }