Book a Demo

Author Topic: Rename element in project browser  (Read 7841 times)

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Rename element in project browser
« on: November 27, 2007, 04:27:02 am »
Is it possible to rename an element without calling
m_Repository.RefreshModelView ( m_package.PackageID ). (It causes the appearance of "Save latest changes? .. " Dialog box, what I don't want)

I have following code:

element.Name = "hallo";
element.Refresh();
element.Update();
m_package.Elements.Refresh();

But the element in the project browser still has its old name. First by pressing the button "Reload project" it becomes the new one.

Does anyone have any idea?
Thanks a lot!
« Last Edit: November 28, 2007, 01:49:31 am by Olga »

TimmyTreeFriends

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Rename element in project browser
« Reply #1 on: November 27, 2007, 06:09:01 am »
Hi Olga, from what I understand, if you are looking at a diagram (or this diagram is open), by calling Repository.RefreshModelView will cause the "save latest changes" dialog to show up. If you don't have the diagram shown, this works fine.

So I tend to use ReloadDiagram(DiagramID), that does not cause the "save latest changes" dialog to show, but refreshes the elements on the diagram and on Project Browser (including their names). But I don't know if it will refresh the elements within the same package but NOT on the diagram though.

However I think I might want to share my experience with you though. Hope it helps.

Tim
« Last Edit: November 27, 2007, 06:15:07 am by TimmyTreeFriends »

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #2 on: November 27, 2007, 07:36:26 am »
First thank you very much for reply!!!

The elements I want to rename are only in project browser, not on any diagram. But some other diagrams can be open.
I have tried ReloadDiagram(DiagramID), it does not refresh my elements, but I can call RefreshModelView after that, and the dialog "save latest changes" does not come any more, because all diagrams are already saved.

The problem is, I don't want to save any diagrams by renaming an element, that is not located on any of them.
Not programatically it is possible (two mouse clicks on the element).

Olga
« Last Edit: November 27, 2007, 07:37:42 am by Olga »

TimmyTreeFriends

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Rename element in project browser
« Reply #3 on: November 27, 2007, 09:29:32 am »
Olga, well, may I suggest a workaround though? It's not elegant, but it works....somehow....

Use ShowInProjectView(myPackage) to force the package to be highlighted in Project Browser, then use ShowInProjectView(myElement) again to force the element you've just modified the name with to be highlighted. This will cause EA to refresh myElement's name and properties.

Of course you don't have to highlight the package in the first step, just move the highlight away from the element modified. Hope this would help.

Tim
« Last Edit: November 27, 2007, 09:32:46 am by TimmyTreeFriends »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Rename element in project browser
« Reply #4 on: November 27, 2007, 10:32:33 am »
Olga,

You might want to look at some of the Repository methods. The ones dealing with xxxContextItem and the type thereof. Also ShowInProjectView. These will help you determine what's currently selected, and to move and restore the selection, via automation.

David
No, you can't have it!

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Rename element in project browser
« Reply #5 on: November 27, 2007, 02:22:24 pm »
Try calling Repository.AdviseElementChange(ElementID).  This should refresh most common EA windows where the specified element may appear.

HTH.

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #6 on: November 28, 2007, 01:43:45 am »
Thank you so much for your replies!

I have tried all and nothing does it :(
I suppose, maybe I have to update the properties of the element, because afterwards it's enought to open and to close "Properties" dialog of the element and the name changes.
But I can not find the way to do this. "Properties"-Interface does not have any "Refresh" or "Update" mathods.

Olga

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #7 on: November 28, 2007, 01:58:48 am »
One thing I forgot to say:

Neither manual selecting another element nor closing + opening the package does not cause an update of the element name.
The opening + closing "Properties"- dialog of the element is really one, that does it.

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #8 on: December 02, 2007, 11:25:33 pm »
For all interested:

Issue ID: 06060124
Description: Modifying element details and performing Update() does not always reflect changes in project view

Issue ID: 06120376
Description: Repository.RefreshModelView reloads all open diagrams

Daryn

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #9 on: January 15, 2008, 02:34:01 am »
I am having the same problem.
Did you manage to solve the issue?
- Thanks

Daryn

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Rename element in project browser
« Reply #10 on: January 15, 2008, 03:10:53 am »
Solution!

This has worked for me:

// Update the UI, this leaves the package selected
Repository.RefreshModelView(element.PackageID);  

// Re-select the updated element
Repository.ShowInProjectView(element);

                               8)
« Last Edit: January 15, 2008, 03:12:44 am by Daryn »