Exemplo n.º 1
0
        /// <summary>
        ///     Updates the model view, according to the element selected in the context
        /// </summary>
        /// <param name="context"></param>
        /// <param name="rebuildRightPart">Indicates that the right part should be rebuilt</param>
        private void UpdateModelView(Context.SelectionContext context, bool rebuildRightPart)
        {
            StateMachine  stateMachine = GetStateMachine(context);
            IModelElement model        = DisplayedElementInModelDiagramPanel(context);

            if (stateMachine == null)
            {
                DisplayModel(context, rebuildRightPart, model);
            }
            else
            {
                if (model is NameSpace)
                {
                    DisplayStateMachine(context, rebuildRightPart, stateMachine);
                }
                else if (model is Structure)
                {
                    DisplayStateMachine(context, rebuildRightPart, stateMachine);
                }
                else
                {
                    DisplayModel(context, rebuildRightPart, model);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Provides the node corresponding to the model element
        /// </summary>
        /// <param name="selectionContext"></param>
        /// <returns></returns>
        public static BaseTreeNode SourceNode(Context.SelectionContext selectionContext)
        {
            BaseTreeNode retVal = selectionContext.Sender as BaseTreeNode;

            if (retVal == null)
            {
                foreach (IBaseForm form in MdiWindow.SubWindows)
                {
                    if (form != null && form.TreeView != null)
                    {
                        retVal = form.TreeView.FindNode(selectionContext.Element, true);

                        if (retVal != null)
                        {
                            // Finds the upper node for the same model
                            BaseTreeNode parent = retVal.Parent as BaseTreeNode;
                            while (parent != null && parent.Model == retVal.Model)
                            {
                                retVal = parent;
                                parent = retVal.Parent as BaseTreeNode;
                            }

                            break;
                        }
                    }
                }
            }

            return(retVal);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            DisplayedModel = context.Element;

            IEditable editable = DisplayedModel as IEditable;

            if (editable != null)
            {
                SyntaxHighlight = editable.SyntaxHightlight;
                AutoComplete    = editable.SyntaxHightlight;
                setChangeHandler(new EditableTextChangeHandler(editable));
            }
            else
            {
                IExpressionable expressionable = DisplayedModel as IExpressionable;
                if (expressionable != null && !(expressionable is Function))
                {
                    SyntaxHighlight = true;
                    AutoComplete    = true;
                    setChangeHandler(new ExpressionableTextChangeHandler((ModelElement)expressionable));
                }
                else
                {
                    setChangeHandler(null);
                }
            }

            return(retVal);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                SubSequence subSequence = DisplayedModel as SubSequence;
                if (subSequence != null)
                {
                    testDescriptionTimeLineControl.SubSequence = subSequence;
                    testDescriptionTimeLineControl.Refresh();
                    tabControl1.SelectedTab = testDescriptionTabPage;
                }

                TestCase testCase = DisplayedModel as TestCase;
                if (testCase != null)
                {
                    testDescriptionTimeLineControl.TestCase = testCase;
                    testDescriptionTimeLineControl.Refresh();
                    tabControl1.SelectedTab = testDescriptionTabPage;
                }
            }

            return(retVal);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public virtual bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = ShouldTrackSelectionChange(context.Element);

            if (retVal)
            {
                DisplayedModel = context.Element;

                if (TreeView != null)
                {
                    BaseTreeNode node = context.Sender as BaseTreeNode;
                    if (node == null || node.TreeView != TreeView)
                    {
                        node = TreeView.FindNode(context.Element, true);
                    }

                    if (node != null)
                    {
                        TreeView.SilentSelect = true;
                        TreeView.Selected     = node;
                        TreeView.SilentSelect = false;
                        if ((context.Criteria & Context.SelectionCriteria.DoubleClick) != 0)
                        {
                            Focus();
                        }
                    }
                }
            }

            return(retVal);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                INamable namable = DisplayedModel;
                if (namable != null)
                {
                    Text = namable.Name + " history";
                }
                else
                {
                    Text = "History";
                }

                historyTreeView.Root = DisplayedModel;
                if (historyTreeView.Nodes.Count > 0)
                {
                    historyTreeView.SelectedNode = historyTreeView.Nodes[0] as ChangeTreeNode;
                }
                else
                {
                    historyTreeView.SelectedNode = null;
                    Properties.SelectedObject    = null;
                }
            }

            return(retVal);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Updates the status when the selection changes
        /// </summary>
        /// <param name="context"></param>
        private void HandleSelectionChange(Context.SelectionContext context)
        {
            ModelElement element = context.Element as ModelElement;

            if (element != null)
            {
                StatusSynchronizerTask.SetModel(element);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                Refresh();
            }

            return(retVal);
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                staticTimeLineControl.Translation = Translation;
                staticTimeLineControl.Refresh();
            }

            return(retVal);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                navigationPanel.Model = context.Element;
                navigationPanel.RefreshControl();
                navigationPanel.Refresh();
            }

            return(retVal);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Provides the Namespace or the Dictionary enclosing the element in the context
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static IModelElement DisplayedElementInModelDiagramPanel(Context.SelectionContext context)
        {
            IModelElement model = null;

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (model == null)
            {
                model = EnclosingFinder <Function> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <RuleCondition> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <Rule> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <Procedure> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <Structure> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <Range> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <DataDictionary.Types.Enum> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <NameSpace> .find(context.Element, true);
            }

            if (model == null)
            {
                model = EnclosingFinder <Dictionary> .find(context.Element, true);
            }
            return(model);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Displays the model instead of the state machine
 /// </summary>
 /// <param name="context"></param>
 /// <param name="rebuildRightPart"></param>
 /// <param name="model"></param>
 private void DisplayModel(Context.SelectionContext context, bool rebuildRightPart, IModelElement model)
 {
     if (model != null)
     {
         if (rebuildRightPart)
         {
             stateDiagramPanel.Visible = false;
             modelDiagramPanel.Model   = model;
             modelDiagramPanel.Visible = true;
             modelDiagramPanel.RefreshControl();
         }
         modelDiagramPanel.SelectModel(context.Element);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                usageTreeView.Root = DisplayedModel;
                if (usageTreeView.Nodes.Count > 0)
                {
                    usageTreeView.Nodes[0].EnsureVisible();
                }
            }

            return(retVal);
        }
Exemplo n.º 14
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            DisplayedModel = context.Element;
            ICommentable commentable = DisplayedModel as ICommentable;

            if (commentable != null)
            {
                SyntaxHighlight = false;
                AutoComplete    = false;
                setChangeHandler(new CommentableTextChangeHandler((ModelElement)commentable));
            }

            return(retVal);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                if ((context.Sender == modelDiagramPanel) || (context.Sender == stateDiagramPanel))
                {
                    bool rebuildRightPart = (context.Criteria & Context.SelectionCriteria.DoubleClick) != 0;
                    UpdateModelView(context, rebuildRightPart);
                }
                else
                {
                    UpdateModelView(context, true);
                }
            }

            return(retVal);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                messagesDataGridView.DataSource = null;
                if (DisplayedModel != null)
                {
                    IModelElement       current  = DisplayedModel;
                    List <MessageEntry> messages = new List <MessageEntry>();
                    while (current != null)
                    {
                        if (current.Messages != null)
                        {
                            foreach (ElementLog log in current.Messages)
                            {
                                messages.Add(new MessageEntry(log));
                            }
                        }

                        if (EfsSystem.Instance.DisplayEnclosingMessages)
                        {
                            current = current.Enclosing as IModelElement;
                        }
                        else
                        {
                            current = null;
                        }
                    }

                    messagesDataGridView.DataSource = messages;

                    // ReSharper disable PossibleNullReferenceException
                    messagesDataGridView.Columns["Level"].FillWeight   = 10F;
                    messagesDataGridView.Columns["Message"].FillWeight = 90F;
                    // ReSharper restore PossibleNullReferenceException
                }
            }

            return(retVal);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Displays the state machine instead of the model
 /// </summary>
 /// <param name="context"></param>
 /// <param name="rebuildRightPart"></param>
 /// <param name="stateMachine"></param>
 private void DisplayStateMachine(Context.SelectionContext context, bool rebuildRightPart, StateMachine stateMachine)
 {
     if (stateMachine != null)
     {
         if (rebuildRightPart)
         {
             IVariable variable = context.Element as IVariable;
             modelDiagramPanel.Visible = false;
             if (variable != null)
             {
                 stateDiagramPanel.SetStateMachine(variable);
             }
             else
             {
                 stateDiagramPanel.Model = stateMachine;
             }
             stateDiagramPanel.Visible = true;
             stateDiagramPanel.RefreshControl();
         }
         stateDiagramPanel.SelectModel(context.Element);
     }
 }
