Example #1
0
        public static void ValidateFromElement(
            ModelingDocData docData,
            ICollection currentSelection,
            Func <Object, ModelElement> validationTargetProvider)
        {
            ThrowOnInvalidController(docData);
            HashSet <ModelElement> elementList   = new HashSet <ModelElement>();
            FullDepthElementWalker elementWalker = new FullDepthElementWalker(
                new ModelElementVisitor(elementList), new EmbeddingReferenceVisitorFilter(), false);

            foreach (object selectedObject in currentSelection)
            {
                // Build list of elements embedded beneath the selected root.
                ModelElement element = validationTargetProvider(selectedObject);
                if (element != null && !elementList.Contains(element))
                {
                    elementWalker.DoTraverse(element);
                }
            }

            // Clear the previous messages
            IValidationControllerAccesor accesor = docData as IValidationControllerAccesor;

            accesor.Controller.ClearMessages();
            if (elementList.Count > 0)
            {
                accesor.Controller.Validate(elementList, ValidationCategories.Menu);
            }
            elementList.Clear();
        }
Example #2
0
        private bool IsValidModel()
        {
            OnMenuValidate(null, null, this.CurrentDocData);

            IValidationControllerAccesor accesor = this.CurrentDocData as IValidationControllerAccesor;

            return(0 == Logger.Messages[TraceEventType.Error] &&
                   accesor != null &&
                   accesor.Controller.ErrorMessages.Count == 0);
        }
Example #3
0
        public static void ValidateFromModel <T>(ModelingDocData docData) where T : ModelElement
        {
            ThrowOnInvalidController(docData);
            HashSet <ModelElement> elementList   = new HashSet <ModelElement>();
            FullDepthElementWalker elementWalker = new FullDepthElementWalker(
                new ModelElementVisitor(elementList), new EmbeddingReferenceVisitorFilter(), false);

            T model = DomainModelHelper.GetElement <T>(docData.Store);

            if (model != null)
            {
                elementWalker.DoTraverse(model);
            }
            // Clear the previous messages
            IValidationControllerAccesor accesor = docData as IValidationControllerAccesor;

            accesor.Controller.ClearMessages();
            if (elementList.Count > 0)
            {
                accesor.Controller.Validate(elementList, ValidationCategories.Menu);
            }
            elementList.Clear();
        }