Exemplo n.º 1
0
  public void step_Event() {

    System.out.println("Step");
    ISourceProviderService service =
        (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    DebugToolsCommandSourceProvider sourceProvider =
        (DebugToolsCommandSourceProvider)
            service.getSourceProvider(DebugToolsCommandSourceProvider.PLAY_COMMAND_STATE);

    sourceProvider.setPlayState(true);
    sourceProvider.setStopState(true);
    sourceProvider.setPauseState(false);
    sourceProvider.setStepState(true);

    setNonActiveNode(currentActiveNode, ANIMATION_DELAY);
    try {
      currentActiveNode =
          simulator.executeAndReturnNextNode(currentActiveNode, ZestDebuggerView.this);

      if (currentActiveNode == null) {
        if (simulator.isEmpty()) {
          if (MessageDialog.openQuestion(
              ZestDebuggerView.this.getSite().getShell(),
              "Finish",
              "The execution is finished. Do you want to save the animation into .btt (trace file) ?")) {
            FileDialog fd = new FileDialog(ZestDebuggerView.this.getSite().getShell(), SWT.SAVE);
            fd.setText("Save");
            fd.setFilterPath("C:/");
            String[] filterExt = {"*.btt", "*.*"};
            fd.setFilterExtensions(filterExt);
            String selected = fd.open();
            System.out.println(selected);

            if (selected != null) {
              if (simulator.saveTraceToFile(selected))
                MessageDialog.openInformation(
                    ZestDebuggerView.this.getSite().getShell(),
                    "Success",
                    "The BT Trace has been saved successfully");
              else
                MessageDialog.openError(
                    ZestDebuggerView.this.getSite().getShell(),
                    "Failure",
                    "The BT Trace can't be saved");
            }
          }
          finish = true;
        } else {
          System.out.println("ANEH : ");
          System.out.println(currentActiveNode);
        }
      }

      if (currentActiveNode != null) {
        setToCenter(currentActiveNode, ANIMATION_DELAY);
        setActiveNode(currentActiveNode, ANIMATION_DELAY);
        ArrayList<BTNode> interleaveNodes = simulator.getInterleaveNodes(currentActiveNode);
        setInterleaveNodes(interleaveNodes, ANIMATION_DELAY);
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageDialog.openError(
          ZestDebuggerView.this.getSite().getShell(), "Failure", e.getMessage());
      error = true;
    }
    if (error) {

      sourceProvider.setPlayState(false);
      sourceProvider.setStopState(true);
      sourceProvider.setPauseState(false);
      sourceProvider.setStepState(false);
      return;
    }
    if (finish) {
      sourceProvider.setPlayState(true);
      sourceProvider.setStopState(false);
      sourceProvider.setPauseState(false);
      sourceProvider.setStepState(false);
    }
    //
    //		setNonActiveNode(this.currentActiveNode, 400);
    //		this.currentActiveNode = this.simulator.executeAndReturnNextNode(this.currentActiveNode,
    // this);
    //		setToCenter(currentActiveNode, 400);
    //		setActiveNode(currentActiveNode, 400);
  }