glimmer-dsl-swt 4.17.8.2 → 4.17.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 517e5bcedc06e71150e504d4c8ad484adb383e839df9b09e9683d9ebcce72ce8
4
- data.tar.gz: b9792dd4d60cdb642b187848f9cc07d2d33c5bb1801bf2cb961a59f1247d9713
3
+ metadata.gz: 05bc3d6096231cccf821c2aaf5d42a2ef28b23f999d058bc2b2ad2cbf19a1a32
4
+ data.tar.gz: b10d240123f7e7ccd7994c9493abf5d51062c402e96dc6ddd357f6809645c77a
5
5
  SHA512:
6
- metadata.gz: 74eae56731cba0eba1092b9a926cd995cc23190b78126436d5dff8454dc0b0a75e5a70ecc4c5a864d3580bb8f2ad4d003a3ef18bba4d7bb5b0a4f4a44eb5afe3
7
- data.tar.gz: 41b95e7e364eab995e026fec0c442162fefa138b504a48a95ba0e93f39e460b676e635a64228a8c51559ea4c0468afa09695fa1be63f375d6788c7914c6609fc
6
+ metadata.gz: a6b6e9c28482d8dbd6daadb3daab9820a091d961baef5ddd197b9c4198221130487ff44eed35285f5476e9a82c3dc41f89de4652c3375d382a19fb3ef35c6d2b
7
+ data.tar.gz: 2663c8de064e9bbb6f94ac7703e80bb14bb1c5c7cad9ceab69265c84cbacc4d8ae5a87a5fb41533c3e46ba46bb6f3b897fac5091a1108168d216a183faf4d585
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.8.3
4
+
5
+ - Hello, Table! Sample
6
+ - Disable editing on a column with `editor :none`
7
+ - Improve `code_text` performance immensely by only styling the lines being shown upon editing
8
+ - Fix dead spots with syntax highlighting in some files in Gladiator like file.rb
9
+
10
+ ### 4.17.8.2
11
+
12
+ - Hello, Group! Sample
13
+
3
14
  ### 4.17.8.1
4
15
 
5
16
  - Fixed an issue in Windows with code_text
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.8.2
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.8.3
2
+
2
3
  ## JRuby Desktop Development GUI Library
3
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
5
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -447,7 +448,8 @@ jgem install glimmer-dsl-swt
447
448
 
448
449
  Or this command if you want a specific version:
449
450
  ```
450
- jgem install glimmer-dsl-swt -v 4.17.8.2
451
+ jgem install glimmer-dsl-swt -v 4.17.8.3
452
+
451
453
  ```
452
454
 
453
455
  `jgem` is JRuby's version of `gem` command.
@@ -523,7 +525,8 @@ bin/glimmer samples
523
525
  Below are the full usage instructions that come up when running `glimmer` without args.
524
526
 
