コード例 #1
0
ファイル: ErtsProcess.java プロジェクト: huaqiao/erlide
 /**
  * Write something out to the node process.
  *
  * @param value The system.
  * @throws IOException
  */
 public synchronized void writeToErlang(final String value) throws IOException {
   if (!isStarted()) {
     return;
   }
   final IStreamsProxy astreamsProxy = getStreamsProxy();
   if (astreamsProxy != null) {
     astreamsProxy.write(value);
   }
 }
コード例 #2
0
ファイル: StartPVSHandler.java プロジェクト: Lanozavr/pvs
  /**
   * 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;
  }
コード例 #3
0
ファイル: ErtsProcess.java プロジェクト: huaqiao/erlide
 public void addErrListener(final IStreamListener errHandler) {
   final IStreamsProxy streamsProxy = getStreamsProxy();
   if (streamsProxy != null) {
     streamsProxy.getErrorStreamMonitor().addListener(errHandler);
   }
 }
コード例 #4
0
ファイル: ErtsProcess.java プロジェクト: huaqiao/erlide
 public void addStdListener(final IStreamListener dspHandler) {
   final IStreamsProxy streamsProxy = getStreamsProxy();
   if (streamsProxy != null) {
     streamsProxy.getOutputStreamMonitor().addListener(dspHandler);
   }
 }
コード例 #5
0
 public void write(String input) throws IOException {
   in.write(input);
 }
コード例 #6
0
 private IStreamsProxy removeDuplicates(IStreamsProxy streamsProxy) {
   return new StreamsProxy(
       removeDuplicates(streamsProxy.getOutputStreamMonitor()),
       streamsProxy.getErrorStreamMonitor(),
       streamsProxy);
 }