Ejemplo n.º 1
0
 /**
  * ************************************************************************* Refresh all procedure
  * models ************************************************************************
  */
 public void refresh() {
   try {
     Logger.debug("Refresh executors table", Level.GUI, this);
     Object[] procs = ((IStructuredContentProvider) getContentProvider()).getElements(s_procMgr);
     for (Object procObj : procs) {
       if (procObj instanceof IProcedure) {
         IProcedure proc = (IProcedure) procObj;
         Logger.debug("Executor details" + proc.getProcId(), Level.GUI, this);
         Logger.debug(
             "    controlling client " + proc.getRuntimeInformation().getControllingClient(),
             Level.GUI,
             this);
         Logger.debug(
             "    monitoring clients " + proc.getRuntimeInformation().getMonitoringClients(),
             Level.GUI,
             this);
         proc.getController().updateInfo();
         refresh(proc);
       }
     }
     super.refresh();
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Ejemplo n.º 2
0
  @Override
  public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
      monitor.setTaskName("Retrieving LOG file for procedure " + m_proc.getProcName());

      IFileManager fileMgr = (IFileManager) ServiceManager.get(IFileManager.class);
      String path =
          fileMgr.getServerFilePath(m_proc.getProcId(), ServerFileType.EXECUTOR_LOG, monitor);
      Logger.debug("LOG file path: '" + path + "'", Level.PROC, this);

      logFile = (LogFile) fileMgr.getServerFile(path, ServerFileType.EXECUTOR_LOG, null, monitor);

      List<IServerFileLine> lines = logFile.getLines();

      monitor.beginTask("Exporting log data", lines.size());

      PrintWriter writer =
          new PrintWriter(new OutputStreamWriter(new FileOutputStream(m_destinationFileName)));
      for (IServerFileLine line : lines) {
        writer.println(line.toString());
        monitor.worked(1);
        if (monitor.isCanceled()) break;
      }
      writer.close();
      monitor.done();
      result = CommandResult.SUCCESS;
    } catch (Exception e) {
      Logger.error("Could retrieve LOG:" + e.getLocalizedMessage(), Level.PROC, this);
    }
    monitor.done();
  }
