Ejemplo n.º 1
0
  /**
   * Constructs a new instance of <code>BindingService</code> using a JFace binding manager.
   *
   * @param bindingManager The bind ing manager to use; must not be <code>null</code>.
   * @param commandService The command service providing support for this service; must not be
   *     <code>null</code>;
   * @param workbench The workbench on which this context service will act; must not be <code>null
   *     </code>.
   */
  public BindingService(
      final BindingManager bindingManager,
      final ICommandService commandService,
      final IWorkbench workbench) {
    if (bindingManager == null) {
      throw new NullPointerException(
          "Cannot create a binding service with a null manager"); //$NON-NLS-1$
    }
    if (commandService == null) {
      throw new NullPointerException(
          "Cannot create a binding service with a null command service"); //$NON-NLS-1$
    }
    this.bindingManager = bindingManager;

    this.workbench = workbench;
    // Hook up the key binding support.
    this.bindingPersistence = new BindingPersistence(bindingManager, commandService);
    keyboard = new WorkbenchKeyboard(workbench);
    final Display display = workbench.getDisplay();
    final Listener listener = keyboard.getKeyDownFilter();
    display.addFilter(SWT.KeyDown, listener);
    // RAP [if] Listening for both SWT.KeyDown and SWT.Traverse events execute the command twice
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=381092
    //		display.addFilter(SWT.Traverse, listener);
    // ENDRAP

    // Initialize the key formatter.
    KeyFormatterFactory.setDefault(SWTKeySupport.getKeyFormatterForPlatform());
  }
Ejemplo n.º 2
0
 public final void dispose() {
   // RAP [rst] safeguard against NPE
   if (keyboard == null || workbench == null) return;
   // RAP [rst] move "workbench = null" down to prevent NPE
   final Listener listener = keyboard.getKeyDownFilter();
   final Display display = workbench.getDisplay();
   if (display != null) {
     display.removeFilter(SWT.KeyDown, listener);
     display.removeFilter(SWT.Traverse, listener);
   }
   workbench = null;
   keyboard = null;
   bindingPersistence.dispose();
 }
Ejemplo n.º 3
0
 public final void setKeyFilterEnabled(final boolean enabled) {
   keyboard.getKeyDownFilter().setEnabled(enabled);
 }
Ejemplo n.º 4
0
 public final void openKeyAssistDialog() {
   keyboard.openMultiKeyAssistShell();
 }
Ejemplo n.º 5
0
 public final boolean isKeyFilterEnabled() {
   return keyboard.getKeyDownFilter().isEnabled();
 }
Ejemplo n.º 6
0
 public final TriggerSequence getBuffer() {
   return keyboard.getBuffer();
 }