 
   onSetNewIntegration: (newInt) ->
     @settings.newIntegration = newInt
+    @_updateGraphValid()
     @notifyChange()
-    
+
   onRunSimulation: ->
     if @settings.modelIsRunnable and @settings.modelReadyToRun
       @currentSimulation = new Simulation


  onGraphChanged: (data)->
    @nodes = data.nodes

    simulator = new Simulation
      nodes: @nodes
      newIntegration: @settings.newIntegration

    @graphIsValid = simulator.graphIsValid()
    @notifyChange()

  onSetDuration: (n) ->

      @currentSimulation.stop()
    @settings.modelReadyToRun = true
    @notifyChange()

  _updateGraphValid: ->
    simulator = new Simulation
      nodes: @nodes
      newIntegration: @settings.newIntegration
    @graphIsValid = simulator.graphIsValid()

  _checkModelIsRunnable: ->
    @settings.modelIsRunnable = @graphIsValid and @settings.duration > 0
