Book a Demo

Author Topic: HowTo chang package iconstyle  (Read 4484 times)

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
HowTo chang package iconstyle
« on: October 26, 2010, 07:07:28 pm »
Hi

creating a new package with
Package pg = rootNode.Packages.AddNew("MyPackage", "");
returns me a package which has no icon in it. What must be done, to give it for example the "Simple" icon?

Thanks for help.

Regards
Rainer

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: HowTo chang package iconstyle
« Reply #1 on: October 26, 2010, 07:30:23 pm »
.. found it.

Package pg = rootNode.Packages.AddNew("MyPackage", "Simple");
repository.RefreshModelView(0);

Regards
RAiner

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: HowTo chang package iconstyle
« Reply #2 on: October 26, 2010, 11:42:50 pm »
It looks like I celebrated too early.
As it looks, Packages.AddNew always per default uses "Simple" as ViewIconStyle. It doesn't matter whether I create a package like
Package pg = rootNode.Packages.AddNew("MyPackage", "Simple");
or
Package pg = rootNode.Packages.AddNew("MyPackage", "Class");

In both cases the Icon is "Simple".

What must I do to achieve what I want?
Thanks for help!

Regards
Rainer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: HowTo chang package iconstyle
« Reply #3 on: October 27, 2010, 04:10:56 pm »
Rainer,

I had a quick look at the database yesterday, but I haven't found anything obvious that defines the "icon" of a view.
What I would do in such a case is start a database trace, create such a view in EA and then inspect the trace to figure out what has been done at the database level.
Usually that helps in finding out which property (if any) to use in the API. If the property is not exposed in the API you can still update the tables yourself using Repository.Execute(sqlString).

Geert

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: HowTo chang package iconstyle
« Reply #4 on: October 27, 2010, 04:34:49 pm »
Just to point in the right direction - Look at the "VICON" value in the Package.Flags attribute.  As with all string fields that contain multiple properties, just be careful not to lose any existing information when modifying the value.

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: HowTo chang package iconstyle
« Reply #5 on: October 27, 2010, 08:25:25 pm »
Hello Aaron,

thank you very much for this hint!
I wrote me a little extension method to the Package class and as far as I tested it it works nicely. If you with your inside expert knowledge could see situations where this method would break existing information I would appreciate any hints.

public static void SetViewIconStyle(this Package package, int style)
{
    string flags = package.Flags;
    string[] flagArray = flags.Split(new char[] { ';' });
    string vicon = (from vi in flagArray
                    where vi.Contains("VICON")
                    select vi).FirstOrDefault();

    if (vicon == null)
    {
        flags = string.Format("{0}VICON={1};", flags, style);
    }
    else
    {
        flags = flags.Replace(vicon, string.Format("VICON={0}", style));
    }

    package.Flags = flags;
}

Regards
Rainer