| 
| List all views - Bug? [message #332206] | Fri, 10 October 2008 09:35 |  | 
| Eclipse User  |  |  |  |  | Hello, 
 I'm currently trying to get a list of all views currently opened in
 eclipse.
 The views of interest are custom views that have the allowMultiple flag
 set to true.
 
 The follwoing problem occures.
 When running eclipse in with a "OPEN_NEW_PERSPECTIVE" value of
 "OPEN_PERSPECTIVE_WINDOW" every page holds just one perspective.
 It is possible to resolver all views using this code:
 
 for (IWorkbenchWindow window
 :PlatformUI.getWorkbench().getWorkbenchWindows()){
 for (IWorkbenchPage page : window.getPages()){
 IViewReference[] references = page.getViewReferences();
 for (IViewReference reference : references){
 // Restoring the view and resolving it
 IViewPart view = reference.getView(true);
 if (view instanceof TaskView){
 list.add(view);
 }
 }
 }
 }
 
 Unfortunately when having "OPEN_NEW_PERSPECTIVE" set to
 "OPEN_PERSPECTIVE_REPLACE" (default setting) tho code above does not work
 :(
 The problem is the "page.getViewReferences()" part of the code. This
 commands just returns the views that are or where visible in the current
 eclipse session. Since eclipse saves its views and perspectives states on
 shutdown this is less than a user might expect.
 For instance when having two perspectives both holding TaskView views and
 assuming eclipse just having finished to launch the codes just finds the
 views of the perspective that is currently shown to the user. The views
 that are in the second perspective are getting ignored.
 
 Is there really no way to get a list of all views currently opened within
 the workbench no matter if there are allready loaded (hav been showed
 once) or not?
 
 Is this a bug or wanted?
 
 Jan Kohnert
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03287 seconds