Package org.xtext.tortoiseshell.lib

Examples of org.xtext.tortoiseshell.lib.Tortoise


            _and = _not;
          }
          if (_and) {
            boolean _xblockexpression = false;
            {
              final Tortoise tortoise = new Tortoise();
              tortoise.addListener(TortoiseView.this);
              IResourceServiceProvider _resourceServiceProvider = it.getResourceServiceProvider();
              final ITortoiseInterpreter interpreter = _resourceServiceProvider.<ITortoiseInterpreter>get(ITortoiseInterpreter.class);
              boolean _and_1 = false;
              boolean _notEquals_1 = (!Objects.equal(interpreter, null));
              if (!_notEquals_1) {
                _and_1 = false;
              } else {
                EList<EObject> _contents = it.getContents();
                boolean _isEmpty = _contents.isEmpty();
                boolean _not_1 = (!_isEmpty);
                _and_1 = _not_1;
              }
              if (_and_1) {
                try {
                  EList<EObject> _contents_1 = it.getContents();
                  EObject _get = _contents_1.get(0);
                  interpreter.run(tortoise, _get, stopAtLine);
                } catch (final Throwable _t) {
                  if (_t instanceof Exception) {
                    final Exception e = (Exception)_t;
                    IWorkbenchPartSite _site = TortoiseView.this.getSite();
                    Shell _shell = _site.getShell();
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append("Error during execution:");
                    _builder.newLine();
                    _builder.append("  ");
                    String _message = e.getMessage();
                    _builder.append(_message, "  ");
                    _builder.newLineIfNotEmpty();
                    _builder.append("See log for details");
                    MessageDialog.openError(_shell, "Error during Execution", _builder.toString());
                    TortoiseView.LOGGER.error("Error executing TortoiseScript", e);
                  } else {
                    throw Exceptions.sneakyThrow(_t);
                  }
                }
              }
              _xblockexpression = tortoise.removeListener(TortoiseView.this);
            }
            _xifexpression = _xblockexpression;
          }
          return Boolean.valueOf(_xifexpression);
        }
View Full Code Here


  public void handleTortoiseEvent(final ITortoiseEvent event) {
    boolean _matched = false;
    if (!_matched) {
      if (event instanceof MoveEvent) {
        _matched=true;
        Tortoise _tortoise = ((MoveEvent)event).getTortoise();
        boolean _isPaint = _tortoise.isPaint();
        if (_isPaint) {
          final Polyline line = new Polyline();
          Tortoise _tortoise_1 = ((MoveEvent)event).getTortoise();
          Color _lineColor = _tortoise_1.getLineColor();
          line.setForegroundColor(_lineColor);
          Tortoise _tortoise_2 = ((MoveEvent)event).getTortoise();
          int _lineWidth = _tortoise_2.getLineWidth();
          line.setLineWidth(_lineWidth);
          Point _oldPosition = ((MoveEvent)event).getOldPosition();
          Point _oldPosition_1 = ((MoveEvent)event).getOldPosition();
          line.setEndpoints(_oldPosition, _oldPosition_1);
          Point _oldPosition_2 = ((MoveEvent)event).getOldPosition();
          Tortoise _tortoise_3 = ((MoveEvent)event).getTortoise();
          Point _position = _tortoise_3.getPosition();
          Tortoise _tortoise_4 = ((MoveEvent)event).getTortoise();
          int _delay = _tortoise_4.getDelay();
          Animation _animation = new Animation(_oldPosition_2, _position, line, _delay);
          this.animator.addAnimation(_animation);
        } else {
          Point _oldPosition_3 = ((MoveEvent)event).getOldPosition();
          Tortoise _tortoise_5 = ((MoveEvent)event).getTortoise();
          Point _position_1 = _tortoise_5.getPosition();
          Tortoise _tortoise_6 = ((MoveEvent)event).getTortoise();
          int _delay_1 = _tortoise_6.getDelay();
          Animation _animation_1 = new Animation(_oldPosition_3, _position_1, _delay_1);
          this.animator.addAnimation(_animation_1);
        }
      }
    }
    if (!_matched) {
      if (event instanceof TurnEvent) {
        _matched=true;
        double _oldAngle = ((TurnEvent)event).getOldAngle();
        Tortoise _tortoise = ((TurnEvent)event).getTortoise();
        double _angleInRadians = _tortoise.getAngleInRadians();
        Tortoise _tortoise_1 = ((TurnEvent)event).getTortoise();
        int _delay = _tortoise_1.getDelay();
        Animation _animation = new Animation(_oldAngle, _angleInRadians, _delay);
        this.animator.addAnimation(_animation);
      }
    }
  }