Exemplo n.º 18
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            propertyGrid.SelectedObject = null;

            BaseTreeNode node = GuiUtils.SourceNode(context);

            if (node != null)
            {
                propertyGrid.SelectedObject = node.GetEditor();
            }
            else
            {
                BaseBoxArrowPanel panel = GuiUtils.EnclosingFinder <BaseBoxArrowPanel> .Find(context.Sender as Control);

                if (panel != null)
                {
                    propertyGrid.SelectedObject = panel.CreateEditor(context.Element);
                }
            }

            return(retVal);
        }
Exemplo n.º 19
0
        /// <summary>
        ///     Allows to refresh the view, when the selected model changed
        /// </summary>
        /// <param name="context"></param>
        /// <returns>true if refresh should be performed</returns>
        public override bool HandleSelectionChange(Context.SelectionContext context)
        {
            bool retVal = base.HandleSelectionChange(context);

            if (retVal)
            {
                if (GuiUtils.MdiWindow != null)
                {
                    List <HistoryObject> history = new List <HistoryObject>();
                    foreach (Context.SelectionContext selectionContext in EfsSystem.Instance.Context.SelectionHistory)
                    {
                        ModelElement historyElement = selectionContext.Element as ModelElement;
                        if (historyElement != null)
                        {
                            history.Add(new HistoryObject(historyElement));
                        }
                    }

                    historyDataGridView.DataSource = history;
                }
            }

            return(retVal);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Provides the state machine from the context
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static StateMachine GetStateMachine(Context.SelectionContext context)
        {
            StateMachine stateMachine;

            State state = EnclosingFinder <State> .find(context.Element, true);

            if (state != null && state.StateMachine.countStates() > 0)
            {
                stateMachine = state.StateMachine;
            }
            else
            {
                stateMachine = EnclosingFinder <StateMachine> .find(context.Element, true);
            }

            IVariable variable = context.Element as IVariable;

            if (variable != null)
            {
                stateMachine = variable.Type as StateMachine;
            }

            return(stateMachine);
        }
Exemplo n.º 21
0
 /// <summary>
 ///     Tries the find the corresponding node when the selection occurs
 /// </summary>
 /// <param name="context"></param>
 protected virtual void Context_SelectionChange(Context.SelectionContext context)
 {
     HandleSelectionChange(context);
 }