I am extending a AbstractHandler for an event that can be called from different views. What is the recommended way for the handler to find the view or editor that called the event?
HandlerUtil.getActivePart(event) is not returning the view that spawned the event because the active view changed before the event reached the handler. (This is because we have code in a non-UI thread that periodically gathers info and updates a different view which causes the different view to become active.)
This code appears to work, but is it recommended? Could that key or implementation change since it's not really in the api?
public class MyHandler extends AbstractHandler
{
public Object execute(ExecutionEvent event) throws ExecutionException
{
org.eclipse.core.expressions.IEvaluationContext context = (org.eclipse.core.expressions.IEvaluationContext) event.getApplicationContext();
String myParentContext = context.getVariable("parentContext").toString();
This returned
PartImpl (correct.view.id) Context
One idea might be to use naming conventions for the Handlers so they are not re-used across different views. However, that doesn't cover the case where a view has secondary ids. We need to know the secondary id to find the view and refresh the object after taking actions on it.