0

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

1 Answer 1

1

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.

6
  • But in my code I need to make selections in one part and it should draw a chart in the another part that is currently opened.
    – Acjb
    Apr 22, 2014 at 10:01
  • "activePart" gives the value of the part in which I make some selections. But I want to get hold of the part where am gonna send values. I cant use findPart also, as I am creating dynamic parts using partdescriptor.
    – Acjb
    Apr 22, 2014 at 11:23
  • Well you have to some way of identifying the destination. Keep a table of the dynamically created parts somewhere or something like that.
    – greg-449
    Apr 22, 2014 at 11:29
  • Eventhough I keep track of dynamically created parts.How to find the active part that is currently selected.? I am totally confused.
    – Acjb
    Apr 23, 2014 at 9:06
  • The active part is the one you are clicking on, you will have to have some other mechanism for determining which of the other parts to show you data in.
    – greg-449
    Apr 23, 2014 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.