コード例 #1
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (_fr.Index >= 0)
            {
                FindAndReplaceItem item = _fr.l_items[_fr.Index];
                item.Name        = _fr.ChangeString(item.Name, txtTo.Text);
                item.Description = _fr.ChangeString(item.Description, txtTo.Text);
                item.Stereotype  = _fr.ChangeString(item.Stereotype, txtTo.Text);
                // update form
                rtfName.Text       = item.Name;
                rtfNotes.Text      = item.Description;
                rtfStereotype.Text = item.Stereotype;

                //
                if (_fr.isTagSearch && (gridTags != null))
                {
                    gridTags.DataSource = null;
                    //FindAndReplaceItemElement itemEl = (FindAndReplaceItemElement)item;
                    foreach (FindAndReplaceItemTag tag in item.l_itemTag)
                    {
                        tag.Value = _fr.ChangeString(tag.Value, txtTo.Text);
                    }
                    gridTags.AutoGenerateColumns = false;
                    gridTags.DataSource          = item.l_itemTag;
                }
            }
            txtState.Text = StateCurrentItem() + " changed temporary, store if you want it permanently.";
        }
コード例 #2
0
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="pkg"></param>
 /// <param name="fr"></param>
 private static void FindMatchingPackageTaggedValue(EA.Repository rep, EA.Package pkg, FindAndReplace fr)
 {
     EA.Element el = rep.GetElementByGuid(pkg.PackageGUID);
     foreach (EA.TaggedValue tag in el.TaggedValues)
     {
         if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(el, tag.Name));
             if (count > 0)
             {
                 // Create the searchers
                 FindAndReplaceItem frItem = fr.LastItem();
                 if ((frItem == null) || (frItem.Guid != el.ElementGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otPackage, el.ElementGUID);
                     fr.LItems.Add(frItem);
                 }
                 // Search
                 var frItemPkg = (FindAndReplaceItemPackage)frItem;
                 frItemPkg.LItemTag.Add(new FindAndReplaceItemTagPackage(tag));
                 frItemPkg.CountChanges = frItemPkg.CountChanges + count;
             }
         }
     }
 }
コード例 #3
0
        private void SaveItem()
        {
            FindAndReplaceItem frItem = _fr.l_items[_fr.Index];

            frItem.Name        = rtfName.Text;
            frItem.Description = rtfNotes.Text.Replace("\n", "\r\n");
            frItem.Stereotype  = rtfStereotype.Text;
            if (frItem.isUpdated)
            {
                chkIsChanged.Checked = true;
            }
            else
            {
                chkIsChanged.Checked = false;
            }
            frItem.save(_fr.rep, FindAndReplaceItem.FieldType.Description | FindAndReplaceItem.FieldType.Name | FindAndReplaceItem.FieldType.Stereotype);

            // tagged values for elements
            if (_fr.isTagSearch && (gridTags != null))
            {
                foreach (FindAndReplaceItemTag tag in frItem.l_itemTag)
                {
                    tag.save();
                }
            }
        }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     EA.Diagram dia = rep.GetDiagramByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { dia.Notes = _Description; }
     if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0)
     {   dia.Name = _Name; }
     if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0)
     { dia.StereotypeEx = _Stereotype; }
     _isUpdated = true;            
     dia.Update();
 }
        public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
        {

            if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
            { _attr.Notes = _Description; }
            if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0)
            { _attr.StereotypeEx = _Stereotype; }
            if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0)
            {   _attr.Name = _Name; }
            _isUpdated = true;
            _attr.Update();
        }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     EA.Method meth = rep.GetMethodByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { meth.Notes = _Description; }
     if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0)
     {   meth.Name = _Name; }
     if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0)
     { meth.StereotypeEx = _Stereotype; }
     _isUpdated = true;
     meth.Update();
 }
コード例 #7
0
 public void LocateCurrentElement()
 {
     if (_index < 0)
     {
         MessageBox.Show("Nothing found beneath selected package (recursive)", "No search results");
         return;
     }
     else
     {
         FindAndReplaceItem frItem = _l_items[_index];
         frItem.locate(_rep);
     }
 }
