The context is the location in which this binding is valid. For commands that are visible everywhere—typically the kind of options in the default menu—they can be associated with the org.eclipse.ui.contexts.window
context. If the command should also be invoked from dialogs as well, then the org.eclipse.ui.context.dialogAndWindow
context would be used instead.
Open the
plugin.xml
file of theclock.ui
project.To enable the command only for Java editors, go to the plugin.xml tab, and modify the
contextId
as follows:<extension point="org.eclipse.ui.bindings"> <key commandId="com.packtpub.e4.clock.ui.command.hello" sequence="M1+9" //The following commented line needs to be removed /*contextId="org.eclipse.ui.contexts.window"*/ contextId="org.eclipse.jdt.ui.javaEditorScope" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> </extension>
Run the Eclipse instance, and create a Java project, a test...