Beispiel #1
0
  public void setInput(BTSimulator simulator) {
    this.simulator = simulator;
    this.tree = simulator.getBtTree();
    this.graph = this.viewer.getGraphControl();
    this.graph.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseUp(MouseEvent e) {
            if (!pause) return;
            Object selected = ((Graph) e.widget).getSelection().get(0);
            if (selected instanceof BTGraphNode) {
              BTNode selectedNode = mapGraphToData.get(selected);
              IBTNodeFigure fig = (IBTNodeFigure) ((BTGraphNode) selected).getFigure();
              if (selectedNode.isBreakPointed()) {
                System.out.println("Black");
                ((IBTNodeFigure) fig).setBorderColor(ColorConstants.black);
              } else {
                System.out.println("Red");
                ((IBTNodeFigure) fig).setBorderColor(ColorConstants.red);
              }
              selectedNode.setBreakPointed(!selectedNode.isBreakPointed());

              //					}else if(fig instanceof BTNodeFigureWithRelations) {
              //						if(selectedNode.isBreakPointed())
              //							((BTNodeFigureWithRelations)fig).setBorderColor(ColorConstants.black);
              //						else
              //							((BTNodeFigureWithRelations)fig).setBorderColor(ColorConstants.red);
              //						selectedNode.setBreakPointed(!selectedNode.isBreakPointed());
              //					}else if()
            }
          }

          @Override
          public void mouseDown(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            // TODO Auto-generated method stub

          }
        });
    /*this.graph.addSelectionListener(new SelectionListener() {

    	@Override
    	public void widgetSelected(SelectionEvent e) {

    		Object selected = ((Graph)e.widget).getSelection().get(0);
    		if(selected instanceof BTGraphNode) {
    			BTNode selectedNode = mapGraphToData.get(selected);
    			IFigure fig = ((BTGraphNode)selected).getFigure();
    			if(fig instanceof BTNodeFigure) {
    				if(selectedNode.isBreakPointed())
    					((BTNodeFigure)fig).setBorderColor(ColorConstants.black);
    				else
    					((BTNodeFigure)fig).setBorderColor(ColorConstants.red);
    				selectedNode.setBreakPointed(!selectedNode.isBreakPointed());
    			}else if(fig instanceof BTNodeFigureWithRelations) {
    				if(selectedNode.isBreakPointed())
    					((BTNodeFigureWithRelations)fig).setBorderColor(ColorConstants.black);
    				else
    					((BTNodeFigureWithRelations)fig).setBorderColor(ColorConstants.red);
    				selectedNode.setBreakPointed(!selectedNode.isBreakPointed());
    			}
    		}


    	}

    	@Override
    	public void widgetDefaultSelected(SelectionEvent e) {

    	}
    });*/
    // clear the nodes and connection
    clearGraph(this.graph);

    this.setMapDataAndGraph(ZestDebuggerView.buildGraphNodeAndTree(this.tree, this.graph));

    this.viewer.setLayoutAlgorithm(setLayout());
    this.viewer.applyLayout();
  }
Beispiel #2
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);
  }