문제

I'm doing an Eclipse RCP aplication. I have created a new Launch Configuration and a view. When I run the launch configuration, I get a set of results and I want to sent those results to the view.

In this moment, I create a new event which contains the results:

  BundleContext ctx = FrameworkUtil.getBundle(TraditionalLaunchConfigurationDelegate.class).getBundleContext();
  ServiceReference<EventAdmin> ref = ctx.getServiceReference(EventAdmin.class);
  EventAdmin eventAdmin = ctx.getService(ref);
  Map<String, Results> properties = new HashMap<String, Results>();
  properties.put("MUTATIONRESULTS",  //$NON-NLS-1$
                    results);


  Event event = new Event("mutationcommunication/asyncEvent", properties); //$NON-NLS-1$

  eventAdmin.postEvent(event);

The view is listening. When the launch configuration sends the event, the view catches it and shows the results.

The problem is that it works when the view is instantiate. If I don't open manually the view, it doesn't exist, and it doesn't receive anything.

A solution may be open programatically the view, but

PlatformUI.getWorkbench().getViewRegistry().find("ID").createView();

doesn't work.

Is there a way to send elements to a view and, if the view doesn't exist, which creates a new instance?

Thanks for the help.

도움이 되었습니까?

해결책

Use:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("id");

to show the view (it will created if it is not already shown).

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