Beispiel #1
0
        /// <summary>
        /// Gets the drawing information for a particular element in the compartment.
        /// </summary>
        /// <param name="listField">The <see cref="ShapeField"/> of this <see cref="AttributeElementListCompartment"/> which
        /// paints the items in this compartment.</param>
        /// <param name="row">The index of the array of items whose item drawing information is of interest.</param>
        /// <param name="itemDrawInfo">A previously initialized <see cref="ItemDrawInfo"/> object whose properties will be modified.</param>
        public override void GetItemDrawInfo(ListField listField, int row, ItemDrawInfo itemDrawInfo)
        {
            base.GetItemDrawInfo(listField, row, itemDrawInfo);
            Barker.Attribute currentAttribute = this.Items[row] as Barker.Attribute;
            Debug.Assert(currentAttribute != null, "An item in the AttributeElementListCompartment is not an attribute.");

            if (currentAttribute.IsMandatory)
            {
                itemDrawInfo.AlternateFont = true;
            }

            StringBuilder attributeText = new StringBuilder();

            if (currentAttribute.IsPrimaryIdComponent)
            {
                attributeText.Append(PrimaryIdentifierString);
            }
            else
            {
                attributeText.Append(BlankString);
            }
            attributeText.Append(BlankString);

            if (currentAttribute.IsMandatory)
            {
                attributeText.Append(MandatoryString);
            }
            else
            {
                attributeText.Append(OptionalString);
            }
            attributeText.Append(BlankString);
            attributeText.Append(currentAttribute.Name);
            itemDrawInfo.Text = attributeText.ToString();
        }
Beispiel #2
0
		/// <summary>
		/// Constructor
		/// Creates a EntityTypeHasAttribute link in the same Partition as the given EntityType
		/// </summary>
		/// <param name="source">EntityType to use as the source of the relationship.</param>
		/// <param name="target">Attribute to use as the target of the relationship.</param>
		public EntityTypeHasAttribute(EntityType source, Attribute target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(EntityTypeHasAttribute.EntityTypeDomainRoleId, source), new DslModeling::RoleAssignment(EntityTypeHasAttribute.AttributeDomainRoleId, target)}, null)
		{
		}
Beispiel #3
0
        /// <summary>
        /// Reorder compartment items when a attribute is renamed.
        /// </summary>
        private static void AttributeRenamedEvent(object sender, ElementPropertyChangedEventArgs e)
        {
            Barker.Attribute attribute = (Barker.Attribute)e.ModelElement;
            EntityType       barkerEntity;

            if (!attribute.IsDeleted &&
                null != (barkerEntity = attribute.EntityType))
            {
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(barkerEntity))
                {
                    BarkerEntityShape shape = pel as BarkerEntityShape;
                    if (shape != null)
                    {
                        foreach (ShapeElement childShape in shape.NestedChildShapes)
                        {
                            AttributeElementListCompartment compartment;
                            OrderedElementList <Barker.Attribute, AttributeElementListCompartment> attributeList;
                            int oldIndex;
                            int newIndex;
                            if (null != (compartment = childShape as AttributeElementListCompartment) &&
                                null != (attributeList = compartment.Items as OrderedElementList <Barker.Attribute, AttributeElementListCompartment>))

                            {
                                if (attributeList.OnElementReorder(attribute, out oldIndex, out newIndex))
                                {
                                    Diagram     diagram;
                                    DiagramView view;
                                    SelectedShapesCollection selection;
                                    if (null != (diagram = shape.Diagram) &&
                                        null != (view = diagram.ActiveDiagramView) &&
                                        null != (selection = view.Selection))
                                    {
                                        ShapeField testField = compartment.ListField;
                                        foreach (DiagramItem selectedItem in selection)
                                        {
                                            ListItemSubField testSubField;
                                            if (selectedItem.Shape == compartment &&
                                                selectedItem.Field == testField &&
                                                null != (testSubField = selectedItem.SubField as ListItemSubField))
                                            {
                                                int testRow = testSubField.Row;
                                                if (testRow == oldIndex)
                                                {
                                                    testSubField.Row = newIndex;
                                                }
                                                else
                                                {
                                                    int adjustRow = testRow;
                                                    if (testRow > oldIndex)
                                                    {
                                                        --adjustRow;
                                                    }
                                                    if (adjustRow >= newIndex)
                                                    {
                                                        ++adjustRow;
                                                    }
                                                    if (adjustRow != testRow)
                                                    {
                                                        testSubField.Row = adjustRow;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
		public static DslModeling::LinkedElementCollection<Value> GetPossibleValuesCollection(Attribute element)
		{
			return new DslModeling::LinkedElementCollection<Value>(element, AttributeDomainRoleId);
		}
Beispiel #5
0
		public static void SetAttribute(Value element, Attribute newAttribute)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ValueDomainRoleId, newAttribute);
		}
Beispiel #6
0
		/// <summary>
		/// Constructor
		/// Creates a AttributeHasPossibleValue link in the same Partition as the given Attribute
		/// </summary>
		/// <param name="source">Attribute to use as the source of the relationship.</param>
		/// <param name="target">Value to use as the target of the relationship.</param>
		public AttributeHasPossibleValue(Attribute source, Value target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(AttributeHasPossibleValue.AttributeDomainRoleId, source), new DslModeling::RoleAssignment(AttributeHasPossibleValue.ValueDomainRoleId, target)}, null)
		{
		}
Beispiel #7
0
		public static void SetEntityType(Attribute element, EntityType newEntityType)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, AttributeDomainRoleId, newEntityType);
		}
Beispiel #8
0
		public static EntityType GetEntityType(Attribute element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, AttributeDomainRoleId) as EntityType;
		}