In each view, define an identifier. The identifier matches the one you defined in the ID field when you defined the detail view of the extension element. Here is one of mine:
public static final String ID = "gov.bop.rabid.ui.views.PrefetchedInmatesView";
In your RCP plug-in, define the following method:
public static IViewPart getView(IWorkbenchWindow window, String viewId) { IViewReference[] refs = window.getActivePage().getViewReferences(); for (IViewReference viewReference : refs) { if (viewReference.getId().equals(viewId)) { return viewReference.getView(true); } } return null; }
If you want to reference a view from another view, use the following code:
PrefetchedInmatesView view = (PrefetchedInmatesView) RabidPlugin.getView(window, PrefetchedInmatesView.ID);
Replace your view name with PrefetchedInmatesView and your plugin name with RabidPlugin .
source share