Class: View
- Inherits:
-
RPCQooxdooService
- Object
- RPCQooxdooService
- View
- Defined in:
- lib/qooxview/view.rb
Direct Known Subclasses
Constant Summary collapse
- @@list =
[]
- @@tabs =
[]
Instance Attribute Summary collapse
-
#configured ⇒ Object
readonly
Returns the value of attribute configured.
-
#is_tabs ⇒ Object
readonly
Returns the value of attribute is_tabs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_tab ⇒ Object
readonly
Returns the value of attribute name_tab.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#visible ⇒ Object
readonly
Returns the value of attribute visible.
Class Method Summary collapse
-
.list(session, tabs = nil) ⇒ Object
:nodoc:.
- .list_views(list = @@list) ⇒ Object
-
.method_missing(m, *args) ⇒ Object
Used to access subclasses defined in RPCQooxdoo.
- .reply(cmd, data = nil) ⇒ Object
- .reply_one_two(choice, one, two) ⇒ Object
- .reply_show_hide(show, hide) ⇒ Object
- .reply_table_columns_visible(visible, element) ⇒ Object
- .reply_visible(visible, element) ⇒ Object
-
.rpc_list(session) ⇒ Object
Returns a list of the available views for a given user.
- .update_configured_all ⇒ Object
Instance Method Summary collapse
- #call_named(type, session, name, *args) ⇒ Object
- #do_box(btype, arg, b) ⇒ Object
- #do_boxg(btype, arg, b) ⇒ Object
-
#do_container(tags, b) ⇒ Object
Handle a whole GUI-container of different kind: - vbox - starts a vertical box - hbox - starts a horizontal box - fields - starts a group of elements like buttons, labels and input-boxes - group - draws a gray line around the container - tabs - start a tabs-in-tab.
-
#do_container_end ⇒ Object
Finish a GUI-container.
-
#do_container_start(tags) ⇒ Object
Helper for the containers.
-
#filter_from_entity(data) ⇒ Object
Filters data from own Entity, so that these fields are not overwritten.
- #get_tab_members ⇒ Object
-
#gui_fields(arg = nil, &b) ⇒ Object
Contains fields of same kind.
-
#gui_group(&b) ⇒ Object
Draws a gray border around.
- #gui_grow(&b) ⇒ Object
-
#gui_hbox(arg = nil, &b) ⇒ Object
A horizontal box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line.
-
#gui_hboxg(arg = nil, &b) ⇒ Object
A horizontal box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that hbox, it grows.
-
#gui_shrink(&b) ⇒ Object
Draws a gray border around and allows height-fill.
-
#gui_tabs(parent) ⇒ Object
Presents a tabs-in-tab.
-
#gui_vbox(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line.
-
#gui_vboxg(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that vbox, it grows.
-
#gui_vboxgl(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that vboxg, it grows but with limit to it’s parent.
- #gui_window(arg = nil, &b) ⇒ Object
-
#initialize ⇒ View
constructor
A new instance of View.
-
#layout ⇒ Object
Override this class to define your own layout.
- #layout_eval(lay = @layout[0][0].dup) ⇒ Object
- #layout_find(name) ⇒ Object
-
#layout_recurse(lay = @layout) ⇒ Object
Make a flat array containing the elements of the layout.
- #list(session) ⇒ Object
- #method_missing(cmd, *args) ⇒ Object
- #parse_reply(method, session, request) ⇒ Object
-
#parse_request(method, session, params) ⇒ Object
Gets the request and converts the ids of the Entites back to the objects they once were - which makes life much more easy…
-
#reply(cmd, data = nil) ⇒ Object
Packs a command and a data in a hash.
- #reply_one_two(choice, one, two) ⇒ Object
- #reply_show_hide(show, hide) ⇒ Object
- #reply_table_columns_visible(visible, element) ⇒ Object
- #reply_visible(visible, element) ⇒ Object
- #respond_to?(cmd) ⇒ Boolean
- #rpc_autofill(session, args) ⇒ Object
-
#rpc_button(session, name, *args) ⇒ Object
Call the children’s rpc_button_name, if present.
- #rpc_button_close(session, data) ⇒ Object
-
#rpc_button_new(session, data) ⇒ Object
Standard button that cleans all fields.
-
#rpc_button_save(session, data) ⇒ Object
Standard button which just saves the entered data.
-
#rpc_callback(session, name, *args) ⇒ Object
Call the children’s rpc_callback_name, if present.
-
#rpc_find(session, field, data) ⇒ Object
Standard search-field action to take.
- #rpc_list(session) ⇒ Object
-
#rpc_list_choice(session, name, data) ⇒ Object
Upon choice of an entry in the list.
- #rpc_list_tabs(session) ⇒ Object
-
#rpc_show(session) ⇒ Object
Gives the GUI-elements for the active view.
-
#rpc_table(session, name, *args) ⇒ Object
Call the children’s rpc_button_name, if present.
- #rpc_tabs_list_choice(session, args) ⇒ Object
- #rpc_tabs_show(session, args) ⇒ Object
- #rpc_tabs_update_view(session, args) ⇒ Object
-
#rpc_update(session) ⇒ Object
Send the current values that are displayed.
- #rpc_update_async(session) ⇒ Object
-
#rpc_update_view(session, args = nil) ⇒ Object
Updates the layout of the form, especially the lists.
-
#set_data_class(d_c) ⇒ Object
This method lets you set the data_class of your view.
-
#show_add(cmds, args) ⇒ Object
Adds a new, general item.
-
#show_arg(val, args, lay = @layout) ⇒ Object
Adds arguments to an already existing field.
-
#show_button(*buttons) ⇒ Object
Shows a button, takes care about placing it correctly.
-
#show_entity(name, entity, gui, field, args) ⇒ Object
Shows an entity in different formats - name - the internal name - entity - what entity to show - gui - how to display it (drop) - field - what field of the entity to display.
-
#show_field(name, args = nil) ⇒ Object
Shows an existing field.
- #show_field_ro(name, args = {}) ⇒ Object
-
#show_find(name) ⇒ Object
Shows an input-box for an existing field that will call a “match_by_” method if something is entered.
-
#show_in_field(a, args = {}) ⇒ Object
:nodoc:.
- #show_split_button(name, menu) ⇒ Object
-
#update(session) ⇒ Object
Returns the data for the fields as a hash.
- #update_configured ⇒ Object
- #update_form_data(data) ⇒ Object
- #update_layout(session) ⇒ Object
Methods inherited from RPCQooxdooService
add_prime_service, entities, #get_services, inherited, migrate_all, needs, #needs_covered, services
Constructor Details
#initialize ⇒ View
Returns a new instance of View.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/qooxview/view.rb', line 79 def initialize @visible = true @order = 50 @name = self.class.name @debug = false @is_tabs = false @name_tab = nil @main_tab = nil if @name != 'View' @@list.push self if @name =~ /.*Tabs$/ @name_tab = @name.tab_name @is_tabs = true @@tabs.push @name_tab else @main_tab = @name.main_tab end dputs(4) { "Initializing #{self.class.name}" } dputs(5) { "Total list of view-classes: #{@@list.join('::')}" } @layout = [[]] @actual = [] @update = false @update_layout = true @auto_update = 0 @auto_update_async = 0 @auto_update_send_values = true @configured = true @functions_need = [] @values_need = {} @functions_reject = [] @data_class = Entities.service(@name.tab_name.pluralize_simple) @static = Statics.get_hash("View.#{@name}") if Entities.has_entity?(dc = @name.sub(/^[A-Z][a-z_-]*/, '')) dputs(3) { "Setting data-class to #{dc} for #{@name}" } set_data_class(dc.pluralize_simple) end # Fetch the layout of the view if @is_tabs gui_hboxg do gui_vbox :nogroup do layout end gui_tabs @name end else layout end # For debugging purposes, we allow re-ordering of views in config.yaml if o = get_config(nil, :Views, self.class.name, :order) dputs(3){"Overwriting order of #{self.class.name} with #{o}"} @order = o.to_i end # Clean up eventual left-overs from a simple (or very complicated) layout while @layout.size > 1 dputs(5) { 'Cleaning up' } do_container_end end dputs(5) { "Layout is #{@layout.inspect}" } update_configured end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(cmd, *args) ⇒ Object
804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/qooxview/view.rb', line 804 def method_missing(cmd, *args) cmd_str = cmd.to_s dputs(5) { "Method missing: #{cmd}" } case cmd_str when /^show_/ cmds = cmd_str.split('_')[1..-1] show_add(cmds, args) else super(cmd, args) end end |
Instance Attribute Details
#configured ⇒ Object (readonly)
Returns the value of attribute configured.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def configured @configured end |
#is_tabs ⇒ Object (readonly)
Returns the value of attribute is_tabs.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def is_tabs @is_tabs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def name @name end |
#name_tab ⇒ Object (readonly)
Returns the value of attribute name_tab.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def name_tab @name_tab end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def order @order end |
#visible ⇒ Object (readonly)
Returns the value of attribute visible.
74 75 76 |
# File 'lib/qooxview/view.rb', line 74 def visible @visible end |
Class Method Details
.list(session, tabs = nil) ⇒ Object
:nodoc:
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/qooxview/view.rb', line 413 def self.list(session, tabs = nil) # :nodoc: #dputs_func if not session dputs(2) { 'No session given, returning empty' } return {:views => []} end dputs(4) { "Found user #{session.owner.inspect} for session_id #{session_id}" } views = [] dputs(5) { @@list.inspect } @@list.each { |l| shown = l.visible shown &&= session.can_view(l.class.name) shown &&= l.configured if shown dputs(5) { "Found view #{l.class.name}" } views.push(l) end } sub_tabs_only = false if not tabs # First test if we only have sub-tabs (they'll be shown seperatly) main_tabs = views.collect { |v| v.name.tab_name }.uniq dputs(4) { "Main_tabs are #{main_tabs.inspect}" } # Check for lonely tabs main_tabs.each { |t| vlen = views.select { |v| dputs(5) { "We have #{v.name}, #{v.name.tab_name} and #{t}" } v.name.tab_name == t }.length dputs(5) { "Calculating doubles for #{t}, found #{vlen}" } if vlen == 1 dputs(3) { "Deleting tab #{t}" } views.delete_if { |v| v.name.tab_name == t and v.name.sub_name == 'Tabs' } end } if main_tabs.length == 1 # There is only one main_tab, we have to clean it views.delete_if { |v| v.name == "#{main_tabs[0]}Tabs" } sub_tabs_only = true end end if not sub_tabs_only dputs(3) { "Views before: #{views.each { |v| v.name }}" } views.delete_if { |l| tab_name = l.name.tab_name is_tabs_or_tab = @@tabs.index(tab_name) dputs(3) { "#{l.class} is visible? #{l.visible} - " + "configured? #{l.configured} - order is #{l.order}" } #dputs( 3 ){ "tabs: #{tabs.inspect} - tab_name: #{tab_name}" } # Either we ask specifically for all sub-tabs, but then we don't show the main-tab # or we don't ask for tabs and # are the main-tab or # are not tabs or tab at all not ((tab_name == tabs and not l.is_tabs) or (not tabs and (l.is_tabs or not is_tabs_or_tab))) } dputs(3) { "Views after: #{views.each { |v| v.name }}" } end session.s_data._sub_tabs_only = sub_tabs_only self.list_views(views) end |
.list_views(list = @@list) ⇒ Object
480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/qooxview/view.rb', line 480 def self.list_views(list = @@list) {:views => list.select { |l| l.name != 'Welcome' }.sort { |s, t| #dputs( 3 ){ "#{s.order} - #{t.order}" } #dputs( 4 ){ "#{s.name} - #{t.name}" } order = s.order.to_i <=> t.order.to_i if order == 0 order = s.name <=> t.name end order }.collect { |c| [c.name, GetText._(c.name)] } } end |
.method_missing(m, *args) ⇒ Object
Used to access subclasses defined in RPCQooxdoo
821 822 823 824 |
# File 'lib/qooxview/view.rb', line 821 def self.method_missing(m, *args) dputs(3) { "Searching #{m} with #{args.inspect}" } @@services_hash["View.#{m}"] end |
.reply(cmd, data = nil) ⇒ Object
723 724 725 |
# File 'lib/qooxview/view.rb', line 723 def self.reply(cmd, data = nil) [{:cmd => cmd, :data => data}] end |
.reply_one_two(choice, one, two) ⇒ Object
747 748 749 750 |
# File 'lib/qooxview/view.rb', line 747 def self.reply_one_two(choice, one, two) View.reply_visible(choice, one) + View.reply_visible(!choice, two) end |
.reply_show_hide(show, hide) ⇒ Object
756 757 758 |
# File 'lib/qooxview/view.rb', line 756 def self.reply_show_hide(show, hide) self.reply_one_two(true, show, hide) end |
.reply_table_columns_visible(visible, element) ⇒ Object
739 740 741 |
# File 'lib/qooxview/view.rb', line 739 def self.reply_table_columns_visible(visible, element) View.reply(visible ? :table_columns_show : :table_columns_hide, element) end |
.reply_visible(visible, element) ⇒ Object
731 732 733 |
# File 'lib/qooxview/view.rb', line 731 def self.reply_visible(visible, element) View.reply(visible ? :unhide : :hide, element) end |
.rpc_list(session) ⇒ Object
Returns a list of the available views for a given user
399 400 401 402 |
# File 'lib/qooxview/view.rb', line 399 def self.rpc_list(session) View.reply(:list, View.list(session)) + (session.s_data._sub_tabs_only ? View.reply(:bar_position, 'top') : []) end |
.update_configured_all ⇒ Object
892 893 894 895 896 897 |
# File 'lib/qooxview/view.rb', line 892 def self.update_configured_all @@list.each { |l| dputs(4) { "Testing for view #{l.name}" } l.update_configured } end |
Instance Method Details
#call_named(type, session, name, *args) ⇒ Object
606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/qooxview/view.rb', line 606 def call_named(type, session, name, *args) rpc_name = "rpc_#{type}_#{name}" dputs(3) { "Searching for #{rpc_name}" } if self.respond_to? rpc_name dputs(3) { "Found #{rpc_name} and calling it with #{args.inspect}" } return self.send(rpc_name, session, args[0]) else dputs(0) { "Error: Nobody listens to #{rpc_name} in " + "#{self.class.name.to_s} - ignoring" } return [] end end |
#do_box(btype, arg, b) ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/qooxview/view.rb', line 190 def do_box(btype, arg, b) if @actual[-1] == 'fields' dputs(0) { "Can't put a VBox or a HBox in a field!" } exit end do_container(arg == :nogroup ? [btype] : ['group', btype], b) end |
#do_boxg(btype, arg, b) ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/qooxview/view.rb', line 198 def do_boxg(btype, arg, b) if @actual[-1] == 'fields' dputs(0) { "Can't put a VBox or a HBox in a field!" } exit end do_container(arg == :nogroup ? [btype] : ['groupw', btype], b) end |
#do_container(tags, b) ⇒ Object
Handle a whole GUI-container of different kind:
-
vbox - starts a vertical box
-
hbox - starts a horizontal box
-
fields - starts a group of elements like buttons, labels and input-boxes
-
group - draws a gray line around the container
-
tabs - start a tabs-in-tab
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/qooxview/view.rb', line 179 def do_container(, b) # The actual depth has to be kept, because the "b.call" might add additional depths, # for example a "fields, group" in case of an element. depth = @actual.length do_container_start() b.call # Now we can undo all elements, even those perhaps added by "b.call" - close nicely dputs(4) { "Undoing #{@actual.length - depth} levels" } (@actual.length - depth).times { do_container_end } end |
#do_container_end ⇒ Object
Finish a GUI-container
169 170 171 |
# File 'lib/qooxview/view.rb', line 169 def do_container_end @layout[-2].push [@actual.pop, @layout.pop] end |
#do_container_start(tags) ⇒ Object
Helper for the containers
161 162 163 164 165 166 |
# File 'lib/qooxview/view.rb', line 161 def do_container_start() [*].each { |t| @layout.push [] @actual.push t } end |
#filter_from_entity(data) ⇒ Object
Filters data from own Entity, so that these fields are not overwritten
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
# File 'lib/qooxview/view.rb', line 785 def filter_from_entity(data) dputs(3) { data.inspect } if data and data.keys.length > 0 data_only_keys = data.keys.select { |k| !@data_class.has_field? k } if data_only_keys data_only = data_only_keys.collect { |k| [k, data[k]] } else return Hash.new end Hash[*data_only.flatten(1)] else Hash.new end end |
#get_tab_members ⇒ Object
850 851 852 853 854 855 856 857 858 |
# File 'lib/qooxview/view.rb', line 850 def get_tab_members dputs(2) { "Getting tab members of #{@name} with #{@@list.inspect}" } @@list.select { |l| l.name =~ /^#{@name}/ }.collect { |l| dputs(2) { 'Collected ' + l.name } l.name } end |
#gui_fields(arg = nil, &b) ⇒ Object
Contains fields of same kind
248 249 250 251 252 253 254 |
# File 'lib/qooxview/view.rb', line 248 def gui_fields(arg = nil, &b) if arg == :noflex do_container('fields_noflex', b) else do_container('fields', b) end end |
#gui_group(&b) ⇒ Object
Draws a gray border around
257 258 259 |
# File 'lib/qooxview/view.rb', line 257 def gui_group(&b) do_container('group', b) end |
#gui_grow(&b) ⇒ Object
239 240 241 |
# File 'lib/qooxview/view.rb', line 239 def gui_grow(&b) do_container('grow', b) end |
#gui_hbox(arg = nil, &b) ⇒ Object
A horizontal box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line
228 229 230 |
# File 'lib/qooxview/view.rb', line 228 def gui_hbox(arg = nil, &b) do_box('hbox', arg, b) end |
#gui_hboxg(arg = nil, &b) ⇒ Object
A horizontal box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that hbox, it grows
235 236 237 |
# File 'lib/qooxview/view.rb', line 235 def gui_hboxg(arg = nil, &b) do_boxg('hboxg', arg, b) end |
#gui_shrink(&b) ⇒ Object
Draws a gray border around and allows height-fill
262 263 264 |
# File 'lib/qooxview/view.rb', line 262 def gui_shrink(&b) do_container('shrink', b) end |
#gui_tabs(parent) ⇒ Object
Presents a tabs-in-tab
267 268 269 270 |
# File 'lib/qooxview/view.rb', line 267 def gui_tabs(parent) do_container_start(['tabs', parent]) do_container_end end |
#gui_vbox(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line
208 209 210 |
# File 'lib/qooxview/view.rb', line 208 def gui_vbox(arg = nil, &b) do_box('vbox', arg, b) end |
#gui_vboxg(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that vbox, it grows
215 216 217 |
# File 'lib/qooxview/view.rb', line 215 def gui_vboxg(arg = nil, &b) do_box('vboxg', arg, b) end |
#gui_vboxgl(arg = nil, &b) ⇒ Object
A vertical box, takes :nogroup as an argument, so it doesn’t do a “group” around it, and as such doesn’t draw a gray line Different that vboxg, it grows but with limit to it’s parent
222 223 224 |
# File 'lib/qooxview/view.rb', line 222 def gui_vboxgl(arg = nil, &b) do_box('vboxgl', arg, b) end |
#gui_window(arg = nil, &b) ⇒ Object
243 244 245 |
# File 'lib/qooxview/view.rb', line 243 def gui_window(arg = nil, &b) do_container(["window:#{arg.to_s}"], b) end |
#layout ⇒ Object
Override this class to define your own layout. Use eventually set_data_class
150 151 |
# File 'lib/qooxview/view.rb', line 150 def layout end |
#layout_eval(lay = @layout[0][0].dup) ⇒ Object
688 689 690 691 692 693 694 695 696 697 698 |
# File 'lib/qooxview/view.rb', line 688 def layout_eval(lay = @layout[0][0].dup) lay.collect { |l| if l.class == Value l.to_a elsif l.class == Array layout_eval(l) else l end } end |
#layout_find(name) ⇒ Object
684 685 686 |
# File 'lib/qooxview/view.rb', line 684 def layout_find(name) layout_recurse.find { |l| l.name.to_s == name.to_s } end |
#layout_recurse(lay = @layout) ⇒ Object
Make a flat array containing the elements of the layout
671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/qooxview/view.rb', line 671 def layout_recurse(lay = @layout) # :nodoc: return [] if not lay ret = [] lay.each { |l| if l.class == Array ret.push(*layout_recurse(l)) elsif l.class == Value ret.push l end } ret end |
#list(session) ⇒ Object
409 410 411 |
# File 'lib/qooxview/view.rb', line 409 def list(session) View.list(session) end |
#parse_reply(method, session, request) ⇒ Object
845 846 847 848 |
# File 'lib/qooxview/view.rb', line 845 def parse_reply(method, session, request) rep = self.send(method, session, *request) rep end |
#parse_request(method, session, params) ⇒ Object
Gets the request and converts the ids of the Entites back to the objects they once were - which makes life much more easy…
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/qooxview/view.rb', line 828 def parse_request(method, session, params) #dputs_func dputs(3) { "Parsing #{params.inspect}" } return params if params.length == 0 layout_recurse.each { |l| if params.last && params.last.has_key?(l.name.to_s) value = params.last[l.name.to_s] rep = l.parse(value) if rep dputs(3) { "Converted #{value} to #{rep.to_s}" } params.last[l.name.to_s] = rep end end } return params end |
#reply(cmd, data = nil) ⇒ Object
Packs a command and a data in a hash. Multiple commands can be put together:
reply( 'update', { :hello => "hello world" } ) +
reply( 'self-update', 10 )
719 720 721 |
# File 'lib/qooxview/view.rb', line 719 def reply(cmd, data = nil) View.reply(cmd, data) end |
#reply_one_two(choice, one, two) ⇒ Object
743 744 745 |
# File 'lib/qooxview/view.rb', line 743 def reply_one_two(choice, one, two) View.reply_one_two(choice, one, two) end |
#reply_show_hide(show, hide) ⇒ Object
752 753 754 |
# File 'lib/qooxview/view.rb', line 752 def reply_show_hide(show, hide) View.reply_show_hide(show, hide) end |
#reply_table_columns_visible(visible, element) ⇒ Object
735 736 737 |
# File 'lib/qooxview/view.rb', line 735 def reply_table_columns_visible(visible, element) View.reply_table_columns_visible(visible, element) end |
#reply_visible(visible, element) ⇒ Object
727 728 729 |
# File 'lib/qooxview/view.rb', line 727 def reply_visible(visible, element) View.reply_visible(visible, element) end |
#respond_to?(cmd) ⇒ Boolean
816 817 818 |
# File 'lib/qooxview/view.rb', line 816 def respond_to?(cmd) return super(cmd) end |
#rpc_autofill(session, args) ⇒ Object
594 595 596 597 598 599 600 601 602 603 604 |
# File 'lib/qooxview/view.rb', line 594 def rpc_autofill(session, args) dputs(3) { "args is #{args.inspect}" } ret = [] args.keys.each { |a| if l = layout_find(a) dputs(3) { "found layout #{l} for #{a}" } ret += reply(:update, a => args[a]) end } ret end |
#rpc_button(session, name, *args) ⇒ Object
Call the children’s rpc_button_name, if present
620 621 622 |
# File 'lib/qooxview/view.rb', line 620 def (session, name, *args) call_named('button', session, name, *args) end |
#rpc_button_close(session, data) ⇒ Object
770 771 772 |
# File 'lib/qooxview/view.rb', line 770 def (session, data) reply(:window_hide) end |
#rpc_button_new(session, data) ⇒ Object
Standard button that cleans all fields
766 767 768 |
# File 'lib/qooxview/view.rb', line 766 def (session, data) reply(:empty) end |
#rpc_button_save(session, data) ⇒ Object
Standard button which just saves the entered data
761 762 763 |
# File 'lib/qooxview/view.rb', line 761 def (session, data) reply(:update, @data_class.save_data(data)) end |
#rpc_callback(session, name, *args) ⇒ Object
Call the children’s rpc_callback_name, if present
630 631 632 |
# File 'lib/qooxview/view.rb', line 630 def rpc_callback(session, name, *args) call_named('callback', session, name, *args) end |
#rpc_find(session, field, data) ⇒ Object
Standard search-field action to take
775 776 777 778 779 780 781 |
# File 'lib/qooxview/view.rb', line 775 def rpc_find(session, field, data) rep = @data_class.find(field, data) if not rep rep = {"#{field}" => data} end reply('update', rep) + rpc_update(session) end |
#rpc_list(session) ⇒ Object
404 405 406 407 |
# File 'lib/qooxview/view.rb', line 404 def rpc_list(session) dputs(5) { 'rpc_list' } View.rpc_list(session) end |
#rpc_list_choice(session, name, data) ⇒ Object
Upon choice of an entry in the list
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/qooxview/view.rb', line 635 def rpc_list_choice(session, name, data) if respond_to? "rpc_list_choice_#{name}" dputs(3) { "Calling rpc_list_choice-#{name}" } return send("rpc_list_choice_#{name}", session, data) elsif @main_tab dputs(3) { "Calling #{@main_tab}.rpc_list_choice" } mt = View.method_missing(@main_tab) if mt.respond_to? :rpc_list_choice_sub mt.rpc_list_choice_sub(session, name, data) else dputs(0) { "Error: #{@main_tab} doesn't listen to rpc_list_choice_sub and " + "neither does #{@name} listen to rpc_list_choice_#{name.to_s}" } end else dputs(0) { 'Error: Nobody listens to ' + "rpc_list_choice_#{name.to_s} in #{self.class.name.to_s} " + "- #{data.inspect}" } end end |
#rpc_list_tabs(session) ⇒ Object
531 532 533 534 |
# File 'lib/qooxview/view.rb', line 531 def rpc_list_tabs(session) dputs(3) { 'Showing tabs for @name' } reply('list', View.list(session, @name_tab)) end |
#rpc_show(session) ⇒ Object
Gives the GUI-elements for the active view
519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/qooxview/view.rb', line 519 def rpc_show(session) # user = Entities.Persons.match_by_session_id( session_id ) # TODO: test for permission dputs(5) { 'entered rpc_show' } reply('show', {:layout => layout_eval, :data_class => @data_class.class.to_s, :view_class => self.class.to_s}) + rpc_update_view(session) end |
#rpc_table(session, name, *args) ⇒ Object
Call the children’s rpc_button_name, if present
625 626 627 |
# File 'lib/qooxview/view.rb', line 625 def rpc_table(session, name, *args) call_named('table', session, name, *args) end |
#rpc_tabs_list_choice(session, args) ⇒ Object
493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/qooxview/view.rb', line 493 def rpc_tabs_list_choice(session, args) dputs(4) { "args is #{args.inspect}" } ret = [] if args.class == Hash args.keys.sort.each { |k| if args[k].class == Array dputs(3) { "Calling rpc_list_choice with #{k.inspect}" } ret += rpc_list_choice(session, k, args).to_a end } end dputs(3) { "ret is #{ret.inspect}" } ret end |
#rpc_tabs_show(session, args) ⇒ Object
508 509 510 511 |
# File 'lib/qooxview/view.rb', line 508 def rpc_tabs_show(session, args) rpc_show(session) + rpc_tabs_list_choice(session, args) end |
#rpc_tabs_update_view(session, args) ⇒ Object
513 514 515 516 |
# File 'lib/qooxview/view.rb', line 513 def rpc_tabs_update_view(session, args) rpc_update_view(session) + rpc_tabs_list_choice(session, args) end |
#rpc_update(session) ⇒ Object
Send the current values that are displayed
656 657 658 659 |
# File 'lib/qooxview/view.rb', line 656 def rpc_update(session) dputs(4) { 'rpc_update' } reply('update', update(session)) end |
#rpc_update_async(session) ⇒ Object
661 662 663 |
# File 'lib/qooxview/view.rb', line 661 def rpc_update_async(session) rpc_update(session) end |
#rpc_update_view(session, args = nil) ⇒ Object
Updates the layout of the form, especially the lists
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/qooxview/view.rb', line 555 def rpc_update_view(session, args = nil) #dputs_func # reply( 'empty', '*' ) + # reply( 'update', layout_recurse( @layout )) ret = [] if @update_layout dputs(3) { 'updating layout' } ret += update_layout(session) end if @auto_update > 0 dputs(3) { 'auto-updating' } ret += reply('auto_update', @auto_update * (@auto_update_send_values ? -1 : 1)) end if @auto_update_async > 0 dputs(3) { 'auto-updating async' } ret += reply('auto_update_async', @auto_update_async * (@auto_update_send_values ? -1 : 1)) end if @debug dputs(4) { 'debugging' } ret += reply('debug', 1) end if @update update = rpc_update(session) dputs(3) { "@update #{update.inspect}" } update and ret += update end if args dputs(3) { "Args: #{args.inspect}" } if args.class == Array args.flatten!(1) end ret += rpc_autofill(session, args) end dputs(3) { "showing: #{ret.inspect}" } ret end |
#set_data_class(d_c) ⇒ Object
This method lets you set the data_class of your view. Later on this will be automated by taking the first part of the view
155 156 157 158 |
# File 'lib/qooxview/view.rb', line 155 def set_data_class(d_c) dputs(3) { "Getting pointer #{d_c} for class #{@data_class}" } @data_class = Entities.send(d_c) end |
#show_add(cmds, args) ⇒ Object
Adds a new, general item
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/qooxview/view.rb', line 354 def show_add(cmds, args) value = Value.new(cmds, args) case value.dtype when 'block' # Shows a block as defined in an Entities - useful if the same # values will be shown in different views show_in_field(@data_class.blocks[value.name], value.args) when 'block_ro' # as "block", but all elements are read-only show_in_field(@data_class.blocks[value.name], value.args) when 'find_text' # Shows an input-box for any data needed, calling "match_by_" if something is # entered show_in_field [Value.simple('id_text', name)] when 'htmls' # HTML-fields aren't under a "field", but a "group" is enough do_container_start 'group' @layout.last.push value do_container_end else # Simple types that pass directly show_in_field [value] end end |
#show_arg(val, args, lay = @layout) ⇒ Object
Adds arguments to an already existing field
385 386 387 388 389 390 391 392 393 394 395 396 |
# File 'lib/qooxview/view.rb', line 385 def show_arg(val, args, lay = @layout) lay.each { |l| case l.class.name when 'Array' show_arg(val, args, l) when 'Value' if l.name == val l.args.merge! args end end } end |
#show_button(*buttons) ⇒ Object
Shows a button, takes care about placing it correctly. Takes also multiple buttons as arguments
329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/qooxview/view.rb', line 329 def (*) do_container_end if @actual.last == 'fields' do_container(.length > 1 ? 'hbox' : 'vbox', proc { .each { |b| # @layout.last.push [ :button, b, b, nil ] @layout.last.push Value.simple(:button, b) } } ) do_container_end if @actual.last == 'group' end |
#show_entity(name, entity, gui, field, args) ⇒ Object
Shows an entity in different formats
-
name - the internal name
-
entity - what entity to show
-
gui - how to display it (drop)
-
field - what field of the entity to display
294 295 296 |
# File 'lib/qooxview/view.rb', line 294 def show_entity(name, entity, gui, field, args) show_add(['entity', entity], [name, gui, field, args]) end |
#show_field(name, args = nil) ⇒ Object
Shows an existing field
299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/qooxview/view.rb', line 299 def show_field(name, args = nil) @data_class.blocks.each { |k, v| dputs(4) { "#{k}:#{v}" } fields = v.select { |f| f.name == name } if fields.length > 0 dputs(4) { fields.inspect } show_in_field fields end } args and show_arg(name, args) end |
#show_field_ro(name, args = {}) ⇒ Object
311 312 313 |
# File 'lib/qooxview/view.rb', line 311 def show_field_ro(name, args = {}) show_field(name, {:ro => true}.merge(args)) end |
#show_find(name) ⇒ Object
Shows an input-box for an existing field that will call a “match_by_” method if something is entered
317 318 319 320 321 322 323 324 325 |
# File 'lib/qooxview/view.rb', line 317 def show_find(name) a = [] @data_class.blocks.each { |k, v| a.push(*v.select { |b| b.name == name }.collect { |e| Value.simple(e.dtype, e.name, 'id') }) } show_in_field a end |
#show_in_field(a, args = {}) ⇒ Object
:nodoc:
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/qooxview/view.rb', line 272 def show_in_field(a, args={}) # :nodoc: return unless a if not @actual.last =~ /^fields/ do_container_start(%w( group fields )) end dputs(4) { "we'll show: #{a.inspect}" } [a].flatten.each { |v| dputs(4) { "Working on: #{v.dtype.inspect}: #{a.inspect}" } if v.dtype == 'entity' dputs(3) { "Showing entity #{v.inspect}" } end value = v.deep_clone value.args.merge!(args) @layout.last.push value } end |
#show_split_button(name, menu) ⇒ Object
342 343 344 345 346 347 348 349 350 351 |
# File 'lib/qooxview/view.rb', line 342 def (name, ) dputs(4) { "Adding a split-button #{name} with menu #{.inspect}" } do_container_end if @actual.last == 'fields' do_container('vbox', proc { @layout.last.push Value.new([:split_button], [name, {:menu => }]) } ) do_container_end if @actual.last == 'group' end |
#update(session) ⇒ Object
Returns the data for the fields as a hash
666 667 668 |
# File 'lib/qooxview/view.rb', line 666 def update(session) dputs(4) { 'update' } end |
#update_configured ⇒ Object
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
# File 'lib/qooxview/view.rb', line 860 def update_configured if defined? ConfigBase functions = ConfigBase.get_functions @configured = true @functions_need.each { |f| if not functions.index(f) dputs(3) { "Rejecting because #{f} is missing" } @configured = false end } @functions_reject.each { |f| if functions.index(f) dputs(3) { "Rejecting because #{f} is here" } @configured = false end } @values_need.keys.each { |k| v = @values_need[k] dputs(3) { "Testing whether #{k.inspect} has #{v.inspect}" } if data = ConfigBase.data_get(k) dputs(3) { "Found data #{data.inspect}" } if data.to_s != v.to_s @configured = false end else @configured = false end } dputs(3) { "Configured for #{self.name} is #{@configured}" } end end |
#update_form_data(data) ⇒ Object
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/qooxview/view.rb', line 700 def update_form_data(data) rep = {} not data and return rep d = data.to_hash dputs(5) { "update #{d.inspect} with layout #{@layout.inspect} - " + "#{layout_recurse(@layout).inspect}" } layout_recurse(@layout).each { |l| if d.has_key?(l.name) rep[l.name] = d[l.name] end } dputs(4) { "form_data #{rep.inspect}" } reply(:update, rep) end |
#update_layout(session) ⇒ Object
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/qooxview/view.rb', line 536 def update_layout(session) return [] if not @layout dputs(3) { 'Updating layout' } ret = [] layout_recurse(@layout).each { |l| case l.dtype when /list|select|entity/ if not l.args.has_key?(:lazy) values = l.to_a[3][:list_values] dputs(3) { "Here comes element #{l.name} with new list-value #{values.inspect}" } ret += reply(:empty_update, {l.name => values}) end end } dputs(3) { "Reply is #{ret.inspect}" } ret end |