Exemplo n.º 1
0
 public void addStdListener(final IStreamListener dspHandler) {
   final IStreamsProxy streamsProxy = getStreamsProxy();
   if (streamsProxy != null) {
     streamsProxy.getOutputStreamMonitor().addListener(dspHandler);
   }
 }
Exemplo n.º 2
0
  /**
   * the command has been executed, so extract extract the needed information from the application
   * context.
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    log.fine("Message to start PVS was received");
    window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    if (PVSExecutionManager.INST().isPVSRunning()) {
      MessageDialog.openInformation(
          window.getShell(), "PVS Running", "An instance of PVS is already running.");
    } else {
      try {
        final PVSConsole console = PVSConsole.getConsole();
        console.activate();
        console.clearConsole();
        final IOConsoleOutputStream outStream = console.newOutputStream();
        Map<String, String> attributes = new HashMap<String, String>();
        attributes.put(IProcess.ATTR_CMDLINE, PVSExecutionManager.INST().getPVSStartingCommand());
        ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
        IProcess process =
            DebugPlugin.newProcess(
                launch, PVSExecutionManager.INST().startPVS(), Activator.name, attributes);
        PVSExecutionManager.INST().setIProcess(process);
        DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
        DebugPlugin.getDefault().addDebugEventListener(PVSExecutionManager.INST());
        PVSJsonWrapper.init();
        PVSExecutionManager.INST().removeRespondListeners();
        PVSExecutionManager.INST()
            .addListener(
                new PVSRespondListener() {

                  @Override
                  public void onMessageReceived(String message) {
                    log.log(Level.INFO, "Message received: {0}", message);
                    try {
                      outStream.write(message);
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
                  }

                  @Override
                  public void onMessageReceived(JSONObject message) {
                    log.log(Level.INFO, "JSON received: {0}", message);
                    PVSJsonWrapper.INST().addToJSONQueue(message);
                  }

                  @Override
                  public void onPromptReceived(List<String> previousLines, String prompt) {
                    log.log(Level.INFO, "Prompt received: {0}", prompt);
                    try {
                      outStream.write(prompt);
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
                    PVSPromptProcessor.processPrompt(previousLines, prompt);
                  }
                });
        IStreamsProxy streamProxy = process.getStreamsProxy();
        IStreamMonitor outMonitor = streamProxy.getOutputStreamMonitor();
        outMonitor.addListener(new PVSStreamListener(EclipsePluginUtil.getLispType()));

        IOConsoleKeyboardReader.init(console);
        IOConsoleKeyboardReader.INST()
            .addListener(
                new IOConsoleKeyboardReader.IOConsoleKeyboardReaderListener() {
                  public void onTextReceived(String text) {
                    PVSExecutionManager.INST().writeToPVS(text);
                  }
                });
        IOConsoleKeyboardReader.INST().start();
        Thread.sleep(500);
        restorePVSContext();
      } catch (IOException e) {
        log.severe("Failed to start PVS");
        MessageDialog.openInformation(window.getShell(), "Error", "Failed to start PVS");
      } catch (InterruptedException e) {
        log.severe("Failed to restore PVS context");
        MessageDialog.openInformation(
            window.getShell(), "Error", "Failed to restore the PVS context");
      } catch (PVSException e) {
        log.severe("Failed to restore PVS context");
        MessageDialog.openInformation(
            window.getShell(), "Error", "Failed to restore the PVS context");
      }
    }
    return null;
  }
Exemplo n.º 3
0
 private IStreamsProxy removeDuplicates(IStreamsProxy streamsProxy) {
   return new StreamsProxy(
       removeDuplicates(streamsProxy.getOutputStreamMonitor()),
       streamsProxy.getErrorStreamMonitor(),
       streamsProxy);
 }