Defining key shortcut for completion engine via extension point [message #772618] |
Fri, 30 December 2011 08:01 |
|
HI,
I'm looking for a way to specify a key shortcut for a completion engine via extension points.
In preference page > General > Keys I can specify shortcuts like "Ctrl+Shift+Space" which triggers the completion in my current editor. But how can I do that if I want to preconfigure this shortcut as plug-in developer?
I tried:
<extension point="org.eclipse.ui.bindings">
<key sequence="Ctrl+7"
commandId="org.eclipse.recommenders.completion.rcp.chain.category"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.jdt.ui.javaEditorScope"/>
</extension>
but giving the completion context id as commandId does not work. I assume that I have to specify a command before. But how do I specify that this command is bound to the particular code completion?
Thanks in advance for some hints.
|
|
|
|
|
Re: Defining key shortcut for completion engine via extension point [message #776014 is a reply to message #775687] |
Sat, 07 January 2012 06:48 |
|
Found a gem that showed how to trigger code completion from a handler ( org.eclipse.jdt.internal.ui.text.java.JavaContentAssistHandler):
private static final String CHAIN_COMPLETION_CATEGORY = "org.eclipse.recommenders.completion.rcp.chain.category";
private final CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
private final SpecificContentAssistExecutor executor = new SpecificContentAssistExecutor(registry);
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
Optional<JavaEditor> opt = JdtUtils.getActiveJavaEditor();
if (opt.isPresent()) {
executor.invokeContentAssist(opt.get(), CHAIN_COMPLETION_CATEGORY);
}
return null;
}
Despite that it works. It's unclear to me how to make this shortcut appear in "Preferences >> Java >> Editor >> Content Assist >> Advanced". Am _I_ (my code) supposed to keep the shortcut in sync between JDT UI and the 'official' key binding specified for the handler in plug-in XML somehow?
For instance, on plug-in startup check which shortcut is currently defined for my command and than update JDT preferences accordingly? If I have to do this, can't I just set the JDT preference for my category to Ctrl+Shift+Space?
Thanks for a short note on this.
Marcel
[Updated on: Sat, 07 January 2012 06:49] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01838 seconds