glimmer-dsl-opal 0.0.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/README.md +999 -177
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +49 -10
  6. data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
  7. data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
  8. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +1 -1
  9. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
  10. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
  11. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
  12. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
  13. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
  14. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
  15. data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
  16. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
  20. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
  21. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
  25. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
  26. data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
  27. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
  28. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
  29. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
  30. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
  32. data/lib/glimmer-dsl-swt.rb +37 -0
  33. data/lib/glimmer/data_binding/element_binding.rb +1 -0
  34. data/lib/glimmer/data_binding/ext/observable_model.rb +5 -5
  35. data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
  36. data/lib/glimmer/data_binding/table_items_binding.rb +3 -3
  37. data/lib/glimmer/dsl/opal/async_exec_expression.rb +23 -7
  38. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
  39. data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
  40. data/lib/glimmer/dsl/opal/column_properties_expression.rb +2 -2
  41. data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
  42. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +94 -0
  43. data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
  44. data/lib/glimmer/dsl/opal/dsl.rb +18 -16
  45. data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
  46. data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
  47. data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
  48. data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
  49. data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
  50. data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
  51. data/lib/glimmer/dsl/opal/property_expression.rb +6 -2
  52. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
  53. data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
  54. data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
  55. data/lib/glimmer/dsl/opal/shell_expression.rb +20 -3
  56. data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
  57. data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
  58. data/lib/glimmer/dsl/opal/table_expression.rb +2 -2
  59. data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
  60. data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
  61. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
  62. data/lib/glimmer/swt.rb +499 -0
  63. data/lib/glimmer/swt/browser_proxy.rb +27 -0
  64. data/lib/glimmer/swt/button_proxy.rb +54 -0
  65. data/lib/glimmer/swt/checkbox_proxy.rb +80 -0
  66. data/lib/glimmer/swt/color_proxy.rb +119 -0
  67. data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +23 -18
  68. data/lib/glimmer/swt/composite_proxy.rb +31 -0
  69. data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
  70. data/lib/glimmer/swt/custom/radio_group.rb +143 -0
  71. data/lib/glimmer/swt/display_proxy.rb +79 -0
  72. data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
  73. data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
  74. data/lib/glimmer/swt/font_proxy.rb +79 -0
  75. data/lib/glimmer/swt/grid_layout_proxy.rb +82 -0
  76. data/lib/glimmer/swt/group_proxy.rb +38 -0
  77. data/lib/glimmer/swt/label_proxy.rb +54 -0
  78. data/lib/glimmer/swt/layout_data_proxy.rb +105 -0
  79. data/lib/glimmer/swt/layout_proxy.rb +63 -0
  80. data/lib/glimmer/{opal → swt}/list_proxy.rb +30 -22
  81. data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
  82. data/lib/glimmer/swt/message_box_proxy.rb +143 -0
  83. data/lib/glimmer/{opal → swt}/point.rb +1 -1
  84. data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
  85. data/lib/glimmer/swt/radio_proxy.rb +81 -0
  86. data/lib/glimmer/swt/row_layout_proxy.rb +128 -0
  87. data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
  88. data/lib/glimmer/swt/shell_proxy.rb +260 -0
  89. data/lib/glimmer/swt/style_constantizable.rb +154 -0
  90. data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
  91. data/lib/glimmer/swt/swt_proxy.rb +53 -0
  92. data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +20 -21
  93. data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
  94. data/lib/glimmer/{opal/table_column.rb → swt/table_column_proxy.rb} +13 -7
  95. data/lib/glimmer/{opal/table_item.rb → swt/table_item_proxy.rb} +59 -48
  96. data/lib/glimmer/{opal → swt}/table_proxy.rb +66 -56
  97. data/lib/glimmer/swt/text_proxy.rb +46 -0
  98. data/lib/glimmer/swt/widget_proxy.rb +511 -0
  99. data/lib/glimmer/ui/custom_shell.rb +92 -0
  100. data/lib/glimmer/ui/custom_widget.rb +292 -0
  101. data/lib/glimmer/util/proc_tracker.rb +39 -0
  102. data/lib/net/http.rb +17 -0
  103. data/lib/uri.rb +64 -0
  104. metadata +142 -67
  105. data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
  106. data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
  107. data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
  108. data/lib/glimmer/dsl/opal/composite_expression.rb +0 -17
  109. data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
  110. data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
  111. data/lib/glimmer/dsl/opal/list_expression.rb +0 -17
  112. data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
  113. data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
  114. data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
  115. data/lib/glimmer/opal/display_proxy.rb +0 -23
  116. data/lib/glimmer/opal/div_proxy.rb +0 -29
  117. data/lib/glimmer/opal/document_proxy.rb +0 -187
  118. data/lib/glimmer/opal/element_proxy.rb +0 -304
  119. data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
  120. data/lib/glimmer/opal/iframe_proxy.rb +0 -23
  121. data/lib/glimmer/opal/input_proxy.rb +0 -45
  122. data/lib/glimmer/opal/label_proxy.rb +0 -25
  123. data/lib/glimmer/opal/layout_data_proxy.rb +0 -52
  124. data/lib/glimmer/opal/modal.rb +0 -94
  125. data/lib/glimmer/opal/tab_item.rb +0 -98
  126. data/lib/samples/elaborate/launch +0 -6
  127. data/lib/samples/hello/hello_combo.rb +0 -34
  128. data/lib/samples/hello/hello_tab.rb +0 -24
  129. data/lib/samples/hello/hello_world.rb +0 -8
  130. data/lib/samples/hello/launch +0 -10
  131. data/lib/samples/launch +0 -4