Ejemplo n.º 3
0
  @Override
  public void update(IProgressMonitor monitor) {
    List<String> scopes = null;
    SPELLmessage msg = new SPELLmessageGetSharedVariableScopes();
    SPELLmessage response;
    try {
      response = s_proxy.sendRequest(msg);
      if (response != null) {
        scopes = SPELLmessageGetSharedVariableScopes.getScopes(response);
      }
      if (scopes != null) {
        scopes.add(GLOBAL_SCOPE);
        // Create local model scope tables if needed
        for (String scope : scopes) {
          if (!m_tables.containsKey(scope)) {
            SharedScope table = new SharedScope(scope, s_proxy);
            m_tables.put(scope, table);
            Logger.debug("Added new scope during update: " + scope, Level.PROC, this);
          }
          if (monitor.isCanceled()) return;
        }
        // Clean local model scope tables if needed
        List<String> toRemove = new LinkedList<String>();
        for (String scope : m_tables.keySet()) {
          if (!scopes.contains(scope)) {
            toRemove.add(scope);
            Logger.debug("Remove scope during update: " + scope, Level.PROC, this);
          }
          if (monitor.isCanceled()) return;
        }
        for (String scope : toRemove) {
          m_tables.remove(scope);
          if (monitor.isCanceled()) return;
        }
      }

      // Once the set of scopes is aligned, update the tables
      for (ISharedScope table : m_tables.values()) {
        Logger.debug("Updating scope: " + table.getScopeName(), Level.PROC, this);
        table.update(monitor);
        if (monitor.isCanceled()) return;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 4
0
 /**
  * ************************************************************************* Iterate over all
  * ASRUN files for children
  * ************************************************************************
  */
 private void gatherChildAsRunFiles(AsRunFile parent, List<AsRunFile> list) {
   Logger.debug("Fetching child ASRUN files for " + parent.getProcId(), Level.PROC, this);
   for (String childFile : parent.getChildren()) {
     Logger.debug("   - Get child ASRUN file: " + childFile, Level.PROC, this);
     ExportAsRunFileJob childJob = new ExportAsRunFileJob(childFile);
     CommandHelper.executeInProgress(childJob, true, true);
     if (childJob.result.equals(CommandResult.SUCCESS)) {
       list.add(childJob.asrunFile);
       Logger.debug(
           "   - ASRUN file has children: " + childJob.asrunFile.getChildren().size(),
           Level.PROC,
           this);
       if (!childJob.asrunFile.getChildren().isEmpty()) {
         gatherChildAsRunFiles(childJob.asrunFile, list);
       }
     }
   }
 }
Ejemplo n.º 5
0
  /**
   * ************************************************************************* Center the table view
   * on the currently executed line.
   * ************************************************************************
   */
  public void showLastLine() {
    if (!m_autoScroll) return;

    int currentLine = m_procedure.getExecutionManager().getCurrentLineNo();

    Logger.debug("Show last line: " + currentLine, Level.GUI, this);

    showLine(currentLine, false);
  }
Ejemplo n.º 6
0
 /**
  * ************************************************************************* Refresh the selected
  * procedure. In case of failure, refresh the whole list, since the procedure may habe disappeared
  * ************************************************************************
  */
 public void refresh(String procId) {
   try {
     IProcedure proc = s_procMgr.getProcedure(procId);
     Logger.debug("Refreshing procedure with id " + procId, Level.GUI, this);
     Logger.debug("Executor details " + proc.getProcId(), Level.GUI, this);
     Logger.debug("    instance " + proc, Level.GUI, this);
     Logger.debug(
         "    controlling client " + proc.getRuntimeInformation().getControllingClient(),
         Level.GUI,
         this);
     Logger.debug(
         "    monitoring clients " + proc.getRuntimeInformation().getMonitoringClients(),
         Level.GUI,
         this);
     refresh(proc);
   } catch (Exception ex) {
     refresh();
   }
 }
Ejemplo n.º 7
0
 /**
  * ************************************************************************* Issue a textual
  * prompt
  *
  * @param prompt Prompt text
  * @param value Future for storing the answer
  * @param isNumeric Numeric prompt flag
  *     ************************************************************************
  */
 public void prompt(InputData promptData) {
   Logger.debug("Start prompt", Level.PROC, this);
   reset();
   prepareBlinking();
   m_promptData = promptData;
   if (m_clientMode.equals(ClientMode.MONITOR)) {
     promptAsMonitoring();
   } else {
     promptAsControlling();
   }
 }
Ejemplo n.º 8
0
 /**
  * ************************************************************************* Constructor
  * ************************************************************************
  */
 public StatusControlContribution() {
   super(ID);
   if (s_okColor == null) {
     s_cfg = (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);
     s_proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
     s_okColor = s_cfg.getStatusColor(ItemStatus.SUCCESS);
     s_warnColor = s_cfg.getStatusColor(ItemStatus.WARNING);
     s_errorColor = s_cfg.getStatusColor(ItemStatus.ERROR);
     s_boldFont = s_cfg.getFont(FontKey.GUI_BOLD);
   }
   Logger.debug("Created", Level.GUI, this);
 }
Ejemplo n.º 9
0
 /**
  * ************************************************************************* Reset the input area
  * and show the no input page
  *
  * @param resetAll If true, reset automatically all the rest of input handlers
  *     ************************************************************************
  */
 public void reset() {
   Logger.debug("Reset input area", Level.PROC, this);
   m_promptText.setText("Enter command:");
   GridData gd = (GridData) m_promptText.getLayoutData();
   gd.heightHint = SWT.DEFAULT;
   m_promptText.getVerticalBar().setVisible(false);
   m_textInput.delHint();
   m_textInput.reset();
   m_textInput.setEnabled(true);
   clearOptions();
   m_promptData = null;
   m_expected = null;
   stopBlinking();
 }
Ejemplo n.º 10
0
 public void setModel(IProcedure input) {
   Logger.debug("Set model", Level.GUI, this);
   m_input = input;
   m_renderers = new SourceRenderer[5];
   m_renderers[0] = new BpRenderer(input);
   m_renderers[1] = new LineRenderer(input);
   m_renderers[2] = new SourceRenderer(input);
   m_renderers[3] = new DataRenderer(input);
   m_renderers[4] = new StatusRenderer(input);
   for (CodeViewerColumn col : CodeViewerColumn.values()) {
     getGrid().getColumn(col.ordinal()).setCellRenderer(m_renderers[col.ordinal()]);
   }
   input.getExecutionManager().addListener(this);
   applyItemHeight();
   super.setInput(input);
   showLastLine();
 }
Ejemplo n.º 11
0
  /**
   * ************************************************************************* Handle a text command
   * ************************************************************************
   */
  private void handlePromptAnswer() {
    Logger.debug("Handle prompt answer", Level.GUI, this);

    String answer = m_textInput.getValue();
    if (answer.length() == 0 && m_selectedOption < 0) {
      MessageDialog.openError(getShell(), "Prompt error", "Cannot commit, no value given");
      m_textInput.reset();
      m_textInput.promptStart();

      return;
    }
    if (m_numericInput) {
      try {
        // Is it an int?
        Integer.parseInt(answer);
        m_promptData.setReturnValue(answer);
      } catch (NumberFormatException ex) {
        try {
          // Is it a double?
          Double.parseDouble(answer);
          m_promptData.setReturnValue(answer);
        } catch (NumberFormatException ex2) {
          try {
            // Is it a hex?
            if (answer.startsWith("0x")) {
              int a = Integer.parseInt(answer.substring(2), 16);
              m_promptData.setReturnValue(a + "");
            } else {
              throw new NumberFormatException("Hex out of range");
            }
          } catch (NumberFormatException ex3) {
            MessageDialog.openError(
                getShell(), "Prompt error", "Cannot commit, expected a numeric value");

            m_textInput.reset();
            m_textInput.promptStart();

            return;
          }
        }
      }
    } else if (m_expected != null) {
      Logger.debug("Have expected values", Level.GUI, this);
      // If the input text field has an answer
      if (!answer.isEmpty()) {
        Logger.debug("Current text field answer: '" + answer + "'", Level.GUI, this);
        // Check if there is a selected option
        if (m_selectedOption >= 0) {
          // If there is a choice, it must be consistent with the text
          // input
          String optString = m_expected.get(m_selectedOption);

          Logger.debug("Option string: '" + optString + "'", Level.GUI, this);

          if (!optString.equals(answer)) {
            MessageDialog.openError(
                getShell(),
                "Prompt error",
                "Conflicting values found between text area and buttons");

            resetOptions();

            m_textInput.reset();
            m_textInput.promptStart();

            return;
          }
        }
        // If there is no selected option, check that the text input
        // matches any of the expected values
        else {
          boolean accept = false;
          for (String opt : m_expected) {
            if (opt.equals(answer)) {
              accept = true;
              break;
            }
          }
          if (!accept) {
            String values = "";
            for (String exp : m_expected) values += exp + "\n";
            MessageDialog.openError(
                getShell(), "Prompt error", "Must enter one of the expected values:\n" + values);
            m_textInput.reset();
            m_textInput.promptStart();
            return;
          }
        }

        // If we reach this point it is ok. Set the prompt answer, but
        // getting the corresponding index of the option
        int idx = -1;
        int count = 0;
        for (String expected : m_expected) {
          if (expected.equals(answer)) {
            idx = count;
            break;
          }
          count++;
        }
        m_promptData.setReturnValue(Integer.toString(idx));
      }
      // If the text input does not have a text, at least there must be a
      // selected option in the list
      else if (m_selectedOption == -1) {
        String values = "";
        for (String exp : m_expected) values += exp + "\n";
        MessageDialog.openError(
            getShell(), "Prompt error", "Must enter one of the expected values:\n" + values);
        m_textInput.reset();
        m_textInput.promptStart();
        return;
      }
      // We have a selected option
      else {
        // Set the option index as return value
        m_promptData.setReturnValue(Integer.toString(m_selectedOption));
      }
    } else {
      m_promptData.setReturnValue(answer);
    }
    s_proxy.answerPrompt(m_promptData);
    m_parent.resetPrompt();
    m_textInput.promptEnd();
  }