Example #1
0
        private void PopulatePersistentTypesCombos(PersistentTypeItem persistentTypeToSelect)
        {
            disablePreviewUpdate = true;
            try
            {
                disableComboChangeNotification.Add(cmbPersistentTypes, false);
                disableComboChangeNotification.Add(cmbPropertyTypes, false);

                PersistentTypeItem selectedPersistentType = SelectedPersistentType;
                PersistentTypeItem selectedPropertyType   = SelectedPropertyType;

                PopulatePersistentType(cmbPersistentTypes, /*selectedPropertyType, */ selectedPersistentType);
                PopulatePersistentType(cmbPropertyTypes, /*selectedPersistentType, */ selectedPropertyType);
                cmbPropertyTypes.SelectedIndex = 1;

                if (persistentTypeToSelect != null)
                {
                    SelectPersistentType(cmbPersistentTypes, persistentTypeToSelect);
                }

                GenerateAssociationName();
                GeneratePropertyNames();

                PopulateMultiplicity();

                UpdateControlNavigationToItSelf();
            }
            finally
            {
                disablePreviewUpdate = false;
                UpdatePreview();
            }
        }
Example #2
0
        private void PopulatePersistentType(bool end1, PersistentTypeItem itemToSelect = null)
        {
            IconComboBox comboBox = GetPersistentTypeCombo(end1);

            comboBox.Items.Clear();
            foreach (var entry in ownerForm.BuildPersistentTypesItems().Where(entry => ((PersistentTypeItem)entry.Value).Kind != EntityKind.Structure))
            {
                comboBox.Items.Add(entry);
            }

            disableComboChangeNotification[comboBox] = true;
            try
            {
                if (itemToSelect != null)
                {
                    SelectPersistentType(comboBox, itemToSelect);
                }

                if (comboBox.SelectedIndex == -1)
                {
                    comboBox.SelectedIndex = 0;
                }
            }
            finally
            {
                disableComboChangeNotification[comboBox] = false;
            }
        }
Example #3
0
        private void PersistentTypeComboSelectionChanged(object sender, EventArgs e)
        {
            IconComboBox comboBox = (sender as IconComboBox);

            if (disableComboChangeNotification[comboBox])
            {
                return;
            }

            bool isPersistentCombo = (sender as Control).Tag == "0";

            if (!isPersistentCombo)
            {
                PersistentTypeItem selectedPersistentType = SelectedPersistentType;
                PersistentTypeItem selectedPropertyType   = SelectedPropertyType;
                bool isItself = false;
                if (selectedPersistentType != null && selectedPropertyType != null)
                {
                    isItself = selectedPersistentType.EqualsTo(selectedPropertyType);
                }

                chNavigationToItSelf.Checked = isItself;
            }
            UpdateControlNavigationToItSelf();
            UpdatePreview();
            GenerateAssociationName();
            GeneratePropertyNames();
        }
Example #4
0
        private void UpdatePreview()
        {
            if (disablePreviewUpdate)
            {
                return;
            }

            PersistentTypeItem selectedPersistentType = SelectedPersistentType;
            string             persistentType         = selectedPersistentType == null ? VARIABLE_PERSISTENT_TYPE : selectedPersistentType.Name;

            PersistentTypeItem selectedPropertyType = SelectedPropertyType;
            string             propertyType         = selectedPropertyType == null ? VARIABLE_PROPERTY_TYPE : selectedPropertyType.Name;

            string propertyName = string.IsNullOrEmpty(edPropertyName.Text)
                                      ? VARIABLE_PROPERTY_NAME
                                      : edPropertyName.Text;

            MultiplicityKind selectedMultiplicity = SelectedMultiplicity;

            propertyType = selectedMultiplicity == MultiplicityKind.Many
                                          ? string.Format(VARIABLE_ENTITYSET, propertyType)
                                          : propertyType;

            string html = originalPreviewHtml.Replace(VARIABLE_PERSISTENT_TYPE, persistentType);

            html = html.Replace(VARIABLE_PROPERTY_TYPE, propertyType);
            html = html.Replace(VARIABLE_PROPERTY_NAME, propertyName);

            htmlPreview.Text = html;
        }
