Beispiel #1
0
  /**
   * ************************************************************************* The command has been
   * executed, so extract extract the needed information from the application context.
   * ************************************************************************
   */
  public CommandResult execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    IServerProxy proxy = (IServerProxy) ServiceManager.get(IServerProxy.class);
    ServerRole role = proxy.getCurrentServer().getRole();
    if (role != ServerRole.COMMANDING) {
      MessageDialog.openError(
          window.getShell(),
          "Cannot open",
          "Cannot schedule procedures on the current server,\n" + "the role is monitoring");
      return CommandResult.NO_EFFECT;
    }

    IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
    String procId =
        (String) runtime.getRuntimeProperty(RuntimeProperty.ID_NAVIGATION_VIEW_SELECTION);
    if (procId != null) {
      ConditionDialog dlg = new ConditionDialog(window.getShell());
      dlg.open();
      String condition = dlg.getCondition();
      if (condition != null) {
        ScheduleProcedureJob job = new ScheduleProcedureJob(procId, condition);
        CommandHelper.executeInProgress(job, true, true);
        if (job.result != CommandResult.SUCCESS) {
          MessageDialog.openError(window.getShell(), "Schedule error", job.message);
        }
        return job.result;
      } else {
        return CommandResult.NO_EFFECT;
      }
    } else {
      return CommandResult.NO_EFFECT;
    }
  }
 @Override
 public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
   boolean result = false;
   IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
   if (s_proc == null) {
     s_proc = (IProcedureManager) ServiceManager.get(IProcedureManager.class);
   }
   String procId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION);
   if ((procId != null) && (procId.length() > 0) && (s_proc.isLocallyLoaded(procId))) {
     result = true;
   }
   return result;
 }
  /**
   * ************************************************************************* The command has been
   * executed, so extract extract the needed information from the application context.
   * ************************************************************************
   */
  public CommandResult execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class);
    String instanceId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION);

    try {
      IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class);
      IProcedure proc = null;
      if (mgr.isLocallyLoaded(instanceId)) {
        proc = mgr.getProcedure(instanceId);
      } else {
        proc = mgr.getRemoteProcedure(instanceId);
      }

      List<AsRunFile> toExport = new LinkedList<AsRunFile>();

      ExportAsRunFileJob job = new ExportAsRunFileJob(proc);
      CommandHelper.executeInProgress(job, true, true);

      if (job.result.equals(CommandResult.SUCCESS)) {
        toExport.add(job.asrunFile);
        if (!job.asrunFile.getChildren().isEmpty()) {
          boolean alsoChildren =
              MessageDialog.openQuestion(
                  window.getShell(),
                  "Export children ASRUN files",
                  "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?");
          if (alsoChildren) {
            gatherChildAsRunFiles(job.asrunFile, toExport);
          }
        }
      }

      DirectoryDialog dialog = new DirectoryDialog(window.getShell(), SWT.SAVE);
      dialog.setMessage(
          "Select directory to export ASRUN file(s) for '" + proc.getProcName() + "'");
      dialog.setText("Export ASRUN");
      String destination = dialog.open();
      if (destination != null && !destination.isEmpty()) {
        SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport);
        CommandHelper.executeInProgress(saveJob, true, true);
        return saveJob.result;
      } else {
        return CommandResult.NO_EFFECT;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      return CommandResult.FAILED;
    }
  }