示例#1
0
 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
    private void updateStatusBar() {
      if (statusBar != null
          && statusBar.getControl() != null
          && !statusBar.getControl().isDisposed()) {
        StringBuilder message = new StringBuilder();

        message.append("Press ");
        switch (recordingSupport.getMode()) {
          case Recording:
            TriggerSequence[] shortcuts = RecordingContextManager.Instance.getAssertModeShortcuts();
            if (shortcuts != null && shortcuts.length > 0) {
              message.append(
                  Messages.bind(
                      Messages.ControlPanelWindow_AssertShortcutToolTip, shortcuts[0].format()));
              message.append(", ").append(getStopRecordShortcutMessage());
            }
            break;
          case Asserting:
            shortcuts = RecordingContextManager.Instance.getRecordModeShortcuts();
            if (shortcuts != null && shortcuts.length > 0) {
              message.append(
                  Messages.bind(
                      Messages.ControlPanelWindow_RecordShortcutToolTip, shortcuts[0].format()));
              message.append(", ").append(getStopRecordShortcutMessage());
              break;
            }
          case Stopped:
            TriggerSequence[] startShortcuts =
                RecordingContextManager.Instance.getStartRecordShortcuts();
            if (startShortcuts != null && startShortcuts.length > 0) {
              message.append(
                  Messages.bind(
                      Messages.ControlPanelWindow_StartRecordShortcutToolTip,
                      startShortcuts[0].format()));
              message.append(", ");
            }
            TriggerSequence[] replayShortcuts =
                RecordingContextManager.Instance.getReplayShortcuts();
            if (replayShortcuts != null && replayShortcuts.length > 0) {
              message.append(
                  Messages.bind(
                      Messages.ControlPanelWindow_ReplayShortcutToolTip,
                      replayShortcuts[0].format()));
            }
            break;
          default:
            statusBar.showMessage(null);
            return;
        }
        statusBar.showMessage(message.toString());
      }
    }
示例#3
0
 @Override
 public boolean close() {
   recordingSupport.setMode(RecordingMode.Stopped);
   if (isDirty()) {
     if (!openSaveDialog()) {
       return false;
     }
   }
   final boolean result = super.close();
   if (result && !parentShell.isDisposed()) {
     dbc.dispose();
     parentShell.removeShellListener(closeListener);
     parentShell.setMinimized(false);
     try {
       ShellUtilsProvider.getShellUtils().forceActive(parentShell);
     } catch (CoreException e) {
       throw new RuntimeException(e);
     }
     parentShell.setFocus();
     ITestCase model = getModel();
     if (model != null && model.exists()) {
       IFile location = (IFile) model.getResource();
       if (location != null) {
         try {
           IDE.openEditor(Q7UIPlugin.getActiveWindow().getActivePage(), location);
         } catch (PartInitException e) {
           Q7UIPlugin.log(e);
         }
       }
     }
   }
   RecordingContextManager.Instance.deactivateContext();
   return result;
 }
示例#4
0
 private String getStopRecordShortcutMessage() {
   TriggerSequence[] shortcuts = RecordingContextManager.Instance.getStopRecordShortcuts();
   if (shortcuts != null && shortcuts.length > 0) {
     return Messages.bind(
         Messages.ControlPanelWindow_StopRecordShortcutToolTip, shortcuts[0].format());
   }
   return "";
 }
示例#5
0
 private void handleStopRecordShortcutPressed(KeySequence sequence) {
   TriggerSequence[] shortcuts = RecordingContextManager.Instance.getStopRecordShortcuts();
   if (shortcuts != null) {
     for (TriggerSequence s : shortcuts) {
       if (sequence.equals(s)) {
         recordingSupport.setMode(RecordingMode.Stopped);
       }
     }
   }
 }