Esempio n. 1
0
		private string ElementNameChange(IdentificableObject ia)
		{
			string type = string.Empty;

			if(ia.GetType() == typeof(Model))
			{
				type = this.localizer.GetValue("Globals","Model");
			}
			if(ia.GetType() == typeof(Package))
			{
				type = this.localizer.GetValue("Globals","Package");
			}
			if(ia.GetType() == typeof(Actor))
			{
				type = this.localizer.GetValue("Globals","Actor");
			}
			if(ia.GetType() == typeof(UseCase))
			{
				type = this.localizer.GetValue("Globals","UseCase");
			}
			if(ia.GetType() == typeof(GlossaryItem))
			{
				type = this.localizer.GetValue("Globals","GlossaryItem");
			}

			frmNameChanger frm = new frmNameChanger(this.localizer,type);
			frm.lblOldName.Text = ia.Name;

			if(frm.ShowDialog(this) == DialogResult.OK)
			{
				string token = "\"" + frm.lblOldName.Text + "\"";
				token = token.Replace(" ","\t");
				token = token.Replace(".","\v");

				RemoveHighlightDescriptor(token,string.Empty);

				string sub = "\"" + frm.tbNewName.Text + "\"";
				sub = sub.Replace(" ","\t");
				sub = sub.Replace(".","\v");
				HighlightDescriptor hd = new 
					HighlightDescriptor(sub,Color.Red,null,DescriptorType.Word,DescriptorRecognition.WholeWord,true);
				this.hdc.Add(hd);

				if(!frm.cbNoReplace.Checked)
				{
					model.ReplaceElementName(
						frm.lblOldName.Text,
						"\"",
						"\"",
						frm.tbNewName.Text,
						"\"",
						"\"");
					if(this.currentElement.GetType() == typeof(UseCase))
					{
						this.UpdateView();
						tabUseCase.SelectedTab = this.pgUCGeneral;
					}
				}

				ia.Name = frm.tbNewName.Text;

				// Glossary must be always sorted
				if(ia.GetType() == typeof(GlossaryItem))
				{
					model.Glossary.Sorted("Name");
					this.Cursor = Cursors.WaitCursor;
					GList.DataBind();
					this.Cursor = Cursors.Default;
				}
				
				this.SetModified(true);
			}
			frm.Dispose();
			return ia.Name;
		}
Esempio n. 2
0
        public string ElementNameChange(IdentificableObject ia)
        {
            string type = string.Empty;
            Color hdcolor = Color.Red;

            if(ia.GetType() == typeof(Model))
            {
                type = this.localizer.GetValue("Globals","Model");
            }
            if(ia.GetType() == typeof(Package))
            {
                type = this.localizer.GetValue("Globals","Package");
            }
            if(ia.GetType() == typeof(Actor))
            {
                type = this.localizer.GetValue("Globals","Actor");
            }
            if(ia.GetType() == typeof(UseCase))
            {
                type = this.localizer.GetValue("Globals","UseCase");
            }
            if(ia.GetType() == typeof(GlossaryItem))
            {
                type = this.localizer.GetValue("Globals","GlossaryItem");
                hdcolor = Color.Green;
            }
            if(ia.GetType() == typeof(Stakeholder))
            {
                type = this.localizer.GetValue("Globals", "Stakeholder");
                hdcolor = Color.Blue;
            }

            frmNameChanger frm = new frmNameChanger(this.localizer,type);
            frm.lblOldName.Text = ia.Name;

            if(frm.ShowDialog(this) == DialogResult.OK)
            {
                string token = "\"" + frm.lblOldName.Text + "\"";
                token = token.Replace(" ","\t");
                token = token.Replace(".","\v");

                RemoveHighlightDescriptor(token,string.Empty);

                string sub = "\"" + frm.tbNewName.Text + "\"";
                sub = sub.Replace(" ","\t");
                sub = sub.Replace(".","\v");
                HighlightDescriptor hd = new
                    HighlightDescriptor(sub,hdcolor,null,DescriptorType.Word,DescriptorRecognition.WholeWord,true);
                this.hdc.Add(hd);

                if(!frm.cbNoReplace.Checked)
                {
                    model.ReplaceElementName(
                        frm.lblOldName.Text,
                        "\"",
                        "\"",
                        frm.tbNewName.Text,
                        "\"",
                        "\"");
                    if (dockPanel.ActiveDocument != null)
                    {
                        ((frmTabView)dockPanel.ActiveDocument.DockHandler.Form).UpdateView();
                    }
                }

                ia.Name = frm.tbNewName.Text;

                foreach (IDockContent content in this.dockPanel.Documents)
                {
                    if (content.DockHandler.TabText == frm.lblOldName.Text)
                    {
                        content.DockHandler.TabText = frm.tbNewName.Text;
                    }
                    ((frmTabView)content.DockHandler.Form).UpdateView();
                }

                this.SetModified(true);
            }
            frm.Dispose();
            return ia.Name;
        }