Example #5
0
        public FormAddAssociation.ResultData.PersistentItem GetResultPersistentItem(bool firstItem)
        {
            PersistentTypeItem typeItem = firstItem ? SelectedPersistentType : SelectedPropertyType;

            return(new FormAddAssociation.ResultData.PersistentItem(typeItem,
                                                                    edPropertyName.Text, SelectedMultiplicity, false));
        }
Example #6
0
 internal FormAddAssociationOld(IEnumerable <PersistentTypeItem> existingTypeNames, IEnumerable <string> existingAssociations,
                                PersistentTypeItem persistentTypeEnd1)
     : this()
 {
     //this.existingTypeNames = existingTypeNames.Where(type => type.Kind != EntityKind.Structure).ToArray();
     this.existingTypeNames    = existingTypeNames.ToArray();
     this.existingAssociations = existingAssociations;
     PopulateForm(persistentTypeEnd1);
 }
Example #7
0
 public PersistentItem(PersistentTypeItem typeItem,
                       /*PersistentTypeItem propertyTypeItem, */ string propertyName,
                       MultiplicityKind multiplicity, bool useAssociationAttribute)
 {
     TypeItem = typeItem;
     //PropertyTypeItem = propertyTypeItem;
     PropertyName            = propertyName;
     Multiplicity            = multiplicity;
     UseAssociationAttribute = useAssociationAttribute;
 }
Example #8
0
        public bool EqualsTo(PersistentTypeItem other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Util.StringEqual(this.Name, other.Name, true) &&
                   this.Kind == other.Kind);
        }
Example #9
0
        private void UpdatePreview()
        {
            if (disablePreviewUpdate)
            {
                return;
            }

            PersistentTypeItem selectedPersistentTypeEnd1 = GetSelectedPersistentType(true);
            string             persistentTypeEnd1         = selectedPersistentTypeEnd1 == null ? VARIABLE_PERSISTENT_TYPE_END1 : selectedPersistentTypeEnd1.Name;


            PersistentTypeItem selectedPersistentTypeEnd2 = GetSelectedPersistentType(false);
            string             persistentTypeEnd2         = selectedPersistentTypeEnd2 == null ? VARIABLE_PERSISTENT_TYPE_END2 : selectedPersistentTypeEnd2.Name;

            string propertyNameEnd1 = string.IsNullOrEmpty(edPropertyNameEnd1.Text)
                                      ? VARIABLE_PROPERTY_NAME_END1
                                      : edPropertyNameEnd1.Text;

            string propertyNameEnd2 = string.IsNullOrEmpty(edPropertyNameEnd2.Text)
                                      ? VARIABLE_PROPERTY_NAME_END2
                                      : edPropertyNameEnd2.Text;

            MultiplicityKind selectedMultiplicityEnd1 = GetSelectedMultiplicity(true);
            MultiplicityKind selectedMultiplicityEnd2 = GetSelectedMultiplicity(false);

            string propertyTypeEnd1 = selectedMultiplicityEnd1 == MultiplicityKind.Many
                                          ? string.Format(VARIABLE_ENTITYSET, persistentTypeEnd2)
                                          : persistentTypeEnd2;

            string propertyTypeEnd2 = selectedMultiplicityEnd2 == MultiplicityKind.Many
                                          ? string.Format(VARIABLE_ENTITYSET, persistentTypeEnd1)
                                          : persistentTypeEnd1;

            bool   useAssocEnd1       = GetUseAssociationAttributeCheckbox(true).Checked;
            bool   useAssocEnd2       = GetUseAssociationAttributeCheckbox(false).Checked;
            string useAssociationEnd1 = useAssocEnd1 ? HTML_ASSOCIATION_ATTRIBUTE_END1.Replace(VARIABLE_PROPERTY_NAME_END2, propertyNameEnd2) : "<br>";
            string useAssociationEnd2 = useAssocEnd2 ? HTML_ASSOCIATION_ATTRIBUTE_END2.Replace(VARIABLE_PROPERTY_NAME_END1, propertyNameEnd1) : "<br>";

            string html = originalPreviewHtml.Replace(VARIABLE_PERSISTENT_TYPE_END1, persistentTypeEnd1);

            html = html.Replace(VARIABLE_PERSISTENT_TYPE_END2, persistentTypeEnd2);

            html = html.Replace(VARIABLE_PROPERTY_NAME_END1, propertyNameEnd1);
            html = html.Replace(VARIABLE_PROPERTY_NAME_END2, propertyNameEnd2);

            html = html.Replace(VARIABLE_PROPERTY_TYPE_END1, propertyTypeEnd1);
            html = html.Replace(VARIABLE_PROPERTY_TYPE_END2, propertyTypeEnd2);

            html = html.Replace(VARIABLE_ASSOCIATION_ATTRIBUTE_END1, useAssociationEnd1);
            html = html.Replace(VARIABLE_ASSOCIATION_ATTRIBUTE_END2, useAssociationEnd2);


            htmlPreview.Text = html;
        }
