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
@@ -0,0 +1,154 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/error'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ # Mixin for all proxy classes that manage style constants (e.g. SWT, DND, etc...)
27
+ module StyleConstantizable
28
+ module ClassMethods
29
+ REGEX_SYMBOL_NEGATIVITY = /^([^!]+)(!)?$/
30
+
31
+ def constant_source_class
32
+ raise 'Not implemented! Mixer must implement!'
33
+ end
34
+
35
+ def constant_value_none
36
+ # TODO instead of raising error try a convention instead like CLASSNAME::NONE by default
37
+ raise 'Not implemented! Mixer must implement!'
38
+ end
39
+
40
+ # hash of extra styles (i.e. new style combinations)
41
+ def extra_styles
42
+ raise 'Not implemented! Mixer must implement!'
43
+ end
44
+
45
+ def error_message_invalid_style
46
+ " is an invalid #{constant_source_class.name.split(':').last} style! Please choose a style from #{constant_source_class.name} class constants." # TODO parameterize
47
+ end
48
+
49
+ # Gets constants (e.g. SWT::CONSTANT) where constant is
50
+ # passed in as a lower case symbol
51
+ def [](*symbols)
52
+ symbols = symbols.first if symbols.size == 1 && symbols.first.is_a?(Array)
53
+ result = symbols.compact.map do |symbol|
54
+ constant(symbol).tap do |constant_value|
55
+ raise Glimmer::Error, symbol.to_s + error_message_invalid_style unless constant_value.is_a?(Integer)
56
+ end
57
+ end.reduce do |output, constant_value|
58
+ if constant_value < 0
59
+ output & constant_value
60
+ else
61
+ output | constant_value
62
+ end
63
+ end
64
+ result.nil? ? constant_value_none : result
65
+ end
66
+
67
+ # Returns style integer value for passed in symbol or allows
68
+ # passed in object to pass through (e.g. Integer). This makes is convenient
69
+ # to use symbols or actual style integers in Glimmer
70
+ # Does not raise error for invalid values. Just lets them pass as is.
71
+ # (look into [] operator if you want an error raised on invalid values)
72
+ def constant(symbol)
73
+ return symbol unless symbol.is_a?(Symbol) || symbol.is_a?(String)
74
+ symbol_string, negative = extract_symbol_string_negativity(symbol)
75
+ swt_constant_symbol = symbol_string.downcase == symbol_string ? symbol_string.upcase.to_sym : symbol_string.to_sym
76
+ bit_value = constant_source_class.const_get(swt_constant_symbol)
77
+ negative ? ~bit_value : bit_value
78
+ rescue => e
79
+ begin
80
+ # Glimmer::Config.logger.debug {e.full_message}
81
+ alternative_swt_constant_symbol = constant_source_class.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s.upcase}
82
+ bit_value = constant_source_class.const_get(alternative_swt_constant_symbol)
83
+ negative ? ~bit_value : bit_value
84
+ rescue => e
85
+ # Glimmer::Config.logger.debug {e.full_message}
86
+ bit_value = extra_styles[swt_constant_symbol]
87
+ if bit_value
88
+ negative ? ~bit_value : bit_value
89
+ else
90
+ symbol
91
+ end
92
+ end
93
+ end
94
+
95
+ def extract_symbol_string_negativity(symbol)
96
+ if symbol.is_a?(Symbol) || symbol.is_a?(String)
97
+ symbol_negativity_match = symbol.to_s.match(REGEX_SYMBOL_NEGATIVITY)
98
+ symbol = symbol_negativity_match[1]
99
+ negative = !!symbol_negativity_match[2]
100
+ [symbol, negative]
101
+ else
102
+ negative = symbol < 0
103
+ [symbol, negative]
104
+ end
105
+ end
106
+
107
+ def negative?(symbol)
108
+ extract_symbol_string_negativity(symbol)[1]
109
+ end
110
+
111
+ def has_constant?(symbol)
112
+ return false unless symbol.is_a?(Symbol) || symbol.is_a?(String)
113
+ constant(symbol).is_a?(Integer)
114
+ end
115
+
116
+ def constantify_args(args)
117
+ args.map {|arg| constant(arg)}
118
+ end
119
+
120
+ # Deconstructs a style integer into symbols
121
+ # Useful for debugging
122
+ def deconstruct(integer)
123
+ constant_source_class.constants.reduce([]) do |found, c|
124
+ constant_value = constant_source_class.const_get(c) rescue -1
125
+ is_found = constant_value.is_a?(Integer) && (integer & constant_value) == integer
126
+ is_found ? found += [c] : found
127
+ end
128
+ end
129
+
130
+ # Reverse engineer a style integer into a symbol
131
+ # Useful for debugging
132
+ def reverse_lookup(integer)
133
+ constant_source_class.constants.reduce([]) do |found, c|
134
+ constant_value = constant_source_class.const_get(c) rescue -1
135
+ is_found = constant_value.is_a?(Integer) && integer == constant_value
136
+ is_found ? found += [c] : found
137
+ end
138
+ end
139
+
140
+ def include?(swt_constant, *symbols)
141
+ swt_constant & self[symbols] == self[symbols]
142
+ end
143
+
144
+ end
145
+
146
+ def self.included(klass)
147
+ klass.extend(ClassMethods)
148
+ end
149
+
150
+ end
151
+
152
+ end
153
+
154
+ end
@@ -0,0 +1,44 @@
1
+ require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/text_proxy'
3
+ require 'glimmer/swt/swt_proxy'
4
+
5
+ module Glimmer
6
+ module SWT
7
+ class StyledTextProxy < TextProxy
8
+ attr_reader :alignment, :right_margin, :editable, :caret
9
+
10
+ def alignment=(value)
11
+ @alignment = %w[left center right].detect {|alignment_value| SWTProxy[alignment_value] == value}
12
+ dom_element.css('text-align', @alignment)
13
+ end
14
+
15
+ def right_margin=(value)
16
+ @right_margin = value.to_i
17
+ dom_element.css('padding-right', @right_margin)
18
+ end
19
+
20
+ def editable=(value)
21
+ @editable = value
22
+ if !@editable
23
+ dom_element.attr('disabled', true)
24
+ dom_element.css('background', :white)
25
+ dom_element.css('border', 'solid 1px rgb(118, 118, 118)')
26
+ dom_element.css('border-radius', '3px')
27
+ # :hover {
28
+ # border-color: rgb(80, 80, 80);
29
+ # }
30
+ else
31
+ dom_element.prop('disabled', false)
32
+ dom_element.css('background', nil)
33
+ dom_element.css('border', nil)
34
+ dom_element.css('border-radius', nil)
35
+ end
36
+ end
37
+
38
+ def caret=(value)
39
+ @caret = value
40
+ # TODO implement (not needed for disabling caret though)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,53 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/swt'
23
+ require 'glimmer/swt/style_constantizable'
24
+
25
+ module Glimmer
26
+ module SWT
27
+ # Proxy for org.eclipse.swt.SWT
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class SWTProxy
31
+ include StyleConstantizable
32
+
33
+ class << self
34
+ def constant_source_class
35
+ SWT
36
+ end
37
+
38
+ def constant_value_none
39
+ SWT::NONE
40
+ end
41
+
42
+ def extra_styles
43
+ EXTRA_STYLES
44
+ end
45
+ end
46
+
47
+ EXTRA_STYLES = {
48
+ NO_RESIZE: self[:shell_trim, :resize!, :max!],
49
+ NO_SORT: -7,
50
+ }
51
+ end
52
+ end
53
+ end
@@ -1,8 +1,8 @@
1
- require 'glimmer/opal/element_proxy'
1
+ require 'glimmer/swt/widget_proxy'
2
2
 
