当前位置: 首页>>代码示例>>Java>>正文


Java IHandlerService类代码示例

本文整理汇总了Java中org.eclipse.ui.handlers.IHandlerService的典型用法代码示例。如果您正苦于以下问题:Java IHandlerService类的具体用法?Java IHandlerService怎么用?Java IHandlerService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IHandlerService类属于org.eclipse.ui.handlers包,在下文中一共展示了IHandlerService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ModernActionKeyBindingSupport

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
private ModernActionKeyBindingSupport(
    final IAdaptable serviceLocator,
    final Expression expression,
    final int sourcePriorities) {
    Check.notNull(serviceLocator, "serviceLocator"); //$NON-NLS-1$
    Check.notNull(expression, "expression"); //$NON-NLS-1$

    bindingService = (IBindingService) serviceLocator.getAdapter(IBindingService.class);
    handlerService = (IHandlerService) serviceLocator.getAdapter(IHandlerService.class);

    if (bindingService == null || handlerService == null) {
        throw new IllegalArgumentException(
            "specified IAdapable could not provide IBindingService or IHandlerService"); //$NON-NLS-1$
    }

    this.expression = expression;
    this.sourcePriorities = sourcePriorities;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:19,代码来源:ModernActionKeyBindingSupport.java

示例2: execute

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_IMPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_IMPORT_PARM_WIZARDID,
              SessionImportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ImportSessionHandler.java

示例3: execute

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    final ICommandService cs = (ICommandService) site
        .getService(ICommandService.class);
    final IHandlerService hs = (IHandlerService) site
        .getService(IHandlerService.class);
    final Command command = cs
        .getCommand(IWorkbenchCommandConstants.FILE_EXPORT);

    try {
      hs.executeCommand(ParameterizedCommand.generateCommand(command,
          Collections.singletonMap(
              IWorkbenchCommandConstants.FILE_EXPORT_PARM_WIZARDID,
              SessionExportWizard.ID)),
          null);
    } catch (CommandException e) {
      EclEmmaUIPlugin.log(e);
    }

    return null;
  }
 
开发者ID:eclipse,项目名称:eclemma,代码行数:23,代码来源:ExportSessionHandler.java

示例4: hookDoubleClickAction

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
private void hookDoubleClickAction() {
	bookmarksTreeViewer.addDoubleClickListener(event -> {
		ISelection selection = bookmarksTreeViewer.getSelection();
		Object firstElement = ((IStructuredSelection) selection).getFirstElement();
		Bookmark bookmark = Adapters.adapt(firstElement, Bookmark.class);
		if (bookmark instanceof BookmarkFolder) {
			bookmarksTreeViewer.setExpandedState(firstElement, !bookmarksTreeViewer.getExpandedState(firstElement));
		} else {
			// sometimes, selection and part in the command handler are not set to the boomarks view when we double-click on a bookmark
			getSite().getWorkbenchWindow().getActivePage().activate(this);
			IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
			try {
				handlerService.executeCommand(COMMAND_ID_GOTO_FAVORI, null);
			} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) {
				StatusHelper.logError("Could not go to bookmark", e);
			}
		}
	});
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:20,代码来源:BookmarksView.java

示例5: close

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
public boolean close() {
	this.filterJob.cancel();
	this.refreshCacheJob.cancel();
	this.refreshProgressMessageJob.cancel();
	if (showViewHandler != null) {
		IHandlerService service = PlatformUI
				.getWorkbench().getService(IHandlerService.class);
		service.deactivateHandler(showViewHandler);
		showViewHandler.getHandler().dispose();
		showViewHandler = null;
	}
	if (menuManager != null)
		menuManager.dispose();
	if (contextMenuManager != null)
		contextMenuManager.dispose();
	storeDialog(getDialogSettings());
	return super.close();
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:19,代码来源:FilteredItemsSelectionDialog.java

示例6: executeCommand

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) {
    if (workbench == null) {
        workbench = PlatformUI.getWorkbench();
    }
    // get command
    ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
    Command command = commandService != null ? commandService.getCommand(commandName) : null;
    // get handler service
    //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
    //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
    IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
    if (command != null && handlerService != null) {
        ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
        try {
            handlerService.executeCommand(paramCommand, null);
        } catch (Exception e) {
            Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
        }
    }
}
 
开发者ID:anb0s,项目名称:EasyShell,代码行数:21,代码来源:Utils.java

