'Eclipse plugin: update view following a command

I am developing a plugin where I execute a command triggered from a toolbar icon. After the command completes I want to update a view which will display a table containing data collected while executing the command.

My issue is that I don't know how to listen to the command completion from the view.

I have checked the below which concern other view selection changes but no command execution:

How to Refresh Eclipse View Plugin

https://eclipse.org/articles/viewArticle/ViewArticle2.html



Solution 1:[1]

You can get the currently active part in your handler class and check if it is your view. If it is you can call a method you define on the view. Something like:

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

  IWorkbenchPart part = HandlerUtil.getActivePart(event);

  if (part instanceof MyView) {

    MyView view = (MyView)part;

    // Call some method of your view
    view.someMethodOfMyView(....);
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 greg-449