Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 @Nullable
 public static IWorkbenchPartSite getWorkbenchPartSite(IServiceLocator serviceLocator) {
   IWorkbenchPartSite partSite = serviceLocator.getService(IWorkbenchPartSite.class);
   if (partSite == null) {
     IWorkbenchPart activePart = serviceLocator.getService(IWorkbenchPart.class);
     if (activePart == null) {
       IWorkbenchWindow workbenchWindow = DBeaverUI.getActiveWorkbenchWindow();
       if (workbenchWindow != null) {
         IWorkbenchPage activePage = workbenchWindow.getActivePage();
         if (activePage != null) {
           activePart = activePage.getActivePart();
         }
       }
     }
     if (activePart != null) {
       partSite = activePart.getSite();
     }
   }
   return partSite;
 }