private IPartService getPartService() {
   IViewSite site = navigator.getViewSite();
   if (site != null) {
     return site.getService(IPartService.class);
   }
   return null;
 }
コード例 #2
0
 public static void executeCommand(IViewSite site, String command) {
   ICommandService cmdService = (ICommandService) site.getService(ICommandService.class);
   IHandlerService hdlService = (IHandlerService) site.getService(IHandlerService.class);
   Command cmd = cmdService.getCommand(command);
   try {
     hdlService.executeCommand(cmd.getId(), null);
   } catch (ExecutionException e) {
     e.printStackTrace();
   } catch (NotDefinedException e) {
     e.printStackTrace();
   } catch (NotEnabledException e) {
     e.printStackTrace();
   } catch (NotHandledException e) {
     e.printStackTrace();
   }
 }