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;
    }
  }
 /**
  * ************************************************************************* 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);
 }
 @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;
    }
  }
Beispiel #5
0
 /**
  * ************************************************************************* Constructor
  * ************************************************************************
  */
 public SharedDataService() {
   super(ID);
   m_tables = new TreeMap<String, ISharedScope>();
   if (s_proxy == null) {
     s_proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
   }
 }
Beispiel #6
0
  /**
   * ************************************************************************* Create the dialog
   * area contents.
   *
   * @param parent The base composite of the dialog
   * @return The resulting contents
   *     ************************************************************************
   */
  protected Control createDialogArea(Composite parent) {
    // Main composite of the dialog area -----------------------------------
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setLayout(new GridLayout(1, true));

    IConfigurationManager cfg =
        (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);

    Font codeFont = cfg.getFont(FontKey.MASTERC);
    Color bcolor = cfg.getGuiColor(GuiColorKey.CONSOLE_BG);
    Color wcolor = cfg.getGuiColor(GuiColorKey.CONSOLE_FG);

    // Create the console display
    m_display = new Text(top, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    m_display.setFont(codeFont);
    m_display.setBackground(bcolor);
    m_display.setForeground(wcolor);
    GridData ddata = new GridData(GridData.FILL_BOTH);
    ddata.minimumHeight = 200;
    m_display.setLayoutData(ddata);
    m_display.setText("");
    m_display.setEditable(false);

    // Create the input field
    m_prompt = new PromptField(top, "");
    m_prompt.getContents().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    m_prompt.getContents().addKeyListener(this);

    m_prompt.getContents().setFocus();

    return parent;
  }
 public LogFileLabelProvider() {
   IConfigurationManager cfg =
       (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);
   m_warningColor = cfg.getStatusColor(ItemStatus.WARNING);
   m_errorColor = cfg.getStatusColor(ItemStatus.ERROR);
   m_font = cfg.getFont(FontKey.MASTERC);
 }
  @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();
  }
 @Override
 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
   try {
     result = CommandResult.SUCCESS;
     if (m_scope == null && m_variables == null) {
       monitor.setTaskName("Clearing all variables and scopes");
       ISharedDataService svc = (ISharedDataService) ServiceManager.get(ISharedDataService.class);
       for (String scope : svc.getSharedScopes()) {
         svc.removeSharedScope(scope);
       }
       svc.getSharedScope(ISharedDataService.GLOBAL_SCOPE).clear();
     } else if (m_variables != null) {
       monitor.beginTask(
           "Clearing variables in scope " + m_scope.getScopeName(), m_variables.size());
       for (SharedVariable var : m_variables) {
         monitor.subTask("Removing variable " + var.name);
         m_scope.clear(var.name);
         monitor.worked(1);
         if (monitor.isCanceled()) return;
       }
     } else {
       monitor.setTaskName("Clearing variables in scope " + m_scope.getScopeName());
       m_scope.clear();
     }
     monitor.done();
   } catch (Exception ex) {
     ex.printStackTrace();
     message = ex.getLocalizedMessage();
     result = CommandResult.FAILED;
   }
 }
Beispiel #10
0
 /**
  * ************************************************************************* Constructor
  *
  * @param shell The parent shell
  *     ************************************************************************
  */
 public MasterShellDialog(Shell shell) {
   super(shell);
   if (s_smgr == null) {
     s_smgr = (IShellManager) ServiceManager.get(IShellManager.class);
   }
   // Try to load the shell plugin if available
   if (s_smgr.haveShell()) {
     s_smgr.addShellListener(this);
   }
   // Obtain the image for the dialog icon
   ImageDescriptor descr = Activator.getImageDescriptor("icons/dlg_exec.png");
   m_image = descr.createImage();
 }
Beispiel #11
0
 /**
  * ************************************************************************* Constructor.
  *
  * @param procId The procedure identifier
  * @param parent The parent composite
  *     ************************************************************************
  */
 public RecoveryTable(RecoveryComposite parent) {
   super(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
   if (s_proxy == null) {
     s_proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
   }
   getTable().addSelectionListener(parent);
   getTable().setHeaderVisible(true);
   getTable().setLinesVisible(true);
   createColumns();
   m_contentProvider = new RecoveryFilesContentProvider();
   setContentProvider(m_contentProvider);
   setLabelProvider(new RecoveryFilesLabelProvider());
   setInput(s_proxy);
 }
 /**
  * ************************************************************************* Constructor.
  *
  * @param procId The procedure identifier
  * @param parent The parent composite
  *     ************************************************************************
  */
 public CurrentExecutorsTable(ExecutorComposite parent) {
   super(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
   if (s_procMgr == null) {
     s_procMgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class);
   }
   getTable().addSelectionListener(parent);
   getTable().setHeaderVisible(true);
   getTable().setLinesVisible(true);
   createColumns();
   setContentProvider(new CurrentExecutorsContentProvider());
   setLabelProvider(new CurrentExecutorsLabelProvider());
   setInput(s_procMgr);
   addDoubleClickListener(this);
 }
  /**
   * ************************************************************************* Execute the command
   * ************************************************************************
   */
  @Override
  public void execute(Vector<String> args) throws CommandFailed {
    try {
      m_args = args;
      IServerProxy proxy = (IServerProxy) ServiceManager.get(IServerProxy.class);
      IContextProxy cproxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
      if (!proxy.isConnected()) {
        throw new CommandFailed("Not connected to a server");
      }
      if (!cproxy.isConnected()) {
        throw new CommandFailed("Not attached to a context");
      }
      display(
          "Detaching from context at server " + proxy.getCurrentServer().getName(), Severity.INFO);
      proxy.detachContext();

      display("Detached.");
    } catch (CommandFailed ex) {
      throw ex;
    } catch (Exception ex) {
      throw new CommandFailed(ex.getLocalizedMessage());
    }
  }
Beispiel #14
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;
  }
