glimmer 0.4.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +324 -59
  3. data/lib/glimmer.rb +54 -63
  4. data/lib/glimmer/data_binding/list_selection_binding.rb +52 -0
  5. data/lib/glimmer/{swt → data_binding}/model_binding.rb +33 -5
  6. data/lib/glimmer/{swt → data_binding}/observable.rb +6 -3
  7. data/lib/glimmer/{swt → data_binding}/observable_array.rb +3 -1
  8. data/lib/glimmer/{swt → data_binding}/observable_model.rb +3 -2
  9. data/lib/glimmer/data_binding/observable_widget.rb +17 -0
  10. data/lib/glimmer/{swt → data_binding}/observer.rb +3 -3
  11. data/lib/glimmer/{shine.rb → data_binding/shine.rb} +2 -2
  12. data/lib/glimmer/{swt → data_binding}/table_items_binding.rb +12 -11
  13. data/lib/glimmer/{swt → data_binding}/tree_items_binding.rb +15 -12
  14. data/lib/glimmer/{swt → data_binding}/widget_binding.rb +2 -1
  15. data/lib/glimmer/dsl.rb +26 -0
  16. data/lib/glimmer/dsl/async_exec_expression.rb +12 -0
  17. data/lib/glimmer/dsl/bind_expression.rb +44 -0
  18. data/lib/glimmer/dsl/color_expression.rb +28 -0
  19. data/lib/glimmer/dsl/column_properties_expression.rb +22 -0
  20. data/lib/glimmer/dsl/combo_selection_data_binding_expression.rb +40 -0
  21. data/lib/glimmer/dsl/custom_widget_expression.rb +35 -0
  22. data/lib/glimmer/dsl/data_binding_expression.rb +33 -0
  23. data/lib/glimmer/dsl/display_expression.rb +12 -0
  24. data/lib/glimmer/dsl/engine.rb +80 -0
  25. data/lib/glimmer/dsl/exec_expression.rb +23 -0
  26. data/lib/glimmer/dsl/expression.rb +44 -0
  27. data/lib/glimmer/dsl/expression_handler.rb +48 -0
  28. data/lib/glimmer/dsl/layout_data_expression.rb +24 -0
  29. data/lib/glimmer/dsl/layout_expression.rb +26 -0
  30. data/lib/glimmer/dsl/list_selection_data_binding_expression.rb +42 -0
  31. data/lib/glimmer/dsl/observe_expression.rb +27 -0
  32. data/lib/glimmer/dsl/parent_expression.rb +12 -0
  33. data/lib/glimmer/dsl/property_expression.rb +20 -0
  34. data/lib/glimmer/dsl/shell_expression.rb +15 -0
  35. data/lib/glimmer/dsl/static_expression.rb +38 -0
  36. data/lib/glimmer/dsl/swt_expression.rb +23 -0
  37. data/lib/glimmer/dsl/sync_exec_expression.rb +13 -0
  38. data/lib/glimmer/dsl/tab_item_expression.rb +31 -0
  39. data/lib/glimmer/dsl/table_items_data_binding_expression.rb +29 -0
  40. data/lib/glimmer/dsl/tree_items_data_binding_expression.rb +30 -0
  41. data/lib/glimmer/dsl/tree_properties_expression.rb +24 -0
  42. data/lib/glimmer/dsl/widget_expression.rb +26 -0
  43. data/lib/glimmer/dsl/widget_listener_expression.rb +27 -0
  44. data/lib/glimmer/error.rb +6 -0
  45. data/lib/glimmer/invalid_keyword_error.rb +6 -0
  46. data/lib/glimmer/launcher.rb +39 -23
  47. data/lib/glimmer/swt/color_proxy.rb +48 -0
  48. data/lib/glimmer/swt/display_proxy.rb +49 -0
  49. data/lib/glimmer/swt/font_proxy.rb +72 -0
  50. data/lib/glimmer/swt/layout_data_proxy.rb +73 -0
  51. data/lib/glimmer/swt/{g_layout.rb → layout_proxy.rb} +24 -25
  52. data/lib/glimmer/swt/packages.rb +13 -0
  53. data/lib/glimmer/swt/shell_proxy.rb +108 -0
  54. data/lib/glimmer/swt/{g_swt.rb → swt_proxy.rb} +12 -5
  55. data/lib/glimmer/swt/tab_item_proxy.rb +59 -0
  56. data/lib/glimmer/swt/widget_listener_proxy.rb +17 -0
  57. data/lib/glimmer/swt/widget_proxy.rb +366 -0
  58. data/lib/glimmer/{swt → ui}/custom_shell.rb +4 -4
  59. data/lib/glimmer/{swt → ui}/custom_widget.rb +67 -51
  60. data/lib/glimmer/{swt → ui}/video.rb +13 -13
  61. data/lib/glimmer/{swt → util}/proc_tracker.rb +1 -1
  62. data/vendor/swt/linux/swt.jar +0 -0
  63. data/vendor/swt/mac/swt.jar +0 -0
  64. data/vendor/swt/windows/swt.jar +0 -0
  65. metadata +66 -70
  66. data/lib/glimmer/command_handler.rb +0 -15
  67. data/lib/glimmer/command_handler_chain_factory.rb +0 -32
  68. data/lib/glimmer/command_handler_chain_link.rb +0 -25
  69. data/lib/glimmer/command_handlers.rb +0 -46
  70. data/lib/glimmer/ext/module.rb +0 -20
  71. data/lib/glimmer/parent.rb +0 -7
  72. data/lib/glimmer/swt/command_handlers/bind_command_handler.rb +0 -56
  73. data/lib/glimmer/swt/command_handlers/color_command_handler.rb +0 -30
  74. data/lib/glimmer/swt/command_handlers/combo_selection_data_binding_command_handler.rb +0 -44
  75. data/lib/glimmer/swt/command_handlers/custom_widget_command_handler.rb +0 -26
  76. data/lib/glimmer/swt/command_handlers/data_binding_command_handler.rb +0 -40
  77. data/lib/glimmer/swt/command_handlers/display_command_handler.rb +0 -20
  78. data/lib/glimmer/swt/command_handlers/layout_command_handler.rb +0 -27
  79. data/lib/glimmer/swt/command_handlers/layout_data_command_handler.rb +0 -27
  80. data/lib/glimmer/swt/command_handlers/list_selection_data_binding_command_handler.rb +0 -49
  81. data/lib/glimmer/swt/command_handlers/observe_command_handler.rb +0 -35
  82. data/lib/glimmer/swt/command_handlers/property_command_handler.rb +0 -24
  83. data/lib/glimmer/swt/command_handlers/shell_command_handler.rb +0 -20
  84. data/lib/glimmer/swt/command_handlers/tab_item_command_handler.rb +0 -34
  85. data/lib/glimmer/swt/command_handlers/table_column_properties_data_binding_command_handler.rb +0 -29
  86. data/lib/glimmer/swt/command_handlers/table_items_data_binding_command_handler.rb +0 -34
  87. data/lib/glimmer/swt/command_handlers/tree_items_data_binding_command_handler.rb +0 -33
  88. data/lib/glimmer/swt/command_handlers/tree_properties_data_binding_command_handler.rb +0 -29
  89. data/lib/glimmer/swt/command_handlers/widget_command_handler.rb +0 -27
  90. data/lib/glimmer/swt/command_handlers/widget_listener_command_handler.rb +0 -48
  91. data/lib/glimmer/swt/g_color.rb +0 -41
  92. data/lib/glimmer/swt/g_display.rb +0 -36
  93. data/lib/glimmer/swt/g_font.rb +0 -71
  94. data/lib/glimmer/swt/g_layout_data.rb +0 -56
  95. data/lib/glimmer/swt/g_runnable.rb +0 -15
  96. data/lib/glimmer/swt/g_shell.rb +0 -106
  97. data/lib/glimmer/swt/g_tab_item_composite.rb +0 -41
  98. data/lib/glimmer/swt/g_widget.rb +0 -349
  99. data/lib/glimmer/swt/g_widget_listener.rb +0 -12
  100. data/lib/glimmer/swt/list_selection_binding.rb +0 -47
  101. data/lib/glimmer/swt_packages.rb +0 -15
  102. data/lib/glimmer/xml/command_handlers/html_command_handler.rb +0 -50
  103. data/lib/glimmer/xml/command_handlers/xml_command_handler.rb +0 -23
  104. data/lib/glimmer/xml/command_handlers/xml_name_space_command_handler.rb +0 -36
  105. data/lib/glimmer/xml/command_handlers/xml_tag_command_handler.rb +0 -28
  106. data/lib/glimmer/xml/command_handlers/xml_text_command_handler.rb +0 -24
  107. data/lib/glimmer/xml/depth_first_search_iterator.rb +0 -20
  108. data/lib/glimmer/xml/name_space_visitor.rb +0 -21
  109. data/lib/glimmer/xml/node.rb +0 -84
  110. data/lib/glimmer/xml/node_visitor.rb +0 -13
  111. data/lib/glimmer/xml/xml_visitor.rb +0 -63
  112. data/lib/glimmer/xml_command_handlers.rb +0 -18
