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,35 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
-
3
- module Glimmer
4
- module SWT
5
- module CommandHandlers
6
- class ObserveCommandHandler
7
- REGEX_NESTED_OR_INDEXED_PROPERTY = /([^\[]+)(\[[^\]]+\])?/
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- command_symbol.to_s == "observe" and
12
- (
13
- (
14
- (args.size == 2) and
15
- (
16
- args[1].is_a?(Symbol) or
17
- args[1].is_a?(String)
18
- )
19
- )
20
- ) and
21
- !block.nil?
22
- end
23
-
24
- def do_handle(parent, command_symbol, *args, &block)
25
- observer = Observer.proc(&block)
26
- if args[1].to_s.match(REGEX_NESTED_OR_INDEXED_PROPERTY)
27
- observer.observe(ModelBinding.new(args[0], args[1]))
28
- else
29
- observer.observe(args[0], args[1])
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,24 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
-
3
- module Glimmer
4
- module SWT
5
- module CommandHandlers
6
- class PropertyCommandHandler
7
- include CommandHandler
8
-
9
- def can_handle?(parent, command_symbol, *args, &block)
10
- parent.respond_to?(:set_attribute) and
11
- parent.respond_to?(:has_attribute?) and
12
- args.size > 0 and
13
- block == nil and
14
- parent.has_attribute?(command_symbol, *args)
15
- end
16
-
17
- def do_handle(parent, command_symbol, *args, &block)
18
- parent.set_attribute(command_symbol, *args)
19
- nil
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,20 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_shell"
3
-
4
- module Glimmer
5
- module SWT
6
- module CommandHandlers
7
- class ShellCommandHandler
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- command_symbol.to_s == "shell"
12
- end
13
-
14
- def do_handle(parent, command_symbol, *args, &block)
15
- GShell.send(:new, *args)
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,34 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../g_shell"
3
- require File.dirname(__FILE__) + "/../g_tab_item_composite"
4
-
5
- module Glimmer
6
- module SWT
7
- module CommandHandlers
8
- class TabItemCommandHandler
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
- initial_condition = (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) &&
16
- command_symbol.to_s == "tab_item"
17
- if initial_condition
18
- if parent.widget.is_a?(TabFolder)
19
- return true
20
- else
21
- Glimmer.logger.error "tab_item widget may only be used directly under a tab_folder widget!"
22
- end
23
- end
24
- false
25
- end
26
-
27
- def do_handle(parent, command_symbol, *args, &block)
28
- tab_item = GWidget.new(command_symbol.to_s, parent.widget, args)
29
- GTabItemComposite.new(tab_item, parent.widget, args)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,29 +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
- # Responsible for providing a readable keyword (command symbol) to capture
9
- # and return column properties for use in TreeItemsDataBindingCommandHandler
10
- class TableColumnPropertiesDataBindingCommandHandler
11
- include CommandHandler
12
-
13
- include_package 'org.eclipse.swt'
14
- include_package 'org.eclipse.swt.widgets'
15
-
16
- def can_handle?(parent, command_symbol, *args, &block)
17
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
18
- parent.widget.is_a?(Table) and
19
- command_symbol.to_s == "column_properties" and
20
- block == nil
21
- end
22
-
23
- def do_handle(parent, command_symbol, *args, &block)
24
- args
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,34 +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__) + "/../table_items_binding"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- #Depends on BindCommandHandler and TableColumnPropertiesDataBindingCommandHandler
10
- class TableItemsDataBindingCommandHandler
11
- include CommandHandler
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?(Table) and
18
- command_symbol.to_s == "items" and
19
- args.size == 2 and
20
- args[0].is_a?(ModelBinding) and
21
- args[0].evaluate_property.is_a?(Array) and
22
- args[1].is_a?(Array) and
23
- block == nil
24
- end
25
-
26
- def do_handle(parent, command_symbol, *args, &block)
27
- model_binding = args[0]
28
- column_properties = args[1]
29
- TableItemsBinding.new(parent, model_binding, column_properties)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,33 +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__) + "/../tree_items_binding"
5
-
6
- module Glimmer
7
- module SWT
8
- module CommandHandlers
9
- class TreeItemsDataBindingCommandHandler
10
- include CommandHandler
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?(Tree)) and
17
- (command_symbol.to_s == "items") and
18
- (args.size == 2) and
19
- (args[0].is_a?(ModelBinding)) and
20
- (!args[0].evaluate_property.is_a?(Array)) and
21
- (args[1].is_a?(Array) && !args[1].empty? && args[1].first.is_a?(Hash)) and
22
- (block == nil)
23
- end
24
-
25
- def do_handle(parent, command_symbol, *args, &block)
26
- model_binding = args[0]
27
- tree_properties = args[1]
28
- TreeItemsBinding.new(parent, model_binding, tree_properties)
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,29 +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
- # Responsible for providing a readable keyword (command symbol) to capture
9
- # and return tree properties for use in TreeItemsDataBindingCommandHandler
10
- class TreePropertiesDataBindingCommandHandler
11
- include CommandHandler
12
-
13
- include_package 'org.eclipse.swt'
14
- include_package 'org.eclipse.swt.widgets'
15
-
16
- def can_handle?(parent, command_symbol, *args, &block)
17
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
18
- parent.widget.is_a?(Tree) and
19
- command_symbol.to_s == "tree_properties" and
20
- block == nil
21
- end
22
-
23
- def do_handle(parent, command_symbol, *args, &block)
24
- args
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../custom_widget"
3
- require File.dirname(__FILE__) + "/../g_widget"
4
-
5
- module Glimmer
6
- module SWT
7
- module CommandHandlers
8
- class WidgetCommandHandler
9
- include CommandHandler
10
-
11
- include_package 'org.eclipse.swt.widgets'
12
- include_package 'org.eclipse.swt.browser'
13
-
14
- def can_handle?(parent, command_symbol, *args, &block)
15
- (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
16
- command_symbol.to_s != "shell" and
17
- GWidget.widget_exists?(command_symbol.to_s)
18
- end
19
-
20
- def do_handle(parent, command_symbol, *args, &block)
21
- Glimmer.logger.debug "widget styles are: " + args.inspect
22
- GWidget.new(command_symbol.to_s, parent.widget, args)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,48 +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
- # TODO rename to observation command handler (or keyword handler)
9
-
10
- class WidgetListenerCommandHandler
11
- include CommandHandler
12
-
13
- include_package 'org.eclipse.swt.widgets'
14
-
15
- def can_handle?(parent, command_symbol, *args, &block)
16
- widget_parentage = (parent.is_a?(GWidget) || parent.is_a?(CustomWidget))
17
- Glimmer.logger.debug "parent is a widget: #{widget_parentage}"
18
- return unless widget_parentage
19
- Glimmer.logger.debug "keyword starts with on_: #{command_symbol.to_s.start_with?('on_')}"
20
- return unless command_symbol.to_s.start_with?('on_')
21
- Glimmer.logger.debug "args are empty?: #{args.empty?}"
22
- return unless args.empty?
23
- Glimmer.logger.debug "block exists?: #{!block.nil?}"
24
- return unless !block.nil?
25
- result = parent.can_handle_observation_request?(command_symbol.to_s)
26
- Glimmer.logger.debug "can add listener? #{result}"
27
- result
28
- end
29
-
30
- def do_handle(parent, command_symbol, *args, &block)
31
- parent.handle_observation_request(command_symbol.to_s, &block)
32
- ListenerParent.new #TODO refactor and move to models
33
- end
34
-
35
- #TODO refactor and move to separate file
36
- class ListenerParent
37
- include Parent
38
-
39
- def process_block(block)
40
- #NOOP
41
- end
42
-
43
- end
44
-
45
- end
46
- end
47
- end
48
- end
@@ -1,41 +0,0 @@
1
- require_relative 'g_swt'
2
- require_relative 'g_display'
3
-
4
- module Glimmer
5
- module SWT
6
- class GColor
7
- attr_reader :display, :red, :green, :blue, :alpha
8
-
9
- include_package 'org.eclipse.swt.graphics'
10
-
11
- class << self
12
- include_package 'org.eclipse.swt'
13
-
14
- # TODO consider refactoring to simply for and returning GColor instead for consistency
15
-
16
- def color_for(display = nil, standard_color)
17
- standard_color = "color_#{standard_color}".to_sym unless standard_color.to_s.include?('color_')
18
- display ||= GDisplay.instance.display
19
- display.getSystemColor(GSWT[standard_color])
20
- end
21
- end
22
-
23
- def initialize(display, red, green, blue, alpha = nil)
24
- @display = display
25
- @red = red
26
- @green = green
27
- @blue = blue
28
- @alpha = alpha
29
- end
30
-
31
- def color
32
- @color ||= Color.new(@display, *[@red, @green, @blue, @alpha].compact)
33
- end
34
-
35
- def display=(a_display)
36
- @display = a_display
37
- @color = nil
38
- end
39
- end
40
- end
41
- end
@@ -1,36 +0,0 @@
1
- module Glimmer
2
- module SWT
3
- # Wrapper around SWT Display
4
- class GDisplay
5
- include_package 'org.eclipse.swt.widgets'
6
-
7
- class << self
8
- def instance(*args)
9
- if @instance.nil? || @instance.display.isDisposed
10
- @instance = GDisplay.new(*args)
11
- end
12
- @instance
13
- end
14
- end
15
-
16
- # SWT Display object wrapped
17
- attr_reader :display
18
-
19
- def initialize(*args)
20
- @display = Display.new(*args)
21
- end
22
-
23
- def dispose
24
- @display.dispose
25
- end
26
-
27
- def async_exec(&block)
28
- @display.asyncExec(GRunnable.new(&block))
29
- end
30
-
31
- def sync_exec(&block)
32
- @display.syncExec(GRunnable.new(&block))
33
- end
34
- end
35
- end
36
- end
@@ -1,71 +0,0 @@
1
- require_relative 'g_swt'
2
-
3
- module Glimmer
4
- module SWT
5
- class GFont
6
- ERROR_INVALID_FONT_STYLE = " is an invalid font style! Valid values are :normal, :bold, and :italic"
7
- FONT_STYLES = [:normal, :bold, :italic]
8
- include_package 'org.eclipse.swt.graphics'
9
-
10
- attr_reader :g_widget
11
- attr_accessor :display
12
-
13
- class << self
14
- def for(g_widget)
15
- @instances ||= {}
16
- unless @instances[g_widget]
17
- @instances[g_widget] = new(g_widget)
18
- g_widget.on_widget_disposed do |dispose_event|
19
- @instances.delete(g_widget)
20
- end
21
- end
22
- @instances[g_widget]
23
- end
24
- end
25
-
26
- def initialize(g_widget, display = nil)
27
- @g_widget = g_widget
28
- @display = display || @g_widget.widget.display
29
- end
30
-
31
- def g_widget=(a_widget)
32
- @g_widget = a_widget
33
- @font_datum = nil
34
- end
35
-
36
- def font_datum
37
- @font_datum ||= @g_widget.widget.getFont.getFontData[0]
38
- end
39
-
40
- def name
41
- font_datum.getName
42
- end
43
-
44
- def height
45
- font_datum.getHeight
46
- end
47
-
48
- def style
49
- font_datum.getStyle
50
- end
51
-
52
- def font(font_properties)
53
- detect_invalid_font_property(font_properties)
54
- font_properties[:style] = GSWT[*font_properties[:style]]
55
- font_data_args = [:name, :height, :style].map do |font_property_name|
56
- font_properties[font_property_name] || send(font_property_name)
57
- end
58
- font_datum = FontData.new(*font_data_args)
59
- Font.new(@display, font_datum)
60
- end
61
-
62
- def detect_invalid_font_property(font_properties)
63
- [font_properties[:style]].flatten.select do |style|
64
- style.is_a?(Symbol) || style.is_a?(String)
65
- end.each do |style|
66
- raise style.to_s + ERROR_INVALID_FONT_STYLE if !FONT_STYLES.include?(style.to_sym)
67
- end
68
- end
69
- end
70
- end
71
- end