Exemple #1
0
        /// <summary>
        /// Helper method to retrieve the target root element for validation from the selected object.
        /// </summary>
        protected static DslModeling::ModelElement GetValidationTarget(object selectedObject)
        {
            DslModeling::ModelElement        element      = null;
            DslDiagrams::PresentationElement presentation = selectedObject as DslDiagrams::PresentationElement;

            if (presentation != null)
            {
                if (presentation.Subject != null)
                {
                    element = presentation.Subject;
                }
            }
            else
            {
                element = selectedObject as DslModeling::ModelElement;
            }
            return(element);
        }
Exemple #2
0
        /// <summary>
        /// Called when selection changes in this window.
        /// </summary>
        /// <remarks>
        /// Overriden to update the F1 help keyword for the selection.
        /// </remarks>
        /// <param name="e"></param>
        protected override void OnSelectionChanged(global::System.EventArgs e)
        {
            base.OnSelectionChanged(e);

            if (global::Ultramarine.Generators.Language.GeneratorLanguageHelpKeywordHelper.Instance != null)
            {
                DslModeling::ModelElement selectedElement = this.PrimarySelection as DslModeling::ModelElement;
                if (selectedElement != null)
                {
                    string f1Keyword = global::Ultramarine.Generators.Language.GeneratorLanguageHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);

                    // If this is a presentation element, check the underlying model element for a help keyword
                    DslDiagrams::PresentationElement presentationElement = this.PrimarySelection as DslDiagrams::PresentationElement;
                    if (presentationElement != null)
                    {
                        selectedElement = presentationElement.ModelElement;
                        if (selectedElement != null)
                        {
                            string modelElementKeyword = global::Ultramarine.Generators.Language.GeneratorLanguageHelpKeywordHelper.Instance.GetHelpKeyword(selectedElement);
                            if (string.IsNullOrEmpty(f1Keyword))
                            {
                                // Presentation element does not have an F1 keyword, so push the keyword from the model element as an F1 keyword.
                                f1Keyword = modelElementKeyword;
                            }
                            else if (!string.IsNullOrEmpty(modelElementKeyword) && this.SelectionHelpService != null)
                            {
                                // Presentation element has an F1 keyword, so push model element keyword as a general dynamic help keyword (non-F1).
                                this.SelectionHelpService.AddContextAttribute(string.Empty, modelElementKeyword, global::System.ComponentModel.Design.HelpKeywordType.GeneralKeyword);
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(f1Keyword) && this.SelectionHelpService != null)
                    {
                        this.SelectionHelpService.AddContextAttribute(string.Empty, f1Keyword, global::System.ComponentModel.Design.HelpKeywordType.F1Keyword);
                    }
                }
            }
        }