@@ -1,54 +0,0 @@
1
- require 'glimmer/opal/property_owner'
2
-
3
- module Glimmer
4
- module Opal
5
- class GridLayoutProxy
6
- include PropertyOwner
7
- attr_reader :parent, :args, :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing
8
-
9
- def initialize(parent, args)
10
- @parent = parent
11
- @args = args
12
- @parent.add_css_class('grid-layout')
13
- @horizontal_spacing = 10
14
- @vertical_spacing = 10
15
- @num_columns = @args.first || 1
16
- reapply
17
- end
18
-
19
- def num_columns=(columns)
20
- @num_columns = columns
21
- # @parent.add_css_class("num-columns-#{@num_columns}")
22
- reapply
23
- end
24
-
25
- def make_columns_equal_width=(equal_width)
26
- @make_columns_equal_width = equal_width
27
- # @parent.add_css_class('make_columns_equal_width') if @make_columns_equal_width
28
- reapply
29
- end
30
-
31
- def horizontal_spacing=(spacing)
32
- @horizontal_spacing = spacing
33
- # @parent.add_css_class("horizontal-spacing-#{@horizontal_spacing}")
34
- reapply
35
- end
36
-
37
- def vertical_spacing=(spacing)
38
- @vertical_spacing = spacing
39
- # @parent.add_css_class("vertical-spacing-#{@vertical_spacing}")
40
- reapply
41
- end
42
-
43
- def reapply
44
- @parent.css = <<~CSS
45
- display: grid;
46
- grid-template-columns: #{'auto ' * @num_columns.to_i};
47
- grid-row-gap: #{@vertical_spacing}px;
48
- grid-column-gap: #{@horizontal_spacing}px;
49
- justify-content: start;
50
- CSS
51
- end
52
- end
53
- end
54
- end
@@ -1,23 +0,0 @@
1
- require 'glimmer/opal/element_proxy'
2
-
3
- module Glimmer
4
- module Opal
5
- class IframeProxy < ElementProxy
6
- attr_reader :url
7
-
8
- def url=(value)
9
- @url = value
10
- redraw
11
- end
12
-
13
- def dom
14
- iframe_id = id
15
- iframe_url = url
16
- @dom ||= DOM {
17
- iframe(src: iframe_url, frameBorder: 0) {
18
- }
19
- }
20
- end
21
- end
22
- end
23
- end
@@ -1,45 +0,0 @@
1
- require 'glimmer/opal/element_proxy'
2
-
3
- module Glimmer
4
- module Opal
5
- class InputProxy < ElementProxy
6
- attr_reader :text
7
-
8
- def text=(value)
9
- @text = value
10
- redraw
11
- end
12
-
13
- def observation_request_to_event_mapping
14
- {
15
- 'on_widget_selected' => {
16
- event: 'click'
17
- },
18
- 'on_modify_text' => {
19
- event: 'keyup',
20
- event_handler: -> (event_listener) {
21
- -> (event) {
22
- if args.last[:type] == 'text'
23
- @text = event.target.value
24
- event_listener.call(event)
25
- end
26
- }
27
- }
28
- }
29
- }
30
- end
31
-
32
- def dom
33
- input_text = @text
34
- input_id = id
35
- input_style = css
36
- input_args = @args.last
37
- input_disabled = @enabled ? {} : {'disabled': 'disabled'}
38
- input_args = input_args.merge(type: 'password') if has_style?(:password)
39
- @dom ||= DOM {
40
- input input_args.merge(id: input_id, style: input_style, value: input_text, style: 'min-width: 27px;').merge(input_disabled)
41
- }
42
- end
43
- end
44
- end
45
- end
@@ -1,25 +0,0 @@
1
- require 'glimmer/opal/element_proxy'
2
-
3
- module Glimmer
4
- module Opal
5
- class LabelProxy < ElementProxy
6
- attr_reader :text
7
-
8
- def text=(value)
9
- @text = value
10
- redraw
11
- end
12
-
13
- def dom
14
- label_text = @text
15
- label_id = id
16
- label_style = css
17
- @dom ||= DOM {
18
- label(id: label_id, style: label_style) {
19
- label_text
20
- }
21
- }
22
- end
23
- end
24
- end
25
- end
@@ -1,52 +0,0 @@
1
- require 'glimmer/opal/property_owner'
2
-
3
- module Glimmer
4
- module Opal
5
- class LayoutDataProxy
6
- include PropertyOwner
7
- attr_reader :parent,
8
- :args,
9
- :horizontal_alignment,
10
- :vertical_alignment,
11
- :grab_excess_horizontal_space,
12
- :grab_excess_vertical_space,
13
- :height_hint
14
-
15
- def initialize(parent, args)
16
- @parent = parent
17
- @args = args
18
- reapply
19
- end
20
-
21
- def height_hint=(height_hint)
22
- @height_hint = height_hint
23
- reapply
24
- end
25
-
26
- def horizontal_alignment=(horizontal_alignment)
27
- @horizontal_alignment = horizontal_alignment
28
- reapply
29
- end
30
-
31
- def vertical_alignment=(vertical_alignment)
32
- @vertical_alignment = vertical_alignment
33
- reapply
34
- end
35
-
36
- def grab_excess_horizontal_space=(grab_excess_horizontal_space)
37
- @grab_excess_horizontal_space = grab_excess_horizontal_space
38
- reapply
39
- end
40
-
41
- def grab_excess_vertical_space=(grab_excess_vertical_space)
42
- @grab_excess_vertical_space = grab_excess_vertical_space
43
- reapply
44
- end
45
-
46
- def reapply
47
- # @parent.css = <<~CSS
48
- # CSS
49
- end
50
- end
51
- end
52
- end
@@ -1,94 +0,0 @@
1
- require 'glimmer/opal/element_proxy'
2
-
3
- module Glimmer
4
- module Opal
5
- class Modal < ElementProxy
6
- attr_reader :text, :message
7
-
8
- def initialize(parent, args)
9
- i = 0
10
- @parent = parent
11
- @args = args
12
- @children = Set.new
13
- @css_classes = Set.new(['modal'])
14
- @css = ''
15
- @enabled = true
16
- content do
17
- on_widget_selected {
18
- hide
19
- }
20
- end
21
- end
22
-
23
- def text=(txt)
24
- @text = txt
25
- redraw if @dom
26
- end
27
-
28
- def message=(msg)
29
- @message = msg
30
- redraw if @dom
31
- end
32
-
33
- def document
34
- element = self
35
- begin
36
- element = element.parent
37
- end while(element.parent)
38
- element
39
- end
40
-
41
- def open
42
- document.add_child(self)
43
- end
44
-
45
- def hide
46
- dom.remove
47
- end
48
-
49
- def content(&block)
50
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::MessageBoxExpression.new, &block)
51
- end
52
-
53
- def name
54
- 'div'
55
- end
56
-
57
- def selector
58
- super + ' .close'
59
- end
60
-
61
- def observation_request_to_event_mapping
62
- {
63
- 'on_widget_selected' => {
64
- event: 'click'
65
- },
66
- }
67
- end
68
-
69
- def dom
70
- modal_id = id
71
- modal_style = css
72
- modal_text = text
73
- modal_message = message
74
- modal_css_classes = css_classes
75
- modal_class = modal_css_classes.to_a.join(' ')
76
- @dom ||= DOM {
77
- div(id: modal_id, style: modal_style, class: modal_class) {
78
- div(class: 'modal-content') {
79
- header.text {
80
- modal_text
81
- }
82
- p.message {
83
- modal_message
84
- }
85
- input(type: 'button', class: 'close', autofocus: 'autofocus', value: 'OK')
86
- }
87
- }
88
- }
89
- end
90
- end
91
- end
92
- end
93
-
94
- require 'glimmer/dsl/opal/message_box_expression'
@@ -1,98 +0,0 @@
1
- require 'glimmer/opal/div_proxy'
2
-
3
- module Glimmer
4
- module Opal
5
- class TabItem < DivProxy
6
- include Glimmer
7
- attr_reader :text, :content_visible
8
-
9
- def initialize(parent, args)
10
- super(parent, args)
11
- css_classes << 'tab-item'
12
- content do
13
- on_widget_selected {
14
- @parent.hide_all_tab_content
15
- show
16
- }
17
- end
18
- end
19
-
20
- def content(&block)
21
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::TabItemExpression.new, &block)
22
- end
23
-
24
- def show
25
- @content_visible = true
26
- redraw
27
- end
28
-
29
- def hide
30
- @content_visible = false
31
- redraw
32
- end
33
-
34
- def text=(value)
35
- @text = value
36
- redraw
37
- end
38
-
39
- def name
40
- 'button'
41
- end
42
-
43
- def selector
44
- super + '-tab'
45
- end
46
-
47
- def observation_request_to_event_mapping
48
- {
49
- 'on_widget_selected' => {
50
- event: 'click'
51
- },
52
- }
53
- end
54
-
55
- def redraw
56
- if @tab_dom
57
- old_tab_dom = @tab_dom
58
- @tab_dom = nil
59
- old_tab_dom.replace tab_dom
60
- else
61
- tab_dom
62
- end
63
- super
64
- end
65
-
66
- def tab_dom
67
- tab_id = id + '-tab'
68
- tab_text = text
69
- tab_active = content_visible ? 'active' : ''
70
- @tab_dom ||= DOM {
71
- button(id: tab_id, class: "tab #{tab_active}") {
72
- tab_text
73
- }
74
- }
75
- end
76
-
77
- def dom
78
- tab_item_id = id
79
- tab_item_id_style = css
80
- tab_item_css_classes = css_classes
81
- if content_visible
82
- tab_item_css_classes.delete('hide')
83
- else
84
- tab_item_css_classes << 'hide'
85
- end
86
- if !@parent.tabs.include?(self)
87
- @parent.tabs_dom << tab_dom
88
- @parent.tabs << self
89
- end
90
- @dom ||= DOM {
91
- div(id: tab_item_id, style: tab_item_id_style, class: tab_item_css_classes.to_a.join(' ')) {
92
- }
93
- }
94
- end
95
- end
96
- end
97
- end
98
- require 'glimmer/dsl/opal/tab_item_expression'
@@ -1,6 +0,0 @@
1
- # Launches all samples
2
- export DIR=`echo $0 | sed "s/launch//"`
3
- ${DIR}../../bin/glimmer \
4
- "${DIR}contact_manager.rb" \
5
- "${DIR}login.rb" \
6
- "${DIR}tic_tac_toe.rb"
@@ -1,34 +0,0 @@
1
- class Person
2
- attr_accessor :country, :country_options
3
-
4
- def initialize
5
- self.country_options=["", "Canada", "US", "Mexico"]
6
- self.country = "Canada"
7
- end
8
-
9
- def reset_country
10
- self.country = "Canada"
11
- end
12
- end
13
-
14
- class HelloCombo
15
- include Glimmer
16
- def launch
17
- person = Person.new
18
- shell {
19
- composite {
20
- combo(:read_only) {
21
- selection bind(person, :country)
22
- }
23
- button {
24
- text "Reset"
25
- on_widget_selected do
26
- person.reset_country
27
- end
28
- }
29
- }
30
- }.open
31
- end
32
- end
33
-
34
- HelloCombo.new.launch
@@ -1,24 +0,0 @@
1
- class HelloTab
2
- include Glimmer
3
- def launch
4
- shell {
5
- text "Hello, Tab!"
6
- tab_folder {
7
- tab_item {
8
- text "English"
9
- label {
10
- text "Hello, World!"
11
- }
12
- }
13
- tab_item {
14
- text "French"
15
- label {
16
- text "Bonjour, Univers!"
17
- }
18
- }
19
- }
20
- }.open
21
- end
22
- end
23
-
24
- HelloTab.new.launch