glimmer-dsl-opal 0.5.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -0
  3. data/README.md +438 -17
  4. data/VERSION +1 -1
  5. data/app/assets/images/glimmer/images/calendar.gif +0 -0
  6. data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
  7. data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
  8. data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
  9. data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
  10. data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
  11. data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
  12. data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
  13. data/app/assets/stylesheets/glimmer/glimmer.css +15 -0
  14. data/app/assets/stylesheets/glimmer/jquery-ui.css +1312 -0
  15. data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +886 -0
  16. data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +443 -0
  17. data/app/assets/stylesheets/glimmer/jquery.ui.timepicker.css +57 -0
  18. data/lib/display.rb +31 -0
  19. data/lib/file.rb +29 -0
  20. data/lib/glimmer-dsl-opal.rb +40 -8
  21. data/lib/glimmer-dsl-opal/ext/date.rb +49 -3
  22. data/lib/glimmer-dsl-opal/ext/struct.rb +37 -0
  23. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +23 -0
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +283 -0
  26. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
  27. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
  28. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
  29. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
  30. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
  32. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  33. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  34. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  35. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  36. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  37. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  38. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
  39. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
  40. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
  41. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
  42. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
  43. data/lib/glimmer-dsl-swt.rb +20 -35
  44. data/lib/glimmer/data_binding/table_items_binding.rb +32 -19
  45. data/lib/glimmer/dsl/opal/block_property_expression.rb +41 -0
  46. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +1 -1
  47. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  48. data/lib/glimmer/dsl/opal/shell_expression.rb +7 -2
  49. data/lib/glimmer/dsl/opal/widget_expression.rb +10 -1
  50. data/lib/glimmer/engine.rb +9 -0
  51. data/lib/glimmer/swt.rb +3 -3
  52. data/lib/glimmer/swt/button_proxy.rb +5 -5
  53. data/lib/glimmer/swt/checkbox_proxy.rb +1 -0
  54. data/lib/glimmer/swt/color_proxy.rb +45 -45
  55. data/lib/glimmer/swt/combo_proxy.rb +42 -3
  56. data/lib/glimmer/swt/composite_proxy.rb +7 -3
  57. data/lib/glimmer/swt/control_editor.rb +54 -0
  58. data/lib/glimmer/swt/date_time_proxy.rb +209 -0
  59. data/lib/glimmer/swt/display_proxy.rb +6 -2
  60. data/lib/glimmer/swt/fill_layout_proxy.rb +1 -1
  61. data/lib/glimmer/swt/label_proxy.rb +2 -2
  62. data/lib/glimmer/swt/layout_data_proxy.rb +13 -10
  63. data/lib/glimmer/swt/layout_proxy.rb +5 -5
  64. data/lib/glimmer/swt/list_proxy.rb +2 -2
  65. data/lib/glimmer/swt/make_shift_shell_proxy.rb +4 -4
  66. data/lib/glimmer/swt/message_box_proxy.rb +10 -8
  67. data/lib/glimmer/swt/property_owner.rb +2 -2
  68. data/lib/glimmer/swt/radio_proxy.rb +1 -0
  69. data/lib/glimmer/swt/shell_proxy.rb +8 -0
  70. data/lib/glimmer/swt/tab_folder_proxy.rb +5 -5
  71. data/lib/glimmer/swt/tab_item_proxy.rb +7 -7
  72. data/lib/glimmer/swt/table_column_proxy.rb +71 -12
  73. data/lib/glimmer/swt/table_editor.rb +65 -0
  74. data/lib/glimmer/swt/table_item_proxy.rb +50 -7
  75. data/lib/glimmer/swt/table_proxy.rb +595 -22
  76. data/lib/glimmer/swt/text_proxy.rb +51 -3
  77. data/lib/glimmer/swt/widget_proxy.rb +141 -27
  78. data/lib/glimmer/ui/custom_widget.rb +8 -8
  79. data/lib/net/http.rb +1 -5
  80. data/lib/os.rb +36 -0
  81. data/lib/uri.rb +3 -3
  82. metadata +49 -9
  83. data/lib/glimmer/data_binding/ext/observable_model.rb +0 -40