3
3
  module Glimmer
4
- module Opal
5
- class TabFolder < ElementProxy
4
+ module SWT
5
+ class TabFolderProxy < WidgetProxy
6
6
  attr_reader :tabs
7
7
 
8
8
  def initialize(parent, args)
@@ -11,42 +11,41 @@ module Glimmer
11
11
  end
12
12
 
13
13
  def add_child(child)
14
- super(child)
14
+ unless @children.include?(child)
15
+ @children << child
16
+ tabs_dom_element.append(child.tab_dom)
17
+ child.render
18
+ end
19
+
15
20
  if @children.size == 1
16
21
  child.show
17
22
  end
18
23
  end
19
24
 
20
- def redraw
21
- super()
22
- @children.each do |child|
23
- add_child(child) # TODO think of impact of this on performance
24
- end
25
- end
26
-
27
25
  def hide_all_tab_content
28
26
  @children.each(&:hide)
29
27
  end
30
28
 
31
- def name
32
- 'div'
29
+ def tabs_path
30
+ path + " > ##{tabs_id}"
31
+ end
32
+
33
+ def tabs_id
34
+ id + '-tabs'
33
35
  end
34
36
 
35
- def tabs_dom
36
- tabs_id = id + '-tabs'
37
- @tabs_dom ||= DOM {
38
- div(id: tabs_id, class: 'tabs')
39
- }
37
+ def tabs_dom_element
38
+ Document.find(tabs_path)
40
39
  end
