glimmer-dsl-swt 4.24.4.5 → 4.24.4.7

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: 529a6e52ee5f12439588d4e74d7cb71cf571dc5708c0f30d4a8212fc93bbcd94
4
- data.tar.gz: beee81b79e38eb8c4f06efae74cbcf449284dcfdc012662529b304272cd2c959
3
+ metadata.gz: fa2c86f6cd6f3f38a1f5790a1b66b61fd90d354af69ef815be3330a272bd2e4f
4
+ data.tar.gz: ed9d793052ab0f83533f517d90dd0419771a6b110ca642f70691f06eac3159c5
5
5
  SHA512:
6
- metadata.gz: 955e339c7ee47be0f1d2a400a83689b71a7a3c1737a0738ef58cd779f6ac2c805609bf81f462bb3b1dfcf6bfe421e31f18037b2a7139c5bf0877d7ae776d4377
7
- data.tar.gz: ce4943970d11b34972bafe1138a0878431d5e5f5b6c5943edfa8b51f5591540f781c86eef1150e7ee4306d8ba3a38f4e3ca75e6dfa57b424dc13d37b1845921b
6
+ metadata.gz: 250fe4baa75533f2a5c5fec95c26e750f517f6a969621f347ce56e5a1c4f8bb5c8dc8029824809f84b8b0cab3be512b359d45a200ccd7c4942d1bc8535fb04f7
7
+ data.tar.gz: 863cccf44a913613b242dab209be6c1ce24daa974c458c2f4dced7440012573df1c324025eb91220afbf1571e3f57bc5628dd5397ddbb131535b0175394f827f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.4.7
4
+
5
+ - Optimize performance of `refined_table` in filtering (it now caches results and replays them) and pagination (it now remembers last query page and avoids refiltering when paginating on the same query value)
6
+ - Improve `combo` `selection` data-binding by auto-converting `_options` values to `String` before setting as `Item`s on `combo` (e.g. in case `Integer` values were set like years)
7
+
8
+ ## 4.24.4.6
9
+
10
+ - Support `refined_table` sorting (now clicking on headers sorts the entire `model_array` collection, not just the visible rows)
11
+ - Support `table` `no_sort` attribute to disable sorting in general if needed
12
+ - Fix issue with Tetris sample upon restart of game (WidgetProxy#shell_proxy method was failing for being disposed, now it retains a reference to parent that stays if disposed)
13
+
3
14
  ## 4.24.4.5
4
15
 
5
16
  - Support `refined_table` `:editable` SWT style and `model_array` bidirectional data-binding
data/README.md CHANGED
@@ -1,4 +1,4 @@
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.24.4.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.24.4.7
2
2
  ## JRuby Desktop Development GUI Framework
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
4
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
@@ -21,7 +21,7 @@ Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) an
21
21
 
22
22
  ![Eclipse SWT RCP NASA Mars Rover](/images/glimmer-eclipse-swt-rcp-nasa-mars-rover.png)
23
23
 
