Esempio n. 1
0
 /// <summary>
 /// returns the tooltiptext for the given element
 /// </summary>
 /// <param name="element">the element</param>
 /// <returns>the tooltip text</returns>
 private string getToolTipText(UML.UMLItem element)
 {
     //Getting some strange RPC_E_WRONG_THREAD error while getting the owner ElementWrapper.
     //Disablign the tooltiptext for now to avoid the error
     //Enabled again after installing all addins together
     return(element.fqn);
 }
Esempio n. 2
0
 void QuickSearchComboBoxSelectionChangeCommitted(object sender, EventArgs e)
 {
     if (this.quickSearchBox.SelectedIndex >= 0)
     {
         UML.UMLItem quickSearchSelectedItem = this.quickSearchBox.SelectedItem as UML.UMLItem;
         {
             if (quickSearchSelectedItem != null)
             {
                 // if this element is to be selected in the project browser is will
                 // automatically be set as the main element
                 if (settings.quickSearchSelectProjectBrowser)
                 {
                     quickSearchSelectedItem.select();
                 }
                 else
                 {
                     this.setElement(quickSearchSelectedItem);
                 }
                 // also add to diagram if needed
                 if (settings.quickSearchAddToDiagram)
                 {
                     this.addToDiagram(quickSearchSelectedItem);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// event launched just before a node is expanded
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">arguments</param>
 void NavigatorTreeBeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     foreach (TreeNode subNode in e.Node.Nodes)
     {
         if (this.isOwnerNode(subNode))
         {
             UML.UMLItem owner = ((UML.UMLItem)e.Node.Tag).owner;
             if (owner != null)
             {
                 this.addElementToTree(owner, e.Node, subNode);
             }
         }
         else if (this.isTypeNode(subNode))
         {
             UML.Classes.Kernel.Property attribute = e.Node.Tag as UML.Classes.Kernel.Property;
             if (attribute != null &&
                 attribute.type != null)
             {
                 this.addElementToTree(attribute.type, e.Node, subNode);
             }
         }
     }
     if (BeforeExpand != null)
     {
         BeforeExpand(sender, e);
     }
 }
        private void selectFQN(string fqn)
        {
            UML.UMLItem item = null;
            item = this.model.getItemFromFQN(fqn);

            if (item != null)
            {
                item.select();
            }
            else
            {
                string messageText;
                if (fqn.Length > 255)
                {
                    messageText = fqn.Substring(0, 255);
                }
                else
                {
                    messageText = fqn;
                }
                FQNInputForm fqnForm = new FQNInputForm("Could not find item with the string:"
                                                        + Environment.NewLine + messageText, "Fill in the Fully Qualified Name", "FQN:");
                if (fqnForm.ShowDialog() == DialogResult.OK &&
                    fqnForm.fqn.Length > 0)
                {
                    this.selectFQN(fqnForm.fqn);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// set the main element to navigate
        /// </summary>
        /// <param name="newElement">the element to navigate</param>
        public void setElement(UML.UMLItem newElement)
        {
            if (!treeBackgroundWorker.IsBusy)
            {
                this.startThread(newElement);
            }
            else
            {
                //backgroundworker is still busy so we add the element to the workqueue instead
                TimeSpan runtime = (DateTime.Now - lastStartTime);
                if (runtime.TotalSeconds < 5)
                {
                    this.workQueue.Insert(0, newElement);
                    //make sure the queue doesn't get too large.
                    if (this.workQueue.Count > 10)
                    {
                        this.workQueue.RemoveAt(this.workQueue.Count - 1);
                    }
                }
                else
                {
                    //for some reason sometimes the backgroundworker gets stuck.
                    //This always seems to happen shortly after a right click (and thus a call to EA_GetMenuItems) when a lot of elements have been clicked in a short period of time.
                    //when its stuck it is calling a method on the EA API that never returns (someting like EA.Element.Name)
                    //I've tried everything to abort or cancel the thread, but nothing seems to work.
                    //So the only solution that does seem to work is spawn a new thread and start using that one.
                    //In the long rung this will ofcourse cause the a memory/thread leak, but from personal experience, this only seems to happen a few times a day, and only when dealing with a large (and thus slow) model.

                    //current backgoundworker is stuck. Start a new one.
                    this.resetTreeBackgroundWorker();
                    //process the element
                    this.startThread(newElement);
                }
            }
        }
        /// <summary>
        /// initialise based on named elements
        /// </summary>
        /// <param name="namedElements"></param>
        private void InitNamedElements(List <UML.UMLItem> namedElements)
        {
            InitializeComponent();
            this.Text            = "Select Elements";
            this.ItemHeader.Text = "Element";
            this.openButton.Text = "Select";
            //fill the diagramList
            foreach (UML.UMLItem element in namedElements)
            {
                //add the element
                ListViewItem item = new ListViewItem(element.name);
                item.Tag = element;

                string ownerName = string.Empty;

                UML.UMLItem owner = element.owner as UML.UMLItem;
                if (null != owner)
                {
                    ownerName = owner.name;
                }
                item.SubItems.Add(ownerName);
                if (ownerName == string.Empty)
                {
                    item.ForeColor = SystemColors.GrayText;
                }
                item.UseItemStyleForSubItems = true;
                this.navigateListView.Items.Add(item);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// returns all diagrams that show this item
        /// </summary>
        /// <param name="parentElement"></param>
        /// <returns></returns>
        private List <UML.UMLItem> getDepentDiagrams(UML.UMLItem parentElement)
        {
            var elementsToNavigate = new List <UML.UMLItem>();

            elementsToNavigate.AddRange(parentElement.getDependentDiagrams());
            return(elementsToNavigate);
        }
Esempio n. 8
0
        private bool SynchronizeUmlItemTags(UML.UMLItem umlItem, ref string TagName, ref string TagValue, ref string TagNotes)
        {
            inSyncUmlItem = true;
            try {
                if (umlItem is UML.Classes.Kernel.Class)
                {
                    UML.Classes.Kernel.Class classItem = umlItem as UML.Classes.Kernel.Class;
                }
                else if (umlItem is UML.Classes.Interfaces.Interface)
                {
                    return(SynchronizeUmlItemTags(umlItem as UML.Classes.Interfaces.Interface, ref TagName, ref TagValue, ref TagNotes));
                }
                else if (umlItem is UML.Classes.Kernel.Operation)
                {
                    return(SynchronizeUmlItemTags(umlItem as UML.Classes.Kernel.Operation, ref TagName, ref TagValue, ref TagNotes));
                }
            }
            catch (Exception ex) {
                inSyncUmlItem = false;
                throw ex;
            }
            finally {
                inSyncUmlItem = false;
            }

            return(false);
        }
Esempio n. 9
0
 /// <summary>
 /// copies the GUID of the selected element to the clipboard
 /// </summary>
 void copyGUID()
 {
     UML.UMLItem selectedElement = this.NavigatorTree.SelectedNode.Tag as UML.UMLItem;
     if (selectedElement.uniqueID != null)
     {
         Clipboard.SetText(selectedElement.uniqueID);
     }
 }
Esempio n. 10
0
 private void addToDiagram(UML.UMLItem selectedElement)
 {
     if (selectedElement != null)
     {
         selectedElement.addToCurrentDiagram();
         selectedElement.selectInCurrentDiagram();
     }
 }
Esempio n. 11
0
 private void openProperties()
 {
     UML.UMLItem selectedElement = this.NavigatorTree.SelectedNode.Tag as UML.UMLItem;
     if (selectedElement != null)
     {
         selectedElement.openProperties();
     }
 }
 /// <summary>
 /// When a diagram is doubleclicked we need to set it a the main element
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">parameters</param>
 void NavigatorTreeNodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     UML.UMLItem selectedElement = e.Node.Tag as UML.UMLItem;
     if (selectedElement is UML.Diagrams.Diagram)
     {
         this.navigatorControl.setElement(selectedElement);
     }
 }
        /// <summary>
        /// Opens the attributes of that use the selected element as type
        /// </summary>
        private List <UML.UMLItem> getAttributes(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Classes.Kernel.Type selectedType = parentElement as UML.Classes.Kernel.Type;
            // get the attributes that use the selected Type as type
            elementsToNavigate.AddRange(selectedType.getDependentTypedElements <UML.Classes.Kernel.Property>());
            return(elementsToNavigate);
        }
        /// <summary>
        /// Opens the parameters that use the selected element as type
        /// </summary>
        private List <UML.UMLItem> getParameters(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Classes.Kernel.Type selectedType = parentElement as UML.Classes.Kernel.Type;
            // get the parameters that use the selected classifier as type
            elementsToNavigate.AddRange(selectedType.getDependentTypedElements <UML.Classes.Kernel.Parameter>());
            return(elementsToNavigate);
        }
Esempio n. 15
0
        /// <summary>
        /// catches the event that the backgroundworker has finished.
        /// in that case we should select the returned node
        /// </summary>
        /// <param name="sender">the backgroundworder</param>
        /// <param name="e">the parameters</param>
        private void treeBackgroundRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if ((e.Cancelled == true))
            {
                //nothing?
            }
            else if (!(e.Error == null))
            {
                //nothing?
            }
            else
            {
                //do the visual work for the new treenode
                TreeNode elementNode = (TreeNode)e.Result;

                //remove duplicate
                if (this.removeRootNode((UML.UMLItem)elementNode.Tag))
                {
                    try
                    {
                        //no parentNode, add as new root node before any others
                        //inserting a node sometimes causes an InvalidOperationException because its being called in the wrong thread
                        //doing it using the invoke should help.
                        invoker = new MethodDelegate(ThreadSaveInsertNode);
                        this.NavigatorTree.Invoke(invoker, elementNode);
                        //this.NavigatorTree.Nodes.Insert(0,elementNode);
                        //remove the excess nodes
                        this.removeExcessNodes();
                        //expand the node
                        elementNode.Expand();
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace, "An error occured"
                                        , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    //first node is already the one we need
                    elementNode = this.NavigatorTree.Nodes[0];
                }
                this.NavigatorTree.SelectedNode = (TreeNode)e.Result;

                //check if there's still something int the queue
                if (this.workQueue.Count > 0)
                {
                    //get the last element in the queue
                    UML.UMLItem nextElement = this.workQueue[this.workQueue.Count - 1];
                    //remove it
                    this.workQueue.RemoveAt(this.workQueue.Count - 1);
                    //process it
                    this.setElement(nextElement);
                }
            }
        }
Esempio n. 16
0
 private void startThread(UML.UMLItem newElement)
 {
     if (!this.treeBackgroundWorker.IsBusy)
     {
         this.working = true;
         //start new tread here to create new element
         this.lastStartTime = DateTime.Now;
         this.treeBackgroundWorker.RunWorkerAsync(newElement);
     }
 }
        internal static string getOwnerMenuName(UML.UMLItem element)
        {
            string ownerMenuname = ownerMenuPrefix;

            if (element.owner != null)
            {
                ownerMenuname += element.owner.name;
            }
            return(ownerMenuname);
        }
        /// <summary>
        /// Opens the type of the attribute
        /// </summary>
        private List <UML.UMLItem> getClassifier(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Classes.Kernel.Property selectedAttribute = parentElement as UML.Classes.Kernel.Property;
            if (null != selectedAttribute)
            {
                elementsToNavigate.Add(selectedAttribute.type);
            }
            return(elementsToNavigate);
        }
        /// <summary>
        /// Execute the actual functions
        /// </summary>
        /// <param name="Repository">the repository</param>
        /// <param name="Location">menu location</param>
        /// <param name="MenuName">menu name</param>
        /// <param name="ItemName">option clicked</param>
        public override void EA_MenuClick(global::EA.Repository Repository,
                                          String Location,
                                          String MenuName, String ItemName)
        {
            switch (ItemName)
            {
            case menuFQN:
                this.selectFQN();
                break;

            case menuGUID:
                this.selectGUID();
                break;

            case menuAbout:
                new AboutWindow().ShowDialog();
                break;

            case menuSettings:
                new NavigatorSettingsForm(this.settings).ShowDialog();
                //we need to set the toolbar in case that setting was changed
                if (this.navigatorControl != null)
                {
                    this.navigatorControl.toolbarVisible = this.settings.toolbarVisible;
                }
                break;

            case menuOpenInNavigator:
                this.navigate();
                break;

            default:
                UML.UMLItem selectedItem = this.model.selectedItem;
                if (selectedItem != null)
                {
                    List <UML.UMLItem> elementsToNavigate = this.getElementsToNavigate(ItemName, selectedItem);
                    if (elementsToNavigate.Count == 1)
                    {
                        elementsToNavigate[0].open();
                    }
                    else if (elementsToNavigate.Count > 1)
                    {
                        NavigatorList dialog = new NavigatorList(elementsToNavigate, selectedItem);
                        dialog.Show();
                    }
                    else
                    {
                        string message = selectedItem.name + " does not have any " + ItemName.Replace("&", string.Empty);
                        MessageBox.Show(message, "Nothing to navigate", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                break;
            }
        }
Esempio n. 20
0
        private void treeBackground_DoWork(object sender, DoWorkEventArgs e)
        {
            UML.UMLItem      element = e.Argument as UML.UMLItem;
            BackgroundWorker worker  = sender as BackgroundWorker;

            if (element != null)
            {
                //pass the new node to the runworkercompleted event
                e.Result = this.makeElementNode(element, null);
            }
        }
        private List <UML.UMLItem> getCompositeElements(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Diagrams.Diagram compositeDiagram = parentElement as UML.Diagrams.Diagram;
            if (compositeDiagram != null)
            {
                elementsToNavigate = compositeDiagram.compositeElements.Cast <UML.UMLItem>().ToList();
            }
            return(elementsToNavigate);
        }
        /// <summary>
        /// opens the CallOperationActions that call te selected operation
        /// </summary>
        private List <UML.UMLItem> getActions(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Classes.Kernel.Operation selectedOperation = this.getSelectedOperation(parentElement);
            if (selectedOperation != null)
            {
                elementsToNavigate.AddRange(selectedOperation.getDependentCallOperationActions());
            }
            return(elementsToNavigate);
        }
        /// <summary>
        /// returns the owner of the parentElement
        /// </summary>
        /// <param name="parentElement">the selected element</param>
        /// <returns>the owner of the element</returns>
        private List <UML.UMLItem> getOwner(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.UMLItem owner = parentElement.owner;
            if (owner != null)
            {
                elementsToNavigate.Add(owner);
            }
            return(elementsToNavigate);
        }
        /// <summary>
        /// get all using diagrams for the given element
        /// currently only used for operations
        /// </summary>
        /// <param name="parentElement">the element</param>
        /// <returns>the diagrams using the given element</returns>
        private List <UML.UMLItem> getDiagrams(UML.UMLItem parentElement)
        {
            List <UML.UMLItem> elementsToNavigate = new List <UML.UMLItem>();

            UML.Classes.Kernel.Operation selectedOperation = this.getSelectedOperation(parentElement);

            if (selectedOperation != null)
            {
                elementsToNavigate.AddRange(selectedOperation.getUsingDiagrams <UML.Diagrams.Diagram>());
            }
            return(elementsToNavigate);
        }
        internal static string getTypeMenuName(UML.UMLItem element)
        {
            string typeMenuname = typeMenuPrefix;

            UML.Classes.Kernel.Property attribute = element as UML.Classes.Kernel.Property;
            if (attribute != null &&
                attribute.type != null)
            {
                typeMenuname += attribute.type.name;
            }
            return(typeMenuname);
        }
Esempio n. 26
0
 public override TSF.UmlToolingFramework.UML.UMLItem getItemFromRelativePath(List <string> relativePath)
 {
     UML.UMLItem item = null;
     if (ElementWrapper.filterName(relativePath, this.name))
     {
         if (relativePath.Count == 1)
         {
             item = this;
         }
     }
     return(this);
 }
Esempio n. 27
0
 private void navigate(UML.UMLItem item)
 {
     if (fullyLoaded)
     {
         if (this.navigatorControl != null && this.model != null)
         {
             if (item != null)
             {
                 this.navigatorControl.setElement(item);
             }
         }
     }
 }
 /// <summary>
 /// gets the elements of a package right before expanding
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">parameters</param>
 void NavigatorTreeBeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     if (e.Node.Tag == null)
     {
         UML.UMLItem parentElement = e.Node.Parent.Tag as UML.UMLItem;
         if (parentElement != null)
         {
             string             option      = "&" + e.Node.Text;
             List <UML.UMLItem> subElements = this.getElementsToNavigate(option, parentElement);
             this.navigatorControl.setSubNodes(e.Node, subElements);
         }
     }
 }
        /// <summary>
        /// searches downward for the item with the given relative path
        /// This relative path includes the own name
        /// </summary>
        /// <param name="relativePath">list of names inlcuding the own name</param>
        /// <returns>the item matching the path</returns>
        public TSF.UmlToolingFramework.UML.UMLItem getItemFromRelativePath(List <string> relativePath)
        {
            UML.UMLItem   item         = null;
            List <string> filteredPath = new List <string>(relativePath);

            if (ElementWrapper.filterName(filteredPath, this.name))
            {
                if (filteredPath.Count == 1)
                {
                    item = this;
                }
            }
            return(item);
        }
        /// <summary>
        /// The EA_GetMenuItems event enables the Add-In to provide the Enterprise Architect user interface with additional Add-In menu options in various context and main menus. When a user selects an Add-In menu option, an event is raised and passed back to the Add-In that originally defined that menu option.
        /// This event is raised just before Enterprise Architect has to show particular menu options to the user, and its use is described in the Define Menu Items topic.
        /// Also look at:
        /// - EA_MenuClick
        /// - EA_GetMenuState.
        /// </summary>
        /// <param name="Repository">An EA.Repository object representing the currently open Enterprise Architect model.
        /// Poll its members to retrieve model data and user interface status information.</param>
        /// <param name="MenuLocation">String representing the part of the user interface that brought up the menu.
        /// Can be TreeView, MainMenu or Diagram.</param>
        /// <param name="MenuName">The name of the parent menu for which sub-items are to be defined. In the case of the top-level menu it is an empty string.</param>
        /// <returns>One of the following types:
        /// - A string indicating the label for a single menu option.
        /// - An array of strings indicating a multiple menu options.
        /// - Empty (Visual Basic/VB.NET) or null (C#) to indicate that no menu should be displayed.
        /// In the case of the top-level menu it should be a single string or an array containing only one item, or Empty/null.</returns>
        public override object EA_GetMenuItems(EA.Repository Repository, string MenuLocation, string MenuName)
        {
            //check setting for context menus
            if (this.settings.contextmenuVisible || MenuLocation == "MainMenu" ||
                !this.settings.trackSelectedElement)
            {
                switch (MenuName)
                {
                case "":
                    //return top level menu option
                    return(this.menuHeader);

                case menuName:
                    List <string> menuOptionsList = new List <string>();
                    if (!this.settings.trackSelectedElement)
                    {
                        menuOptionsList.Add(menuOpenInNavigator);
                    }
                    //Context menu
                    if (MenuLocation != "MainMenu" && this.settings.contextmenuVisible)
                    {
                        // get the selected element from the model
                        UML.UMLItem selectedElement = this.model.selectedItem;
                        menuOptionsList.AddRange(getMenuOptions(selectedElement));
                    }
                    // Main menu
                    else if (MenuLocation == "MainMenu")
                    {
                        // To FQN
                        menuOptionsList.Add(menuFQN);
                        // To GUID
                        menuOptionsList.Add(menuGUID);
                        // setting
                        menuOptionsList.Add(menuSettings);
                        //menu about
                        menuOptionsList.Add(menuAbout);
                    }
                    // return submenu options
                    return(menuOptionsList.ToArray());

                default:
                    return(string.Empty);
                }
            }
            //don't show menu;
            else
            {
                return(null);
            }
        }
 	/// <summary>
 	/// createas a new navigatorList based on the given list of UML Items
 	/// </summary>
 	/// <param name="items">the items to show</param>
 	public NavigatorList(List<UML.UMLItem> items, UML.UMLItem context):base()
     {
 		if (items.Count > 0)
 		{
 			this.context = context;
 			if (items[0] is UML.Diagrams.Diagram)
 			{
 				this.InitDiagrams(items.Cast<UML.Diagrams.Diagram>().ToList());
 			}
 			else
 			{
 				this.InitNamedElements(items);
 			}
 		}
 			
     }