Permalink
Browse files

Merge commit with jessicas branch

  • Loading branch information...
2 parents 2b9e3d4 + 84de4ec commit d2db0e4a164d933f62ffecb4ddaf9de2e44c4bd7 @sfeu committed Nov 1, 2011
@@ -14,10 +14,10 @@ def AUIControl.organize(aio,parent_aio = nil, layer = 0)
last = organize(child,aio,layer+1)
end
- aio.process_event!("organize")
+ aio.process_event("organize")
return last
else
- aio.process_event!("organize")
+ aio.process_event("organize")
return aio
end
end
@@ -18,20 +18,15 @@ def initial_calculation(result)
root_cio = CIO.first(:name=>result.root)
- # create a CIO if no CIO has been defined or root element
- if not root_cio
- root_cio = CIO.createCIOfromAIO(AIO.first(:name=>result.root),0)
- root_cio.save
- end
# p "#{root_le} root:#{root}"
#p "minimumspace = "+ calculateMinimumSquareSpace(root_le).to_s
#calculateOptSquareSpace(result.root, 800*600, 10)
root_cio.print
# pts = result.interactionTasks.map &:name
- #root = find_common_container(pts,true)
+ #root = find_common_container(pts,true)
# c = Box.new(:name=>le.name, :x=>0,:y=>0, :width=>1200, :height=>800, :layer=>1)
# c.save
@@ -54,7 +49,7 @@ def calculate_layout_on_task_change(result)
#private
# @param [String] taskname name of container
- # @return [String] container name to recalculate
+ # @return [String] container name to recalculate
def find_container_to_recalculate(taskname)
le = Layout.first(:name=>taskname)
@@ -63,7 +58,7 @@ def find_container_to_recalculate(taskname)
# luis = Layout.all(:parent=>le.parent).map &:task
# luis.each do |name|
# cui = CUI.first(:task=>name)
- # if (cui != nil)
+ # if (cui != nil)
# cui.destroy!
# end
# end
@@ -130,7 +125,7 @@ def wait_border_crossing(result)
cio = CIO.first(:name=>result.parent.name)
p "got #{cio.inspect}"
- t = Thread.new(cio.name,cio.x,cio.y,cio.width,cio.height) { |name,cx,cy,cw,ch|
+ Thread.new(cio.name,cio.x,cio.y,cio.width,cio.height) { |name,cx,cy,cw,ch|
Redis.new.subscribe("juggernaut") do |on|
on.message do |c,msg|
@@ -160,7 +155,6 @@ def wait_border_crossing(result)
end
}
- t.abort_on_exception = true
end
end
@@ -24,7 +24,7 @@ def initialize_statemachine
end
superstate :presenting do
- on_entry :inform_parent_presenting
+ on_entry [:inform_parent_presenting, :present_children]
on_exit :hide_children
event :suspend, :suspended
@@ -5,7 +5,7 @@ def initialize_statemachine
parser = StatemachineParser.new(self)
@statemachine = parser.build_from_scxml "#{File.dirname(__FILE__)}/aichoice.scxml"
=begin
- @statemachine = Statemachine.build do
+@statemachine = Statemachine.build do
trans :initialized,:organize, :organized
trans :organized, :present, :p_t
trans :organized, :suspend, :suspended
@@ -20,7 +20,7 @@ def initialize_statemachine
parallel :p do
statemachine :s1 do
superstate :presenting do
- on_entry [:present_child, :inform_parent_presenting]
+ on_entry :present_children
on_exit :hide_children
state :defocused do
on_entry :sync_cio_to_displayed
@@ -29,7 +29,7 @@ def initialize_statemachine
on_entry :sync_cio_to_highlighted
end
trans :defocused,:focus,:focused
- trans :focused,:defocus, :presented
+ trans :focused,:defocus, :defocused
trans :focused, :next, :defocused, :focus_next, Proc.new { exists_next}
trans :focused, :prev, :defocused, :focus_previous, Proc.new { exists_prev}
trans :focused, :parent, :defocused, :focus_parent
@@ -39,7 +39,7 @@ def initialize_statemachine
end
statemachine :s2 do
superstate :l do
- trans :listing, :drop, :listing, :add_element
+ trans :listing, :drop, :listing, :add_element, "In(:focused)"
end
end
end
@@ -50,15 +50,15 @@ def initialize_statemachine
end
end
def add_element
- if self.is_in? :focused
+ #if self.is_in? :focused
f = AISingleChoiceElement.first(:new_states=> /#{Regexp.quote("dragging")}/)
self.childs << f
self.childs.save
f.process_event(:drop)
f.process_event(:focus)
self.process_event(:defocus)
f.destroy
- end
+ #end
end
end
@@ -14,7 +14,7 @@ def sync_cio_to_selected
def unchoose_others
- aios = @element.parent.childs.all(:states=>/chosen/)
+ aios = @element.parent.childs.all(:states=>/\bchosen\b/)
aios.each do |aio|
aio.process_event("unchoose") if aio.is_in? :chosen
end
@@ -38,15 +38,15 @@ def sync_cio_to_selected
def sync_cio_to_listed
cio = MINT::Selectable.first(:name=>self.name)
if (cio and not cio.is_in? :listed)
- cio.sync_event(:select)
+ cio.sync_event(:listed)
end
true
end
def unchoose_others
- aios = self.parent.childs.all(:states=>/chosen/)
+ aios = self.parent.childs.all(:states=>/\bchosen\b/)
aios.each do |aio|
- aio.process_event("unchoose") if not aio.is_in? :unchosen
+ aio.process_event("unchoose")
end
end
end
@@ -24,7 +24,8 @@ def initialize_statemachine
if @statemachine.blank?
parser = StatemachineParser.new(self)
@statemachine = parser.build_from_scxml "#{File.dirname(__FILE__)}/aio.scxml"
-=begin @statemachine = Statemachine.build do
+=begin
+@statemachine = Statemachine.build do
superstate :AIO do
trans :initialized,:organize, :organized
@@ -123,12 +124,10 @@ def sync_cio_to_highlighted
def sync_cio_to_displayed
cio = MINT::CIO.first(:name=>self.name)
if (cio and not cio.is_in? :displayed)
- if (cio.is_in? :suspended)
+ if (cio.is_in? :suspended or cio.is_in? :positioned)
cio.sync_event(:display)
-
else
cio.sync_event(:unhighlight)
-
end
#cio.states=[:displayed]
end
View
@@ -51,7 +51,7 @@
end
end
- it 'should transform all children to presented if presented' do
+ it 'should transform all children to suspended if suspended' do
@a.childs.each do |c|
c.states = [:defocused]
end
View
@@ -0,0 +1,179 @@
+require "spec_helper"
+
+include MINT
+describe 'AUI' do
+ before :each do
+ connection_options = { :adapter => "in_memory"}
+ DataMapper.setup(:default, connection_options)
+ # DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
+ AIC.new(:name=>"interactive_sheet", :childs => [
+ AIC.new(:name=>"sheets", :childs =>[]),
+ AISingleChoice.new(:name=>"option", :label=>"Options", :childs => [
+ AISingleChoiceElement.new(:name=>"nodding",:label=>"Nodding"),
+ AISingleChoiceElement.new(:name=>"tilting",:label=>"Tilting"),
+ AISingleChoiceElement.new(:name=>"turning",:label=>"Turning")
+ ])
+ ]).save
+
+ @interactive_sheet = AIC.first
+ AUIControl.organize(@interactive_sheet,nil,0)
+ @interactive_sheet.save!
+
+ @sheets = MINT::AIC.first(:name=>"sheets")
+ @option = MINT::AISingleChoice.first(:name=>"option")
+ end
+
+ describe 'music sheet' do
+ it 'interactive_sheet should recover state after save and reload' do
+ @interactive_sheet.states.should == [:organized]
+ @interactive_sheet.save!
+ b = MINT::AIC.first(:name=>"interactive_sheet")
+ b.states.should == [:organized]
+ b.process_event(:present).should == [:defocused]
+ end
+
+ it 'sheets should recover state after save and reload' do
+ # @a.process_event(:organize).should ==[:organized]
+ @sheets.states.should == [:organized]
+ @sheets.new_states.should == [:organized]
+ @sheets.process_event(:present).should ==[:defocused]
+ @sheets.save!
+ sheets = MINT::AIC.first(:name=>"sheets")
+ sheets.states.should == [:defocused]
+ sheets.process_event(:focus).should == [:focused]
+ end
+
+ it 'option list should recover state after save and reload' do
+ # @a.process_event(:organize).should ==[:organized]
+ @option.states.should == [:organized]
+ @option.new_states.should == [:organized]
+ @option.process_event(:present).should ==[:defocused, :listing]
+ @option.childs.each do |c|
+ c.process_event(:focus)
+ c.states.should == [:focused, :unchosen]
+ end
+ @option.save!
+ option = MINT::AISingleChoice.first(:name=>"option")
+ option.states.should == [:defocused, :listing]
+ option.process_event(:focus).should == [:focused, :listing]
+ option.childs.each do |c|
+ c.states.should == [:focused, :unchosen]
+ end
+ end
+
+ it 'lists options should recover state after save and reload' do
+ # @a.process_event(:organize).should ==[:organized]
+ @option.states.should == [:organized]
+ @option.new_states.should == [:organized]
+ @option.process_event(:present).should ==[:defocused, :listing]
+ #save list
+ @option.save!
+ #recover one of its children and alter its state
+ nodding = MINT::AISingleChoiceElement.first(:name=>"nodding")
+ nodding.states.should == [:defocused, :unchosen]
+ nodding.process_event(:choose).should == [:defocused, :chosen]
+ #save child
+ nodding.save!
+ #recover child and check
+ nodding = MINT::AISingleChoiceElement.first(:name=>"nodding")
+ nodding.states.should == [:defocused, :chosen]
+ #recover another child and alter its state
+ tilting = MINT::AISingleChoiceElement.first(:name=>"tilting")
+ tilting.process_event(:focus).should == [:focused, :unchosen]
+ #save child
+ tilting.save!
+ #recover child and check
+ tilting = MINT::AISingleChoiceElement.first(:name=>"tilting")
+ tilting.states.should == [:focused, :unchosen]
+ # choose option tilting, thus unchoosing nodding
+ tilting.process_event(:choose)
+ tilting.states.should == [:focused, :chosen]
+ # recover nodding to see the change made
+ nodding = MINT::AISingleChoiceElement.first(:name=>"nodding")
+ nodding.states.should == [:defocused, :unchosen]
+ #save child
+ tilting.save!
+ #recover and check
+ tilting = MINT::AISingleChoiceElement.first(:name=>"tilting")
+ tilting.states.should == [:focused, :chosen]
+ end
+ end
+
+ describe "AUI/CUI synchronization" do
+ before :each do
+ MINT::CIC.create(:name =>"interactive_sheet",:x=>15, :y=>15, :width =>1280, :height => 1000,:layer=>0, :rows=>2, :cols=>1,:states=>[:positioned])
+ MINT::SingleHighlight.create(:name => "sheets", :width=>1198, :height => 820,:states=>[:positioned])
+
+ MINT::RadioButtonGroup.create(:name =>"option", :x=>30,:y=>840, :width=>1200, :height => 100,:rows=>1,:cols=>3,:states=>[:positioned])
+ MINT::RadioButton.create(:name => "nodding",:x=>40, :y=>850, :width=>200, :height => 80,:states=>[:positioned])
+ MINT::RadioButton.create(:name => "tilting",:x=>440, :y=>850,:width=>200, :height => 80,:states=>[:positioned])
+ MINT::RadioButton.create(:name => "turning",:x=>840, :y=>850,:width=>200, :height => 80,:states=>[:positioned])
+ end
+
+ it "should sync to displayed" do
+ @interactive_sheet.process_event(:present)
+ @interactive_sheet.states.should == [:defocused]
+ MINT::CIC.first(:name=>"interactive_sheet").states.should == [:displayed]
+ MINT::SingleHighlight.first(:name=>"sheets").states.should == [:displayed]
+ MINT::RadioButtonGroup.first(:name=>"option").states.should == [:displayed]
+ MINT::RadioButton.first(:name=>"nodding").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"tilting").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"turning").states.should == [:displayed, :listed]
+ end
+
+ it "should sync interactive_sheet to highlighted" do
+ @interactive_sheet.process_event(:present)
+ @interactive_sheet.process_event(:focus)
+ @interactive_sheet.states.should == [:focused]
+ MINT::CIC.first(:name=>"interactive_sheet").states.should == [:highlighted]
+ MINT::SingleHighlight.first(:name=>"sheets").states.should == [:displayed]
+ MINT::RadioButtonGroup.first(:name=>"option").states.should == [:displayed]
+ MINT::RadioButton.first(:name=>"nodding").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"tilting").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"turning").states.should == [:displayed, :listed]
+ end
+
+ it "should sync sheets to highlighted" do
+ @interactive_sheet.process_event(:present)
+ @sheets = MINT::AIC.first(:name=>"sheets")
+ @sheets.process_event(:focus)
+ @sheets.states.should == [:focused]
+ MINT::CIC.first(:name=>"interactive_sheet").states.should == [:displayed]
+ MINT::SingleHighlight.first(:name=>"sheets").states.should == [:highlighted]
+ MINT::RadioButtonGroup.first(:name=>"option").states.should == [:displayed]
+ MINT::RadioButton.first(:name=>"nodding").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"tilting").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"turning").states.should == [:displayed, :listed]
+ end
+
+ it "should sync option to highlighted" do
+ @interactive_sheet.process_event(:present)
+ @sheets = MINT::AIC.first(:name=>"sheets")
+ @option = MINT::AISingleChoice.first(:name=>"option")
+ @option.process_event(:focus)
+ @option.states.should == [:focused, :listing]
+ MINT::CIC.first(:name=>"interactive_sheet").states.should == [:displayed]
+ MINT::SingleHighlight.first(:name=>"sheets").states.should == [:displayed]
+ MINT::RadioButtonGroup.first(:name=>"option").states.should == [:highlighted]
+ MINT::RadioButton.first(:name=>"nodding").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"tilting").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"turning").states.should == [:displayed, :listed]
+ end
+
+ it "should sync only one RadioButton to selected at a time" do
+ @interactive_sheet.process_event(:present)
+
+ MINT::AISingleChoiceElement.first(:name=>"nodding").process_event(:choose)
+
+ MINT::AISingleChoiceElement.first(:name=>"nodding").states.should == [:defocused, :chosen]
+ MINT::AISingleChoiceElement.first(:name=>"tilting").states.should == [:defocused, :unchosen]
+ MINT::AISingleChoiceElement.first(:name=>"turning").states.should == [:defocused, :unchosen]
+
+ MINT::RadioButton.first(:name=>"nodding").states.should == [:displayed, :selected]
+ MINT::RadioButton.first(:name=>"tilting").states.should == [:displayed, :listed]
+ MINT::RadioButton.first(:name=>"turning").states.should == [:displayed, :listed]
+ end
+
+ end
+
+end

0 comments on commit d2db0e4

Please sign in to comment.