@@ -6,8 +6,8 @@ module Glimmer
6
6
  ITEM_EMPTY = '_____'
7
7
  attr_reader :items, :selection
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  @selection = []
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -26,7 +26,7 @@ module Glimmer
26
26
  # No Op
27
27
  end
28
28
 
29
- def add_child(child)
29
+ def post_initialize_child(child)
30
30
  # No Op
31
31
  end
32
32
 
@@ -1,14 +1,16 @@
1
1
  require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/display_proxy'
2
3
 
3
4
  module Glimmer
4
5
  module SWT
5
6
  class MessageBoxProxy < WidgetProxy
6
7
  attr_reader :text, :message
7
8
 
8
- def initialize(parent, args)
9
+ def initialize(parent, args, block)
9
10
  i = 0
10
- @parent = parent
11
+ @parent = parent || DisplayProxy.instance.shells.first
11
12
  @args = args
13
+ @block = block
12
14
  @children = Set.new
13
15
  @enabled = true
14
16
  content do
@@ -37,7 +39,7 @@ module Glimmer
37
39
  end
38
40
 
39
41
  def open
40
- document.add_child(self)
42
+ document.post_initialize_child(self)
41
43
  end
42
44
 
43
45
  def hide
@@ -53,11 +55,11 @@ module Glimmer
53
55
  end
54
56
 
55
57
  def selector
56
- super + ' .close'
58
+ super + ' .close'
57
59
  end
58
60
 
59
61
  def listener_path
60
- path + ' .close'
62
+ path + ' .close'
61
63
  end
62
64
 
63
65
  def observation_request_to_event_mapping
@@ -66,7 +68,7 @@ module Glimmer
66
68
  event: 'click'
67
69
  },
68
70
  }
69
- end
71
+ end
70
72
 
71
73
  def style_dom_modal_css
72
74
  <<~CSS
@@ -119,11 +121,11 @@ module Glimmer
119
121
  modal_text = text
120
122
  modal_message = message
121
123
  modal_class = ['modal', name].join(' ')
