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; }
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; } } }