I implemented an Eclipse view by extending ViewPart. In this particular view, I have also implemented a text input field Text and a few buttons which execute a particular Eclipse command.
For example:
IHandlerService handlerService = (IHandlerService) PlatformUI
                                .getWorkbench().getService(
                                        IHandlerService.class);
handlerService.executeCommand("com.company.commandxyz", null);
This command calls a handler which then invokes a service to hook into the DSF extensions. To be specific, I have implemented a custom CommandFactory by extending CommandFactory_6_8. This allows me to queue commands to GDB and then get the result back. However, I want to set the response in the Text field which is located located in the View where the com.example.commandxyz was invoked.
Unfortunately, I cannot pass any reference to this implementation of the DSF extension. I tried the following code to get the Eclipse view in order to subsequently set the text (which is a property of this view):
IViewPart vp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("com.example.myview");
However, I receive the following exception upon calling:
Exception in thread "MI RX Thread" java.lang.NullPointerException
Any idea how I can access the UI thread to retrieve the property of the view in order to set it?
                        
The
PlatformUIcode you mention must run in the UI thread.Use
Display.asyncExecorDisplay.syncExecto execute code in the UI thread from some other thread.With Java 8 use:
With earlier versions of Java use:
asyncExecruns the UI code asynchronously the next time the UI is ready to run code.syncExecruns synchronously blocking the current thread until the UI runs the code.