Exemplo n.º 1
0
 @Override
 protected boolean isToolAlive() {
   if (fConnectionState != 0 || !fRjs.runAsyncPing()) {
     return false;
   }
   if (Thread.currentThread() == getControllerThread()
       && !isInHotModeL()
       && !fRjs.isConsoleReady()) {
     return false;
   }
   return true;
 }
Exemplo n.º 2
0
 @Override
 public ElementTracepointInstallationReport exec(
     final ElementTracepointInstallationRequest request, final IProgressMonitor monitor)
     throws CoreException {
   return (ElementTracepointInstallationReport)
       fRjs.execSyncDbgOp(DbgCmdItem.OP_INSTALL_TP_POSITIONS, request, monitor);
 }
Exemplo n.º 3
0
 @Override
 protected FrameContext doEvalFrameContext(final int position, final IProgressMonitor monitor)
     throws Exception {
   return (FrameContext)
       fRjs.execSyncDbgOp(
           DbgCmdItem.OP_LOAD_FRAME_CONTEXT, new FrameContextDetailRequest(position), monitor);
 }
Exemplo n.º 4
0
 @Override
 protected int setSuspended(final int level, final int enterDetail, final Object enterData) {
   final int diff = super.setSuspended(level, enterDetail, enterData);
   if (level > 0 && diff > 0) {
     fRjs.requestExtraMode((AbstractRJComClient.EXTRA_BEFORE | AbstractRJComClient.EXTRA_NESTED));
   }
   return diff;
 }
Exemplo n.º 5
0
  @Override
  protected void clear() {
    fRjs.setClosed(true);

    super.clear();

    if (fEmbedded && !isDisconnected()) {
      try {
        Naming.unbind(fAddress.getAddress());
      } catch (final Throwable e) {
      }
    }
    fRjs.disposeAllGraphics();
    if (fRjsId > 0) {
      RjsComConfig.unregisterClientComHandler(fRjsId);
      fRjsId = 0;
    }
  }
Exemplo n.º 6
0
 @Override
 public void downloadFile(
     final OutputStream out,
     final String fileName,
     final int options,
     final IProgressMonitor monitor)
     throws CoreException {
   fRjs.downloadFile(out, fileName, options, monitor);
 }
Exemplo n.º 7
0
 @Override
 public void uploadFile(
     final InputStream in,
     final long length,
     final String fileName,
     final int options,
     final IProgressMonitor monitor)
     throws CoreException {
   fRjs.uploadFile(in, length, fileName, options, monitor);
 }
Exemplo n.º 8
0
 public RObject evalData(
     final String command,
     final RObject envir,
     final String factoryId,
     final int options,
     final int depth,
     final IProgressMonitor monitor)
     throws CoreException {
   return fRjs.evalData(command, envir, factoryId, options, depth, monitor);
 }
Exemplo n.º 9
0
 @Override
 public RObject evalData(
     final RReference reference,
     final String factoryId,
     final int options,
     final int depth,
     final IProgressMonitor monitor)
     throws CoreException {
   return fRjs.evalData(reference, factoryId, options, depth, monitor);
 }
Exemplo n.º 10
0
 public RObject[] findData(
     final String symbol,
     final RObject envir,
     final boolean inherits,
     final String factoryId,
     final int options,
     final int depth,
     final IProgressMonitor monitor)
     throws CoreException {
   return fRjs.findData(symbol, envir, inherits, factoryId, options, depth, monitor);
 }
Exemplo n.º 11
0
 @Override
 protected void killTool(final IProgressMonitor monitor) {
   fRjs.setClosed(true);
   final ToolProcess consoleProcess = getTool();
   // TODO: kill remote command?
   final IProcess[] processes = consoleProcess.getLaunch().getProcesses();
   for (int i = 0; i < processes.length; i++) {
     if (processes[i] != consoleProcess && !processes[i].isTerminated()) {
       try {
         processes[i].terminate();
       } catch (final Exception e) {
       }
     }
   }
 }
Exemplo n.º 12
0
  /**
   * This is an async operation cancel is not supported by this implementation
   *
   * @param monitor a progress monitor
   */
  @Override
  public void disconnect(final IProgressMonitor monitor) throws CoreException {
    switch (getStatus()) {
      case STARTED_IDLING:
      case STARTED_SUSPENDED:
      case STARTED_PROCESSING:
      case STARTED_PAUSED:
        monitor.beginTask("Disconnecting from R remote engine...", 1);
        synchronized (fQueue) {
          beginInternalTask();
        }
        try {
          fRjs.getConsoleServer().disconnect();
          fConnectionState = Server.S_DISCONNECTED;
        } catch (final RemoteException e) {
          throw new CoreException(
              new Status(
                  IStatus.ERROR,
                  RConsoleCorePlugin.PLUGIN_ID,
                  ICommonStatusConstants.LAUNCHING,
                  "Disconnecting from R remote engine failed.",
                  e));
        } finally {
          synchronized (fQueue) {
            scheduleControllerRunnable(
                new ControllerSystemRunnable(
                    "common/disconnect/finish", "Disconnect") { // $NON-NLS-1$

                  @Override
                  public void run(final IToolService s, final IProgressMonitor monitor)
                      throws CoreException {
                    if (!isTerminated()) {
                      fRjs.runMainLoopPing(monitor);
                      fRjs.handleServerStatus(
                          new RjsStatus(RjsStatus.INFO, Server.S_DISCONNECTED), monitor);
                    }
                  }
                });
            endInternalTask();
          }
          monitor.done();
        }
    }
  }
