Пример #1
1
  @SuppressWarnings("deprecation")
  public void stop_Event() {
    System.out.println("Stop");
    stop = true;
    pause = true;
    if (playThreadAnimation != null
        && (playThreadAnimation.isAlive() || playThreadAnimation.isDaemon()))
      playThreadAnimation.stop();
    ISourceProviderService service =
        (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    DebugToolsCommandSourceProvider sourceProvider =
        (DebugToolsCommandSourceProvider)
            service.getSourceProvider(DebugToolsCommandSourceProvider.PLAY_COMMAND_STATE);

    sourceProvider.setPlayState(true);
    sourceProvider.setStopState(false);
    sourceProvider.setPauseState(false);
    sourceProvider.setStepState(false);
    IWorkbenchPage page = getSite().getPage();
    System.out.println("page:" + page);
    if (page != null) {
      IPerspectiveDescriptor perspective = page.getPerspective();
      if (perspective != null) {
        page.closePerspective(perspective, false, true);
      }
    }
  }
Пример #2
0
  private void activateHandler() {
    ISourceProviderService service =
        (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    DebugToolsCommandSourceProvider sourceProvider =
        (DebugToolsCommandSourceProvider)
            service.getSourceProvider(DebugToolsCommandSourceProvider.PLAY_COMMAND_STATE);

    sourceProvider.setPlayState(true);
    sourceProvider.setStopState(false);
    sourceProvider.setPauseState(false);
    sourceProvider.setStepState(false);
  }
Пример #3
0
  public void pause_Event() {
    System.out.println("Pause");
    pause = true;

    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);
  }
Пример #4
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);
  }
Пример #5
0
  public void play_Event() {
    pause = false;
    stop = false;
    System.out.println("Play");
    ISourceProviderService service =
        (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    DebugToolsCommandSourceProvider sourceProvider =
        (DebugToolsCommandSourceProvider)
            service.getSourceProvider(DebugToolsCommandSourceProvider.PLAY_COMMAND_STATE);

    sourceProvider.setPlayState(false);
    sourceProvider.setStopState(true);
    sourceProvider.setPauseState(true);
    sourceProvider.setStepState(true);
    if (this.currentActiveNode == null) {
      this.currentActiveNode = this.simulator.startExecute(this);
      this.startNode = currentActiveNode;

      setToCenter(currentActiveNode, ANIMATION_DELAY);
      setActiveNode(currentActiveNode, ANIMATION_DELAY);
    }
    if (playThreadAnimation == null || !playThreadAnimation.isAlive()) {

      playThreadAnimation =
          new Thread(
              new Runnable() {

                @Override
                public void run() {
                  while (!pause && !error) {
                    try {
                      Thread.sleep(EXECUTION_DELAY);
                    } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                    }

                    Display.getDefault()
                        .syncExec(
                            new Runnable() {

                              @Override
                              public void run() {
                                try {
                                  if (currentActiveNode.isBreakPointed()) {
                                    pause_Event();
                                    return;
                                  }

                                  setNonActiveNode(currentActiveNode, ANIMATION_DELAY);
                                  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 (finish || error) {
                      Display.getDefault()
                          .asyncExec(
                              new Runnable() {

                                @Override
                                public void run() {
                                  stop_Event();
                                }
                              });

                      break;
                    }
                  }
                }
              });
      playThreadAnimation.start();
    }
  }