Module: IronNails::Core::ViewOperations

Included in:
NailsEngine
Defined in:
lib/ironnails/nails_engine.rb

Instance Method Summary collapse

Instance Method Details

#build_view(options) ⇒ Object



15
16
17
18
19
20
# File 'lib/ironnails/nails_engine.rb', line 15

def build_view(options)
  logger.debug "View to load: #{options[:name]}", IRONNAILS_FRAMEWORKNAME
  vw = IronNails::View::View.new(options)
  #vw.add_observer(:loaded) { |sender| set_data_context_for(sender) }
  vw
end

#find_view(controller, name) ⇒ Object



96
97
98
# File 'lib/ironnails/nails_engine.rb', line 96

def find_view(controller, name)
  registry.view_for(controller).find(name)
end

#from_view(controller, name, target, method) ⇒ Object



37
38
39
# File 'lib/ironnails/nails_engine.rb', line 37

def from_view(controller, name, target, method)
  find_view(controller, name).get_property(target, method)
end

#init_view_operationsObject



12
13
# File 'lib/ironnails/nails_engine.rb', line 12

def init_view_operations
end

#on_ui_thread(controller, options = nil, &b) ⇒ Object Also known as: on_ui_thread_with



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ironnails/nails_engine.rb', line 70

def on_ui_thread(controller, options=nil, &b)
  if options.is_a? Hash
    data = options[:data]
    klass = options[:class] || data.class
  else
    unless options.nil?
      klass = options.class
      data = options
    end
  end
  b.call
  #registry.view_for(controller).dispatcher.begin_invoke(DispatcherPriority.normal, options.nil? ? Action.new(&b) : Action.of(klass).new(&b), data)
end

#on_view(controller, name = nil, &b) ⇒ Object



33
34
35
# File 'lib/ironnails/nails_engine.rb', line 33

def on_view(controller, name = nil, &b)
  find_view(controller, name).on_proxy(&b) #unless vw.nil?
end

#play_storyboard(controller, name, storyboard) ⇒ Object



86
87
88
89
90
# File 'lib/ironnails/nails_engine.rb', line 86

def play_storyboard(controller, name, storyboard)
  logger.debug "finding controller #{controller.controller_name} and view #{name} to play #{storyboard}"
  vw = find_view(controller, name)
  find_view(controller, name).play_storyboard(storyboard)
end

#register_child_view(options) ⇒ Object



22
23
24
25
# File 'lib/ironnails/nails_engine.rb', line 22

def register_child_view(options)
  vw = registry.view_for options[:controller]
  vw.add_child(options)
end

#register_view_for(controller) ⇒ Object



27
28
29
30
31
# File 'lib/ironnails/nails_engine.rb', line 27

def register_view_for(controller)
  vw = build_view(:name => controller.view_name.to_sym, :controller => controller.controller_name)
  vw.add_observer(:configuring) { |sender| configure_view(sender) }
  registry.register_view_for controller, vw
end

#stop_storyboard(controller, view_name, storyboard) ⇒ Object



92
93
94
# File 'lib/ironnails/nails_engine.rb', line 92

def stop_storyboard(controller, view_name, storyboard)
  find_view(controller, name).stop_storyboard(storyboard)
end

#to_update_ui_after(controller, options, &b) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ironnails/nails_engine.rb', line 41

def to_update_ui_after(controller, options, &b)
#        if options.is_a? Hash
#          klass = options[:class]||BindableCollection
#          request = options[:request]
#        else
#          klass = BindableCollection
#          request = options
#        end
#        cb = System::Threading::WaitCallback.new do
#          begin
#            registry.view_for(controller).dispatcher.begin_invoke(DispatcherPriority.normal, Action.of(klass).new(&b), request.call)
#          rescue WebException => e
#            MessageBox.Show("There was a problem logging in to Twitter. #{e.message}");
#          rescue RequestLimitException => e
#            MessageBox.Show(e.message)
#          rescue SecurityException => e
#            MessageBox.Show("Incorrect username or password. Please try again");
#          end
#        end
#        System::Threading::ThreadPool.queue_user_work_item cb  
  cb = nil
  cb = options[:callback] unless options[:callback].nil?
  options[:callback] = lambda do |vw|
    b.call
    refresh_view(vw)
  end
  find_view(controller, name).to_update_ui_after(options, &b)
end