Exemplo n.º 13
0
 @Override
 protected void doRequestSuspend(final IProgressMonitor monitor) throws CoreException {
   fRjs.execSyncDbgOp(DbgCmdItem.OP_REQUEST_SUSPEND, null, monitor);
 }
Exemplo n.º 14
0
 @Override
 protected boolean canSuspend(final IProgressMonitor monitor) {
   return (fRjs.getDataLevel() == 0);
 }
Exemplo n.º 15
0
 @Override
 public byte[] downloadFile(
     final String fileName, final int options, final IProgressMonitor monitor)
     throws CoreException {
   return fRjs.downloadFile(fileName, options, monitor);
 }
Exemplo n.º 16
0
 @Override
 public void waitingForUser(final IProgressMonitor monitor) {
   fRjs.waitingForUser();
 }
Exemplo n.º 17
0
 @Override
 public void exec(final TracepointStatesUpdate request) throws CoreException {
   fRjs.execAsyncDbgOp(DbgCmdItem.OP_UPDATE_TP_STATES, request);
 }
Exemplo n.º 18
0
 @Override
 public void exec(final DbgEnablement request) throws CoreException {
   fRjs.execAsyncDbgOp(DbgCmdItem.OP_SET_ENABLEMENT, request);
 }
Exemplo n.º 19
0
 @Override
 protected CallStack doEvalCallStack(final IProgressMonitor monitor) throws CoreException {
   return (CallStack) fRjs.execSyncDbgOp(DbgCmdItem.OP_LOAD_FRAME_LIST, null, monitor);
 }
Exemplo n.º 20
0
 @Override
 protected boolean initilizeHotMode() {
   return fRjs.startHotMode();
 }
Exemplo n.º 21
0
 @Override
 protected void requestHotMode(final boolean async) {
   fRjs.requestHotMode(async);
 }