525
527
  ```
526
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.8.2
528
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.8.3
529
+
527
530
 
528
531
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
529
532
 
@@ -1000,7 +1003,8 @@ Output:
1000
1003
 
1001
1004
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1002
1005
  Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
1003
- Swt glimmer-dsl-swt 4.17.8.2 AndyMaleh Glimmer DSL for SWT
1006
+ Swt glimmer-dsl-swt 4.17.8.3
1007
+ AndyMaleh Glimmer DSL for SWT
1004
1008
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1005
1009
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
1006
1010
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.8.2
1
+ 4.17.8.3
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.8.2 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.8.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.8.2"
9
+ s.version = "4.17.8.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-11-03"
14
+ s.date = "2020-11-05"
15
15
  s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
@@ -152,6 +152,7 @@ Gem::Specification.new do |s|
152
152
  "samples/hello/hello_sash_form.rb",
153
153
  "samples/hello/hello_styled_text.rb",
154
154
  "samples/hello/hello_tab.rb",
155
+ "samples/hello/hello_table.rb",
155
156
  "samples/hello/hello_world.rb",
156
157
  "vendor/swt/linux/swt.jar",
157
158
  "vendor/swt/mac/swt.jar",
@@ -38,32 +38,25 @@ module Glimmer
38
38
  swt_widget&.text
39
39
  end
40
40
 
41
- def syntax_highlighting
41
+ def syntax_highlighting(text)
42
42
  return [] if text.to_s.strip.empty?
43
- return @syntax_highlighting if already_syntax_highlighted?
44
- @last_text = text
45
- @lexer ||= Rouge::Lexer.find_fancy('ruby', text)
46
- lex = @lexer.lex(text).to_a
47
- text_size = 0
48
- lex_hashes = lex.map do |pair|
49
- {token_type: pair.first, token_text: pair.last}
50
- end.each do |hash|
51
- hash[:token_index] = text_size
52
- text_size += hash[:token_text].size
53
- end
54
- text_lines = text.split("\n")
55
- line_index = 0
56
- @syntax_highlighting = text_lines_map = text_lines.reduce({}) do |hash, line|
57
- line_hashes = []
58
- line_hashes << lex_hashes.shift while lex_hashes.any? && lex_hashes.first[:token_index].between?(line_index, line_index + line.size)
59
- hash.merge(line_index => line_hashes).tap do
60
- line_index += line.size + 1
43
+ @syntax_highlighting ||= {}
44
+ unless @syntax_highlighting.keys.include?(text)
45
+ lex = lexer.lex(text).to_a
46
+ text_size = 0
47
+ @syntax_highlighting[text] = lex.map do |pair|
48
+ {token_type: pair.first, token_text: pair.last}
49
+ end.each do |hash|
50
+ hash[:token_index] = text_size
51
+ text_size += hash[:token_text].size
61
52
  end
62
53
  end
54
+ @syntax_highlighting[text]
63
55
  end
64
56
 
65
- def already_syntax_highlighted?
66
- @last_text == text
57
+ def lexer
58
+ # TODO Try to use Rouge::Lexer.find_fancy('guess', code) in the future to guess the language or otherwise detect it from file extension
59
+ @lexer ||= Rouge::Lexer.find_fancy('ruby')
67
60
  end
68
61
 
69
62
  before_body {
@@ -78,22 +71,31 @@ module Glimmer
78
71
  top_margin 5
79
72
  right_margin 5
80
73
  bottom_margin 5
74
+
75
+ on_modify_text { |event|
76
+ # clear unnecessary syntax highlighting cache on text updates, and do it async to avoid affecting performance
77
+ new_text = event.data
78
+ async_exec {
79
+ unless @syntax_highlighting.nil?
80
+ lines = new_text.to_s.split("\n")
81
+ line_diff = @syntax_highlighting.keys - lines
82
+ line_diff.each do |line|
83
+ @syntax_highlighting.delete(line)
84
+ end
85
+ end
86
+ }
87
+ }
81
88
 
82
89
  on_line_get_style { |line_style_event|
83
- @styles ||= {}
84
- @styles = {} unless already_syntax_highlighted?
85
- if @styles[line_style_event.lineOffset].nil?
86
- styles = []
87
- syntax_highlighting[line_style_event.lineOffset].to_a.each do |token_hash|
88
- start_index = token_hash[:token_index]
89
- size = token_hash[:token_text].size
90
- token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
91
- token_color = color(*token_color).swt_color
92
- styles << StyleRange.new(start_index, size, token_color, nil)
93
- end
94
- @styles[line_style_event.lineOffset] = styles.to_java(StyleRange)
90
+ styles = []
91
+ syntax_highlighting(line_style_event.lineText).to_a.each do |token_hash|
92
+ start_index = token_hash[:token_index]
93
+ size = token_hash[:token_text].size
94
+ token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
95
+ token_color = color(*token_color).swt_color
96
+ styles << StyleRange.new(line_style_event.lineOffset + start_index, size, token_color, nil)
95
97
  end
96
- line_style_event.styles = @styles[line_style_event.lineOffset] unless @styles[line_style_event.lineOffset].empty?
98
+ line_style_event.styles = styles.to_java(StyleRange) unless styles.empty?
97
99
  }
98
100
  }
99
101
  }
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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,14 +26,14 @@ module Glimmer
26
26
  class TableProxy < Glimmer::SWT::WidgetProxy
27
27
  include Glimmer
28
28
 
29
- module TableListenerEvent
29
+ module TableListenerEvent
30
30
  def table_item
31
31
  table_item_and_column_index[:table_item]
32
32
  end
33
33
 
34
34
  def column_index
35
35
  table_item_and_column_index[:column_index]
36
- end
36
+ end
37
37
 
38
38
  private
39
39
 
@@ -51,7 +51,7 @@ module Glimmer
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
55
55
  end
56
56
 
57
57
  class << self
@@ -74,9 +74,9 @@ module Glimmer
74
74
  elsif key_event.keyCode == swt(:esc)
75
75
  table_proxy.cancel_edit!
76
76
  end
77
- }
77
+ }
78
78
  }
79
- table_editor_widget_proxy.swt_widget.selectAll
79
+ table_editor_widget_proxy.swt_widget.selectAll
80
80
  table_editor_widget_proxy
81
81
  end,
82
82
  },
@@ -101,8 +101,8 @@ module Glimmer
101
101
  }
102
102
  on_widget_selected {
103
103
  if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
104
- table_proxy.finish_edit!
105
- end
104
+ table_proxy.finish_edit!
105
+ end
106
106
  }
107
107
  }
108
108
  table_editor_widget_proxy
@@ -117,10 +117,10 @@ module Glimmer
117
117
  selection model.send(property)
118
118
  focus true
119
119
  on_widget_selected {
120
- table_proxy.finish_edit!
120
+ table_proxy.finish_edit!
121
121
  }
122
122
  on_focus_lost {
123
- table_proxy.finish_edit!
123
+ table_proxy.finish_edit!
124
124
  }
125
125
  on_key_pressed { |key_event|
126
126
  if key_event.keyCode == swt(:cr)
@@ -128,7 +128,7 @@ module Glimmer
128
128
  elsif key_event.keyCode == swt(:esc)
129
129
  table_proxy.cancel_edit!
130
130
  end
131
- }
131
+ }
132
132
  }
133
133
  end,
134
134
  },
@@ -141,10 +141,10 @@ module Glimmer
141
141
  selection model.send(property)
142
142
  focus true
143
143
  on_widget_selected {
144
- table_proxy.finish_edit!
144
+ table_proxy.finish_edit!
145
145
  }
146
146
  on_focus_lost {
147
- table_proxy.finish_edit!
147
+ table_proxy.finish_edit!
148
148
  }
149
149
  on_key_pressed { |key_event|
150
150
  if key_event.keyCode == swt(:cr)
@@ -152,11 +152,11 @@ module Glimmer
152
152
  elsif key_event.keyCode == swt(:esc)
153
153
  table_proxy.cancel_edit!
154
154
  end
155
- }
155
+ }
156
156
  }
157
157
  end,
158
- }
159
- }
158
+ }
159
+ }
160
160
  end
161
161
  end
162
162
 
@@ -188,7 +188,7 @@ module Glimmer
188
188
  end
189
189
  end
190
190
 
191
- @sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
191
+ @sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
192
192
  swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]
193
193
 
194
194
  @sort_property = new_sort_property
@@ -202,7 +202,7 @@ module Glimmer
202
202
  elsif table_column_proxy.sort_block
203
203
  @sort_block = table_column_proxy.sort_block
204
204
  else
205
- detect_sort_type
205
+ detect_sort_type
206
206
  end
207
207
  sort
208
208
  end
@@ -229,7 +229,7 @@ module Glimmer
229
229
 
230
230
  def editor=(args)
231
231
  @editor = args
232
- end
232
+ end
233
233
 
234
234
  def cells_for(model)
235
235
  column_properties.map {|property| model.send(property)}
@@ -248,7 +248,7 @@ module Glimmer
248
248
  if sort_block
249
249
  sorted_array = array.sort(&sort_block)
250
250
  elsif sort_by_block
251
- sorted_array = array.sort_by(&sort_by_block)
251
+ sorted_array = array.sort_by(&sort_by_block)
252
252
  else
253
253
  sorted_array = array.sort_by do |object|
254
254
  sort_property.each_with_index.map do |a_sort_property, i|
@@ -289,7 +289,7 @@ module Glimmer
289
289
  observer.call(@swt_widget.getSelection)
290
290
  }
291
291
  end
292
- },
292
+ },
293
293
  })
294
294
  end
295
295
 
@@ -370,13 +370,13 @@ module Glimmer
370
370
  swt_widget.showItem(edited_table_item)
371
371
  @table_editor_widget_proxy&.swt_widget&.dispose
372
372
  @table_editor_widget_proxy = nil
373
- after_write&.call(edited_table_item)
373
+ after_write&.call(edited_table_item)
374
374
  @edit_in_progress = false
375
375
  end
376
376
  end
377
377
  end
378
378
 
379
- content {
379
+ content {
380
380
  @table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
381
381
  }
382
382
  @table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -40,7 +40,7 @@ module Glimmer
40
40
 
41
41
  def widget_remove_listener_method
42
42
  @widget_add_listener_method.sub('add', 'remove')
43
- end
43
+ end
44
44
 
45
45
  def unregister
46
46
  # TODO consider renaming to deregister (and in Observer too)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -43,7 +43,7 @@ class HelloGroup
43
43
  person = Person.new
44
44
 
45
45
  shell {
46
- text 'Hello, Radio!'
46
+ text 'Hello, Group!'
47
47
  row_layout :vertical
48
48
 
49
49
  group {
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-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
@@ -0,0 +1,130 @@
1
+ # Copyright (c) 2007-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
+ class HelloTable
23
+ class BaseballGame
24
+ class << self
25
+ def schedule
26
+ @schedule ||= [
27
+ new('Chicago Cubs', 'Milwaukee Brewers', Time.new(2037, 10, 6, 12, 0)),
28
+ new('Chicago Cubs', 'Milwaukee Brewers', Time.new(2037, 10, 7, 12, 0)),
29
+ new('Milwaukee Brewers', 'Chicago Cubs', Time.new(2037, 10, 8, 12, 0)),
30
+ new('Milwaukee Brewers', 'Chicago Cubs', Time.new(2037, 10, 9, 12, 0)),
31
+ new('Milwaukee Brewers', 'Chicago Cubs', Time.new(2037, 10, 10, 12, 0)),
32
+ new('Chicago White Sox', 'St Louis Cardinals', Time.new(2037, 10, 6, 18, 0)),
33
+ new('Chicago White Sox', 'St Louis Cardinals', Time.new(2037, 10, 7, 18, 0)),
34
+ new('St Louis Cardinals', 'Chicago White Sox', Time.new(2037, 10, 8, 18, 0)),
35
+ new('St Louis Cardinals', 'Chicago White Sox', Time.new(2037, 10, 9, 18, 0)),
36
+ new('St Louis Cardinals', 'Chicago White Sox', Time.new(2037, 10, 10, 18, 0)),
37
+ ]
38
+ end
39
+
40
+ def schedule=(new_schedule)
41
+ @schedule = new_schedule
42
+ end
43
+ end
44
+
45
+ include Glimmer::DataBinding::ObservableModel
46
+
47
+ TEAM_BALLPARKS = {
48
+ 'Chicago Cubs' => 'Wrigley Field',
49
+ 'Chicago White Sox' => 'Guaranteed Rate Field',
50
+ 'Milwaukee Brewers' => 'Miller Park',
51
+ 'St Louis Cardinals' => 'Busch Stadium'
52
+ }
53
+
54
+ attr_accessor :home_team, :away_team, :date_time, :ballpark
55
+
56
+ def initialize(home_team, away_team, date_time)
57
+ self.home_team = home_team
58
+ self.away_team = away_team
59
+ self.date_time = date_time
60
+ end
61
+
62
+ def home_team=(home_team_value)
63
+ if home_team_value != away_team
64
+ @home_team = home_team_value
65
+ self.ballpark = TEAM_BALLPARKS[@home_team]
66
+ end
67
+ end
68
+
69
+ def away_team=(away_team_value)
70
+ if away_team_value != home_team
71
+ @away_team = away_team_value
72
+ end
73
+ end
74
+
75
+ def game_date_time
76
+ date_time.strftime("%Y-%m-%d %I:%M %p")
77
+ end
78
+
79
+ def home_team_options
80
+ TEAM_BALLPARKS.keys
81
+ end
82
+
83
+ def away_team_options
84
+ TEAM_BALLPARKS.keys
85
+ end
86
+ end
87
+
88
+ include Glimmer
89
+
90
+ def launch
91
+ shell {
92
+ text 'Hello, Table!'
93
+ table { |table_proxy|
94
+ table_column {
95
+ text 'Game Date/Time'
96
+ width 150
97
+ sort_property :date_time # ensure sorting by real date value (not `game_date_time` string specified in items below)
98
+ editor :none
99
+ }
100
+ table_column {
101
+ text 'Home Team'
102
+ width 150
103
+ editor :combo, :read_only
104
+ }
105
+ table_column {
106
+ text 'Away Team'
107
+ width 150
108
+ editor :combo, :read_only
109
+ }
110
+ table_column {
111
+ text 'Ballpark'
112
+ width 150
113
+ editor :none
114
+ }
115
+
116
+ # Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
117
+ items bind(BaseballGame, :schedule), column_properties(:game_date_time, :home_team, :away_team, :ballpark)
118
+
119
+ # Sort by these additional properties after handling the main column sort the user selected
120
+ additional_sort_properties :date_time, :home_team, :away_team, :ballpark
121
+
122
+ on_mouse_up { |event|
123
+ table_proxy.edit_table_item(event.table_item, event.column_index)
124
+ }
125
+ }
126
+ }.open
127
+ end
128
+ end
129
+
130
+ HelloTable.new.launch
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.17.8.2
4
+ version: 4.17.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -452,6 +452,7 @@ files:
452
452
  - samples/hello/hello_sash_form.rb
453
453
  - samples/hello/hello_styled_text.rb
454
454
  - samples/hello/hello_tab.rb
455
+ - samples/hello/hello_table.rb
455
456
  - samples/hello/hello_world.rb
456
457
  - vendor/swt/linux/swt.jar
457
458
  - vendor/swt/mac/swt.jar