View Full Code Here

  @Extension
  private ParseHelper<Program> _parseHelper;
 
  @Test
  public void testTortoiseDefaults() {
    Tortoise _tortoise = new Tortoise();
    final Procedure1<Tortoise> _function = new Procedure1<Tortoise>() {
      public void apply(final Tortoise it) {
        boolean _isPaint = it.isPaint();
        Assert.assertTrue(_isPaint);
        double _angle = it.getAngle();
View Full Code Here

  }
 
  @Test
  public void testTortoisProgram() {
    try {
      Tortoise _tortoise = new Tortoise();
      final Procedure1<Tortoise> _function = new Procedure1<Tortoise>() {
        public void apply(final Tortoise it) {
          boolean _isPaint = it.isPaint();
          Assert.assertTrue(_isPaint);
          double _angle = it.getAngle();
          Assert.assertEquals(0.0, _angle, 0.0);
          Point _point = new Point(0, 0);
          Point _position = it.getPosition();
          Assert.assertEquals(_point, _position);
          int _delay = it.getDelay();
          Assert.assertEquals(200, _delay);
          Color _lineColor = it.getLineColor();
          Assert.assertEquals(ColorConstants.black, _lineColor);
          int _lineWidth = it.getLineWidth();
          Assert.assertEquals(1, _lineWidth);
        }
      };
      final Tortoise tortoise = ObjectExtensions.<Tortoise>operator_doubleArrow(_tortoise, _function);
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("begin");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("delay = 1");
View Full Code Here

  }
 
  @Test
  public void testSubProgram() {
    try {
      final Tortoise tortoise = new Tortoise();
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("begin");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("delay = 0");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("val angle = 20");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("for(i: (0..360).withStep(angle)) {");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("turnAndGo(10, angle)");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("end");
      _builder.newLine();
      _builder.newLine();
      _builder.append("sub turnAndGo");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("int dist");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("int angle");
      _builder.newLine();
      _builder.append("begin");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("forward(dist) ");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("turnLeft(angle)");
      _builder.newLine();
      _builder.append("end");
      _builder.newLine();
      final Program program = this._parseHelper.parse(_builder);
      final ArrayList<MoveEvent> moveEvents = CollectionLiterals.<MoveEvent>newArrayList();
      final ArrayList<TurnEvent> turnEvents = CollectionLiterals.<TurnEvent>newArrayList();
      final ITortoiseEvent.Listener _function = new ITortoiseEvent.Listener() {
        public void handleTortoiseEvent(final ITortoiseEvent it) {
          boolean _matched = false;
          if (!_matched) {
            if (it instanceof MoveEvent) {
              _matched=true;
              moveEvents.add(((MoveEvent)it));
            }
          }
          if (!_matched) {
            if (it instanceof TurnEvent) {
              _matched=true;
              turnEvents.add(((TurnEvent)it));
            }
          }
        }
      };
      tortoise.addListener(_function);
      this._tortoiseShellInterpeter.run(tortoise, program, (-10));
      int _size = moveEvents.size();
      Assert.assertEquals(19, _size);
      int _size_1 = turnEvents.size();
      Assert.assertEquals(19, _size_1);
View Full Code Here

TOP

Related Classes of org.xtext.tortoiseshell.lib.Tortoise

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.