Author Topic: InvokeConstructPicker default package  (Read 14863 times)

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
InvokeConstructPicker default package
« on: November 19, 2021, 07:58:35 pm »
Probably a question for @Sparx...
How does the InvokeConstructPicker API call decide where in the package hierarchy to open onto ?
When invoking this on a newly-opened repository, it very reliably opens the tree at the exact same place. Is there a way to set that place?

When invoked a second time (without closing the rep), it correctly goes back to the last position, which is great - it's just that first invocation which is driving me crazy.
It then forgets that position, if the repository is closed and re-opened. Is there a Secret Setting?
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: InvokeConstructPicker default package
« Reply #1 on: November 19, 2021, 09:54:57 pm »
You can set the default selection yourself.

This is the code I use to call the constructpicker

 
Code: [Select]
public UML.Classes.Kernel.Element getUserSelectedElement(List<string> allowedTypes, List<string> allowedStereotypes, string defaultSelectionGUID = null)
        {
            //construct the include string
            string includeString = "IncludedTypes=";
            var eaTypeNames = new List<string>();
            foreach (var allowedType in allowedTypes)
            {
                eaTypeNames.Add(((Factory)this.factory).translateTypeName(allowedType));
            }
            includeString += string.Join(",", allowedTypes);
            //close section
            includeString += ";";
            if (allowedStereotypes != null && allowedStereotypes.Any())
            {
                //add stereotype filter
                includeString += "StereoType="
                                  + string.Join(",", allowedStereotypes)
                                + ";";
            }
            if (string.IsNullOrEmpty(defaultSelectionGUID))
            {
                defaultSelectionGUID = this.wrappedModel.GetTreeSelectedPackage()?.PackageGUID;
            }
            //get the currently selected package
            var treeSelectedPackage = this.wrappedModel.GetTreeSelectedPackage();
            if (!string.IsNullOrEmpty(defaultSelectionGUID))
            {
                includeString += "Selection="
                            + defaultSelectionGUID
                            + ";";
            }
            //currenlty only supported for ElementWrappers
            int EAElementID = this.wrappedModel.InvokeConstructPicker(includeString);
            return this.getElementWrapperByID(EAElementID);
        }

The part you are looking for is the "Selection" part

Geert

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: InvokeConstructPicker default package
« Reply #2 on: December 03, 2021, 09:41:21 pm »
Thanks Geert - I didn't spot the 'Selection' parameter in the API call.
When I tried this (in V16 beta 1) the package returned from 'GetTreeSelectedPackage' is the same one which I can't seem to change, so, unless I keep a record of 'last package used', I'm no further ahead.

 Is this, I wonder, connected with the issue of not being able to set the detault diagram (in v16) without having security switched-on? My model - created in V15 and now opened in V16 - had a default diagram set, which I now can't un-set using v16, without implementing security, which, as this is my main test repository, I don't want to do. It's he parent package of this diagram which always pops-up.
In the production world, where eaDocX is embedded inside EA, this won't be a problem: it will find the package which the user has currently got selected, and use that as a starting point for the selection.
But when I'm opening the repository from the API, and testing stuff outside of the EA user interface, I think I'm stuck.
The question is, despite your excellent reply, still valid - where does EA save the 'My Diagram' and 'My Package' values ? And why do I now need (in v16) security enabled to set 'My Diagram' or 'My Package' ? For 20 years I didn't need to do this :-(
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: InvokeConstructPicker default package
« Reply #3 on: December 06, 2021, 08:43:01 am »
The question is, despite your excellent reply, still valid - where does EA save the 'My Diagram' and 'My Package' values ? And why do I now need (in v16) security enabled to set 'My Diagram' or 'My Package' ? For 20 years I didn't need to do this :-(
It's in t_xref with Name='Default Diagram' and Client=the guid of the security user it's for. I don't believe there has ever been an option to set a per user default diagram without security. However, as stated below, I tried to do it in 15.0-15.2 and could not. If you share an exact build and menu sequence you could use to set a default diagram I'll have another look.

But it worked fine in V15 with no security. So why the change? I have asked @Sparx.
So what's this - a v15 bug which got fixed, or a V15 feature which got disabled?

As Ian pointed out, it worked fine in EA 15.x without security enabled. The question now is whether it is a bug in EA 16 or a bug in EA 15.x that has now been fixed.
Just in case my memory was failing me I just tested 15.0, 15.1 and 15.2. None of them allowed setting a per user diagram without security enabled.

