lib/jldrill/contexts/ShowStatisticsContext.rb in jldrill-0.5.1.7 vs lib/jldrill/contexts/ShowStatisticsContext.rb in jldrill-0.6.0.1

- old
+ new

@@ -1,5 +1,6 @@ +# encoding: utf-8 require 'Context/Context' require 'Context/Bridge' require 'Context/View' module JLDrill @@ -28,10 +29,17 @@ # Destroy the window containing the view def destroy # Please define in the concrete class end + # Show the busy cursor in the UI if bool is true. + # This happens during a long event where the user can't + # interact with the window + def showBusy(bool) + # Please define in the concrete class + end + # Update the view with the statistics from the quiz def update(quiz) @quiz = quiz # Please define the rest of this method in the concrete class. # You should call super(quiz) first. @@ -55,18 +63,31 @@ def enter(parent) if hasQuiz?(parent) super(parent) @mainView.update(parent.quiz) @parent.quiz.publisher.subscribe(self, "newProblem") + @parent.longEventPublisher.subscribe(self, "startLongEvent") + @parent.longEventPublisher.subscribe(self, "stopLongEvent") end end def exit @parent.quiz.publisher.unsubscribe(self, "newProblem") + @parent.longEventPublisher.unsubscribe(self, "startLongEvent") + @parent.longEventPublisher.unsubscribe(self, "stopLongEvent") super end def newProblemUpdated(problem) @mainView.update(@parent.quiz) unless @mainView.nil? end + + def startLongEventUpdated(source) + @mainView.showBusy(true) + end + + def stopLongEventUpdated(source) + @mainView.showBusy(false) + end + end end