public void SetWatermarkInfo(TreeGridDesignerWatermarkInfo watermarkInfo)
        {
            if (watermarkInfo == null)
            {
                Debug.Fail("Unexpected null value for watermarkInfo");
                return;
            }

            SetHintColor(Color.Transparent);

            watermarkLabel.Links.Clear();

            if (watermarkInfo.WatermarkText == null)
            {
                Debug.Fail("Unexpected null value for watermarkText");
                return;
            }
            watermarkLabel.Text = watermarkInfo.WatermarkText;
            if (watermarkInfo.WatermarkLinkData == null)
            {
                Debug.Fail("Unexpected null value watermarkInfo.WatermarkLinkData");
                return;
            }
            foreach (var ld in watermarkInfo.WatermarkLinkData.Where(ld => ld.LinkStart > 0))
            {
                watermarkLabel.Links.Add(new LinkLabel.Link(ld.LinkStart, ld.LinkLength, ld.LinkClickedHandler));
            }
        }
        private static TreeGridDesignerWatermarkInfo CreateWatermarkInfoPKToFKRC_NoASM()
        {
            var watermarkInfo = new TreeGridDesignerWatermarkInfo(
                Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_NoASM);

            return(watermarkInfo);
        }
Exemple #3
0
 public void SetWatermarkInfo(TreeGridDesignerWatermarkInfo watermarkInfo)
 {
     Debug.Assert(watermarkInfo != null, "watermark info is null!");
     if (watermarkInfo != null)
     {
         _watermarkInfo = watermarkInfo;
         ForceWatermarkTextChange();
     }
 }
        private static TreeGridDesignerWatermarkInfo CreateWatermarkInfoPKToPKRC_NoASM(MappingDetailsWindowContainer windowContainer)
        {
            var errorMessage = String.Format(
                CultureInfo.CurrentCulture,
                Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToPK_NoASM,
                Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToPK_NoASM_Display);
            var idx1 = errorMessage.IndexOf(
                Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToPK_NoASM_Display, StringComparison.Ordinal);
            var watermarkInfo = new TreeGridDesignerWatermarkInfo(
                errorMessage,
                new TreeGridDesignerWatermarkInfo.LinkData(
                    idx1,
                    Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToPK_NoASM_Display.Length,
                    windowContainer.watermarkLabel_LinkClickedDisplayAssociation));

            return(watermarkInfo);
        }
Exemple #5
0
        private void SetUpDefaultWatermarkInfo()
        {
            // set up default watermark info
            var watermarkText = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_Watermark, Resources.ExplorerWindowTitle);

            // container will only be null when we initialize this through the constructor.
            if (MappingDetailsWindowContainer != null)
            {
                var linkStart  = watermarkText.IndexOf(Resources.ExplorerWindowTitle, StringComparison.Ordinal);
                var linkLength = Resources.ExplorerWindowTitle.Length;
                _defaultWatermarkInfo = new TreeGridDesignerWatermarkInfo(
                    watermarkText,
                    new TreeGridDesignerWatermarkInfo.LinkData(
                        linkStart, linkLength, MappingDetailsWindowContainer.watermarkLabel_LinkClickedShowExplorer));
            }
            else
            {
                _defaultWatermarkInfo = new TreeGridDesignerWatermarkInfo(watermarkText);
            }
            _watermarkInfo = _defaultWatermarkInfo;
        }
Exemple #6
0
        // <summary>
        //     Calls a validation method to check if this association's MSL is editable by the designer
        // </summary>
        internal bool CanEditMappingsForAssociation(Association association, bool allowAssociationMappingEditWithFKs)
        {
            if (association == null)
            {
                throw new ArgumentNullException("association");
            }

            TreeGridDesignerWatermarkInfo watermarkInfo = null;

            if (MappingViewModelHelper.CanEditMappingsForAssociation(
                    association, MappingDetailsWindowContainer, ref watermarkInfo, allowAssociationMappingEditWithFKs))
            {
                return(true);
            }
            else
            {
                Debug.Assert(watermarkInfo != null, "watermark should not be null");
                if (watermarkInfo != null)
                {
                    SetWatermarkInfo(watermarkInfo);
                }
                return(false);
            }
        }