Example #10
0
        private void Initialize(IEnumerable <PersistentTypeItem> existingTypeNames,
                                IEnumerable <string> existingAssociations, PersistentTypeItem persistentTypeToSelect)
        {
            associationNames.Add(true, string.Empty);
            associationNames.Add(false, string.Empty);

            this.existingTypeNames    = existingTypeNames;
            this.existingAssociations = existingAssociations;

            this.controlSimple.Initialize(this, persistentTypeToSelect);
            this.controlAdvanced.Initialize(this, persistentTypeToSelect);

            UpdateControls(true);
        }
Example #11
0
        private void GeneratePropertyNames()
        {
            PersistentTypeItem source = GetSelectedPersistentType(true);
            PersistentTypeItem target = GetSelectedPersistentType(false);
            string             generatePropertyNameA = GeneratePropertyName(target, source);
            string             generatePropertyNameB = GeneratePropertyName(source, target);

            if (generatePropertyNameB == generatePropertyNameA)
            {
                generatePropertyNameB = generatePropertyNameB + "_1";
            }

            edNavPropertyEnd1.Text = generatePropertyNameA;
            edNavPropertyEnd2.Text = generatePropertyNameB;
        }
Example #12
0
        private int FindPersistentTypeIndex(IconComboBox combo, PersistentTypeItem persistentTypeItem)
        {
            int idx = -1;

            foreach (var entry in combo.Items.OfType <IconListEntry>())
            {
                idx++;
                PersistentTypeItem item = entry.Value as PersistentTypeItem;
                if (item.EqualsTo(persistentTypeItem))
                {
                    break;
                }
            }

            return(idx);
        }
Example #13
0
        private void SelectPersistentType(IconComboBox comboBox, PersistentTypeItem itemToSelect)
        {
            int idx = 0;

            foreach (var entry in comboBox.Items.OfType <IconListEntry>())
            {
                PersistentTypeItem item = entry.Value as PersistentTypeItem;
                if (item.EqualsTo(itemToSelect))
                {
                    comboBox.SelectedIndex = idx;
                    break;
                }

                idx++;
            }
        }
Example #14
0
        private void PopulateForm(PersistentTypeItem persistentTypeToSelect)
        {
            disablePreviewUpdate = true;
            try
            {
                persistentTypesEntries = ownerForm.BuildPersistentTypesItems().Where(
                    entry => ((PersistentTypeItem)entry.Value).Kind != EntityKind.Structure);

                isValidToShow = persistentTypesEntries.Count() >= 2;
                if (!isValidToShow)
                {
                    showValidationError = "There must be at least 2 persistent types (exclude structures) to make advanced association.";
                    return;
                }

                disableComboChangeNotification.Add(cmbPersistentTypesEnd1, false);
                disableComboChangeNotification.Add(cmbPersistentTypesEnd2, false);

                PersistentTypeItem selectedPersistentType = GetSelectedPersistentType(true);
                PersistentTypeItem selectedPropertyType   = GetSelectedPersistentType(false);

                PopulatePersistentType(true, selectedPersistentType);
                PopulatePersistentType(false, selectedPropertyType);
                GetPersistentTypeCombo(false).SelectedIndex = 1;

                PopulateMultiplicity(true);
                PopulateMultiplicity(false);

                GetUseAssociationAttributeCheckbox(true).Checked  = true;
                GetUseAssociationAttributeCheckbox(false).Checked = true;

                if (persistentTypeToSelect != null)
                {
                    SelectPersistentType(GetPersistentTypeCombo(true), persistentTypeToSelect);
                }

                GenerateAssociationName();
                GeneratePropertyNames();
            }
            finally
            {
                disablePreviewUpdate = false;
            }

            UpdatePreview();
        }
