コード例 #1
0
 public static CompareHandlerService createFor(ICompareContainer container, Shell shell) {
   IServiceLocator serviceLocator = container.getServiceLocator();
   if (serviceLocator != null) {
     IHandlerService service = (IHandlerService) serviceLocator.getService(IHandlerService.class);
     if (service != null) return new CompareHandlerService(container, null);
   }
   if (container.getWorkbenchPart() == null && shell != null) {
     // We're in a dialog so we can use an active shell expression
     IHandlerService service =
         (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
     if (service != null) {
       Expression e = new ActiveShellExpression(shell);
       return new CompareHandlerService(container, e);
     }
   }
   return new CompareHandlerService(null, null);
 }
コード例 #2
0
 private void initialize() {
   if (fHandlerService == null) {
     IServiceLocator serviceLocator = fContainer.getServiceLocator();
     if (serviceLocator != null) {
       IHandlerService service =
           (IHandlerService) serviceLocator.getService(IHandlerService.class);
       if (service != null) fHandlerService = service;
     }
     if (fHandlerService == null && fContainer.getWorkbenchPart() == null && fExpression != null) {
       // We're in a dialog so we can use an active shell expression
       IHandlerService service =
           (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
       if (service != null) {
         fHandlerService = service;
       }
     }
   }
 }