41
40
 
42
41
  def dom
43
42
  tab_folder_id = id
44
43
  tab_folder_id_style = css
45
- @dom ||= DOM {
44
+ @dom ||= html {
46
45
  div(id: tab_folder_id, style: tab_folder_id_style, class: 'tab-folder') {
47
-
46
+ div(id: tabs_id, class: 'tabs')
48
47
  }
49
- }.tap {|the_dom| the_dom << tabs_dom }
48
+ }.to_s
50
49
  end
51
50
  end
52
51
  end
@@ -0,0 +1,84 @@
1
+ require 'glimmer/swt/composite_proxy'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ class TabItemProxy < CompositeProxy
6
+ include Glimmer
7
+ attr_reader :text, :content_visible
8
+
9
+ def initialize(parent, args)
10
+ super(parent, args)
11
+ content {
12
+ on_widget_selected {
13
+ @parent.hide_all_tab_content
14
+ show
15
+ }
16
+ }
17
+ end
18
+
19
+ def show
20
+ @content_visible = true
21
+ dom_element.remove_class('hide')
22
+ tab_dom_element.add_class('selected')
23
+ end
24
+
25
+ def hide
26
+ @content_visible = false
27
+ dom_element.add_class('hide')
28
+ tab_dom_element.remove_class('selected')
29
+ end
30
+
31
+ def text=(value)
32
+ @text = value
33
+ tab_dom_element.html(@text)
34
+ end
35
+
36
+ def selector
37
+ super + '-tab'
38
+ end
39
+
40
+ def observation_request_to_event_mapping
41
+ {
42
+ 'on_widget_selected' => {
43
+ event: 'click'
44
+ },
45
+ }
46
+ end
47
+
48
+ def listener_path
49
+ tab_path
50
+ end
51
+
52
+ def tab_path
53
+ "#{parent.tabs_path} > ##{tab_id}"
54
+ end
55
+
56
+ def tab_dom_element
57
+ Document.find(tab_path)
58
+ end
59
+
60
+ def tab_id
61
+ id + '-tab'
62
+ end
63
+
64
+ # This contains the clickable tab area with tab names
65
+ def tab_dom
66
+ @tab_dom ||= html {
67
+ button(id: tab_id, class: "tab") {
68
+ @text
69
+ }
70
+ }.to_s
71
+ end
72
+
73
+ # This contains the tab content
74
+ def dom
75
+ tab_item_id = id
76
+ tab_item_class_string = [name, 'hide'].join(' ')
77
+ @dom ||= html {
78
+ div(id: tab_item_id, class: tab_item_class_string) {
79
+ }
80
+ }.to_s
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,9 +1,10 @@
1
- require 'glimmer/opal/element_proxy'
1
+ require 'glimmer/swt/widget_proxy'
2
2
 
3
3
  module Glimmer
4
- module Opal
5
- class TableColumn < ElementProxy
4
+ module SWT
5
+ class TableColumnProxy < WidgetProxy
6
6
  include Glimmer
7
+
7
8
  attr_reader :text, :width
8
9
 
9
10
  def text=(value)
@@ -16,13 +17,17 @@ module Glimmer
16
17
  redraw
17
18
  end
18
19
 
20
+ def parent_path
21
+ parent.columns_path
22
+ end
23
+
19
24
  def css
20
25
  <<~CSS
21
- width: #{width};
26
+ width: #{width}px;
22
27
  CSS
23
28
  end
24
29
 
25
- def name
30
+ def element
26
31
  'th'
27
32
  end
28
33
 
@@ -39,11 +44,12 @@ module Glimmer
39
44
  table_column_id = id
40
45
  table_column_id_style = css
41
46
  table_column_css_classes = css_classes
42
- @dom ||= DOM {
47
+ table_column_css_classes << name
48
+ @dom ||= html {
43
49
  th(id: table_column_id, style: table_column_id_style, class: table_column_css_classes.to_a.join(' ')) {
44
50
  table_column_text
45
51
  }
46
- }
52
+ }.to_s
47
53
  end
48
54
  end
49
55
  end