コード例 #8
0
        private void ChangeItem(FindAndReplaceItem item)
        {
            item.Name        = _fr.ChangeString(item.Name, txtTo.Text);
            item.Description = _fr.ChangeString(item.Description, txtTo.Text);
            item.Stereotype  = _fr.ChangeString(item.Stereotype, txtTo.Text);

            if (_fr.IsTagSearch && (gridTags != null))
            {
                foreach (FindAndReplaceItemTag itemTag in item.LItemTag)
                {
                    itemTag.Value = _fr.ChangeString(itemTag.Value, txtTo.Text);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Find the count of found searches in item:
        /// - add item to l_items
        /// - update item to l_items if item is already available
        ///
        /// </summary>
        /// <param name="object_type"></param>
        /// <param name="GUID"></param>
        public int FindStringInItem(EA.ObjectType object_type, string GUID)
        {
            int count = 0;
            FindAndReplaceItem frItem = null;


            frItem = FindAndReplaceItem.Factory(_rep, object_type, GUID);
            count  = frItem.findCount(_regExPattern, _searchFieldTypes);
            if (count > 0)
            {
                frItem.CountChanges = count;
                this.l_items.Add(frItem);
            }

            return(count);
        }
コード例 #10
0
        /// <summary>
        /// Replace all occurences of "Search string" by "Replace String" in current selected item.
        /// </summary>
        public int ReplaceItem()
        {
            if (_index < 0)
            {
                return(0);
            }
            FindAndReplaceItem item = _l_items[_index];// get item

            item.load(_rep);

            // search for name
            if ((_searchFieldTypes & FindAndReplaceItem.FieldType.Name) > 0)
            {
                item.Name = ChangeString(item.Name);
            }

            // search for description
            if ((_searchFieldTypes & FindAndReplaceItem.FieldType.Description) > 0)
            {
                item.Description = ChangeString(item.Description);
            }
            // search for stereotype
            if ((_searchFieldTypes & FindAndReplaceItem.FieldType.Stereotype) > 0)
            {
                item.Stereotype = ChangeString(item.Stereotype);
            }



            if ((_searchFieldTypes & FindAndReplaceItem.FieldType.Tag) > 0)
            {
                foreach (FindAndReplaceItemTag tag in item.l_itemTag)
                {
                    tag.Value = ChangeString(tag.Value);
                    tag.save();
                }
            }

            // set to changed
            item.save(_rep, _searchFieldTypes);
            return(item.CountChanges);
        }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     _pkg = rep.GetPackageByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     { _pkg.Notes = _Description; }
     if ((fieldType & (FindAndReplaceItem.FieldType.Name | FindAndReplaceItem.FieldType.Stereotype) ) > 0)
     {
         // model don't have an element
         if (_pkg.ParentID != 0)
         {
             EA.Element el = rep.GetElementByGuid(GUID);
             el.StereotypeEx = _Stereotype;
             el.Name = _Name;
             el.Update();
         }
         _pkg.Name = _Name;
     }
     _isUpdated = true;
     _pkg.Update();
 }
コード例 #12
0
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="el"></param>
 /// <param name="fr"></param>
 private static void FindMatchingElementTaggedValue(EA.Repository rep, EA.Element el, FindAndReplace fr)
 {
     foreach (EA.TaggedValue tag in el.TaggedValues)
     {
         if ((fr.tagValueNames.Length == 0) || (fr.tagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.findCountForType(fr.regexPattern, tag.Value);
             if (count > 0)
             {
                 FindAndReplaceItem frItem = fr.lastItem();
                 if ((frItem == null) || (frItem.GUID != el.ElementGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otElement, el.ElementGUID);
                     fr.l_items.Add(frItem);
                 }
                 var frItemEl = (FindAndReplaceItemElement)frItem;
                 frItemEl.l_itemTag.Add(new FindAndReplaceItemTagElement(tag));
                 frItemEl.CountChanges = frItemEl.CountChanges + count;
             }
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// Find matching tagged values for element
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="el"></param>
        /// <param name="fr"></param>
        private static void FindMatchingAttributeTaggedValue(EA.Repository rep, EA.Attribute a, FindAndReplace fr)
        {
            foreach (EA.AttributeTag tag in a.TaggedValues)
            {
                if ((fr.tagValueNames.Length == 0) || (fr.tagValueNames.Contains(tag.Name)))
                {
                    int count = FindAndReplaceItem.findCountForType(fr.regexPattern, tag.Value);
                    if (count > 0)
                    {
                        FindAndReplaceItem frItem = fr.lastItem();
                        if ((frItem == null) || (frItem.GUID != a.AttributeGUID))
                        {
                            frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otAttribute, a.AttributeGUID);
                            fr.l_items.Add(frItem);
                        }

                        var frItemAttr = (FindAndReplaceItemAttribute)frItem;
                        frItemAttr.l_itemTag.Add(new FindAndReplaceItemTagAttribute(tag));
                        frItemAttr.CountChanges = frItemAttr.CountChanges + count;
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Find matching tagged values for element
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="method"></param>
        /// <param name="fr"></param>
        private static void FindMatchingMethodTaggedValue(EA.Repository rep, EA.Method method, FindAndReplace fr)
        {
            foreach (EA.MethodTag tag in method.TaggedValues)
            {
                if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
                {
                    int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(method, tag.Name));
                    if (count > 0)
                    {
                        FindAndReplaceItem frItem = fr.LastItem();
                        if ((frItem == null) || (frItem.Guid != method.MethodGUID))
                        {
                            frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otMethod, method.MethodGUID);
                            fr.LItems.Add(frItem);
                        }

                        var frItemMeth = (FindAndReplaceItemMethod)frItem;
                        frItemMeth.LItemTag.Add(new FindAndReplaceItemTagMethod(tag));
                        frItemMeth.CountChanges = frItemMeth.CountChanges + count;
                    }
                }
            }
        }
コード例 #15
0
 /// <summary>
 /// Find matching tagged values for element
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="attr"></param>
 /// <param name="fr"></param>
 private static void FindMatchingAttributeTaggedValue(EA.Repository rep, EA.Attribute attr, FindAndReplace fr)
 {
     foreach (EA.AttributeTag tag in attr.TaggedValues)
     {
         if ((fr.TagValueNames.Length == 0) || (fr.TagValueNames.Contains(tag.Name)))
         {
             int count = FindAndReplaceItem.FindCountForType(fr.RegexPattern, Utils.TaggedValue.GetTaggedValue(attr, tag.Name));
             if (count > 0)
             {
                 FindAndReplaceItem frItem = fr.LastItem();
                 if ((frItem == null) || (frItem.Guid != attr.AttributeGUID))
                 {
                     frItem = FindAndReplaceItem.Factory(rep, EA.ObjectType.otAttribute, attr.AttributeGUID);
                     fr.LItems.Add(frItem);
                 }
                 // find tagged value
                 var frItemAttr = (FindAndReplaceItemAttribute)frItem;
                 frItemAttr.LItemTag.Add(new FindAndReplaceItemTagAttribute(tag));
                 frItemAttr.CountChanges = frItemAttr.CountChanges + count;
             }
         }
     }
 }
コード例 #16
0
        /// <summary>
        /// Show the current item
        /// </summary>
        private void ShowItem()
        {
            // fill information
            _frItem = _fr.l_items[_fr.Index];
            _frItem.load(_fr.rep);

            txtType.Text    = _frItem.getType();
            txtSubType.Text = _frItem.getSubType();
            txtFrom.Text    = _fr.findString;
            txtTo.Text      = _fr.replaceString;

            // rtf fields
            _fr.SetRtfBoxText(rtfName, _frItem.Name);
            _fr.SetRtfBoxText(rtfStereotype, _frItem.Stereotype);
            _fr.SetRtfBoxText(rtfNotes, _frItem.Description);

            if (_fr.isTagSearch)
            {
                txtTaggedValueNames.Text     = string.Join(",", _fr.tagValueNames);
                txtTaggedValueNames.Visible  = true;
                lblTaggedValues.Visible      = true;
                gridTags.Visible             = true;
                gridTags.DataSource          = null;
                gridTags.AutoGenerateColumns = false;
                // load tags
                gridTags.DataSource = _frItem.l_itemTag;
            }
            else
            {
                txtTaggedValueNames.Text    = "";
                txtTaggedValueNames.Visible = false;
                lblTaggedValues.Visible     = false;
                gridTags.Visible            = false;
            }

            txtState.Text = StateCurrentItem() + " found";
        }
        /// <summary>
        /// Show the current item
        /// </summary>
        private void ShowItem()
        {
            // fill information
            _frItem = _fr.l_items[_fr.Index];
            _frItem.load(_fr.rep);
            
            txtType.Text = _frItem.getType();
            txtSubType.Text = _frItem.getSubType();
            txtFrom.Text = _fr.findString;
            txtTo.Text = _fr.replaceString;

            // rtf fields 
            _fr.SetRtfBoxText(rtfName, _frItem.Name);
            _fr.SetRtfBoxText(rtfStereotype, _frItem.Stereotype);
            _fr.SetRtfBoxText(rtfNotes, _frItem.Description);

            if (_fr.isTagSearch)
            {
                txtTaggedValueNames.Text = string.Join(",", _fr.tagValueNames);
                txtTaggedValueNames.Visible = true;
                lblTaggedValues.Visible = true;
                gridTags.Visible = true;
                gridTags.DataSource = null;
                gridTags.AutoGenerateColumns = false;
                // load tags
                gridTags.DataSource = _frItem.l_itemTag;
            }
            else
            {
                txtTaggedValueNames.Text = "";
                txtTaggedValueNames.Visible = false;
                lblTaggedValues.Visible = false;
                gridTags.Visible = false;
            }

            txtState.Text = StateCurrentItem() + " found" ;
        }