/** * Constructs a new selection tracker for the given window and part id. * * @param window workbench window * @param partId part identifier */ public WindowPartSelectionTracker(IWorkbenchWindow window, String partId) { super(partId); setWindow(window); window.addPageListener(this); IWorkbenchPage[] pages = window.getPages(); for (int i = 0; i < pages.length; i++) { pageOpened(pages[i]); } }
private IEditorInput getEditorInput() throws IOException { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow[] wws = wb.getWorkbenchWindows(); if (wws.length != 1) throw new IOException("Failed to find workbench window"); IWorkbenchWindow ww = wws[0]; IWorkbenchPage[] wps = ww.getPages(); if (wws.length != 1) throw new IOException("Failed to find workbench page"); IWorkbenchPage wp = wps[0]; IEditorPart ep = wp.getActiveEditor(); if (ep == null) throw new IOException("Failed to find active editor"); return ep.getEditorInput(); }