@Override
 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
   /*
    * Set the viewer
    */
   m_viewer = (TreeViewer) v;
   /*
    * Update the input
    */
   m_input = null;
   if (newInput != null) {
     IProcedure proc = (IProcedure) newInput;
     /*
      * Set procId
      */
     m_procId = proc.getProcId();
     /*
      * Set the input
      */
     m_input = new CallstackProcedureModel(m_procId, proc);
     /*
      * Subscribe to events
      */
     if (oldInput == null) {
       ProcedureBridge.get().addProcedureStackListener(this);
       ProcedureBridge.get().addProcedureStatusListener(this);
     }
   }
 }
 /**
  * ************************************************************************* 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();
   }
 }
  @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();
  }
Exemple #4
0
 /**
  * ************************************************************************* Constructor
  * ************************************************************************
  */
 public RemoteProcedure(IProcedure wasLocalProcedure) {
   m_procId = wasLocalProcedure.getProcId();
   m_properties = new HashMap<ProcProperties, String>();
   for (ProcProperties prop : ProcProperties.values()) {
     m_properties.put(prop, wasLocalProcedure.getProperty(prop));
   }
   m_controller = new RemoteController();
   ClientMode cmode = wasLocalProcedure.getRuntimeInformation().getClientMode();
   m_executionInformation = new ExecutionInformationHandler(cmode, this);
   IExecutorInfo info = (IExecutorInfo) wasLocalProcedure.getAdapter(ExecutorInfo.class);
   m_properties.put(ProcProperties.PROC_NAME, info.getName());
   m_executionInformation.copyFrom(info);
 }
  /**
   * ************************************************************************* 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;
    }
  }
  @Override
  public void notifyStack(IProcedure model, StackNotification data) {
    // We want to keep all models updated
    String instanceId = model.getProcId();
    // There may be stack notifications coming before having a model
    // actually created
    if (!m_procId.equals(instanceId)) {
      return;
    }

    CallstackNode currentNode = m_input.getCurrentNode();
    CallstackNode newNode = m_input.notifyStack(model, data);

    switch (data.getStackType()) {
      case CALL:
        m_viewer.add(currentNode, newNode);
        m_viewer.expandToLevel(newNode, TreeViewer.ALL_LEVELS);
        break;
      case RETURN:
        m_viewer.collapseToLevel(currentNode, TreeViewer.ALL_LEVELS);
        m_viewer.update(new Object[] {currentNode, newNode}, null);
        break;
      case LINE:
        m_viewer.refresh(newNode, true);
        break;
    }
  }
Exemple #7
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    /*
     * Retrieve data
     */
    String procId = event.getParameter(ARG_PROCID);
    /*
     * Retrieve the procedure
     */
    IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class);
    IProcedure proc = mgr.getProcedure(procId);

    proc.getController().recover();

    return CommandResult.SUCCESS;
  }
Exemple #8
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);
  }
 /**
  * ************************************************************************* 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();
   }
 }
Exemple #10
0
  /**
   * ************************************************************************* Prepare the blinking
   * *************************************************************************
   */
  private void prepareBlinking() {
    m_blinkSwitch = true;
    long msec = 10000;

    try {
      msec = m_model.getRuntimeInformation().getPromptWarningDelay() * 1000;
    } catch (NumberFormatException ex) {
      ex.printStackTrace();
    }

    m_blinkerLauncher = new PromptBlinkerLauncher(this, msec);
  }
Exemple #11
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();
 }
  @Override
  public void notifyStatus(IProcedure model, StatusNotification data) {
    // We want to keep all models updated
    String instanceId = model.getProcId();
    // There may be stack notifications coming before having a model
    // actually created
    if (!m_procId.equals(instanceId)) {
      return;
    }

    switch (data.getStatus()) {
      case RELOADING:
        m_input.clear();
        m_viewer.refresh(true);
        break;
      default:
        break;
    }
  }
Exemple #13
0
  public void forceRefresh() {
    GridVisibleRange range = getGrid().getVisibleRange();

    int visibleCount = range.getItems().length;

    GridItem first = range.getItems()[0];
    GridItem last = range.getItems()[visibleCount - 1];
    int firstIndex = getGrid().getIndexOfItem(first);
    int lastIndex = getGrid().getIndexOfItem(last);

    for (int index = firstIndex; index < lastIndex; index++) {
      ICodeLine line = m_input.getExecutionManager().getLine(index);
      if (line.hasNotifications()) {
        line.calculateSummary();
      }
      update(line, null);
    }
    showLastLine();
  }
Exemple #14
0
 /**
  * ************************************************************************* Dispose resources
  * ************************************************************************
  */
 public void dispose() {
   m_input.getExecutionManager().removeListener(this);
   s_cfg.removePropertyChangeListener(this);
 }