org.eclipse.ui.handlers.IHandlerActivation Java Examples

The following examples show how to use org.eclipse.ui.handlers.IHandlerActivation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyBindingsManager.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void dispose() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        //During Eclipse shutdown the active workbench window is null
        return;
    }
    Object serviceObject = window.getService(IHandlerService.class);
    IHandlerService service = (IHandlerService) serviceObject;
    for (IHandlerActivation activation : fHandlerActivations) {
        service.deactivateHandler(activation);
    }
    fHandlerActivations.clear();

    fGoToMessageForKeyBinding = null;
    fFindForKeyBinding = null;
    fMoveUpForKeyBinding = null;
    fMoveDownForKeyBinding = null;
    fMoveLeftForKeyBinding = null;
    fMoveRightForKeyBinding = null;
    fShowNodeStartForKeyBinding = null;
    fShowNodeEndForKeyBinding = null;
}
 
Example #2
Source File: CorrectionCommandInstaller.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
		}
	}
}
 
Example #3
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final void dispose() {
	doDispose();
	
	for (IHandlerActivation handlerActivation : handlerActivations) {
		getHandlerService_2().deactivateHandler(handlerActivation);
	}
	
	super.dispose();
}
 
Example #4
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected void activateHandler(String string, AbstractHandler handler) {
	IHandlerActivation handlerActivation = getHandlerService_2().activateHandler(string, handler);
	handlerActivations.add(handlerActivation);
}