Beispiel #15
0
 /*
  * Static block to retrieve the context proxy
  */
 static {
   s_proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
 }
Beispiel #16
0
  /**
   * ************************************************************************* Constructor
   *
   * @param view The parent procedure view
   * @param top The dictionary composite
   *     ************************************************************************
   */
  public InputArea(ControlArea area, IProcedure model) {
    super(area, SWT.NONE);
    m_parent = area;
    m_promptData = null;
    m_expected = null;
    m_clientMode = null;
    m_model = model;

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.marginBottom = 5;
    layout.numColumns = 1;
    setLayout(layout);

    setLayoutData(new GridData(GridData.FILL_BOTH));

    m_promptText = new Text(this, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    m_promptText.setText("Enter command");
    m_promptText.getVerticalBar().setVisible(false);
    GridData tpData = new GridData(GridData.FILL_HORIZONTAL);
    m_promptText.setLayoutData(tpData);
    m_promptText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    if (s_cfg == null) {
      s_cfg = (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);
      s_proxy = (IContextProxy) ServiceManager.get(IContextProxy.class);
    }

    Composite inputGroup = new Composite(this, SWT.NONE);
    GridLayout ig_layout = new GridLayout(4, false);
    ig_layout.marginHeight = 0;
    ig_layout.marginTop = 0;
    ig_layout.marginBottom = 5;
    ig_layout.marginWidth = 0;
    ig_layout.marginLeft = 3;
    ig_layout.marginRight = 3;
    ig_layout.horizontalSpacing = 8;
    inputGroup.setLayout(ig_layout);
    inputGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    m_textInput = new PromptField(inputGroup, "", this);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    m_textInput.getContents().setLayoutData(gd);

    m_commitButton = new Button(inputGroup, SWT.PUSH);
    m_commitButton.addSelectionListener(this);
    m_commitButton.setText(BTN_COMMIT);
    m_commitButton.setData("ID", BTN_COMMIT_ID);
    m_resetButton = new Button(inputGroup, SWT.PUSH);
    m_resetButton.addSelectionListener(this);
    m_resetButton.setText(BTN_RESET);
    m_resetButton.setData("ID", BTN_RESET_ID);

    m_commitButton.setEnabled(false);
    m_resetButton.setEnabled(false);

    m_optionsRadio = new ArrayList<Button>();
    m_optionsCombo = null;
    m_selectedOption = -1;
    m_optionScroll = null;

    m_blinker = null;
    m_blinkerLauncher = null;
    m_blinkSwitch = true;

    m_fontSize = s_cfg.getFont(FontKey.TEXT).getFontData()[0].getHeight();
    updateFontFromSize();

    // Set tab order
    Control[] tabOrder = {inputGroup};
    this.setTabList(tabOrder);
  }
Beispiel #17
0
  /**
   * ************************************************************************* Constructor.
   *
   * @param procId The procedure identifier
   * @param parent The parent composite
   *     ************************************************************************
   */
  public CodeViewer(Composite parent, IProcedure model) {
    super(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    if (s_cfg == null) {
      s_cfg = (IConfigurationManager) ServiceManager.get(IConfigurationManager.class);
    }

    m_procedure = model;

    m_autoScroll = true;
    getGrid().setHeaderVisible(true);
    getGrid().setLinesVisible(false);

    createColumns();

    final CodeViewer theViewer = this;
    getGrid()
        .addKeyListener(
            new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                if ((e.stateMask & SWT.CONTROL) > 0) {
                  if (e.keyCode == 99) // C
                  {
                    copySelected();
                    getGrid().deselectAll();
                  } else if (e.keyCode == 102) // F
                  {
                    getGrid().deselectAll();
                    SearchDialog dialog = new SearchDialog(getGrid().getShell(), theViewer);
                    dialog.open();
                  }
                }
              }
            });

    getGrid()
        .getColumn(CodeViewerColumn.BREAKPOINT.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.LINE_NO.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.CODE.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid()
        .getColumn(CodeViewerColumn.DATA.ordinal())
        .addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.RESULT));
    getGrid().addControlListener(new ColumnSizer(getGrid(), CodeViewerColumn.CODE));

    /*
     * Popup menu manager
     */
    new CodeViewerMenuManager(this, m_procedure);

    m_search = new CodeSearch(this);

    s_cfg.addPropertyChangeListener(this);

    getGrid()
        .addDisposeListener(
            new DisposeListener() {
              @Override
              public void widgetDisposed(DisposeEvent e) {
                dispose();
              }
            });
  }