Пример #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();
   }
 }
Пример #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();
  }
Пример #3
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
  * IApplicationContext)
  */
 public Object start(IApplicationContext context) throws Exception {
   Display display = PlatformUI.createDisplay();
   try {
     Logger.info("Application starting", Level.MAIN, this);
     int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
     Logger.info("Workbench exited with code " + returnCode, Level.MAIN, this);
     if (returnCode == PlatformUI.RETURN_RESTART) return IApplication.EXIT_RESTART;
     else return IApplication.EXIT_OK;
   } finally {
     display.dispose();
   }
 }
Пример #4
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();
    }
  }
Пример #5
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);
       }
     }
   }
 }
Пример #6
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);
  }
Пример #7
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();
   }
 }
Пример #8
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();
   }
 }
 /**
  * ************************************************************************* 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);
 }
Пример #10
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();
 }
Пример #11
0
  /**
   * ************************************************************************* Setup combo options
   * ************************************************************************
   */
  private boolean setupComboOptions(
      Vector<String> options, Vector<String> expectedValues, String defaultOption) {
    boolean defaultOptionSet = false;

    m_optionsCombo = new Combo(m_optionContainer, SWT.DROP_DOWN | SWT.READ_ONLY);
    m_optionsCombo.setData("IDs", expectedValues);
    m_optionsCombo.addKeyListener(this);
    m_optionsCombo.addSelectionListener(this);

    String s = ""; // expected value

    for (String option : options) {
      try {
        s = option.substring(option.indexOf(KEY_SEPARATOR) + 1, option.length());
        m_optionsCombo.add(s);

      } catch (Exception ex) {
        ex.printStackTrace();
        Logger.error(
            "Error processing combo options: " + ex.getLocalizedMessage(), Level.GUI, this);
        m_optionsCombo.add("???");
      }
    } // for
    try {
      if (!defaultOption.isEmpty()) {
        int idx = expectedValues.indexOf(defaultOption);
        m_optionsCombo.select(idx);
        defaultOptionSet = true;
        m_selectedOption = idx;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      Logger.error(
          "Error processing default combo option: " + ex.getLocalizedMessage(), Level.GUI, this);
    }
    return defaultOptionSet;
  }
Пример #12
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();
 }
Пример #13
0
 /**
  * *************************************************************************
  *
  * <p>************************************************************************
  */
 @Override
 public void removeSharedScope(String scope) {
   if (scope.equals(GLOBAL_SCOPE)) return;
   if (m_tables.containsKey(scope)) {
     SPELLmessage msg = new SPELLmessageRemoveSharedVariableScope(s_proxy.getClientKey(), scope);
     SPELLmessage response;
     try {
       response = s_proxy.sendRequest(msg);
       if (response != null) {
         if (SPELLmessageRemoveSharedVariableScope.isSuccess(response)) {
           Logger.info("Remove shared scope " + scope, Level.PROC, this);
           m_tables.remove(scope);
         }
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
Пример #14
0
  /**
   * ************************************************************************* Setup radio options
   * ************************************************************************
   */
  private boolean setupRadioOptions(
      Vector<String> options, Vector<String> expectedValues, String defaultOption) {
    int count = 0;
    boolean defaultOptionSet = false;
    for (String option : options) {
      try {
        String expected = "";
        if (expectedValues.size() > count) {
          expected = expectedValues.elementAt(count);
        }

        Button b = new Button(m_optionContainer, SWT.RADIO);
        b.setFont(m_myFont);
        String value = option.substring(option.indexOf(KEY_SEPARATOR) + 1, option.length());
        // Take into account the LIST|ALPHA case. When keys are the same
        // as values,
        // we do not want to display it twice.
        if (!expected.isEmpty() && !expected.equals(value)) {
          b.setText(expected + " : " + value);
        } else {
          b.setText(value);
        }

        if (!defaultOption.isEmpty() && (expected.equals(defaultOption))) {
          b.setSelection(true);
          defaultOptionSet = true;
          m_selectedOption = count;
        } else {
          b.setSelection(false);
        }
        b.setData("ID", count);
        b.addKeyListener(this);
        b.addSelectionListener(this);
        m_optionsRadio.add(b);
      } catch (Exception ex) {
        ex.printStackTrace();
        Logger.error(
            "Error processing prompt radio options: " + ex.getLocalizedMessage(), Level.GUI, this);
      }
      count++;
    }
    return defaultOptionSet;
  }
Пример #15
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();
  }