@Override
 public Object execute(final ExecutionEvent event) throws ExecutionException {
   ToolProcess process = fProcess;
   if (process == null) {
     final IWorkbenchPage page = UIAccess.getActiveWorkbenchPage(false);
     process = NicoUI.getToolRegistry().getActiveToolSession(page).getProcess();
   }
   if (!NicoUITools.isToolReady(RTool.TYPE, RTool.R_DATA_FEATURESET_ID, process)) {
     return null;
   }
   process.getQueue().add(new REnvIndexAutoUpdater.UpdateRunnable(fCompletely));
   return null;
 }
Exemple #2
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) {
       }
     }
   }
 }
 private void handleTerminated(final ToolProcess tool) {
   synchronized (this) {
     if (fCurrentTool == tool) {
       if (DEBUG) {
         System.out.println("[tool source] terminated:" + (tool != null ? tool.getLabel() : "-"));
       }
       fireSourceChanged(ISources.WORKBENCH, ACTIVE_TOOL_NAME, tool);
     }
   }
 }
 private void handleActivated(final ToolProcess tool) {
   synchronized (this) {
     if (fCurrentTool == tool || (fCurrentTool == null && tool == null)) {
       return;
     }
     fCurrentTool = tool;
   }
   if (DEBUG) {
     System.out.println("[tool source] changed:" + (tool != null ? tool.getLabel() : "-"));
   }
   final Object value = (tool != null) ? tool : IEvaluationContext.UNDEFINED_VARIABLE;
   fireSourceChanged(ISources.WORKBENCH, ACTIVE_TOOL_NAME, value);
 }
    public SelectFileDialog(
        final Shell shell, final ToolProcess tool, final String message, final boolean newFile) {
      super(shell);

      setTitle(message);
      setMessage(message);
      fTool = tool;
      fMode =
          newFile
              ? (ResourceInputComposite.MODE_FILE | ResourceInputComposite.MODE_SAVE)
              : (ResourceInputComposite.MODE_FILE | ResourceInputComposite.MODE_OPEN);
      fHistoryId =
          "statet:" + fTool.getMainType() + ":location.commonfile"; // $NON-NLS-1$ //$NON-NLS-2$
    }
 protected void addBindings(final DatabindingSupport db) {
   final IFileStore current = fTool.getWorkspaceData().getWorkspaceDir();
   String dir = ""; // $NON-NLS-1$
   if (current != null) {
     final IPath path = URIUtil.toPath(current.toURI());
     if (path != null) {
       dir = path.toOSString();
     }
   }
   fNewLocationString = new WritableValue(dir, String.class);
   db.getContext()
       .bindValue(
           fLocationGroup.getObservable(),
           fNewLocationString,
           new UpdateValueStrategy().setAfterGetValidator(fLocationGroup.getValidator()),
           null);
 }
  @Override
  public boolean performFinish() {
    fPage.saveSettings();

    try {
      final History history = fProcess.getHistory();
      final Object file = fPage.getFile();
      final String charset = fPage.fEncoding;

      assert (history != null);
      assert (file != null);
      assert (charset != null);

      getContainer()
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException {
                  final IStatus status = history.load(file, charset, false, monitor);
                  if (status.getSeverity() == IStatus.ERROR) {
                    throw new InvocationTargetException(new CoreException(status));
                  }
                }
              });
      return true;
    } catch (final OperationCanceledException e) {
      return false;
    } catch (final Exception e) {
      if (e instanceof InvocationTargetException) {
        final Throwable cause = ((InvocationTargetException) e).getTargetException();
        if (cause instanceof CoreException) {
          StatusManager.getManager()
              .handle(((CoreException) cause).getStatus(), StatusManager.LOG | StatusManager.SHOW);
          return false;
        }
      }
      NicoUIPlugin.logError(
          NicoUIPlugin.INTERNAL_ERROR,
          "Error of unexpected type occured, when performing load history.",
          e); //$NON-NLS-1$
      return false;
    }
  }