24
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.4.5 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
24
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.24.4.7 includes [SWT 4.24](https://download.eclipse.org/eclipse/downloads/drops4/R-4.24-202206070700/), which was released on June 7, 2022. Gem version numbers are in sync with the SWT library versions. The first two digits represent the SWT version number. The last two digits represent the minor and patch versions of Glimmer DSL for SWT.
25
25
 
26
26
  **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword. That was [originally conceived back in 2007](https://andymaleh.blogspot.com/2007/12/data-shining-in-glimmer.html).
27
27
 
@@ -338,7 +338,7 @@ jgem install glimmer-dsl-swt
338
338
 
339
339
  Or this command if you want a specific version:
340
340
  ```
341
- jgem install glimmer-dsl-swt -v 4.24.4.5
341
+ jgem install glimmer-dsl-swt -v 4.24.4.7
342
342
  ```
343
343
 
344
344
  `jgem` is JRuby's version of `gem` command.
@@ -366,7 +366,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
366
366
 
367
367
  Add the following to `Gemfile`:
368
368
  ```
369
- gem 'glimmer-dsl-swt', '~> 4.24.4.5'
369
+ gem 'glimmer-dsl-swt', '~> 4.24.4.7'
370
370
  ```
371
371
 
372
372
  And, then run:
@@ -389,7 +389,7 @@ glimmer
389
389
  ```
390
390
 
391
391
  ```
392
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.4.5
392
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.4.7
393
393
 
394
394
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
395
395
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.24.4.5
1
+ 4.24.4.7
@@ -4309,7 +4309,7 @@ Here is an explanation of the example above:
4309
4309
 
4310
4310
  ##### Refined Table
4311
4311
 
4312
- **(ALPHA FEATURE)**
4312
+ **(BETA FEATURE)**
4313
4313
 
4314
4314
  `refined_table` is a custom widget that can handle very large amounts of data by applying pagination and filtering.
4315
4315
 
@@ -4320,7 +4320,9 @@ Options:
4320
4320
  - `page` (default: `1` if table is filled and `0` otherwise): specifies initial page
4321
4321
  - `query` (default: `''`): specifies filter query term (empty shows all results)
4322
4322
 
4323
- Note that currently `refined_table` does not support sorting by clicking columns yet.
4323
+ When click columns (headers) in a `refined_table`, it sorts the entire `model_array`, not just the visible rows.
4324
+
4325
+ Also, upon filtering with a query term, moving in pages, and then unfiltering (backspacing)/refiltering, it remembers the last query term's page and results (through caching) and goes back to them, thus ensuring better performance.
4324
4326
 
4325
4327
  Example taken from [Hello, Refined Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-refined-table):
4326
4328
 
Binary file
@@ -39,6 +39,7 @@ module Glimmer
39
39
 
40
40
  before_body do
41
41
  self.query ||= ''
42
+ @last_query = self.query
42
43
  self.model_array ||= []
43
44
  self.filtered_model_array = []
44
45
  self.refined_model_array = []
@@ -50,7 +51,10 @@ module Glimmer
50
51
  if new_widget_binding.property.to_s == 'model_array' && !@data_bound
51
52
  @data_bound = true
52
53
  model_binding = new_widget_binding.model_binding
54
+ configure_sorting
53
55
  observe(self, :model_array) do
56
+ @query_to_filtered_model_array_hash = {}
57
+ @query_to_page_hash = {}
54
58
  filter_and_paginate
55
59
  end
56
60
  @table_proxy.content {
@@ -199,17 +203,83 @@ module Glimmer
199
203
  end
200
204
 
201
205
  def filter
202
- self.filtered_model_array = model_array.select do |model|
203
- @table_proxy.cells_for(model).any? do |cell_text|
204
- cell_text.to_s.downcase.include?(query.to_s.downcase)
206
+ new_query = query.to_s.strip
207
+ new_filtered_model_array = query_to_filtered_model_array_hash[new_query]
208
+ if new_filtered_model_array.nil?
209
+ if new_query.empty?
210
+ query_to_filtered_model_array_hash[new_query] = new_filtered_model_array = model_array.dup
211
+ else
212
+ new_filtered_model_array = model_array.select do |model|
213
+ @table_proxy.cells_for(model).any? do |cell_text|
214
+ cell_text.to_s.downcase.include?(new_query.downcase)
215
+ end
216
+ end
217
+ query_to_filtered_model_array_hash[new_query] = new_filtered_model_array
205
218
  end
206
219
  end
220
+ self.filtered_model_array = new_filtered_model_array
221
+ restore_query_page
222
+ @last_query = new_query
207
223
  end
208
224
 
209
225
  def paginate
210
226
  self.page = corrected_page(page)
211
227
  self.refined_model_array = filtered_model_array[(page - 1) * per_page, per_page]
212
228
  end
229
+
230
+ def restore_query_page
231
+ new_query = query.to_s.strip
232
+ last_query = @last_query.to_s.strip
233
+ if last_query != new_query
234
+ query_to_page_hash[last_query] = page
235
+ else
236
+ query_to_page_hash[new_query] = page
237
+ end
238
+ if last_query != new_query && last_query.include?(new_query)
239
+ new_page = query_to_page_hash[new_query]
240
+ self.page = corrected_page(new_page) if new_page
241
+ end
242
+ end
243
+
244
+ def query_to_filtered_model_array_hash
245
+ @query_to_filtered_model_array_hash ||= {}
246
+ end
247
+
248
+ def query_to_page_hash
249
+ @query_to_page_hash ||= {}
250
+ end
251
+
252
+ private
253
+
254
+ def configure_sorting
255
+ @table_proxy.sort_strategy = lambda do
256
+ array = model_array.dup
257
+ array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
258
+ # Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
259
+ if @table_proxy.sort_block
260
+ sorted_array = array.sort(&@table_proxy.sort_block)
261
+ elsif @table_proxy.sort_by_block
262
+ sorted_array = array.sort_by(&@table_proxy.sort_by_block)
263
+ else
264
+ sorted_array = array.sort_by do |object|
265
+ @table_proxy.sort_property.each_with_index.map do |a_sort_property, i|
266
+ value = object.send(a_sort_property)
267
+ # handle nil and difficult to compare types gracefully
268
+ if @table_proxy.sort_type[i] == Integer
269
+ value = value.to_i
270
+ elsif @table_proxy.sort_type[i] == Float
271
+ value = value.to_f
272
+ elsif @table_proxy.sort_type[i] == String
273
+ value = value.to_s
274
+ end
275
+ value
276
+ end
277
+ end
278
+ end
279
+ sorted_array = sorted_array.reverse if @table_proxy.sort_direction == :descending
280
+ self.model_array = sorted_array
281
+ end
282
+ end
213
283
  end
214
284
  end
215
285
  end
@@ -27,15 +27,15 @@ module Glimmer
27
27
  # A proxy object representing SWT TableColumn
28
28
  # Accepts a :no_sort custom style to disable sorting on this column
29
29
  class TableColumnProxy < Glimmer::SWT::WidgetProxy
30
- attr_reader :no_sort, :sort_property, :editor
30
+ attr_reader :sort_property, :editor
31
+ attr_accessor :no_sort, :sort_block, :sort_by_block
31
32
  alias no_sort? no_sort
32
- attr_accessor :sort_block, :sort_by_block
33
33
 
34
34
  def initialize(underscored_widget_name, parent, args)
35
35
  @no_sort = args.delete(:no_sort)
36
36
  super
37
37
  on_widget_selected do |event|
38
- parent.sort_by_column!(self)
38
+ parent.sort_by_column!(self) unless no_sort?
39
39
  end unless no_sort?
40
40
  end
41
41
 
@@ -247,7 +247,7 @@ module Glimmer
247
247
 
248
248
  attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor, :editable
249
249
  attr_writer :column_properties
250
- attr_accessor :table_items_binding
250
+ attr_accessor :table_items_binding, :sort_strategy
251
251
  alias column_attributes= column_properties=
252
252
  alias editable? editable
253
253
 
@@ -398,36 +398,46 @@ module Glimmer
398
398
 
399
399
  def sort!(internal_sort: false)
400
400
  return unless sort_property && (sort_type || sort_block || sort_by_block)
401
- original_array = array = model_binding.evaluate_property
402
- array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
403
- # Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
404
- if sort_block
405
- sorted_array = array.sort(&sort_block)
406
- elsif sort_by_block
407
- sorted_array = array.sort_by(&sort_by_block)
401
+ if sort_strategy
402
+ sort_strategy.call
408
403
  else
409
- sorted_array = array.sort_by do |object|
410
- sort_property.each_with_index.map do |a_sort_property, i|
411
- value = object.send(a_sort_property)
412
- # handle nil and difficult to compare types gracefully
413
- if sort_type[i] == Integer
414
- value = value.to_i
415
- elsif sort_type[i] == Float
416
- value = value.to_f
417
- elsif sort_type[i] == String
418
- value = value.to_s
404
+ original_array = array = model_binding.evaluate_property
405
+ array = array.sort_by(&:hash) # this ensures consistent subsequent sorting in case there are equivalent sorts to avoid an infinite loop
406
+ # Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
407
+ if sort_block
408
+ sorted_array = array.sort(&sort_block)
409
+ elsif sort_by_block
410
+ sorted_array = array.sort_by(&sort_by_block)
411
+ else
412
+ sorted_array = array.sort_by do |object|
413
+ sort_property.each_with_index.map do |a_sort_property, i|
414
+ value = object.send(a_sort_property)
415
+ # handle nil and difficult to compare types gracefully
416
+ if sort_type[i] == Integer
417
+ value = value.to_i
418
+ elsif sort_type[i] == Float
419
+ value = value.to_f
420
+ elsif sort_type[i] == String
421
+ value = value.to_s
422
+ end
423
+ value
419
424
  end
420
- value
421
425
  end
422
426
  end
427
+ sorted_array = sorted_array.reverse if sort_direction == :descending
428
+ if model_binding.binding_options.symbolize_keys[:read_only_sort]
429
+ table_items_binding.call(sorted_array, internal_sort: true) unless internal_sort
430
+ else
431
+ model_binding.call(sorted_array)
432
+ end
433
+ sorted_array
423
434
  end
424
- sorted_array = sorted_array.reverse if sort_direction == :descending
425
- if model_binding.binding_options.symbolize_keys[:read_only_sort]
426
- table_items_binding.call(sorted_array, internal_sort: true) unless internal_sort
427
- else
428
- model_binding.call(sorted_array)
435
+ end
436
+
437
+ def no_sort=(value)
438
+ table_column_proxies.each do |table_column_proxy|
439
+ table_column_proxy.no_sort = value
429
440
  end
430
- sorted_array
431
441
  end
432
442
 
433
443
  def editor=(args)
@@ -167,6 +167,7 @@ module Glimmer
167
167
  parent = swt_widget.parent
168
168
  @parent_proxy = parent&.get_data('proxy') || parent_proxy_class.new(swt_widget: parent)
169
169
  end
170
+ shell_proxy # populates @shell_proxy attribute
170
171
  if @swt_widget&.get_data('proxy').nil?
171
172
  @swt_widget.set_data('proxy', self)
172
173
  DEFAULT_INITIALIZERS[underscored_widget_name.to_s.to_sym]&.call(@swt_widget)
@@ -201,10 +202,12 @@ module Glimmer
201
202
  end
202
203
 
203
204
  def shell_proxy
204
- if @swt_widget.respond_to?(:shell)
205
- @swt_widget.shell.get_data('proxy')
205
+ if @swt_widget.respond_to?(:shell) && !@swt_widget.is_disposed
206
+ @shell_proxy = @swt_widget.shell.get_data('proxy')
207
+ elsif @parent_proxy&.shell_proxy
208
+ @shell_proxy = @parent_proxy&.shell_proxy
206
209
  else
207
- @parent_proxy&.shell_proxy
210
+ @shell_proxy
208
211
  end
209
212
  end
210
213
 
@@ -1143,7 +1146,7 @@ module Glimmer
1143
1146
  end.to_java(Image)
1144
1147
  end,
1145
1148
  items: lambda do |value|
1146
- value.to_java :string
1149
+ value.map(&:to_s).to_java :string
1147
1150
  end,
1148
1151
  maximized_control: lambda do |value|
1149
1152
  value = (value.respond_to?(:swt_widget) ? value.swt_widget : value) if swt_widget.is_a?(SashForm)
@@ -31,3 +31,5 @@ Hello, Custom Shell!: c8Eb8GWM_XQ
31
31
  Hello, Custom Shape!: H3J8ecp30Ak
32
32
  Battleship: b00OWeLZOt8
33
33
  Klondike Solitaire: qOzgiz9X3sI
34
+ Tetris: oQbBCXACOLY
35
+ Hello, Refined Table!: PEfCZiUa1qo
@@ -28,11 +28,11 @@ class Tetris
28
28
 
29
29
  options :parent_shell, :game
30
30
 
31
- after_body {
31
+ after_body do
32
32
  @game_over_observer = observe(game, :game_over) do |game_over|
33
33
  close if !game_over
34
34
  end
35
- }
35
+ end
36
36
 
37
37
  body {
38
38
  dialog(parent_shell) {
@@ -112,6 +112,7 @@ class HelloRefinedTable
112
112
 
113
113
  BaseballSeason = Struct.new(:year) do
114
114
  attr_accessor :selected_game
115
+ attr_writer :games
115
116
 
116
117
  def games
117
118
  if @games.nil?
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.24.4.5
4
+ version: 4.24.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-17 00:00:00.000000000 Z
11
+ date: 2022-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement