/********************************************************************************************
        ** EAMain Callbacks
        ********************************************************************************************/

        /// <summary>
        ///     This method is called when double clicking an element in the view pane. It opens the respective View.
        /// </summary>
        /// <param name="guid">
        ///     A string holding the GUID of the EAElement clicked by the user.
        /// </param>
        /// <param name="type">
        ///     The EANativeType of the element clicked by the user.
        /// </param>
        /// <returns></returns>
        public override bool OnContextItemDoubleClicked(string guid, EANativeType type)
        {
            // If the type is not an Element
            if (type != EANativeType.Element)
            {
                return(false);
            }
            // Get the element
            IEAElement element = EAMain.Repository.GetElementByGUID(guid);

            // If it is not a decision or a topic, leave!
            if (!(EAMain.IsDecision(element) || EAMain.IsTopic(element)))
            {
                return(false);
            }

            // Check if the tab is already open.
            if (EAMain.IsDecision(element))
            {
                OpenDecisionDetailView(Decision.Load(element));
                return(true);
            }

            if (EAMain.IsTopic(element))
            {
                OpenTopicDetailView(Topic.Load(element));
                return(true);
            }
            return(false);
        }
        /********************************************************************************************
        ** Invoke View Change methods
        ********************************************************************************************/

        internal static void InvokeViewChange(string elementGUID, EANativeType eANativeType)
        {
            if (eANativeType == EANativeType.Diagram)
            {
                IEAElement   element  = EAMain.Repository.GetElementByGUID(elementGUID);
                IEADiagram[] diagrams = element.GetDiagrams();
                if (diagrams.Length == 1)
                {
                    IEADiagram diagram = diagrams[0];
                    diagram.OpenAndSelectElement(element);
                }
                else if (diagrams.Length >= 2)
                {
                    var selectForm = new SelectDiagramDialog(diagrams);
                    if (selectForm.ShowDialog() == DialogResult.OK)
                    {
                        IEADiagram diagram = selectForm.GetSelectedDiagram();
                        diagram.OpenAndSelectElement(element);
                    }
                }
            }
            else if (eANativeType == EANativeType.Element)
            {
                Instance.OnContextItemDoubleClicked(elementGUID, eANativeType);
            }
        }
        public override void OnNotifyContextItemModified(string guid, EANativeType ot)
        {
            string message;

            switch (ot)
            {
            case EANativeType.Element:

                IEAElement element = EAMain.Repository.GetElementByGUID(guid);

                //dirty hack to prevent that the event is fired twice when an decision is modified
                if (_lastGUID.Equals(guid) && _lastChange.Equals(element.Modified))
                {
                    return;
                }

                if (!RuleManager.Instance.ValidateElement(element, out message))
                {
                    MessageBox.Show(
                        message,
                        Messages.WarningCreateRelation,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation,
                        MessageBoxDefaultButton.Button1);
                }
                _lastGUID   = guid;
                _lastChange = element.Modified;

                break;

            case EANativeType.Connector:
                IEAConnector connector = EAMain.Repository.GetConnectorByGUID(guid);

                //dirty hack that prevents that an modified event is fired after a connector has been created
                if (_preventConnectorModifiedEvent)
                {
                    _preventConnectorModifiedEvent = false;
                }
                else
                {
                    if (!RuleManager.Instance.ValidateConnector(connector, out message))
                    {
                        MessageBox.Show(
                            message,
                            Messages.WarningCreateRelation,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation,
                            MessageBoxDefaultButton.Button1);
                    }
                }
                break;
            }
        }
 public override void OnNotifyContextItemModified(string guid, EANativeType type)
 {
     if (EANativeType.Diagram.Equals(type))
     {
         IEADiagram diagram = EAMain.Repository.GetDiagramByGuid(guid);
         if (!diagram.IsRelationshipView())
         {
             return;
         }
         diagram.HideConnectors(new[]
         {
             EAConstants.RelationFollowedBy
         });
     }
 }
Example #5
0
        /// <summary>
        ///     Checks whether the _btnAddForce should be enabled or disabled
        ///     Cannot add force if no force or concern is selected or if selected element is a model or package
        /// </summary>
        /// <returns></returns>
        private bool ButtonEnabled()
        {
            TreeNode selectedNode = _tvForce.SelectedNode;

            if (selectedNode == null || _lbConcern.SelectedItems.Count < 1)
            {
                return(false);
            }

            EANativeType type = EAUtilities.IdentifyGUIDType(selectedNode.ImageKey);

            if (type == EANativeType.Model || type == EANativeType.Package)
            {
                return(false);
            }

            return(true);
        }
 public override void OnNotifyContextItemModified(string guid, EANativeType type)
 {
     switch (type)
     {
     case EANativeType.Diagram:
         IEADiagram diagram = EAMain.Repository.GetDiagramByGuid(guid);
         if (!diagram.IsChronologicalView())
         {
             break;
         }
         diagram.HideConnectors(new[]
         {
             EAConstants.RelationAlternativeFor, EAConstants.RelationCausedBy,
             EAConstants.RelationDependsOn,
             EAConstants.RelationExcludedBy, EAConstants.RelationReplaces
         });
         break;
     }
 }
        public override bool OnContextItemDoubleClicked(string guid, EANativeType type)
        {
            if (EANativeType.Diagram != type)
            {
                return(false);
            }
            IEARepository repository = EAMain.Repository;
            IEADiagram    diagram    = repository.GetDiagramByGuid(guid);

            if (!diagram.IsForcesView())
            {
                return(false);
            }
            var forcesDiagramModel = new ForcesModel(diagram);

            if (repository.IsTabOpen(forcesDiagramModel.Name) > 0)
            {
                // naming is not optimal as tabs can have same names... need to find a solution that we can
                // distinguish tabs more optimal
                repository.ActivateTab(forcesDiagramModel.Name);
                return(true);
            }

            IForcesView forcesView = repository.AddTab(forcesDiagramModel.Name,
                                                       "DecisionViewpoints.Forces");
            IForcesController forcesController;

            if (!_controllers.ContainsKey(forcesDiagramModel.DiagramGUID))
            {
                forcesController = new ForcesController(forcesView, forcesDiagramModel);
                _controllers.Add(forcesDiagramModel.DiagramGUID, forcesController);
            }
            else
            {
                forcesController       = _controllers[forcesDiagramModel.DiagramGUID];
                forcesController.View  = forcesView;
                forcesController.Model = forcesDiagramModel;
            }

            forcesController.Update();
            return(true);
        }
Example #8
0
        public override void OnNotifyContextItemModified(string guid, EANativeType type)
        {
            switch (type)
            {
            case EANativeType.Element:
                OnModelChanged(new ModelChangedEventArgs
                {
                    GUID       = guid,
                    Type       = ModelChangedType.ModifiedElement,
                    NativeType = EANativeType.Element
                });
                break;

            case EANativeType.Connector:

                OnModelChanged(new ModelChangedEventArgs
                {
                    GUID       = guid,
                    Type       = ModelChangedType.ModifiedConnector,
                    NativeType = EANativeType.Connector
                });
                break;
            }
        }
Example #9
0
 public virtual bool OnContextItemDoubleClicked(string guid, EANativeType type)
 {
     return(false);
 }
Example #10
0
 public virtual void OnContextItemChanged(string guid, EANativeType type)
 {
 }
Example #11
0
 public virtual void OnNotifyContextItemModified(string guid, EANativeType type)
 {
 }
        public override void OnNotifyContextItemModified(string guid, EANativeType type)
        {
            IEARepository     repository = EAMain.Repository;
            IForcesController forcesController;

            switch (type)
            {
            // the diagram is modified when we remove an element or a connector from it
            case EANativeType.Diagram:
                IEADiagram diagram = repository.GetDiagramByGuid(guid);
                if (!diagram.IsForcesView())
                {
                    return;
                }
                // if the name of a diagram changed and the forces tab is open then close it to avoid conflicts
                if (repository.IsTabOpen(ForcesModel.CreateForcesTabName(diagram.Name)) <= 0)
                {
                    if (!_controllers.ContainsKey(diagram.GUID))
                    {
                        break;
                    }
                    forcesController = _controllers[diagram.GUID];
                    if (repository.IsTabOpen(forcesController.Model.Name) > 0)
                    {
                        repository.RemoveTab(forcesController.Model.Name);
                    }
                    break;
                }
                if (!_controllers.ContainsKey(diagram.GUID))
                {
                    break;
                }
                forcesController = _controllers[diagram.GUID];
                forcesController.SetDiagramModel(diagram);
                break;

            case EANativeType.Element:
                IEAElement element = repository.GetElementByGUID(guid);
                foreach (
                    IEADiagram eaDiagram in
                    element.GetDiagrams()
                    .Where(eaDiagram => eaDiagram.IsForcesView())
                    .Where(eaDiagram => _controllers.ContainsKey(eaDiagram.GUID)))
                {
                    forcesController = _controllers[eaDiagram.GUID];
                    // An element can be of multiple types:
                    if (element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateDecision(element);
                    }
                    if (element.TaggedValueExists(EATaggedValueKeys.IsConcernElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateConcern(element);
                    }
                    if (element.TaggedValueExists(EATaggedValueKeys.IsForceElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateForce(element);
                    }
                }
                break;
            }
        }