How to get a Workspace's working sets information in a plugin?

旧时模样 提交于 2020-01-23 19:23:07

问题


I want to get the runtime working sets information of the current workspace. I have tried the method: IWorkingSet[] getWorkingSets() of the IWorkbenchPage

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      if (page != null) { IWorkingSet[] sets = page.getWorkingSets();} 

but when I debug the code, the method returns nothing.

I am wondering am I use the right method to get a workspace's working sets information? If not, how to get the data?


回答1:


The IWorkbenchPage getWorkingSets() method returns the 'Window Working Sets' in use for the page - this option is not enabled by default so returns null.

If you want all the working sets defined in the workbench you use:

IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();

IWorkingSet [] allSets = manager.getAllWorkingSets();

The working set manager has many other methods for handling working sets.



来源:https://stackoverflow.com/questions/23134798/how-to-get-a-workspaces-working-sets-information-in-a-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!