Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Problem with key bindings
Problem with key bindings [message #933685] Fri, 05 October 2012 08:38 Go to next message
Mikael Petterson is currently offline Mikael Petterson
Messages: 152
Registered: July 2009
Senior Member
Hi,

I have defined a Ctrl+S key binding for a view. When I run it I get a popup ( lower left corner) see attached file.

Then in the console I get the following:

!ENTRY org.eclipse.jface 2 0 2012-10-05 10:30:57.482
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2012-10-05 10:30:57.482
!MESSAGE A conflict occurred for CTRL+S:
Binding(CTRL+S,
	ParameterizedCommand(Command(net.sourceforge.eclipseccase.ui.command.savecs,Save CS,
		Save Config Spec,
		Category(net.sourceforge.eclipseccase.category,ClearCase,ClearCase actions,true),
		,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+S,
	ParameterizedCommand(Command(org.eclipse.ui.file.save,Save,
		Save the current contents,
		Category(org.eclipse.ui.category.file,File,null,true),
		org.eclipse.ui.internal.handlers.SaveHandler@13e9963,
		,,true),null),
	org.eclipse.ui.defaultAcceleratorConfiguration,
	org.eclipse.ui.contexts.window,,,system)



I have defined the Ctrl+S to be enabled for that specific view.

Is this not same definitions but for different contexts?


Another question is how I can provide values from my View class to the command handler?

br,

//mike

<!-- Command Handlers and other definitions -->

<extension
       point="org.eclipse.ui.handlers">
    <handler
          class="net.sourceforge.eclipseccase.ui.commands.SaveCsHandler"
          commandId="net.sourceforge.eclipseccase.ui.command.savecs">
          <activeWhen>
            <reference
                  definitionId="net.sourceforge.eclispeccase.ui.contributions.csview">
            </reference>
         </activeWhen>
    </handler>
 </extension>

<extension
         point="org.eclipse.core.expressions.definitions">
      <definition
            id="net.sourceforge.eclispeccase.ui.contributions.csview">
         <with
               variable="activePartId">
            <equals
                  value="net.sourceforge.eclipseccase.views.ConfigSpecView">
            </equals>
         </with>
      </definition>
   </extension>
   
   	<extension point="org.eclipse.ui.bindings">
		<key commandId="net.sourceforge.eclipseccase.ui.command.savecs"
			 schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
			sequence="Ctrl+S">
		</key>
	</extension>


  • Attachment: save_cs.JPG
    (Size: 16.52KB, Downloaded 140 times)
Re: Problem with key bindings [message #933902 is a reply to message #933685] Fri, 05 October 2012 12:49 Go to previous message
Mikael Petterson is currently offline Mikael Petterson
Messages: 152
Registered: July 2009
Senior Member
I realize that I have not been very clear on what I want to do so I try to summarize it here:

- I have an action today ( Save config file) that is called from a view. Before we call the action I set 3 parameters that is used in the execution.
- Now I need to add some short cuts ( like Ctrl+S to "save config file") that should be active in the context of my view.
- So I want to execute the command when Ctrl+S is pressed. I need to set the 3 parameters ( that is contained in view) and then command can be executed.

I have read this:

http://wiki.eclipse.org/Platform_Command_Framework

It is not clear how the connection between key and executing the command can be done.

Is it enough to specify the following in plugin.xml

If I implement this in my view class:

	private static final String VIEW_COUNT_ID = "org.eclipse.ui.examples.contributions.view.count"; //$NON-NLS-1$
	...
	/**
	 * Instantiate any handlers specific to this view and activate them.
	 */
	private void createHandlers() {
		// 1 - get the handler service from the view site
		IHandlerService handlerService = (IHandlerService) getSite()
				.getService(IHandlerService.class);
		// 2 - create the handler instance
		countHandler = new AbstractHandler() {
			public Object execute(ExecutionEvent event)
					throws ExecutionException {
				// viewer is an instance variable of InfoView
				List elements = (List) viewer.getInput();
				MessageDialog.openInformation(getSite().getShell(),
						ContributionMessages.SampleHandler_plugin_name,
						NLS.bind(ContributionMessages.InfoView_countElements,
								new Integer(elements.size())));
				return null;
			}
		};
		// 3 - activate this handler instance for the count command
		handlerService.activateHandler(VIEW_COUNT_ID, countHandler);
	}


Does it mean that I can skip the this in plugin.xml

<extension
       point="org.eclipse.ui.handlers">
    <handler
          class="net.sourceforge.eclipseccase.ui.commands.SaveCsHandler"
          commandId="net.sourceforge.eclipseccase.ui.commands.savecs">
          <activeWhen>
            <reference
                  definitionId="net.sourceforge.eclipseccase.views.ConfigSpecView">
            </reference>
         </activeWhen>
    </handler>


br,

//mike
Previous Topic:Undo command description
Next Topic:Automatically add a project nature
Goto Forum:
  


Current Time: Fri Oct 31 10:05:11 GMT 2014

Powered by FUDForum. Page generated in 0.32146 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software