简体   繁体   中英

How connect DirectToolItem wiht the Part in e4

I have added a toolbar in a Part that contain a DirectToolItem.

So in my files i have a class for the part and a class for DirectToolItem

code from the Part

code from the toolbar

How i connect this 2 class, i want call from @Execute of DirectToolItem a method inside the class of the Part

You can inject the currently active MPart in your execute method using the IServiceConstants.ACTIVE_PART name. The getObject() method of MPart returns your part class:

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart mpart)
{
  PartStackOverflow part = (PartStackOverflow)mpart.getObject();

  ... call methods
}

Alternatively use the find method of EModelService to find your part by its id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM