コード例 #1
0
ファイル: ControlPanelWindow.java プロジェクト: xored/rcptt
 public void handleEvent(Event event) {
   if (recordingSupport != null) {
     int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
     KeySequence sequence =
         KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
     switch (recordingSupport.getMode()) {
       case Recording:
         TriggerSequence[] assertShortcuts =
             RecordingContextManager.Instance.getAssertModeShortcuts();
         if (assertShortcuts != null) {
           for (TriggerSequence s : assertShortcuts) {
             if (sequence.equals(s)) {
               recordingSupport.setMode(RecordingMode.Asserting);
             }
           }
         }
         handleStopRecordShortcutPressed(sequence);
         break;
       case Asserting:
         TriggerSequence[] recordShortcuts =
             RecordingContextManager.Instance.getRecordModeShortcuts();
         if (recordShortcuts != null) {
           for (TriggerSequence s : recordShortcuts) {
             if (sequence.equals(s)) {
               recordingSupport.setMode(RecordingMode.Recording);
             }
           }
         }
         handleStopRecordShortcutPressed(sequence);
         break;
       case Stopped:
         TriggerSequence[] startShortcuts =
             RecordingContextManager.Instance.getStartRecordShortcuts();
         if (startShortcuts != null) {
           for (TriggerSequence s : startShortcuts) {
             if (sequence.equals(s)) {
               recordingSupport.setMode(RecordingMode.Connecting);
             }
           }
         }
         TriggerSequence[] replayShortcuts =
             RecordingContextManager.Instance.getReplayShortcuts();
         if (replayShortcuts != null) {
           for (TriggerSequence s : replayShortcuts) {
             if (sequence.equals(s)) {
               recordingSupport.setMode(RecordingMode.Replaying);
             }
           }
         }
         break;
       case Connecting:
       case ImageRecognition:
       case Replaying:
       case WaitingForAUTRestart:
       default:
         break;
     }
   }
 }
コード例 #2
0
ファイル: BindingService.java プロジェクト: oaperez/rap
  /**
   * 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());
  }
コード例 #3
0
ファイル: NotesPopup.java プロジェクト: Bluelich/xmind
    private List<KeyStroke> generateKeyStrokes(Event event) {
      final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>(3);

      /*
       * If this is not a keyboard event, then there are no key strokes.
       * This can happen if we are listening to focus traversal events.
       */
      if ((event.stateMask == 0) && (event.keyCode == 0) && (event.character == 0)) {
        return keyStrokes;
      }

      // Add each unique key stroke to the list for consideration.
      final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event);
      keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator));

      // We shouldn't allow delete to undergo shift resolution.
      if (event.character == SWT.DEL) {
        return keyStrokes;
      }

      final int secondAccelerator = SWTKeySupport.convertEventToUnshiftedModifiedAccelerator(event);
      if (secondAccelerator != firstAccelerator) {
        keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator));
      }

      final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event);
      if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) {
        keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator));
      }

      return keyStrokes;
    }
コード例 #4
0
  /**
   * Initialize a part renderer from the extension point.
   *
   * @param context the context for the part factories
   */
  @PostConstruct
  void initialize(IEclipseContext context) {
    this.appContext = context;

    // initialize the correct key-binding display formatter
    KeyFormatterFactory.setDefault(SWTKeySupport.getKeyFormatterForPlatform());

    // Add the renderer to the context
    context.set(IPresentationEngine.class.getName(), this);

    IRendererFactory factory = null;
    IContributionFactory contribFactory = context.get(IContributionFactory.class);
    try {
      factory = (IRendererFactory) contribFactory.create(factoryUrl, context);
    } catch (Exception e) {
      logger.warn(e, "Could not create rendering factory");
    }

    // Try to load the default one
    if (factory == null) {
      try {
        factory = (IRendererFactory) contribFactory.create(defaultFactoryUrl, context);
      } catch (Exception e) {
        logger.error(e, "Could not create default rendering factory");
      }
    }

    if (factory == null) {
      throw new IllegalStateException("Could not create any rendering factory. Aborting ...");
    }

    curFactory = factory;
    context.set(IRendererFactory.class, curFactory);

    // Hook up the widget life-cycle subscriber
    if (eventBroker != null) {
      eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, toBeRenderedHandler);
      eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, visibilityHandler);
      eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, childrenHandler);
      eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, windowsHandler);
      eventBroker.subscribe(UIEvents.Perspective.TOPIC_WINDOWS, windowsHandler);
      eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS, trimHandler);
    }
  }