refactor to move get trace length logic out of the step manager ui

pull/3094/head
Iuri Matias 6 years ago committed by yann300
parent 1bb1dcd288
commit 064e3fa25b
  1. 72
      src/app/debugger/debuggerUI/StepManager.js

@ -18,6 +18,25 @@ class DebuggerStepManager {
this.currentStepIndex = 0
}
triggerStepChanged (step) {
const self = this
this.traceManager.getLength(function (error, length) {
let stepState = 'valid'
if (error) {
stepState = 'invalid'
} else if (step <= 0) {
stepState = 'initial'
} else if (step >= length - 1) {
stepState = 'end'
}
let jumpOutDisabled = (step === self.traceManager.findStepOut(step))
self.event.trigger('stepChanged', [step, stepState, jumpOutDisabled])
})
}
stepIntoBack () {
if (!this.traceManager.isLoaded()) return
var step = this.currentStepIndex - 1
@ -171,39 +190,40 @@ StepManager.prototype.startButtonNavigator = function () {
self.parent.breakpointManager.jumpPreviousBreakpoint(self._parent.currentStepIndex, true)
})
this.step_manager.event.register('stepChanged', (step) => {
self.updateStep(step)
this.step_manager.event.register('stepChanged', (step, stepState, jumpOutDisabled) => {
self.updateStep(step, stepState, jumpOutDisabled)
})
}
StepManager.prototype.updateStep = function (step) {
StepManager.prototype.updateStep = function (step, stepState, jumpOutDisabled) {
this.slider.setValue(step)
this.changeState(step)
}
StepManager.prototype.changeState = function (step) {
const self = this
this.currentStepIndex = step
this.traceManager.getLength(function (error, length) {
let stepState = 'valid'
if (error) {
stepState = 'invalid'
} else if (step <= 0) {
stepState = 'initial'
} else if (step >= length - 1) {
stepState = 'end'
}
let jumpOutDisabled = (step === self.traceManager.findStepOut(step))
self.buttonNavigator.stepChanged(stepState, jumpOutDisabled)
})
this.buttonNavigator.stepChanged(stepState, jumpOutDisabled)
this.event.trigger('stepChanged', [step])
}
// StepManager.prototype.changeState = function (step) {
// const self = this
// this.currentStepIndex = step
//
// this.traceManager.getLength(function (error, length) {
// let stepState = 'valid'
//
// if (error) {
// stepState = 'invalid'
// } else if (step <= 0) {
// stepState = 'initial'
// } else if (step >= length - 1) {
// stepState = 'end'
// }
//
// let jumpOutDisabled = (step === self.traceManager.findStepOut(step))
//
// self.buttonNavigator.stepChanged(stepState, jumpOutDisabled)
// })
//
// this.event.trigger('stepChanged', [step])
// }
StepManager.prototype.remove = function () {
// used to stop listenning on event. bad and should be "refactored"
this.slider.view = null

Loading…
Cancel
Save