Book a Demo

Author Topic: Open Element Properties Dialog  (Read 4296 times)

Jeremie

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Open Element Properties Dialog
« on: August 26, 2015, 07:34:07 pm »
Hi everyone,

I created a UseCase element with a stereotype in my model and i'd like to open automatically the properties dialog
Is it possible ?

So far, no relevant method found in the documentation...

Thanks,
Jeremie.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Open Element Properties Dialog
« Reply #1 on: August 26, 2015, 07:48:31 pm »
Yes,

That is possible, but it is not documented.

Check the operation openProperties(UML.UMLItem item) from the class Model.cs

It opens the properties dialog for any item in the model.

Geert
« Last Edit: August 26, 2015, 07:48:45 pm by Geert.Bellekens »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Open Element Properties Dialog
« Reply #2 on: August 26, 2015, 08:21:14 pm »
Ehrm Wasn't that Respository.CustomCommand? Your method just returns the parameter name.

q.
« Last Edit: August 26, 2015, 08:23:00 pm by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Open Element Properties Dialog
« Reply #3 on: August 26, 2015, 08:32:32 pm »
The first part of the operation gets the correct parameter.

The last part uses CustomCommand to actually open the properties.

Code: [Select]
           //open the actual dialog
            if (this.mainEAWindow != null
                && typeString != string.Empty
                && itemID != 0)
          {
                  string ret = this.wrappedModel.CustomCommand("CFormCommandHelper", "ProcessCommand", "Dlg=" + typeString + ";id=" + itemID.ToString() + ";hwnd=" + this.mainEAWindow.Handle);
          }

Geert

Jeremie

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Open Element Properties Dialog
« Reply #4 on: August 26, 2015, 10:33:51 pm »
I'm sorry, i'm not sure how to implement those methods in my program...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Open Element Properties Dialog
« Reply #5 on: August 26, 2015, 10:55:41 pm »
You'll need some kind of WindowWrapper like this

Code: [Select]
using System;

namespace TSF.UmlToolingFramework.Wrappers.EA
{
      /// <summary>
      /// Wrapper needed to be able to open properties dialog in EA
      /// </summary>
   internal class WindowWrapper : System.Windows.Forms.IWin32Window
   {
     public WindowWrapper(IntPtr handle)
     {
       _hwnd = handle;
     }

     public IntPtr Handle
     {
       get { return _hwnd; }
     }

     private IntPtr _hwnd;
   }
}
and initialize that window wrapper  like this:

Code: [Select]
   /// <summary>
    /// the main EA window to use when opening properties dialogs
    /// </summary>
    public IWin32Window mainEAWindow
    {
          get
          {
                if //(true)
                      (this._mainEAWindow == null)
                {
                      List<Process> allProcesses = new List<Process>( Process.GetProcesses());
                           Process proc = allProcesses.Find(pr => pr.ProcessName == "EA");
                       //if we don't find the process then we set the mainwindow to null
                           if (proc == null
                               || proc.MainWindowHandle == null)
                       {
                             this._mainEAWindow = null;
                       }
                       else
                       {
                             //found it. Create new WindowWrapper
                             this._mainEAWindow  = new WindowWrapper(proc.MainWindowHandle);
                       }
                }
                 return this._mainEAWindow;
          }
    }
Then use Repository.CustomCommand as posted before.

This is all already working in my open source EA Addin Framework
I use that in the EANavigator addin.


Geert
« Last Edit: August 26, 2015, 10:56:04 pm by Geert.Bellekens »

Jeremie

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Open Element Properties Dialog
« Reply #6 on: August 27, 2015, 12:34:02 am »
thanks Geert i did it :)