org.eclipse.ui.commands.ICommandService#getDefinedCommandIds ( )源码实例Demo

下面列出了org.eclipse.ui.commands.ICommandService#getDefinedCommandIds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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);
		}
	}
}
 
源代码2 项目: e4macs   文件: KbdMacroLoadHandler.java
/**
 * Verify statically that this macro will execute properly
 * - Ensure the current Eclipse defines the commands used by the macro 
 * 
 * @param editor
 * @param kbdMacro
 * @return true if validates, else false
 */
private String checkMacro(ITextEditor editor, KbdMacro kbdMacro) {
	String result = null;
	ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : 
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);		
	@SuppressWarnings("unchecked")	// Eclipse documents the type 
	Collection<String> cmdIds = (Collection<String>)ics.getDefinedCommandIds();
	for (KbdEvent e : kbdMacro.getKbdMacro()) {
		String cmdId;
		if ((cmdId = e.getCmd()) != null) {
			if (!cmdIds.contains(cmdId)) {
				result = cmdId;
				break;
			}
		}
	}
	return result;
}
 
源代码3 项目: translationstudio8   文件: KeysPreferencePage.java
public void init(IWorkbench workbench) {
	keyController = new KeyController2();
	keyController.init(workbench, lstRemove);
	model = keyController.getBindingModel();
	
	commandService = (ICommandService) workbench.getService(ICommandService.class);
	Collection definedCommandIds = commandService.getDefinedCommandIds();
	
	fDefaultCategory = commandService.getCategory(null);
	fBindingService = (IBindingService) workbench.getService(IBindingService.class);

	commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class);
}
 
源代码4 项目: tmxeditor8   文件: KeysPreferencePage.java
public void init(IWorkbench workbench) {
	keyController = new KeyController2();
	keyController.init(workbench, lstRemove);
	model = keyController.getBindingModel();
	
	commandService = (ICommandService) workbench.getService(ICommandService.class);
	Collection definedCommandIds = commandService.getDefinedCommandIds();
	
	fDefaultCategory = commandService.getCategory(null);
	fBindingService = (IBindingService) workbench.getService(IBindingService.class);

	commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class);
}
 
源代码5 项目: tmxeditor8   文件: KeysPreferencePage.java
public void init(IWorkbench workbench) {
	keyController = new KeyController2();
	keyController.init(workbench, lstRemove);
	model = keyController.getBindingModel();
	
	commandService = (ICommandService) workbench.getService(ICommandService.class);
	Collection definedCommandIds = commandService.getDefinedCommandIds();
	
	fDefaultCategory = commandService.getCategory(null);
	fBindingService = (IBindingService) workbench.getService(IBindingService.class);

	commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class);
}
 
源代码6 项目: Pydev   文件: FirstCharAction.java
/**
 * Creates a handler that will properly treat home considering python code (if it's still not defined
 * by the platform -- otherwise, just go with what the platform provides).
 */
public static VerifyKeyListener createVerifyKeyListener(final SourceViewer viewer, final IWorkbenchPartSite site,
        boolean forceCreation) {
    // This only needs to be done for eclipse 3.2 (where line start is not
    // defined).
    // Eclipse 3.3 onwards already defines the home key in the text editor.

    final boolean isDefined;
    if (site != null) {
        ICommandService commandService = (ICommandService) site.getService(ICommandService.class);
        Collection definedCommandIds = commandService.getDefinedCommandIds();
        isDefined = definedCommandIds.contains("org.eclipse.ui.edit.text.goto.lineStart");

    } else {
        isDefined = false;
    }

    if (forceCreation || !isDefined) {
        return new VerifyKeyListener() {

            @Override
            public void verifyKey(VerifyEvent event) {
                if (event.doit) {
                    boolean isHome;
                    if (isDefined) {
                        isHome = KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask,
                                "org.eclipse.ui.edit.text.goto.lineStart");
                    } else {
                        isHome = event.keyCode == SWT.HOME && event.stateMask == 0;
                    }
                    if (isHome) {
                        ISelection selection = viewer.getSelection();
                        if (selection instanceof ITextSelection) {
                            FirstCharAction firstCharAction = new FirstCharAction();
                            firstCharAction.viewer = viewer;
                            firstCharAction.perform(viewer.getDocument(), (ITextSelection) selection);
                            event.doit = false;
                        }
                    }
                }
            }
        };
    }
    return null;
}