示例7: hookDoubleClickCommand

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
/**
    * Hook double click command.
    */
   private void hookDoubleClickCommand() {

this.getCommonViewer().addDoubleClickListener(new IDoubleClickListener() {
    public void doubleClick(DoubleClickEvent event) {
	IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
	try {
	    if ((event.getSelection() != null) && (event.getSelection() instanceof IStructuredSelection)) {
		IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
		Object element = structSel.iterator().next();

		if (element instanceof CollectionNode) {
		    handlerService.executeCommand("synergyviewcore.collections.openMediaCollection", null);
		}
		if (element instanceof AnnotationSetNode) {
		    handlerService.executeCommand("synergyviewcore.subtitle.openannotationseteditor", null);
		}

	    }
	} catch (Exception ex) {
	    IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex);
	    logger.log(status);
	}
    }
});
   }
 
开发者ID:synergynet,项目名称:synergyview,代码行数:29,代码来源:ProjectExplorerViewPart.java

示例8: run

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
@Override
public void run(IAction action) {
   System.err.println("In run(IACtion)");
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:23,代码来源:CompareWithRouteAction.java

示例9: run

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
@Override
public void run(IAction action) {
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:22,代码来源:PersistToRouteModelAction.java

示例10: fillActionBars

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
/**
 * Fills the actions bars.
 * <p>
 * Subclasses may extend.
 *
 * @param actionBars the action bars
 */
protected void fillActionBars(IActionBars actionBars) {
	IToolBarManager toolBar= actionBars.getToolBarManager();
	fillToolBar(toolBar);

	IAction action;

	action= getCopyToClipboardAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), action);

	action= getSelectAllAction();
	if (action != null)
		actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), action);

	IHandlerService handlerService= (IHandlerService) getSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkAction));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:AbstractInfoView.java

示例11: setGlobalActionHandlers

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
private void setGlobalActionHandlers(IActionBars actionBars) {
	// Navigate Go Into and Go To actions.
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
	actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
	actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
	actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
	actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
	actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);

	fRefactorActionGroup.retargetFileMenuActions(actionBars);

	IHandlerService handlerService= (IHandlerService) fPart.getViewSite().getService(IHandlerService.class);
	handlerService.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, new ActionHandler(fToggleLinkingAction));
	handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:PackageExplorerActionGroup.java

示例12: registerCommands

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
public void registerCommands(CompilationUnitEditor editor) {
	IWorkbench workbench= PlatformUI.getWorkbench();
	ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
	IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
	if (commandService == null || handlerService == null) {
		return;
	}

	if (fCorrectionHandlerActivations != null) {
		JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
	}
	fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();

	Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
	for (Iterator<String> iter= definedCommandIds.iterator(); iter.hasNext();) {
		String id= iter.next();
		if (id.startsWith(ICommandAccess.COMMAND_ID_PREFIX)) {
			boolean isAssist= id.endsWith(ICommandAccess.ASSIST_SUFFIX);
			CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
			IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
			fCorrectionHandlerActivations.add(activation);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:CorrectionCommandInstaller.java

示例13: createPage0

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
/**
 * Creates page 0 of the multi-page editor,
 * which contains a text editor.
 */
void createPage0() {
	try {
		editor = new TextEditor();
	

		int index = addPage(editor, getEditorInput());
		setPageText(index, editor.getTitle());
	
	
		IHandlerService serv = (IHandlerService) getSite().getService(IHandlerService.class);
		MyCopyHandler cp = new MyCopyHandler();
		serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_PASTE, cp);
		//serv.activateHandler(org.eclipse.ui.IWorkbenchCommandConstants.EDIT_, cp);

	} catch (PartInitException e) {
		ErrorDialog.openError(
			getSite().getShell(),
			"Error creating nested text editor",
			null,
			e.getStatus());
	}
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:27,代码来源:ExperimentConfigurationEditor.java

示例14: callRuleGenerationCommand

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
private boolean callRuleGenerationCommand(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation.rule");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:18,代码来源:MACLIncQueryGenerator.java

示例15: execute

import org.eclipse.ui.handlers.IHandlerService; //导入依赖的package包/类
@Override
public boolean execute(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		MACLCommandContext context = new MACLCommandContext(ePack, pattern, iPath);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:20,代码来源:MACLPatternImplementation.java


注:本文中的org.eclipse.ui.handlers.IHandlerService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。