Example #15
0
        private void SelectPersistentType(bool end1, PersistentTypeItem typeToSelect)
        {
            var combo = GetPersistentTypeCombo(end1);
            int idx   = 0;

            foreach (var entry in combo.Items.OfType <IconListEntry>())
            {
                PersistentTypeItem item = entry.Value as PersistentTypeItem;
                if (item.EqualsTo(typeToSelect))
                {
                    combo.SelectedIndex = idx;
                    break;
                }

                idx++;
            }
        }
Example #16
0
        public static bool DialogShow(IEnumerable <PersistentTypeItem> existingTypeNames,
                                      IEnumerable <string> existingAssociations, PersistentTypeItem persistentTypeEnd1, out ResultData resultData)
        {
            bool result;

            resultData = null;

            using (FormAddAssociationOld form = new FormAddAssociationOld(existingTypeNames, existingAssociations, persistentTypeEnd1))
            {
                result = form.ShowDialog() == DialogResult.OK;
                if (result)
                {
                    resultData = form.GetResultData();
                }
            }

            return(result);
        }
Example #17
0
        public static bool DialogShow(IEnumerable <PersistentTypeItem> existingTypeNames,
                                      IEnumerable <string> existingAssociations, PersistentTypeItem persistentTypeToSelect,
                                      out ResultData resultData)
        {
            resultData = null;
            DialogResult dialogResult;

            using (FormAddAssociation form = new FormAddAssociation())
            {
                form.Initialize(existingTypeNames, existingAssociations, persistentTypeToSelect);
                dialogResult = form.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    resultData = form.GetResultData();
                }
            }

            return(dialogResult == DialogResult.OK);
        }
Example #18
0
        private void chNavigationToItSelf_CheckedChanged(object sender, EventArgs e)
        {
            PersistentTypeItem selectedPersistentType = SelectedPersistentType;
            PersistentTypeItem selectedPropertyType   = SelectedPropertyType;

            bool isItself = false;

            if (selectedPersistentType != null && selectedPropertyType != null)
            {
                isItself = selectedPersistentType.EqualsTo(selectedPropertyType);
            }

            if (chNavigationToItSelf.Checked && !isItself)
            {
                SelectPersistentType(cmbPropertyTypes, selectedPersistentType);
            }

            UpdateControlNavigationToItSelf();
            UpdatePreview();
        }
Example #19
0
        private void PopulatePeristentTypes(bool end1, PersistentTypeItem persistentTypeToSelect)
        {
            PersistentTypeItem currentSelectedPersistentType = GetSelectedPersistentType(end1);
            var combo      = GetPersistentTypeCombo(end1);
            var otherCombo = GetPersistentTypeCombo(!end1);

            combo.Items.Clear();
            foreach (var entry in persistentTypesItems)
            {
                combo.Items.Add(entry);
            }

            DisabledOnPersistentTypeChanged = true;

            try
            {
                if (persistentTypeToSelect != null)
                {
                    currentSelectedPersistentType = persistentTypeToSelect;
                }

                if (currentSelectedPersistentType != null)
                {
                    SelectPersistentType(end1, currentSelectedPersistentType);
                }
                else
                {
                    combo.SelectedIndex = end1 ? 0 : 1;
                    if (combo.SelectedIndex == otherCombo.SelectedIndex)
                    {
                        combo.SelectedIndex = combo.SelectedIndex == 0 ? 1 : 0;
                    }
                }
            }
            finally
            {
                DisabledOnPersistentTypeChanged = false;
            }
        }
Example #20
0
        private void PopulateForm(PersistentTypeItem persistentTypeEnd1)
        {
            chCreateEnd1.Checked = true;
            chCreateEnd2.Checked = true;

            BuildPersistentTypesItems();

            PopulateMultiplicity(true);
            PopulateMultiplicity(false);

            PopulatePeristentTypes(true, persistentTypeEnd1);
            PopulatePeristentTypes(false);

            GenerateAssociationName();
            GeneratePropertyNames();

            PopulateOnRemoveActions(true);
            PopulateOnRemoveActions(false);

            chUseAssocEnd1.Checked = true;
            chUseAssocEnd2.Checked = true;
        }
