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,12 +0,0 @@
1
- module Glimmer
2
- module SWT
3
- class GWidgetListener
4
-
5
- attr_reader :listener
6
-
7
- def initialize(listener)
8
- @listener = listener
9
- end
10
- end
11
- end
12
- end
@@ -1,47 +0,0 @@
1
- require_relative 'observable'
2
- require_relative 'observer'
3
-
4
- module Glimmer
5
- module SWT
6
- # SWT List widget selection binding
7
- class ListSelectionBinding
8
- include Glimmer
9
- include Observable
10
- include Observer
11
-
12
- attr_reader :widget
13
- @@property_type_updaters = {
14
- :string => lambda { |widget, value| widget.widget.select(widget.widget.index_of(value.to_s)) },
15
- :array => lambda { |widget, value| widget.widget.selection=((value or []).to_java :string) }
16
- }
17
- @@property_evaluators = {
18
- :string => lambda do |selection_array|
19
- return nil if selection_array.empty?
20
- selection_array[0]
21
- end,
22
- :array => lambda do |selection_array|
23
- selection_array
24
- end
25
- }
26
- # Initialize with list widget and property_type
27
- # property_type :string represents default list single selection
28
- # property_type :array represents list multi selection
29
- def initialize(widget, property_type)
30
- property_type = :string if property_type.nil? or property_type == :undefined
31
- @widget = widget
32
- @property_type = property_type
33
- @widget.on_widget_disposed do |dispose_event|
34
- unregister_all_observables
35
- end
36
- end
37
- def call(value)
38
- @@property_type_updaters[@property_type].call(@widget, value) unless evaluate_property == value
39
- end
40
- def evaluate_property
41
- selection_array = @widget.widget.send("selection").to_a
42
- property_value = @@property_evaluators[@property_type].call(selection_array)
43
- return property_value
44
- end
45
- end
46
- end
47
- end
@@ -1,15 +0,0 @@
1
- module Glimmer
2
- # edit to add more packages and support custom widgets
3
- module SwtPackages
4
- def self.included(klass)
5
- klass.class_eval do
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
- include_package 'org.eclipse.swt.graphics'
10
- include_package 'org.eclipse.swt.browser'
11
- include_package 'org.eclipse.swt.custom'
12
- end
13
- end
14
- end
15
- end
@@ -1,50 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../node"
3
-
4
- module Glimmer
5
- module XML
6
- module CommandHandlers
7
- class HtmlCommandHandler
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- (parent == nil or parent.is_a?(Node)) and
12
- (args.size == 0 or ((args.size == 1) and ((args[0].is_a?(Hash)) or (args[0].is_a?(Hash)))))
13
- end
14
-
15
- def do_handle(parent, command_symbol, *args, &block)
16
- attributes = Hash.new
17
- attributes = args[0] if (args.size == 1)
18
- append_id_and_class_attributes(command_symbol.to_s, attributes)
19
- tag_name = parse_tag_name(command_symbol.to_s)
20
- Node.new(parent, tag_name, attributes, &block)
21
- end
22
-
23
- def parse_tag_name(command)
24
- match_data = command.match("_")
25
- if (match_data.to_a.size > 0)
26
- command.match("_").pre_match
27
- else
28
- command
29
- end
30
- end
31
-
32
- def append_id_and_class_attributes(command, attributes)
33
- class_only_match = command.match("__.+").to_s
34
- if class_only_match.length > 0
35
- class_value = class_only_match[2, class_only_match.length]
36
- else
37
- match_data = command.match("_[^_]+")
38
- return unless match_data
39
- match = match_data.to_s
40
- id_value = match[1, match.length] if match.length > 0
41
- attributes[:id] = id_value if id_value
42
- match2 = match_data.post_match.match("_[^_]+").to_s if match_data.post_match
43
- class_value = match2[1, match2.length] if match2.length > 0
44
- end
45
- attributes[:class] = class_value if class_value
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,23 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../node"
3
-
4
- module Glimmer
5
- module XML
6
- module CommandHandlers
7
- class XmlCommandHandler
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- (parent == nil or parent.is_a?(Node)) and
12
- (args.size == 0 or ((args.size == 1) and ((args[0].is_a?(Hash)) or (args[0].is_a?(Hash)))))
13
- end
14
-
15
- def do_handle(parent, command_symbol, *args, &block)
16
- attributes = Hash.new
17
- attributes = args[0] if (args.size == 1)
18
- Node.new(parent, command_symbol.to_s, attributes, &block)
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,36 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../node"
3
- require File.dirname(__FILE__) + "/../depth_first_search_iterator"
4
- require File.dirname(__FILE__) + "/../name_space_visitor"
5
-
6
- module Glimmer
7
- module XML
8
- module CommandHandlers
9
- class XmlNameSpaceCommandHandler
10
- include CommandHandler, Glimmer
11
-
12
- def can_handle?(parent, command_symbol, *args, &block)
13
- (parent == nil or parent.is_a?(Node)) and
14
- (command_symbol.to_s == "name_space")
15
- (args.size == 1) and
16
- (args[0].is_a?(Symbol)) and
17
- block
18
- end
19
-
20
- def do_handle(parent, command_symbol, *args, &block)
21
- node = block.call
22
- unless node.is_a?(String)
23
- name_space_visitor = NameSpaceVisitor.new(args[0].to_s)
24
- DepthFirstSearchIterator.new(node, name_space_visitor).iterate
25
- def node.process_block(block)
26
- Glimmer.logger.debug 'block'
27
- #NOOP
28
- end
29
- end
30
- parent.children << node if parent and !parent.children.include?(node)
31
- node
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,28 +0,0 @@
1
- require "facets"
2
- require File.dirname(__FILE__) + "/../../command_handler"
3
- require File.dirname(__FILE__) + "/../node"
4
-
5
- module Glimmer
6
- module XML
7
- module CommandHandlers
8
- class XmlTagCommandHandler
9
- include CommandHandler
10
-
11
- def can_handle?(parent, command_symbol, *args, &block)
12
- (parent == nil or parent.is_a?(Node)) and
13
- (command_symbol.to_s == "tag") and
14
- ((args.size == 1) and ((args[0].is_a?(Hash)) or (args[0].is_a?(Hash)))) and
15
- args[0].include?(:_name)
16
- end
17
-
18
- def do_handle(parent, command_symbol, *args, &block)
19
- attributes = nil
20
- attributes = args[0] if (args.size == 1)
21
- tag_name = attributes[:_name]
22
- attributes.delete(:_name)
23
- Node.new(parent, tag_name, attributes, &block)
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,24 +0,0 @@
1
- require File.dirname(__FILE__) + "/../../command_handler"
2
- require File.dirname(__FILE__) + "/../node"
3
-
4
- module Glimmer
5
- module XML
6
- module CommandHandlers
7
- class XmlTextCommandHandler
8
- include CommandHandler
9
-
10
- def can_handle?(parent, command_symbol, *args, &block)
11
- (parent == nil or parent.is_a?(Node)) and
12
- (command_symbol.to_s == "text") and
13
- ((args.size == 1) and (args[0].is_a?(String))) and
14
- !block
15
- end
16
-
17
- def do_handle(parent, command_symbol, *args, &block)
18
- parent.children << args[0] if parent
19
- args[0]
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,20 +0,0 @@
1
- module Glimmer
2
- module XML
3
- class DepthFirstSearchIterator
4
- def initialize(node, node_visitor)
5
- @node = node
6
- @node_visitor = node_visitor
7
- end
8
-
9
- def iterate
10
- process(@node)
11
- end
12
-
13
- def process(node)
14
- @node_visitor.process_before_children(node)
15
- node.children.each { |child| process(child) } unless node.is_a?(String)
16
- @node_visitor.process_after_children(node)
17
- end
18
- end
19
- end
20
- end
@@ -1,21 +0,0 @@
1
- require File.dirname(__FILE__) + "/node_visitor"
2
-
3
- module Glimmer
4
- module XML
5
- class NameSpaceVisitor < NodeVisitor
6
-
7
- def initialize(name_space_name)
8
- @name_space_name = name_space_name
9
- end
10
-
11
- def process_before_children(node)
12
- return if node.is_a?(String)
13
- node.name_space = Node.new(nil, @name_space_name, nil) if node and !node.name_space
14
- end
15
-
16
- def process_after_children(node)
17
- #NOOP
18
- end
19
- end
20
- end
21
- end
@@ -1,84 +0,0 @@
1
- require File.dirname(__FILE__) + "/depth_first_search_iterator"
2
- require File.dirname(__FILE__) + "/xml_visitor"
3
-
4
- module Glimmer
5
- module XML
6
- class Node
7
- include Parent, Glimmer
8
-
9
- attr_accessor :children, :name, :contents, :attributes, :is_name_space, :is_attribute, :name_space, :parent
10
-
11
- def initialize(parent, name, attributes, &contents)
12
- @is_name_space = false
13
- @children = []
14
- @parent = parent
15
- if (parent and parent.is_name_space)
16
- @name_space = parent
17
- @parent = @name_space.parent
18
- end
19
- @parent.children << self if @parent
20
- @name = name
21
- @contents = contents
22
- @attributes = attributes
23
- if @attributes
24
- @attributes.each_key do |attribute|
25
- if attribute.is_a?(Node)
26
- attribute.is_attribute = true
27
- attribute.parent.children.delete(attribute) if attribute.parent
28
- attribute.parent = nil #attributes do not usually have parents
29
- end
30
- end
31
- Glimmer.logger.debug(attributes)
32
- end
33
- end
34
-
35
- def method_missing(symbol, *args, &block)
36
- @is_name_space = true
37
- parent.children.delete(self) if parent
38
- Glimmer.add_contents(self) {@tag = super}
39
- @tag
40
- end
41
-
42
- def to_xml
43
- xml_visitor = XmlVisitor.new
44
- DepthFirstSearchIterator.new(self, xml_visitor).iterate
45
- xml_visitor.document
46
- end
47
-
48
- def process_block(block)
49
- return_value = block.call(@widget) #TODO fix (remove @widget reference)
50
- if return_value.is_a?(String) and !@children.include?(return_value)
51
- text = return_value
52
- first_match = text.match(/[#][^{]+[{][^}]+[}]/)
53
- match = first_match
54
- while (match)
55
- Glimmer.module_eval(text_command(match.pre_match))
56
- tag_text = match.to_s
57
- Glimmer.module_eval(rubyize(tag_text))
58
- text = tag_text
59
- post_match = match.post_match
60
- match = text.match(/[#]\w+[{]\w+[}]/)
61
- end
62
- Glimmer.module_eval(text_command(post_match)) if post_match
63
- @children << return_value unless first_match
64
- end
65
- end
66
-
67
- def text_command(text)
68
- "text \"#{text}\""
69
- end
70
-
71
- def rubyize(text)
72
- text = text.gsub(/[}]/, '"}')
73
- text = text.gsub(/[{]/, '{"')
74
- text = text.gsub(/[#]/, '')
75
- end
76
-
77
- #override Object default id method and route it to Glimmer engine
78
- def id
79
- method_missing(:id)
80
- end
81
-
82
- end
83
- end
84
- end
@@ -1,13 +0,0 @@
1
- module Glimmer
2
- module XML
3
- class NodeVisitor
4
- def process_before_children
5
- raise "must be implemented by a class"
6
- end
7
-
8
- def process_after_children
9
- raise "must be implemented by a class"
10
- end
11
- end
12
- end
13
- end
@@ -1,63 +0,0 @@
1
- require File.dirname(__FILE__) + "/node_visitor"
2
-
3
- module Glimmer
4
- module XML
5
- class XmlVisitor < NodeVisitor
6
-
7
- attr_reader :document
8
-
9
- def initialize
10
- @document = ""
11
- end
12
-
13
- def process_before_children(node)
14
- if (node.is_a?(String))
15
- @document << node
16
- return
17
- end
18
- begin_open_tag(node)
19
- append_attributes(node) if node.attributes
20
- end_open_tag(node)
21
- end
22
-
23
- def process_after_children(node)
24
- return if (node.is_a?(String))
25
- append_close_tag(node)
26
- end
27
-
28
- def begin_open_tag(node)
29
- @document << "<"
30
- @document << "#{node.name_space.name}:" if node.name_space
31
- @document << node.name
32
- end
33
-
34
- def end_open_tag(node)
35
- if (node.contents)
36
- @document << ">"
37
- else
38
- @document << " " if node.attributes.keys.size > 0
39
- @document << "/>"
40
- end
41
- end
42
-
43
- def append_close_tag(node)
44
- if (node.contents)
45
- @document << "</"
46
- @document << "#{node.name_space.name}:" if node.name_space
47
- @document << "#{node.name}>"
48
- end
49
- end
50
-
51
- def append_attributes(node)
52
- Glimmer.logger.debug "Take 3"
53
- Glimmer.logger.debug(node.attributes)
54
- node.attributes.each_key do |attribute|
55
- attribute_name = attribute
56
- attribute_name = "#{attribute.name_space.name}:#{attribute.name}" if attribute.is_a?(Node)
57
- @document << " #{attribute_name}=\"#{node.attributes[attribute]}\""
58
- end
59
- end
60
-
61
- end
62
- end
63
- end