0

I want to programmatically open an eclipse view, I tried this code:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(view.ID);

It opens the view but it only instantiate it once.. I need to open a view on a double click on a file in the package explorer, the only way I found so far is opening it in the editor constructor ( a custom editor, btw if anybody knows how to open a view on double click on a file in the package explorer I'm all ears). To populate the view (tree view) I use data from a file, it works fine the first time I open it but then it does not refresh its content.

Can I perhaps access the view class object and manipulate somehow (get the tree viewer object maybe)? The perfect way to do this would be to open the view on a double click directly in the file that I need to render but I didn't find how, can anybody help?

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
kamel
  • 45
  • 4

1 Answers1

0

What you are describing is really a read-only editor. There shouldn't be any reason that you couldn't implement an editor with dummy save() and saveAs() implementations. You'd get the double-click support you want in any navigation view.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
  • So you're saying that I should add another editor which implements the tree viewer in an editor? I thought about that but it would mean that it will be opened separately from my editor.. it's a rather extreme solution I would rather not do it like that since all I need is find a way to "restart" the tree viewer programmatically – kamel Nov 21 '12 at 08:17
  • You didn't mention anything about already having an editor, only about opening a view by double clicking a file in a navigator view. If you have an editor and a view already open then you can have your EditorPart call a method on the ViewerPart to refresh itself with a file reference passed in the method call. Both the editor and viewer should have access to the Activator class in your plugin and can communicate via that Activator. – Chris Gerken Nov 21 '12 at 13:15
  • I figured that I should use the editor since it's opened at double click, but I never thought about using the activator. Thank you for your help. – kamel Nov 22 '12 at 17:19