Example #21
0
        private ResultData GetResultData()
        {
            PersistentTypeItem persistentTypeEnd1 = GetSelectedPersistentType(true);
            PersistentTypeItem persistentTypeEnd2 = GetSelectedPersistentType(false);

            AssociationOnRemoveAction onOwnerRemoveActionEnd1 = GetSelectedOnRemoveAction(true, true);
            AssociationOnRemoveAction onOwnerRemoveActionEnd2 = GetSelectedOnRemoveAction(false, true);

            AssociationOnRemoveAction onTargetRemoveActionEnd1 = GetSelectedOnRemoveAction(true, false);
            AssociationOnRemoveAction onTargetRemoveActionEnd2 = GetSelectedOnRemoveAction(false, false);

            MultiplicityKind multiplicityEnd1 = GetSelectedMultiplicity(true);
            MultiplicityKind multiplicityEnd2 = GetSelectedMultiplicity(false);

            string navigationPropertyEnd1 = edNavPropertyEnd1.Text;
            string navigationPropertyEnd2 = edNavPropertyEnd2.Text;

            string associationName = edAssociationName.Text;

            return(new ResultData(persistentTypeEnd1, persistentTypeEnd2, multiplicityEnd1, multiplicityEnd2,
                                  navigationPropertyEnd1, navigationPropertyEnd2, associationName,
                                  onOwnerRemoveActionEnd1, onOwnerRemoveActionEnd2, onTargetRemoveActionEnd1, onTargetRemoveActionEnd2,
                                  chCreateEnd1.Checked, chCreateEnd2.Checked, chUseAssocEnd1.Checked, chUseAssocEnd2.Checked));
        }
Example #22
0
 public ResultData(PersistentTypeItem persistentTypeEnd1, PersistentTypeItem persistentTypeEnd2,
                   MultiplicityKind multiplicityEnd1, MultiplicityKind multiplicityEnd2, string navigationPropertyEnd1,
                   string navigationPropertyEnd2, string associationName,
                   AssociationOnRemoveAction onOwnerRemoveEnd1, AssociationOnRemoveAction onOwnerRemoveEnd2,
                   AssociationOnRemoveAction onTargetRemoveEnd1, AssociationOnRemoveAction onTargetRemoveEnd2,
                   bool createPropertyEnd1, bool createPropertyEnd2,
                   bool useAssociationAttributeEnd1, bool useAssociationAttributeEnd2)
 {
     PersistentTypeEnd1               = persistentTypeEnd1;
     PersistentTypeEnd2               = persistentTypeEnd2;
     MultiplicityEnd1                 = multiplicityEnd1;
     MultiplicityEnd2                 = multiplicityEnd2;
     NavigationPropertyEnd1           = navigationPropertyEnd1;
     NavigationPropertyEnd2           = navigationPropertyEnd2;
     AssociationName                  = associationName;
     this.OnOwnerRemoveEnd1           = onOwnerRemoveEnd1;
     this.OnOwnerRemoveEnd2           = onOwnerRemoveEnd2;
     this.OnTargetRemoveEnd1          = onTargetRemoveEnd1;
     this.OnTargetRemoveEnd2          = onTargetRemoveEnd2;
     this.CreatePropertyEnd1          = createPropertyEnd1;
     this.CreatePropertyEnd2          = createPropertyEnd2;
     this.UseAssociationAttributeEnd1 = useAssociationAttributeEnd1;
     this.UseAssociationAttributeEnd2 = useAssociationAttributeEnd2;
 }
Example #23
0
 internal void Initialize(FormAddAssociation ownerForm, PersistentTypeItem persistentTypeToSelect)
 {
     this.ownerForm = ownerForm;
     PopulatePersistentTypesCombos(persistentTypeToSelect);
 }
Example #24
0
        private void PopulatePersistentType(IconComboBox comboBox, /*PersistentTypeItem exceptItem, */ PersistentTypeItem itemToSelect = null)
        {
            comboBox.Items.Clear();
            foreach (var entry in ownerForm.BuildPersistentTypesItems())
            {
                comboBox.Items.Add(entry);
            }

            disableComboChangeNotification[comboBox] = true;
            try
            {
                if (itemToSelect != null)
                {
                    SelectPersistentType(comboBox, itemToSelect);
                }

                if (comboBox.SelectedIndex == -1)
                {
                    comboBox.SelectedIndex = 0;
                }
            }
            finally
            {
                disableComboChangeNotification[comboBox] = false;
            }
        }
Example #25
0
 private string GeneratePropertyName(PersistentTypeItem source, PersistentTypeItem target)
 {
     return(Util.GenerateUniqueName(target.Properties, source.Name));
 }