View , as well as ViewPart registered in the ViewRegistry when the workbench starts. Workbench contains all registered views and editors. The easiest way to get information for this view is from the workbench registry. First you check to see if there is PlatformUI.getWorkbench().isStarting() . Once this method returns false , you can get
IViewDescriptor descriptor = PlatformUI.getWorkbench().getViewRegistry().find("view");
When you run the workbench, it logs all views and editors contributed to it, but to run your code that you need, make sure the desktop is running and you have an instance of the view.
To create an instance of View , you must use the code
try { IViewPart view = descriptor.createView(); view.createPartControl(); } catch (CoreException e) {
Now you will be able to use View.addToList("Message") anywhere in the application .
source share