Exemplo n.º 22
0
  @Override
  protected void startToolL(final IProgressMonitor monitor) throws CoreException {
    fRjsId = RjsComConfig.registerClientComHandler(fRjs);
    fRjs.initClient(getTool(), this, fRjsProperties, fRjsId);
    try {
      final Map<String, Object> data = new HashMap<String, Object>();
      final IToolEventHandler loginHandler =
          getEventHandler(IToolEventHandler.LOGIN_REQUEST_EVENT_ID);
      String msg = null;
      boolean connected = false;
      while (!connected) {
        final Map<String, Object> initData = getInitData();
        final ServerLogin login = fRjsConnection.getServer().createLogin(Server.C_CONSOLE_CONNECT);
        try {
          final Callback[] callbacks = login.getCallbacks();
          if (callbacks != null) {
            final List<Callback> checked = new ArrayList<Callback>();
            FxCallback fx = null;
            for (final Callback callback : callbacks) {
              if (callback instanceof FxCallback) {
                fx = (FxCallback) callback;
              } else {
                checked.add(callback);
              }
            }

            if (initData != null) {
              data.putAll(initData);
            }
            data.put(
                LOGIN_ADDRESS_DATA_KEY, (fx != null) ? fAddress.getHost() : fAddress.getAddress());
            data.put(LOGIN_MESSAGE_DATA_KEY, msg);
            data.put(LOGIN_CALLBACKS_DATA_KEY, checked.toArray(new Callback[checked.size()]));

            if (loginHandler == null) {
              throw new CoreException(
                  new Status(
                      IStatus.ERROR,
                      RConsoleCorePlugin.PLUGIN_ID,
                      ICommonStatusConstants.LAUNCHING,
                      "Login requested but not supported by this configuration.",
                      null));
            }
            if (!loginHandler
                .handle(IToolEventHandler.LOGIN_REQUEST_EVENT_ID, this, data, monitor)
                .isOK()) {
              throw new CoreException(Status.CANCEL_STATUS);
            }

            if (fx != null) {
              RjsUtil.handleFxCallback(
                  RjsUtil.getSession(data, new SubProgressMonitor(monitor, 1)),
                  fx,
                  new SubProgressMonitor(monitor, 1));
            }
          }

          msg = null;
          if (monitor.isCanceled()) {
            throw new CoreException(Status.CANCEL_STATUS);
          }

          final Map<String, Object> args = new HashMap<String, Object>();
          args.putAll(fRjsProperties);
          ConsoleEngine rjServer;
          if (fStartup) {
            args.put("args", fRArgs); // $NON-NLS-1$
            rjServer =
                (ConsoleEngine)
                    fRjsConnection
                        .getServer()
                        .execute(Server.C_CONSOLE_START, args, login.createAnswer());
          } else {
            rjServer =
                (ConsoleEngine)
                    fRjsConnection
                        .getServer()
                        .execute(Server.C_CONSOLE_CONNECT, args, login.createAnswer());
          }
          fRjs.setServer(rjServer, 0);
          connected = true;

          if (callbacks != null) {
            loginHandler.handle(IToolEventHandler.LOGIN_OK_EVENT_ID, this, data, monitor);
            if (initData != null) {
              initData.put(LOGIN_USERNAME_DATA_KEY, data.get(LOGIN_USERNAME_DATA_KEY));
            }
          }
        } catch (final LoginException e) {
          msg = e.getLocalizedMessage();
        } finally {
          if (login != null) {
            login.clearData();
          }
        }
      }

      final ServerInfo info = fRjsConnection.getServer().getInfo();
      if (fWorkspaceData.isRemote()) {
        try {
          final String wd = FileUtil.toString(fWorkspaceData.toFileStore(info.getDirectory()));
          if (wd != null) {
            setStartupWD(wd);
          }
        } catch (final CoreException e) {
        }
      } else {
        setStartupWD(info.getDirectory());
      }
      final long timestamp = info.getTimestamp();
      if (timestamp != 0) {
        setStartupTimestamp(timestamp);
      }

      final List<IStatus> warnings = new ArrayList<IStatus>();

      initTracks(info.getDirectory(), monitor, warnings);

      if (fStartup && !fStartupsRunnables.isEmpty()) {
        fQueue.add(fStartupsRunnables.toArray(new IToolRunnable[fStartupsRunnables.size()]));
        fStartupsRunnables.clear();
      }

      if (!fStartup) {
        handleStatus(
            new Status(
                IStatus.INFO,
                RConsoleCorePlugin.PLUGIN_ID,
                addTimestampToMessage(
                    RNicoMessages.R_Info_Reconnected_message, fProcess.getConnectionTimestamp())),
            monitor);
      }
      // fRjs.runMainLoop(null, null, monitor); must not wait at server side
      fRjs.activateConsole();

      scheduleControllerRunnable(
          new ControllerSystemRunnable(
              "r/rj/start2", "Finish Initialization / Read Output") { // $NON-NLS-1$

            @Override
            public void run(final IToolService s, final IProgressMonitor monitor)
                throws CoreException {
              if (!fRjs.isConsoleReady()) { // R is still working
                fRjs.runMainLoop(null, null, monitor);
              }
              for (final IStatus status : warnings) {
                handleStatus(status, monitor);
              }
            }
          });
    } catch (final RemoteException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              "The R engine could not be started.",
              e));
    } catch (final RjException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              "An error occured when creating login data.",
              e));
    }
  }
Exemplo n.º 23
0
 @Override
 public void resume() {
   fRjs.resume();
 }
Exemplo n.º 24
0
 @Override
 protected SetDebugReport doExec(final SetDebugRequest request, final IProgressMonitor monitor)
     throws CoreException {
   return (SetDebugReport) fRjs.execSyncDbgOp(DbgCmdItem.OP_SET_DEBUG, request, monitor);
 }
Exemplo n.º 25
0
 @Override
 public void removeCancelHandler(final Callable<Boolean> handler) {
   fRjs.removeCancelHandler(handler);
 }
Exemplo n.º 26
0
 @Override
 protected void interruptTool() throws UnsupportedOperationException {
   fRjs.runAsyncInterrupt();
 }
Exemplo n.º 27
0
 @Override
 public void exec(final DbgFilterState request) throws CoreException {
   fRjs.execAsyncDbgOp(DbgCmdItem.OP_RESET_FILTER_STATE, request);
 }
Exemplo n.º 28
0
 @Override
 public void addCancelHandler(final Callable<Boolean> handler) {
   fRjs.addCancelHandler(handler);
 }
Exemplo n.º 29
0
 @Override
 public void exec(final TracepointStatesUpdate request, final IProgressMonitor monitor)
     throws CoreException {
   fRjs.execSyncDbgOp(DbgCmdItem.OP_UPDATE_TP_STATES, request, monitor);
 }
Exemplo n.º 30
0
 @Override
 public Lock getWaitLock() {
   return fRjs.getWaitLock();
 }