As I said. That option has always been stored using the id (guid) of a security user. Even if there was a bug that enabled it in 15, it could never have loaded a diagram from that.

Is it possible that you actually had security on with 'Accept Windows Authentication' enabled?

PS.
  • 20 years takes you back to 3.0.
  • 3.1.440 is when a default diagram for the project was added. (Although that's only a couple of months later)
    Build 440
    ...
    - Ability to set the Default Diagram for a project (EA opens to this if available)
  • 3.5 is when user security was added.
    General Changes for Version 3.50
    ********************************
    ...
    User security (Corporate Version)
  • 3.6.614 is when the option to set a user default diagram was added:
    Changes in Build 614
    ********************
    ...
    Added ability to define a default user diagram for corporate edition when security is enabled.
       User may set any diagram to be their own default
  • 4.0 was released just before I joined Sparx Systems.
« Last Edit: December 06, 2021, 09:12:28 am by Eve »

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: InvokeConstructPicker default package
« Reply #4 on: December 07, 2021, 02:18:50 am »
Ok, @Eve - maybe 20 years was a bit of hyperbole -  I started at v3.5.

The V15 function I used and loved  was:
Start / Workspaces / Model Places / Manage / Set curret as default

Please tell me this has just been moved somewhere new again, and that I can still use it ? MyPackage and MyDiagram seemed the obvious place to look...
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: InvokeConstructPicker default package
« Reply #5 on: December 07, 2021, 03:43:19 am »
Ian,

The model default diagram still exists in v16

Start | Collaborate | Model Home | Manage

Geert

Ian Mitchell

  • EA User
  • **
  • Posts: 506
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: InvokeConstructPicker default package
« Reply #6 on: December 07, 2021, 04:24:02 am »
Genius - I should have thought to look in a "Collaborate" menu.
...when it's a single-user repository.

I think I have now worked-out how @Sparx create the UI design for each new release:
  • Write all menu options on a piece of paper
  • Throw all pieces of paper high into the air, preferably on a windy day
  • Which ever bits of paper land near each other become the menu structure for the next release
But seriously, this constant re-positioing of menu options wastes hundreds of hours of our users time, and I am constantly told is the #1 reason why customers don't want upgrade to new versions, and therefore why they don't bother getting maintanance for EA. This is consting @Sparx real money. I guess Geoff doesn't need the extra....
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: InvokeConstructPicker default package
« Reply #7 on: December 07, 2021, 06:09:47 am »
Genius - I should have thought to look in a "Collaborate" menu.
...when it's a single-user repository.

I think I have now worked-out how @Sparx create the UI design for each new release:
  • Write all menu options on a piece of paper
  • Throw all pieces of paper high into the air, preferably on a windy day
  • Which ever bits of paper land near each other become the menu structure for the next release
But seriously, this constant re-positioing of menu options wastes hundreds of hours of our users time, and I am constantly told is the #1 reason why customers don't want upgrade to new versions, and therefore why they don't bother getting maintanance for EA. This is consting @Sparx real money. I guess Geoff doesn't need the extra....
Going from menu's (v12) to ribbons (v13) was a big change, so I can understand it takes a while to get the menu structure right.

But even now in v16 they keep playing "hide the easter egg" game.

I'm lucky I like a challenge, but this one was especially well hidden.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: InvokeConstructPicker default package
« Reply #8 on: December 07, 2021, 08:23:36 am »
Ok, @Eve - maybe 20 years was a bit of hyperbole -  I started at v3.5.
I know. That extra detail was my way of breaking the hyperbole.

The V15 function I used and loved  was:
Start / Workspaces / Model Places / Manage / Set curret as default
I'm glad you accepted Geert's answer on this, but that information was given to you when you first asked.

Hi Ian

Yep, it has moved again.

https://sparxsystems.com/enterprise_architect_user_guide/16.0/modeling/usr_model-default_diags.html

Henrik
Quote
Set Model Default Diagram

Make the current diagram the default diagram displayed when any user re-opens this model.
  • Start > Collaborate > Model Home > Manage > Set Current as Default (if the required diagram is open and active)
  • Start > Collaborate > Model Home > Manage > Choose Default (to browse for the required diagram)
Please. Do yourself a favour and try not to jump to conclusions, and when you do, try to listen to what people are telling you.
« Last Edit: December 07, 2021, 08:55:05 am by Eve »