@@ -1,15 +0,0 @@
1
- module Glimmer
2
- # rename to keyword handler
3
-
4
- module CommandHandler
5
- def can_handle?(parent, command_symbol, *args, &block)
6
- raise "must be implemented by a class"
7
- end
8
-
9
- # TODO rename do_handle to just handle
10
-
11
- def do_handle(parent, command_symbol, *args, &block)
12
- raise "must be implemented by a class"
13
- end
14
- end
15
- end
@@ -1,32 +0,0 @@
1
- require File.dirname(__FILE__) + "/command_handler_chain_link"
2
-
3
- module Glimmer
4
- class CommandHandlerChainFactory
5
- @@dsls = {}
6
-
7
- def self.def_dsl(dsl, *command_handler_array)
8
- @@last_chain_link = nil
9
- @@chain = nil
10
- command_handler_array.each do |command_handler|
11
- Glimmer.logger.debug "Loading #{command_handler.class.to_s}..."
12
- chain_link = CommandHandlerChainLink.new(command_handler)
13
- @@last_chain_link.chain_to(chain_link) if @@last_chain_link
14
- @@last_chain_link = chain_link
15
- @@chain = chain_link unless @@chain
16
- end
17
- @@dsls[dsl] = {
18
- :last_chain_link => @@last_chain_link,
19
- :chain => @@chain
20
- }
21
- end
22
-
23
- def self.select_dsl(dsl)
24
- @@last_chain_link = @@dsls[dsl][:last_chain_link]
25
- @@chain = @@dsls[dsl][:chain]
26
- end
27
-
28
- def self.chain
29
- @@chain
30
- end
31
- end
32
- end
@@ -1,25 +0,0 @@
1
- module Glimmer
2
- class CommandHandlerChainLink
3
- def initialize(command_handler)
4
- @command_handler = command_handler
5
- end
6
- def chain_to(next_chain_link)
7
- @next_chain_link = next_chain_link
8
- end
9
- def handle(parent, command_symbol, *args, &block)
10
- if (@command_handler.can_handle?(parent, command_symbol, *args, &block))
11
- Glimmer.logger.debug "#{@command_handler.class.to_s} will handle command: #{command_symbol} with arguments #{args}"
12
- return @command_handler.do_handle(parent, command_symbol, *args, &block)
13
- elsif @next_chain_link
14
- return @next_chain_link.handle(parent, command_symbol, *args, &block)
15
- else
16
- # TODO see if we need a better response here (e.g. dev mode error raising vs production mode silent failure)
17
- message = "Glimmer keyword #{command_symbol} with args #{args} cannot be handled"
18
- message += " inside parent #{parent.inspect}" if parent
19
- message += "! Check the validity of the code."
20
- # Glimmer.logger.error message
21
- raise message
22
- end
23
- end
24
- end
25
- end
@@ -1,46 +0,0 @@
1
- require_relative "command_handler_chain_factory"
2
- require_relative "swt/command_handlers/observe_command_handler"
3
- require_relative "swt/command_handlers/color_command_handler"
4
- require_relative "swt/command_handlers/display_command_handler"
5
- require_relative "swt/command_handlers/shell_command_handler"
6
- require_relative "swt/command_handlers/layout_command_handler"
7
- require_relative "swt/command_handlers/layout_data_command_handler"
8
- require_relative "swt/command_handlers/widget_listener_command_handler"
9
- require_relative "swt/command_handlers/bind_command_handler"
10
- require_relative "swt/command_handlers/tab_item_command_handler"
11
- require_relative "swt/command_handlers/combo_selection_data_binding_command_handler"
12
- require_relative "swt/command_handlers/list_selection_data_binding_command_handler"
13
- require_relative "swt/command_handlers/tree_items_data_binding_command_handler"
14
- require_relative "swt/command_handlers/tree_properties_data_binding_command_handler"
15
- require_relative "swt/command_handlers/table_items_data_binding_command_handler"
16
- require_relative "swt/command_handlers/table_column_properties_data_binding_command_handler"
17
- require_relative "swt/command_handlers/data_binding_command_handler"
18
- require_relative "swt/command_handlers/property_command_handler"
19
- require_relative "swt/command_handlers/widget_command_handler"
20
- require_relative "swt/command_handlers/custom_widget_command_handler"
21
-
22
- # TODO move into SWT namespace
23
- module Glimmer
24
- # edit to add more command handlers and extend Glimmer
25
- CommandHandlerChainFactory.def_dsl(:swt,
26
- SWT::CommandHandlers::ObserveCommandHandler.new,
27
- SWT::CommandHandlers::DisplayCommandHandler.new,
28
- SWT::CommandHandlers::ShellCommandHandler.new,
29
- SWT::CommandHandlers::LayoutDataCommandHandler.new,
30
- SWT::CommandHandlers::LayoutCommandHandler.new,
31
- SWT::CommandHandlers::WidgetListenerCommandHandler.new,
32
- SWT::CommandHandlers::BindCommandHandler.new,
33
- SWT::CommandHandlers::TabItemCommandHandler.new,
34
- SWT::CommandHandlers::ComboSelectionDataBindingCommandHandler.new,
35
- SWT::CommandHandlers::ListSelectionDataBindingCommandHandler.new,
36
- SWT::CommandHandlers::TreeItemsDataBindingCommandHandler.new,
37
- SWT::CommandHandlers::TreePropertiesDataBindingCommandHandler.new,
38
- SWT::CommandHandlers::TableItemsDataBindingCommandHandler.new,
39
- SWT::CommandHandlers::TableColumnPropertiesDataBindingCommandHandler.new,
40
- SWT::CommandHandlers::DataBindingCommandHandler.new,
41
- SWT::CommandHandlers::ColorCommandHandler.new,
42
- SWT::CommandHandlers::PropertyCommandHandler.new,
43
- SWT::CommandHandlers::WidgetCommandHandler.new,
44
- SWT::CommandHandlers::CustomWidgetCommandHandler.new
45
- )
46
- end
@@ -1,20 +0,0 @@
1
- class Module
2
- # TODO improve this (make it work dynamically per DSL loaded)
3
- begin
4
- instance_method(:const_missing_without_glimmer)
5
- rescue
6
- alias const_missing_without_glimmer const_missing
7
-
8
- def const_missing(constant)
9
- return const_missing_without_glimmer(constant) if @const_missing_without_glimmer_constant
10
- @const_missing_without_glimmer_constant = constant
11
- ::Glimmer::SWT.const_get(constant)
12
- rescue LoadError => e
13
- const_missing_without_glimmer(constant)
14
- rescue => e
15
- const_missing_without_glimmer(constant)
16
- ensure
17
- @const_missing_without_glimmer_constant = nil
18
- end
19
- end
20
- end
@@ -1,7 +0,0 @@
1
- module Glimmer
2
- module Parent
3
- def process_block(block)
4
- raise "must be implemented by a class"
5
- end
6
- end
7
- end
@@ -1,56 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_widget"
3
- require File.dirname(__FILE__) + "/../custom_widget"
4
- require File.dirname(__FILE__) + "/../model_binding"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- # Responsible for setting up the return value of the bind keyword (command symbol)
10
- # as a ModelBinding. It is then used by another command handler like
11
- # DataBindingCommandHandler for text and selection properties on Text and Spinner
12
- # or TableItemsDataBindingCommandHandler for items in a Table
13
- class BindCommandHandler
14
- include CommandHandler
15
-
16
- include_package 'org.eclipse.swt.widgets'
17
-
18
- def can_handle?(parent, command_symbol, *args, &block)
19
- # TODO refactor this long condition below
20
- (
21
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
22
- command_symbol.to_s == "bind" and
23
- (
24
- (
25
- (args.size == 2) and
26
- (
27
- args[1].is_a?(Symbol) or
28
- args[1].is_a?(String)
29
- )
30
- ) or
31
- (
32
- (args.size == 3) and
33
- (args[1].is_a?(Symbol) or args[1].is_a?(String)) and
34
- (args[2].is_a?(Symbol) or args[2].is_a?(String) or args[2].is_a?(Hash))
35
- ) or
36
- (
37
- (args.size == 4) and
38
- (args[1].is_a?(Symbol) or args[1].is_a?(String)) and
39
- (args[2].is_a?(Symbol) or args[2].is_a?(String)) and
40
- (args[3].is_a?(Hash))
41
- )
42
- ) and
43
- block == nil
44
- )
45
- end
46
-
47
- def do_handle(parent, command_symbol, *args, &block)
48
- property_type = args[2] if (args.size == 3) && !args[2].is_a?(Hash)
49
- binding_options = args[2] if args[2].is_a?(Hash)
50
- binding_options = args[3] if args[3].is_a?(Hash)
51
- ModelBinding.new(args[0], args[1].to_s, property_type, binding_options)
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,30 +0,0 @@
1
- require_relative '../../command_handler'
2
- require_relative '../g_color'
3
-
4
- module Glimmer
5
- module SWT
6
- module CommandHandlers
7
- class ColorCommandHandler
8
- include CommandHandler
9
-
10
- include_package 'org.eclipse.swt.widgets'
11
-
12
- def can_handle?(parent, command_symbol, *args, &block)
13
- ['rgba', 'rgb'].include?(command_symbol.to_s) and
14
- (3..5).include?(args.count)
15
- end
16
-
17
- def do_handle(parent, command_symbol, *args, &block)
18
- if args.first.is_a?(Display) || args.first.nil?
19
- display = args.delete_at(0)
20
- elsif parent.is_a?(GWidget) || parent.is_a?(CustomWidget)
21
- display = parent.widget.display
22
- else
23
- display = GDisplay.instance.display
24
- end
25
- GColor.new(display, *args)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,44 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_widget"
3
- require File.dirname(__FILE__) + "/../custom_widget"
4
-
5
- module Glimmer
6
- module SWT
7
- module CommandHandlers
8
- class ComboSelectionDataBindingCommandHandler
9
- include CommandHandler
10
- include Glimmer
11
-
12
- include_package 'org.eclipse.swt.widgets'
13
-
14
- def can_handle?(parent, command_symbol, *args, &block)
15
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
16
- parent.widget.is_a?(Combo) and
17
- command_symbol.to_s == "selection" and
18
- args.size == 1 and
19
- args[0].is_a?(ModelBinding) and
20
- args[0].evaluate_options_property.is_a?(Array) and
21
- block == nil
22
- end
23
-
24
- def do_handle(parent, command_symbol, *args, &block)
25
- model_binding = args[0]
26
- widget_binding = WidgetBinding.new(parent, "items")
27
- widget_binding.call(model_binding.evaluate_options_property)
28
- model = model_binding.base_model
29
- widget_binding.observe(model, model_binding.options_property_name)
30
-
31
- widget_binding = WidgetBinding.new(parent, "text")
32
- widget_binding.call(model_binding.evaluate_property)
33
- widget_binding.observe(model, model_binding.property_name_expression)
34
-
35
- add_contents(parent) {
36
- on_widget_selected {
37
- model_binding.call(widget_binding.evaluate_property)
38
- }
39
- }
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,26 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../custom_widget"
3
- require File.dirname(__FILE__) + "/../custom_shell"
4
- require File.dirname(__FILE__) + "/../g_widget"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- class CustomWidgetCommandHandler
10
- include CommandHandler
11
-
12
- def can_handle?(parent, command_symbol, *args, &block)
13
- custom_widget_class = CustomWidget.for(command_symbol)
14
- custom_widget_class and
15
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget) || custom_widget_class.ancestors.include?(CustomShell))
16
- end
17
-
18
- def do_handle(parent, command_symbol, *args, &block)
19
- options = args.last.is_a?(Hash) ? args.pop : {}
20
- Glimmer.logger.debug "Custom widget #{command_symbol} styles are: [" + args.inspect + "] and options are: #{options}"
21
- CustomWidget.for(command_symbol).new(parent, *args, options, &block)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_widget"
3
- require File.dirname(__FILE__) + "/../custom_widget"
4
- require File.dirname(__FILE__) + "/../observable_model"
5
- require File.dirname(__FILE__) + "/../model_binding"
6
- require File.dirname(__FILE__) + "/../widget_binding"
7
-
8
- module Glimmer
9
- module SWT
10
- module CommandHandlers
11
- # Responsible for wiring two-way data-binding for text and selection properties
12
- # on Text, Button, and Spinner widgets.
13
- # Does so by using the output of the bind(model, property) command in the form
14
- # of a ModelBinding, which is then connected to an anonymous widget observer
15
- # (aka widget_data_binder as per widget_data_binders array)
16
- #
17
- # Depends on BindCommandHandler
18
- class DataBindingCommandHandler
19
- include CommandHandler
20
-
21
- include_package 'org.eclipse.swt.widgets'
22
-
23
- def can_handle?(parent, command_symbol, *args, &block)
24
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
25
- args.size == 1 and
26
- args[0].is_a?(ModelBinding)
27
- end
28
-
29
- def do_handle(parent, command_symbol, *args, &block)
30
- model_binding = args[0]
31
- widget_binding_parameters = [parent, command_symbol.to_s]
32
- widget_binding = WidgetBinding.new(*widget_binding_parameters)
33
- widget_binding.call(model_binding.evaluate_property)
34
- widget_binding.observe(model_binding)
35
- parent.add_observer(model_binding, command_symbol.to_s.to_sym) #TODO consider reversing statement
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,20 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_display"
3
-
4
- module Glimmer
5
- module SWT
6
- module CommandHandlers
7
- class DisplayCommandHandler
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- command_symbol.to_s == "display"
12
- end
13
-
14
- def do_handle(parent, command_symbol, *args, &block)
15
- GDisplay.instance(*args)
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_layout"
3
-
4
- module Glimmer
5
- module SWT
6
- module CommandHandlers
7
- class LayoutCommandHandler
8
- include CommandHandler
9
-
10
- include_package 'org.eclipse.swt.widgets'
11
- include_package 'org.eclipse.swt.layout'
12
-
13
- def can_handle?(parent, command_symbol, *args, &block)
14
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
15
- parent.widget.is_a?(Composite) and
16
- command_symbol.to_s.end_with?('_layout') and
17
- GLayout.layout_exists?(command_symbol.to_s)
18
- end
19
-
20
- def do_handle(parent, command_symbol, *args, &block)
21
- Glimmer.logger.debug "Layout #{command_symbol} args are: #{args.inspect}"
22
- GLayout.new(command_symbol.to_s, parent.widget, args)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_widget"
3
- require File.dirname(__FILE__) + "/../custom_widget"
4
- require File.dirname(__FILE__) + "/../g_layout_data"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- class LayoutDataCommandHandler
10
- include CommandHandler
11
-
12
- include_package 'org.eclipse.swt.widgets'
13
- include_package 'org.eclipse.swt.layout'
14
-
15
- def can_handle?(parent, command_symbol, *args, &block)
16
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
17
- command_symbol.to_s == 'layout_data'
18
- end
19
-
20
- def do_handle(parent, command_symbol, *args, &block)
21
- Glimmer.logger.debug "Layout Data args are: #{args.inspect}"
22
- GLayoutData.new(parent.widget, args)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_widget"
3
- require File.dirname(__FILE__) + "/../custom_widget"
4
- require File.dirname(__FILE__) + "/../list_selection_binding"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- class ListSelectionDataBindingCommandHandler
10
- include CommandHandler
11
- include Glimmer
12
-
13
- include_package 'org.eclipse.swt.widgets'
14
-
15
- def can_handle?(parent, command_symbol, *args, &block)
16
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
17
- parent.widget.is_a?(List) and
18
- command_symbol.to_s == "selection" and
19
- args.size == 1 and
20
- args[0].is_a?(ModelBinding) and
21
- args[0].evaluate_options_property.is_a?(Array) and
22
- block == nil
23
- end
24
-
25
- def do_handle(parent, command_symbol, *args, &block)
26
- model_binding = args[0]
27
- widget_binding = WidgetBinding.new(parent, "items")
28
- widget_binding.call(model_binding.evaluate_options_property)
29
- model = model_binding.base_model
30
- #TODO make this options observer dependent and all similar observers in widget specific data binding handlers
31
- widget_binding.observe(model, model_binding.options_property_name)
32
-
33
- property_type = :string
34
- property_type = :array if parent.has_style?(:multi)
35
- list_selection_binding = ListSelectionBinding.new(parent, property_type)
36
- list_selection_binding.call(model_binding.evaluate_property)
37
- #TODO check if nested data binding works for list widget and other widgets that need custom data binding
38
- list_selection_binding.observe(model, model_binding.property_name_expression)
39
-
40
- add_contents(parent) {
41
- on_widget_selected {
42
- model_binding.call(list_selection_binding.evaluate_property)
43
- }
44
- }
45
- end
46
- end
47
- end
48
- end
49
- end