Book a Demo

Author Topic: GetContextItemType returns wrong values for Models  (Read 6286 times)

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
GetContextItemType returns wrong values for Models
« on: October 23, 2014, 03:04:54 am »
Hi all,

using Repository.GetContextItemType() function when a root package (model) is selected and has a focus in the Project Browser returns otNone instead of otModel (or otPackage at least). Is it an EA mistake or my misunderstanding of mentioned function? If the latter is right, what is the proper way?

Cheers for your answers.

Slávek

Win 8.1, EA 11 build 1112 Corporade Edition, MS Visual Studio Express 2013 SP 3 for Windows Desktop, C#

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: GetContextItemType returns wrong values for Mo
« Reply #1 on: October 23, 2014, 04:45:53 am »
I faintly remember that this was reported as a bug here on the forum. No idea whether it ever has reached some development team at Sparx.

q.

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: GetContextItemType returns wrong values for Mo
« Reply #2 on: October 23, 2014, 04:53:28 am »
Not very positive answer.

Anyway, for the time being I wrote a small routine to fix mentioned mistake:

protected EA.ObjectType temporaryGetContextItemType(EA.Repository Repository) {
    EA.ObjectType vOT = Repository.GetContextItemType();
    if (vOT == EA.ObjectType.otNone) {
        //try it to retype to Package and check if it is a model...
        //if anything gets wrong, forget it
        try {
            if (((EA.Package)(Repository.GetContextObject())).ParentID == 0)
                return EA.ObjectType.otModel;
        } catch { }
    }
    return vOT;
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: GetContextItemType returns wrong values for Mo
« Reply #3 on: October 23, 2014, 09:10:22 am »
The issue is that Enterprise Architect doesn't set a root item as context. So the context really is none.

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: GetContextItemType returns wrong values for Mo
« Reply #4 on: October 23, 2014, 06:21:01 pm »
Simon, why is not a root item considered as a context? It sounds strange to me. By the way, the documentation says: "Models are of type package and belong to a collection of packages." (Repository Class) There should be a proper way how to get the type of selected item in Project Browser.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GetContextItemType returns wrong values for Mo
« Reply #5 on: October 23, 2014, 06:41:52 pm »
There is more funny stuff with the root packages.
They are the only packages that don't have an element for instance.
Why? Only Geoffrey knows :-/

Geert

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: GetContextItemType returns wrong values for Mo
« Reply #6 on: October 23, 2014, 06:57:57 pm »
Geert, that is the other think that is missing in documentation. On the other hand, EA doesn't allow to set for instance tagged values for a model. Well, I can't see a reason why it is disabled.