Exemple #7
0
        public void SetWatermarkInfo(string text)
        {
            var wm = new TreeGridDesignerWatermarkInfo(text);

            SetWatermarkInfo(wm);
        }
        internal static bool CanEditMappingsForAssociation(
            Association association, MappingDetailsWindowContainer windowContainer, ref TreeGridDesignerWatermarkInfo watermarkInfo,
            bool allowMappingEditWithFKs)
        {
            if (association == null)
            {
                throw new ArgumentNullException("association");
            }

            // make sure that we have an EntitySet (or can find one)
            if (association.AssociationSet == null)
            {
                var errorMessage = String.Format(
                    CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral,
                    Resources.MappingDetails_ErrMslCantFindAssociationSet);
                watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                return(false);
            }

            var asms = association.AssociationSet.GetAntiDependenciesOfType <AssociationSetMapping>();

            var rc = association.ReferentialConstraint;

            if (rc != null)
            {
                // allowMappingEditWithFKs is an override flag that suppresses the following watermarks.
                if (allowMappingEditWithFKs == false)
                {
                    if (EdmFeatureManager.GetForeignKeysInModelFeatureState(association.Artifact.SchemaVersion)
                        .IsEnabled())
                    {
                        // set up watermarks association mapping window watermarks when FKs are supported
                        if (rc.IsPrimaryKeyToPrimaryKey())
                        {
                            if (asms.Count > 0)
                            {
                                watermarkInfo = CreateWatermarkInfoPKToPKRC_WithASM(windowContainer);
                            }
                            else
                            {
                                watermarkInfo = CreateWatermarkInfoPKToPKRC_NoASM(windowContainer);
                            }
                            return(false);
                        }
                        else
                        {
                            if (asms.Count > 0)
                            {
                                watermarkInfo = CreateWatermarkInfoPKToFKRC_WithASM(windowContainer);
                            }
                            else
                            {
                                watermarkInfo = CreateWatermarkInfoPKToFKRC_NoASM();
                            }
                            return(false);
                        }
                    }
                    else
                    {
                        // targeting netfx 3.5.  FKs are not supported
                        if (rc.IsPrimaryKeyToPrimaryKey() == false)
                        {
                            if (asms.Count > 0)
                            {
                                watermarkInfo = CreateWatermarkInfoPKToFKRC_WithASM(windowContainer);
                            }
                            else
                            {
                                watermarkInfo = CreateWatermarkInfoPKToFKRC_NoASM();
                            }
                            return(false);
                        }
                    }
                }
            }

            // make sure that there is just one AssociationSetMapping for our set
            if (asms.Count > 1)
            {
                var errorMessage = String.Format(
                    CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral,
                    Resources.MappingDetails_ErrMslTooManyAssociationSetMappings);
                watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                return(false);
            }
            else
            {
                foreach (var asm in asms)
                {
                    // if AssociationSetMapping contains QueryView
                    if (asm.HasQueryViewElement)
                    {
                        var errorMessage = String.Format(
                            CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral,
                            Resources.MappingDetails_ErrMslAssociationSetMappingHasQueryView);
                        watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                        return(false);
                    }

                    // make sure that we fully resolve
                    var errorMsg = string.Empty;
                    if (EnsureResolvedStatus(asm, ref errorMsg) == false)
                    {
                        var errorMessage = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, errorMsg);
                        watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                        return(false);
                    }

                    // ensure that we don't have any C-side conditions
                    foreach (var cond in asm.Conditions())
                    {
                        if (cond.Name.RefName != null)
                        {
                            var errorMessage = String.Format(
                                CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral,
                                Resources.MappingDetails_ErrMslUnsupportedCondition);
                            watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                            return(false);
                        }
                    }
                }
            }

            foreach (var associationEnd in association.AssociationEnds())
            {
                string duplicatePropertyName;
                var    entityType = associationEnd.Type.Target;
                if (!CheckDuplicateEntityProperty(entityType, out duplicatePropertyName))
                {
                    var errorMessage = String.Format(
                        CultureInfo.CurrentCulture, Resources.MappingDetails_ErrDuplicatePropertyNameForAssociationEndEntity,
                        entityType.LocalName.Value, duplicatePropertyName);
                    errorMessage  = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, errorMessage);
                    watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage);
                    return(false);
                }
            }

            return(true);
        }