當前位置: 首頁>>代碼示例>>Java>>正文


Java ICommandService.getDefinedCommandIds方法代碼示例

本文整理匯總了Java中org.eclipse.ui.commands.ICommandService.getDefinedCommandIds方法的典型用法代碼示例。如果您正苦於以下問題:Java ICommandService.getDefinedCommandIds方法的具體用法?Java ICommandService.getDefinedCommandIds怎麽用?Java ICommandService.getDefinedCommandIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.ui.commands.ICommandService的用法示例。


在下文中一共展示了ICommandService.getDefinedCommandIds方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerCommands

import org.eclipse.ui.commands.ICommandService; //導入方法依賴的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

示例2: checkMacro

import org.eclipse.ui.commands.ICommandService; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:MulgaSoft,項目名稱:e4macs,代碼行數:26,代碼來源:KbdMacroLoadHandler.java

示例3: init

import org.eclipse.ui.commands.ICommandService; //導入方法依賴的package包/類
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);
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:14,代碼來源:KeysPreferencePage.java

示例4: createVerifyKeyListener

import org.eclipse.ui.commands.ICommandService; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:49,代碼來源:FirstCharAction.java


注:本文中的org.eclipse.ui.commands.ICommandService.getDefinedCommandIds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。