122
- @dom ||= html {
124
+ @dom ||= html {
123
125
  div(id: modal_id, style: modal_style, class: modal_class) {
124
126
  style(class: 'modal-style') {
125
127
  style_dom_modal_css #.split("\n").map(&:strip).join(' ')
126
- }
128
+ }
127
129
  div(class: 'modal-content') {
128
130
  header(class: 'text') {
129
131
  modal_text
@@ -7,7 +7,7 @@ module Glimmer
7
7
  end
8
8
 
9
9
  def set_attribute(attribute_name, *args)
10
- send(attribute_setter(attribute_name), *args) unless send(attribute_getter(attribute_name)) == args.first
10
+ send(attribute_setter(attribute_name), *args) unless args.size == 1 && send(attribute_getter(attribute_name)) == args.first
11
11
  end
12
12
 
13
13
  def attribute_setter(attribute_name)
@@ -16,7 +16,7 @@ module Glimmer
16
16
 
17
17
  def attribute_getter(attribute_name)
18
18
  attribute_name.to_s.underscore
19
- end
19
+ end
20
20
  end
21
21
  end
22
22
  end
@@ -3,6 +3,7 @@ require 'glimmer/swt/widget_proxy'
3
3
  module Glimmer
4
4
  module SWT
5
5
  class RadioProxy < WidgetProxy
6
+ # TODO add a create method that ensures passing :radio style in if not there
6
7
  STYLE=<<~CSS
7
8
  .radio {
8
9
  display: inline;
@@ -21,6 +21,7 @@ module Glimmer
21
21
  @layout.margin_width = 0
22
22
  @layout.margin_height = 0
23
23
  self.minimum_size = Point.new(WIDTH_MIN, HEIGHT_MIN)
24
+ DisplayProxy.instance.shells << self
24
25
  end
25
26
 
26
27
  def element
@@ -207,6 +208,7 @@ module Glimmer
207
208
  body_class = ([name] + css_classes.to_a).join(' ')
208
209
  @dom ||= html {
209
210
  div(id: body_id, class: body_class) {
211
+ # TODO support the idea of dynamic CSS building on close of shell that adds only as much CSS as needed for widgets that were mentioned
210
212
  style(class: 'common-style') {
211
213
  style_dom_css
212
214
  }
@@ -246,6 +248,12 @@ module Glimmer
246
248
  style(class: 'scrolled-composite-style') {
247
249
  Glimmer::SWT::ScrolledCompositeProxy::STYLE
248
250
  }
251
+ style(class: 'table-item-style') {
252
+ Glimmer::SWT::TableItemProxy::STYLE
253
+ }
254
+ style(class: 'table-column-style') {
255
+ Glimmer::SWT::TableColumnProxy::STYLE
256
+ }
249
257
  }
250
258
  }.to_s
251
259
  end
@@ -2,17 +2,17 @@ require 'glimmer/swt/widget_proxy'
2
2
 
3
3
  module Glimmer
4
4
  module SWT
5
- class TabFolderProxy < WidgetProxy
5
+ class TabFolderProxy < WidgetProxy
6
6
  attr_reader :tabs
7
7
 
8
- def initialize(parent, args)
9
- super(parent, args)
8
+ def initialize(parent, args, block)
9
+ super(parent, args, block)
10
10
  @tabs = []
11
11
  end
12
12
 
13
- def add_child(child)
13
+ def post_initialize_child(child)
14
14
  unless @children.include?(child)
15
- @children << child
15
+ @children << child
16
16
  tabs_dom_element.append(child.tab_dom)
17
17
  child.render
18
18
  end
@@ -4,10 +4,10 @@ module Glimmer
4
4
  module SWT
5
5
  class TabItemProxy < CompositeProxy
6
6
  include Glimmer
7
- attr_reader :text, :content_visible
7
+ attr_reader :text, :content_visible
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  content {
12
12
  on_widget_selected {
13
13
  @parent.hide_all_tab_content
@@ -35,7 +35,7 @@ module Glimmer
35
35
 
36
36
  def selector
37
37
  super + '-tab'
38
- end
38
+ end
39
39
 
40
40
  def observation_request_to_event_mapping
41
41
  {
@@ -47,7 +47,7 @@ module Glimmer
47
47
 
48
48
  def listener_path
49
49
  tab_path
50
- end
50
+ end
51
51
 
52
52
  def tab_path
53
53
  "#{parent.tabs_path} > ##{tab_id}"
@@ -72,13 +72,13 @@ module Glimmer
72
72
 
73
73
  # This contains the tab content
74
74
  def dom
75
- tab_item_id = id
75
+ tab_item_id = id
76
76
  tab_item_class_string = [name, 'hide'].join(' ')
77
77
  @dom ||= html {
78
78
  div(id: tab_item_id, class: tab_item_class_string) {
79
79
  }
80
80
  }.to_s
81
- end
81
+ end
82
82
  end
83
83
  end
84
84
  end
@@ -1,12 +1,51 @@
1
1
  require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/swt_proxy'
2
3
 
3
4
  module Glimmer
4
5
  module SWT
5
6
  class TableColumnProxy < WidgetProxy
7
+ STYLE = <<~CSS
8
+ th.table-column {
9
+ background: rgb(246, 246, 246);
10
+ text-align: left;
11
+ padding: 5px;
12
+ }
13
+
14
+ th.table-column .sort-direction {
15
+ float: right;
16
+ }
17
+ CSS
6
18
  include Glimmer
7
19
 
8
- attr_reader :text, :width
20
+ attr_accessor :sort_block, :sort_by_block
21
+ attr_reader :text, :width,
22
+ :no_sort, :sort_property, :editor
23
+ alias no_sort? no_sort
24
+
25
+ def initialize(parent, args, block)
26
+ @no_sort = args.delete(:no_sort)
27
+ super(parent, args, block)
28
+ unless no_sort?
29
+ content {
30
+ on_widget_selected { |event|
31
+ parent.sort_by_column!(self)
32
+ }
33
+ }
34
+ end
35
+ end
9
36
 
37
+ def sort_property=(args)
38
+ @sort_property = args unless args.empty?
39
+ end
40
+
41
+ def sort_direction
42
+ parent.sort_direction if parent.sort_column == self
43
+ end
44
+
45
+ def redraw_sort_direction
46
+ sort_icon_dom_element.attr('class', sort_icon_class)
47
+ end
48
+
10
49
  def text=(value)
11
50
  @text = value
12
51
  redraw
@@ -21,36 +60,56 @@ module Glimmer
21
60
  parent.columns_path
22
61
  end
23
62
 
24
- def css
25
- <<~CSS
26
- width: #{width}px;
27
- CSS
28
- end
29
-
30
63
  def element
31
64
  'th'
32
65
  end
33
66
 
67
+ def sort_icon_class
68
+ @sort_icon_class = 'sort-direction'
69
+ @sort_icon_class += (sort_direction == SWTProxy[:up] ? ' ui-icon ui-icon-caret-1-n' : ' ui-icon ui-icon-caret-1-s') unless sort_direction.nil?
70
+ @sort_icon_class
71
+ end
72
+
73
+ def sort_icon_dom_element
74
+ dom_element.find('.sort-direction')
75
+ end
76
+
77
+ # Sets editor (e.g. combo)
78
+ def editor=(*args)
79
+ @editor = args
80
+ end
81
+
82
+ def editable?
83
+ !@editor&.include?(:none)
84
+ end
85
+
34
86
  def observation_request_to_event_mapping
35
87
  {
36
88
  'on_widget_selected' => {
37
- event: 'click'
89
+ event: 'click',
90
+ event_handler: -> (event_listener) {
91
+ -> (event) {
92
+ event_listener.call(event)
93
+ redraw_sort_direction
94
+ }
95
+ }
38
96
  },
39
97
  }
40
- end
98
+ end
41
99
 
42
100
  def dom
43
101
  table_column_text = text
44
102
  table_column_id = id
45
- table_column_id_style = css
103
+ table_column_id_style = "width: #{width}px;"
46
104
  table_column_css_classes = css_classes
47
105
  table_column_css_classes << name
48
106
  @dom ||= html {
49
107
  th(id: table_column_id, style: table_column_id_style, class: table_column_css_classes.to_a.join(' ')) {
50
- table_column_text
108
+ span {table_column_text}
109
+ span(class: sort_icon_class)
51
110
  }
52
111
  }.to_s
53
- end
112
+ end
54
113
  end
55
114
  end
56
115
  end
@@ -0,0 +1,65 @@
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/control_editor'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ # Emulates SWT's native org.eclipse.swt.custom.TableEditor
27
+ class TableEditor < ControlEditor
28
+ alias table composite
29
+
30
+ def editor=(editor_widget, table_item, table_column_index)
31
+ # TODO consider making editor not gain an ID or gain a separate set of IDs to avoid clashing with standard widget predictability of ID
32
+ @table_item = table_item
33
+ @table_column_index = table_column_index
34
+ @editor_widget = editor_widget
35
+ @old_value = table_item.cell_dom_element(table_column_index).html
36
+ table_item.cell_dom_element(table_column_index).html('')
37
+ editor_widget.render(table_item.cell_dom_element(table_column_index))
38
+ # TODO tweak the width perfectly so it doesn't expand the table cell
39
+ # editor_widget.dom_element.css('width', 'calc(100% - 20px)')
40
+ editor_widget.dom_element.css('width', "#{minimumWidth}%") # TODO implement property with pixels (and perhaps derive percentage separately from pixels)
41
+ editor_widget.dom_element.css('height', "#{minimumHeight}px")
42
+ editor_widget.dom_element.add_class('table-editor')
43
+ # TODO consider relying on autofocus instead
44
+ editor_widget.dom_element.focus
45
+ # TODO consider doing the following line only for :text editor
46
+ editor_widget.dom_element.select
47
+ end
48
+ alias set_editor editor=
49
+ alias setEditor editor=
50
+
51
+ def cancel!
52
+ done!
53
+ end
54
+
55
+ def save!
56
+ done!
57
+ end
58
+
59
+ def done!
60
+ @table_item.cell_dom_element(@table_column_index).html(@old_value) unless @old_value.nil?
61
+ @old_value = nil
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,12 +1,43 @@
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
+
1
22
  require 'glimmer/swt/widget_proxy'
2
23
 
3
24
  module Glimmer
4
25
  module SWT
5
26
  class TableItemProxy < WidgetProxy
27
+ STYLE = <<~CSS
28
+ tr.table-item td {
29
+ padding-bottom: 0;
30
+ }
31
+ tr.table-item:nth-child(even):not(.selected) {
32
+ background: rgb(243, 244, 246);
33
+ }
34
+ CSS
35
+
6
36
  attr_reader :data
7
37
 
8
- def initialize(parent, args)
9
- super(parent, args)
38
+ def initialize(parent, args, block)
39
+ super(parent, args, block)
40
+ # TODO check if there is a need to remove this observer when removing widget from table upon items update
10
41
  on_widget_selected { |event|
11
42
  parent.select(parent.index_of(self), event.meta?)
12
43
  }
@@ -53,8 +84,12 @@ module Glimmer
53
84
  'tr'
54
85
  end
55
86
 
87
+ def cell_dom_element(column_index)
88
+ dom_element.find("td:nth-child(#{column_index + 1})")
89
+ end
90
+
56
91
  def redraw
57
- super() #TODO re-enalbe and remove below lines
92
+ super() #TODO re-enable and remove below lines
58
93
 
59
94
  # TODO perhaps turn the following lambdas into methods
60
95
  table_item_edit_handler = lambda do |event, cancel = false|
@@ -70,11 +105,11 @@ module Glimmer
70
105
  redraw
71
106
  end
72
107
  end
73
- table_item_edit_cancel_handler = lambda do |event|
108
+ table_item_edit_cancel_handler = lambda do |event|
74
109
  Async::Task.new do
75
110
  table_item_edit_handler.call(event, true)
76
111
  end
77
- end
112
+ end
78
113
  table_item_edit_key_handler = lambda do |event|
79
114
  Async::Task.new do
80
115
  if event.key_code == 13
@@ -91,7 +126,7 @@ module Glimmer
91
126
  Async::Task.new do
92
127
  table_item_input.focus
93
128
  table_item_input.on('keyup', &table_item_edit_key_handler)
94
- table_item_input.on('focusout', &table_item_edit_cancel_handler)
129
+ table_item_input.on('focusout', &table_item_edit_cancel_handler)
95
130
  end
96
131
  end
97
132
  end
@@ -104,6 +139,14 @@ module Glimmer
104
139
  redraw
105
140
  end
106
141
 
142
+ def redraw_selection
143
+ if parent.selection.include?(self)
144
+ dom_element.add_class('selected')
145
+ else
146
+ dom_element.remove_class('selected')
147
+ end
148
+ end
149
+
107
150
  def on_widget_selected(&block)
108
151
  event = 'click'
109
152
  delegate = $document.on(event, selector, &block)
@@ -132,7 +175,7 @@ module Glimmer
132
175
  tr(id: table_item_id, style: table_item_id_style, class: table_item_css_classes.to_a.join(' ')) {
133
176
  table_item_text_array.each_with_index do |table_item_text, column_index|
134
177
  td('data-column-index' => column_index) {
135
- if @edit_column_index == column_index
178
+ if @edit_column_index == column_index
136
179
  input(type: 'text', value: table_item_text, style: "max-width: #{table_item_max_width - 11}px;")
137
180
  else
138
181
  table_item_text