문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top