简体   繁体   中英

How to set the input for the UI part in eclipse e4?

I am using eclipse e4 application. I am using the eventBroker to pass values from one part to another part. If many parts(Kind of tabs) are open , how to pass values to the part(tab) that is currently selected. ? I am using the @UIEventTopic to get the values for the part. But the problem is ,the values are replicated to all the tabs. In other words , I am trying to show different JFreechart in different tabs, but the charts are replicated to the previous tabs.

Can anyone please suggest me some ideas?

Thanks in advance

The event broker always broadcasts to anything that is dealing with the event, you can't use it to send to one specific thing.

If you are in a Handler you can get the current part in the @Execute method and set a value directly in your class - something like:

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

  if (part instanceof MyClass)
   {
     ((MyClass)part).setValue(xxxx);
   }
}

Update:

If you are in another part use the EPartService to get the active part:

@Inject
EPartService partService;

...

MPart activePart = partService.getActivePart();

Object part = activePart.getObject();

if (part instanceof MyClass)
 {
    ((MyClass)part).setValue(xxxx);
 }

You can also use EPartService.findPart("part id") to find a part with a given 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