示例#1
0
 @Nullable
 public static ISelectionProvider getSelectionProvider(IServiceLocator serviceLocator) {
   ISelectionProvider selectionProvider = serviceLocator.getService(ISelectionProvider.class);
   if (selectionProvider != null) {
     return selectionProvider;
   }
   IWorkbenchPartSite partSite = getWorkbenchPartSite(serviceLocator);
   if (partSite == null) {
     IWorkbenchPart activePart = serviceLocator.getService(IWorkbenchPart.class);
     if (activePart == null) {
       IWorkbenchWindow activeWindow = DBeaverUI.getActiveWorkbenchWindow();
       if (activeWindow != null) {
         activePart = activeWindow.getActivePage().getActivePart();
       }
     }
     if (activePart != null) {
       partSite = activePart.getSite();
     }
   }
   if (partSite != null) {
     return partSite.getSelectionProvider();
   } else {
     return null;
   }
 }
示例#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;
 }
示例#3
0
 @Nullable
 public static Shell getShell(IWorkbenchPart part) {
   return part == null ? null : getShell(part.getSite());
 }