lib/jldrill/contexts/DisplayProblemContext.rb in jldrill-0.5.1.7 vs lib/jldrill/contexts/DisplayProblemContext.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'
require 'jldrill/contexts/behaviour/SearchDictionary'
@@ -67,10 +68,18 @@
# Show the answer to the problem
def showAnswer
# Should be overridden 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
+
end
def createViews
@mainView = @viewBridge.ProblemView.new(self)
end
@@ -88,10 +97,12 @@
@parent.quiz.publisher.subscribe(self, "problemModified")
end
if !@parent.reference.nil?
@parent.reference.publisher.subscribe(self, "edictLoad")
end
+ @parent.longEventPublisher.subscribe(self, "startLongEvent")
+ @parent.longEventPublisher.subscribe(self, "stopLongEvent")
newProblemUpdated(@parent.quiz.currentProblem)
end
end
def exit
@@ -102,10 +113,12 @@
@parent.quiz.publisher.unsubscribe(self, "problemModified")
end
if !@parent.reference.nil?
@parent.reference.publisher.unsubscribe(self, "edictLoad")
end
+ @parent.longEventPublisher.unsubscribe(self, "startLongEvent")
+ @parent.longEventPublisher.unsubscribe(self, "stopLongEvent")
end
super
end
def differs?(problem)
@@ -133,9 +146,17 @@
def edictLoadUpdated(reference)
quiz = @parent.quiz
@mainView.updateProblem(quiz.currentProblem)
end
+
+ def startLongEventUpdated(source)
+ @mainView.showBusy(true)
+ end
+
+ def stopLongEventUpdated(source)
+ @mainView.showBusy(false)
+ end
def showAnswer
@mainView.showAnswer
end