Eclipse 3.x key bindings are removed when migrated to e4 (Eclipse Luna ) series

254 Views Asked by At

The key bindings that I defined in my 3.x RCP workspace :

   <extension
   id="vebscheme.scheme"
   name="vebscheme.scheme"
   point="org.eclipse.ui.bindings">

    <key
       commandId="com.ami.veb.ui.menu.file.new.command"
       contextId="com.ami.veb.ui.context"
       schemeId="com.ami.veb.ui.scheme"
       sequence="CTRL+N"/>  
    <key
      commandId="com.ami.veb.ui.menu.file.openexternalfile.command"
      contextId="com.ami.veb.ui.context"
      schemeId="com.ami.veb.ui.scheme"
      sequence="CTRL+O"/>
    <key     
      commandId="com.ami.veb.ui.menu.file.new.components.addcomponentwizard.command"
      contextId="com.ami.veb.ui.context"
      schemeId="com.ami.veb.ui.scheme"
      sequence="CTRL+ALT+A"/>   
    <key
         commandId="com.ami.veb.ui.menu.file.new.components.updatecomponentwizard.command"  
      contextId="com.ami.veb.ui.context"
      schemeId="com.ami.veb.ui.scheme"
      sequence="CTRL+ALT+U"/>

      /** Scheme for the key-bindings **/
       <scheme
      id="com.ami.veb.ui.scheme"
      name="com.ami.veb.ui.scheme">
       </scheme>

      //----------------
       -----------------//
  </extension>

Scheme Activation :

    IBindingService bindingService = (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
    BindingService bindingServiceObj = (BindingService) bindingService;
    //get the binding manager for the binding service
    BindingManager bindingManager = bindingServiceObj.getBindingManager();

    //constructs a scheme instance with the schemeId
    Scheme newScheme = bindingManager.getScheme("com.ami.veb.ui.scheme");
    //check if the newScheme is not null
    //then set the scheme as active scheme
    if(newScheme != null) {
        try {
            bindingManager.setActiveScheme(newScheme);
        } catch (NotDefinedException e) {
            String message = "Problem occurred when updating current active scheme."+
                    " This may result in issues with shortcut key bindings. "+
                    "Exit and re-launch the application to resolve this issue";
            VeBLogger.getInstance().log(message);
            VeBPluginActivator.getDefault().logPluginError(e);
        }
    }

Context Activation :

     IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
    contextService.activateContext("com.ami.veb.ui.context");

I've generated a product (with Luna). I observed that the keyboard shortcuts are not working as soon as I launch the product (until I do a save on the shortcuts).

BindingTable table = getTable(c.getId());
        if (table != null) {
            currentResult = table.getPerfectMatch(triggerSequence);
        }

While debugging, I noticed that the BindingTable table is empty initially for my binding context, and therefore I'm getting Eclipse defined shortcuts and not the one which I'd defined for my context.

P.S. I recently migrated my RCP workspace from Eclipse Indigo (3.x RCP) to Luna (e4 series) and I observed that as soon as I export my RCP product my bindings got cleared and when I try to press any short-cut key (say Ctrl+N) I am able to see only the eclipse shortcuts and not the one which I'd defined in my plugin.xml.

Also, Please note that the migration is a partial migration (or soft migration) and not a complete migration (pure 'e4') and the application is still based on the compatibility layer.

The key bindings (defined in plugin.xml) pertained to the my binding context are getting cleared upon product launch.

I'm confused on what went wrong with the migration :( :(

Suggestions are welcomed and will be appreciated !

0

There are 0 best solutions below