/**
  * Called whenever a full reply has been received from the 430. Also called with value=-1 if a
  * timeout occurs waiting for a reply or if a garbled reply is received.
  *
  * @param what The parameter that the value refers to. For one byte replies (ACK, NACK, or NACK0)
  *     the command that produced this reply.
  * @param value The value of the "what" parameter. For one byte replies, the <i>negated</i> value
  *     of that byte as an integer.
  */
 protected void processReply(String what, boolean value) {
   if (SwingUtilities.isEventDispatchThread()) {
     processReplyInEventThread(what, value);
   } else {
     SwingUtilities.invokeLater(new ReplyProcessor(what, value));
   }
 }
Exemple #2
0
 // Utility method to make sure a task is executed on the Swing display
 // thread.
 private void invokeAndWait(Runnable aRunnable) {
   if (!SwingUtilities.isEventDispatchThread()) {
     try {
       SwingUtilities.invokeAndWait(aRunnable);
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else {
     aRunnable.run();
   }
 }
Exemple #3
0
  /** @see nl.lxtreme.ols.api.devices.CaptureCallback#captureStarted(int, int, int) */
  @Override
  public synchronized void captureStarted(
      final int aSampleRate, final int aChannelCount, final int aChannelMask) {
    final Runnable runner =
        new Runnable() {
          @Override
          public void run() {
            updateActions();
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      runner.run();
    } else {
      SwingUtilities.invokeLater(runner);
    }
  }
Exemple #4
0
 /** Invoked when the installer has failed. */
 public static void installFailed(final String description, Throwable th) {
   Config.trace("installFailed: " + description + " " + th);
   if (SwingUtilities.isEventDispatchThread()) {
     Config.getInstallService().installFailed();
     System.exit(-1);
   } else {
     try {
       SwingUtilities.invokeAndWait(
           new Runnable() {
             public void run() {
               Config.getInstallService().installFailed();
               System.exit(-1);
             }
           });
     } catch (java.lang.reflect.InvocationTargetException ite) {
       Config.trace("Unexpected exception: " + ite);
     } catch (InterruptedException ie) {
       Config.trace("Unexpected exception: " + ie);
     }
   }
 }
Exemple #5
0
  public boolean processExEntry(@NotNull final Editor editor, @NotNull final DataContext context) {
    ExEntryPanel panel = ExEntryPanel.getInstance();
    panel.deactivate();
    boolean res = true;
    int flags = 0;
    try {
      CommandState.getInstance(editor).popState();
      logger.debug("processing command");
      final String text = panel.getText();
      record(editor, text);
      if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
      if (panel.getLabel().equals(":")) {
        flags = CommandParser.getInstance().processCommand(editor, context, text, 1);
        if (logger.isDebugEnabled()) logger.debug("flags=" + flags);
        if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
          CommandGroups.getInstance().getMotion().exitVisual(editor, true);
        }
      } else {
        int pos =
            CommandGroups.getInstance()
                .getSearch()
                .search(
                    editor,
                    text,
                    panel.getCount(),
                    panel.getLabel().equals("/")
                        ? Command.FLAG_SEARCH_FWD
                        : Command.FLAG_SEARCH_REV,
                    true);
        if (pos == -1) {
          res = false;
        }
      }
    } catch (ExException ex) {
      // VimPlugin.showMessage(ex.getMessage());
      ProcessGroup.logger.info(ex.getMessage());
      VimPlugin.indicateError();
      res = false;
    } catch (Exception bad) {
      ProcessGroup.logger.error(bad);
      VimPlugin.indicateError();
      res = false;
    } finally {
      final int flg = flags;
      final Project project = PlatformDataKeys.PROJECT.getData(context); // API change - don't merge
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              // editor.getContentComponent().requestFocus();
              // Reopening the file was the only way I could solve the focus problem introduced in
              // IDEA at
              // version 1050.
              if (!ApplicationManager.getApplication().isUnitTestMode()
                  && (flg & CommandParser.RES_DONT_REOPEN) == 0) {
                VirtualFile vf = EditorData.getVirtualFile(editor);
                if (vf != null) {
                  FileEditorManager.getInstance(project)
                      .openFile(EditorData.getVirtualFile(editor), true);
                }
              }

              // If the result of the ex command is to display the "more" panel, show it here.
              if ((flg & CommandParser.RES_MORE_PANEL) != 0
                  && MorePanel.getInstance(editor).hasText()) {
                RunnableHelper.runReadCommand(
                    project,
                    new Runnable() {
                      public void run() {
                        MorePanel.getInstance(editor).activate();
                      }
                    },
                    "ShowMorePanel",
                    "ExCommand");
              }
            }
          });
    }

    return res;
  }