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(); }
public static void updateMainWindowTitle(IWorkbenchWindow window) { IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject(); IProduct product = Platform.getProduct(); String title = product == null ? "Unknown" : product.getName(); // $NON-NLS-1$ if (activeProject != null) { title += " - " + activeProject.getName(); // $NON-NLS-1$ } IWorkbenchPage activePage = window.getActivePage(); if (activePage != null) { IEditorPart activeEditor = activePage.getActiveEditor(); if (activeEditor != null) { title += " - [ " + activeEditor.getTitle() + " ]"; } } window.getShell().setText(title); }