glimmer-dsl-swt 4.24.4.0 → 4.24.4.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: 81eb61402ae45b2e3782b9c10dc6b0374e39fb7f74351d2ed940719fbd6e4ec3
4
- data.tar.gz: dfa93b670ddc363dd2dc602920d5e24510202b179f7e7740ee8abc50fc91eee4
3
+ metadata.gz: 1b47f7d900d7e9e17d688b2a87f6996e2a4e23f2aec2139b7d5efc03fc1837d7
4
+ data.tar.gz: 0dd67034463fa4193ebbb4c064f6d2dccfd26dde29d326fef69b8a12b80a04a6
5
5
  SHA512:
6
- metadata.gz: 46bee26330ce88284c85f263b0db58dda6dfb76cd2d2f37938c881f6567d74cd0a514565625a6c21da53b91e119fd31185dda8b22626e357fb79612e9013f6fe
7
- data.tar.gz: '049762158e8e4015ec1a157edd148212078a106b753b9ad4f6111ab49746fe2934471382b4c5c20d9ee00a9abca8d8c22866c1c3ecd7aa733ccc5aeb28eb6c7b'
6
+ metadata.gz: 5737d7b9ad280998dfe94b4e4df7879ee48ff805c2abb0bb1626a3d688684371c2aca03c0da8eb27e2011a4ab26e58f3e4c3a44154056d7197a66acfb89ef4c1
7
+ data.tar.gz: 05e8484a449adcbd19a4f1b4ba8644614032a272ec957770bbbc1c11cdbea8299fdeaed0ebcbf42df493280782d6b425ec4d967dca8f967a6fc1a1a95dbaeff2
data/CHANGELOG.md CHANGED
@@ -1,7 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.24.4.3
4
+
5
+ - Fix issue with failed `table` extra property data-binding (e.g. foreground color, background color) due to asynchronous multi-threading optimization (now it works).
6
+
7
+ ## 4.24.4.2
8
+
9
+ - `refined_table` filtering support
10
+ - Ensure correct `refined_table` enablement of pagination buttons based on whether on first/last page or not
11
+ - Display vertical scroll bar when setting `refined_table` `per_page` to a height value that results in table exceeding screen height
12
+ - Support `refined_table` nested elements `first_button {}`, `previous_button {}`, `page_text {}`, `next_button {}`, `last_button {}` to customize every widget within.
13
+ - Support `refined_table` attributes for accessing nested elements: `table_proxy`, `first_button_proxy`, `previous_button_proxy`, `page_text_proxy`, `next_button_proxy`, `last_button_proxy` to customize every widget within.
14
+
15
+ ## 4.24.4.1
16
+
17
+ - Optimize `table` data-binding performance (improving paging performance in `refined_table`) by making observer registrations run asynchronously in a separate thread
18
+ - Fix cleaning of old `table` data-binding observers (it was retaining some old observers after table updates)
19
+ - Fix issue with ActiveSupport overriding Facets String `underscore`/`snakecase`/`titlecase`/`camelcase` methods with different incompatible implementations when loaded by a project (now, that is repaired automatically)
20
+
3
21
  ## 4.24.4.0
4
22
 
23
+ - `refined_table` custom widget with pagination support (and future filtering support)
24
+ - Hello, Refined Table! sample demonstrating `refined_table`
5
25
  - Save `WidgetBinding` instances on `WidgetProxy` objects via `widget_bindings` attribute
6
26
  - Support specifying `@children_owner` in any custom widget for which adding children will not add them under the `body_root` (e.g. a composite wrapping a table will designate the table as the `@children_owner` for adding `table_column`s)
7
27
  - Add explicit `shell_proxy` method to `Glimmer::UI::CustomWidget` that delegates to `body_root` to avoid annoying false negative error every time that method is called
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.0
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.3
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.0 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.3 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.0
341
+ jgem install glimmer-dsl-swt -v 4.24.4.3
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.0'
369
+ gem 'glimmer-dsl-swt', '~> 4.24.4.3'
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.0
392
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.24.4.3
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.0
1
+ 4.24.4.3
@@ -58,7 +58,7 @@ This guide should help you get started with Glimmer DSL for SWT. For more advanc
58
58
  - [Table Selection](#table-selection)
59
59
  - [Table Editing](#table-editing)
60
60
  - [Table Sorting](#table-sorting)
61
- - [Refined Table with Pagination](#refined-table-with-pagination)
61
+ - [Refined Table](#refined-table)
62
62
  - [Tree](#tree)
63
63
  - [DateTime](#datetime)
64
64
  - [Observer](#observer)
@@ -4111,8 +4111,8 @@ This automatically leverages the SWT TableEditor custom class behind the scenes,
4111
4111
  passed table item text into something else.
4112
4112
  It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
4113
4113
 
4114
- Note that `table` is designed to expect about 100 rows only, not more than that, or otherwise it will not offer a user-friendly experience due to requiring users to scroll through a lot of data.
4115
- If you need to display a table with more than 100 rows, then you need to employ pagination. That is already supported in the [Refined Table (`refined_table`)](#refined-table-with-pagination) custom widget documented below.
4114
+ Note that `table` is useful with a maximum of about 100 rows only, not more than that, or otherwise it will not offer a user-friendly experience due to requiring users to scroll through a lot of data.
4115
+ If you need to display a table with more than 100 rows, then you need to employ pagination. That is already supported in the [Refined Table (`refined_table`)](#refined-table) custom widget documented below.
4116
4116
 
4117
4117
  ##### Table Item Properties
4118
4118
 
@@ -4241,7 +4241,7 @@ shell {
4241
4241
 
4242
4242
  Check out [Hello, Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-table) for an actual example including table editors.
4243
4243
 
4244
- [Are We There Yet?](#are-we-there-yet) is an actual production Glimmer application that takes full advantage of table capabilities, storing model data in a database via ActiveRecord. As such, it's an excellent demonstration of how to use Glimmer DSL for SWT with a database.
4244
+ [Are We There Yet?](#are-we-there-yet) is an actual production Glimmer application that takes full advantage of table capabilities, storing model data in a database via ActiveRecord and SQLite DB. As such, it's an excellent demonstration of how to use Glimmer DSL for SWT with a database. [Contact Manager](https://github.com/AndyObtiva/contact_manager) is an external sample application that also utilizes a table with ActiveRecord and SQLite DB. It comes with a [blog post](https://andymaleh.blogspot.com/2022/06/using-activerecord-with-sqlite-db-in.html?m=0) that provides a step by step guide on how to build such an application.
4245
4245
 
4246
4246
  ##### Table Sorting
4247
4247
 
@@ -4307,19 +4307,20 @@ Here is an explanation of the example above:
4307
4307
 
4308
4308
  `<= [model, :property, read_only_sort: true]` could be used with items to make sorting not propagate sorting changes to model.
4309
4309
 
4310
- ##### Refined Table with Pagination
4310
+ ##### Refined Table
4311
4311
 
4312
4312
  **(ALPHA FEATURE)**
4313
4313
 
4314
- `refined_table` is a custom widget that can handle very large amounts of data by applying pagination.
4314
+ `refined_table` is a custom widget that can handle very large amounts of data by applying pagination and filtering.
4315
4315
 
4316
- Just use like a standard `table`, but data-bind models to a `model_array` property instead of `items`. `refined_table` will take care of the rest.
4316
+ Just use like a standard `table`, but data-bind models to the `model_array` property instead of `items`. `refined_table` will take care of the rest.
4317
4317
 
4318
4318
  Options:
4319
4319
  - `per_page` (default: `10`): specifies how many rows to display per page
4320
4320
  - `page` (default: `1` if table is filled and `0` otherwise): specifies initial page
4321
+ - `query` (default: `''`): specifies filter query term (empty shows all results)
4321
4322
 
4322
- Note that currently `refined_table` only supports displaying a **read-only** table (meaning it can read updates from the model, but it cannot write back to the model through table editing cells).
4323
+ Note that currently `refined_table` only supports displaying a **read-only** table (meaning it can read updates from the model, but it cannot write back to the model through `TableEditor` cells). Also, it does not support selection or sorting by clicking columns yet.
4323
4324
 
4324
4325
  Example taken from [Hello, Refined Table!](/docs/reference/GLIMMER_SAMPLES.md#hello-refined-table):
4325
4326
 
@@ -783,7 +783,7 @@ Hello, Table! Game Booked Rows
783
783
 
784
784
  #### Hello, Refined Table!
785
785
 
786
- This sample demonstrates the use of the [`refined_table` widget](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#refined-table-with-pagination), which provides a paginated `table` that can handle very large amounts of data.
786
+ This sample demonstrates the use of the [`refined_table` widget](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#refined-table), which provides a paginated `table` that can handle very large amounts of data.
787
787
 
788
788
  Code:
789
789
 
Binary file
data/lib/ext/glimmer.rb CHANGED
@@ -27,6 +27,11 @@ module Glimmer
27
27
  if Object.const_defined?(:ActiveSupport) && ActiveSupport.const_defined?(:Dependencies)
28
28
  begin
29
29
  ActiveSupport::Dependencies.unhook!
30
+ # override activesupport string method implementations if already loaded
31
+ gem 'facets'
32
+ load 'facets/string/snakecase.rb'
33
+ load 'facets/string/titlecase.rb'
34
+ load 'facets/string/camelcase.rb'
30
35
  rescue => e
31
36
  # noop TODO support logging unimportant details below debug level
32
37
  end
@@ -37,9 +37,12 @@ module Glimmer
37
37
  include_package 'org.eclipse.swt.widgets'
38
38
 
39
39
  TABLE_ITEM_PROPERTIES = %w[background foreground font image]
40
+
41
+ attr_reader :data_binding_done
40
42
 
41
43
  def initialize(parent, model_binding, column_properties = nil)
42
44
  @table = parent.is_a?(Glimmer::SWT::TableProxy) ? parent : parent.body_root # assume custom widget in latter case
45
+ @table.table_items_binding = self
43
46
  @model_binding = model_binding
44
47
  @read_only_sort = @model_binding.binding_options[:read_only_sort]
45
48
  @table.editable = false if @model_binding.binding_options[:read_only]
@@ -81,35 +84,43 @@ module Glimmer
81
84
  else
82
85
  if new_model_collection and new_model_collection.is_a?(Array)
83
86
  @model_observer_registrations ||= {}
84
- new_model_collection.each do |model|
85
- @model_observer_registrations[model] ||= {}
86
- @column_properties.each do |column_property|
87
- old_model_observer_registration = @model_observer_registrations[model][column_property]
88
- remove_dependent(@table_observer_registration => old_model_observer_registration) if old_model_observer_registration
89
- old_model_observer_registration&.unobserve
90
- model_observer_registration = observe(model, column_property)
91
- @model_observer_registrations[model][column_property] = model_observer_registration
92
- add_dependent(@table_observer_registration => model_observer_registration)
93
- end
94
- end
95
-
96
- if !same_model_collection_with_different_sort?(new_model_collection)
97
- new_model_collection.each do |model|
98
- TABLE_ITEM_PROPERTIES.each do |table_item_property|
87
+ @table_item_property_observation_mutex ||= Mutex.new
88
+
89
+ brand_new_model_collection = !same_model_collection_with_different_sort?(new_model_collection)
90
+
91
+ Thread.new do
92
+ @data_binding_done = false
93
+ @table_item_property_observation_mutex.synchronize do
94
+ deregister_model_observer_registrations
95
+
96
+ new_model_collection.each_with_index do |model, model_index|
97
+ @model_observer_registrations[model_index] ||= {}
99
98
  @column_properties.each do |column_property|
100
- column_property = "#{column_property}_#{table_item_property}"
101
- old_model_observer_registration = @model_observer_registrations[model][column_property]
102
- remove_dependent(@table_observer_registration => old_model_observer_registration) if old_model_observer_registration
103
- old_model_observer_registration&.unobserve
104
99
  model_observer_registration = observe(model, column_property)
105
- @model_observer_registrations[model][column_property] = model_observer_registration
100
+ @model_observer_registrations[model_index][column_property] = model_observer_registration
106
101
  add_dependent(@table_observer_registration => model_observer_registration)
107
102
  end
108
103
  end
104
+
105
+ if brand_new_model_collection
106
+ new_model_collection.each_with_index do |model, model_index|
107
+ TABLE_ITEM_PROPERTIES.each do |table_item_property|
108
+ @column_properties.each do |column_property|
109
+ column_property = "#{column_property}_#{table_item_property}"
110
+ model_observer_registration = observe(model, column_property)
111
+ @model_observer_registrations[model_index][column_property] = model_observer_registration
112
+ add_dependent(@table_observer_registration => model_observer_registration)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ @data_binding_done = true
109
118
  end
110
119
  end
111
120
 
112
121
  @model_collection = new_model_collection
122
+ else
123
+ @model_collection = []
113
124
  end
114
125
 
115
126
  populate_table(@model_collection, @table, @column_properties, internal_sort: internal_sort)
@@ -214,6 +225,17 @@ module Glimmer
214
225
  @table.swt_widget.items.map(&:get_data)
215
226
  end
216
227
 
228
+ def deregister_model_observer_registrations
229
+ @model_observer_registrations&.dup&.each do |model_index, model_column_properties|
230
+ model_column_properties.dup.each do |column_property, model_observer_registration|
231
+ remove_dependent(@table_observer_registration => model_observer_registration) if model_observer_registration
232
+ model_observer_registration&.unobserve
233
+ model_column_properties.delete(column_property)
234
+ end
235
+ @model_observer_registrations.delete(model_index)
236
+ end
237
+ end
238
+
217
239
  def model_collection_attribute_values(model_collection)
218
240
  model_collection.map do |model|
219
241
  (["text"] + TABLE_ITEM_PROPERTIES).map do |table_item_property|
@@ -31,12 +31,16 @@ module Glimmer
31
31
  option :per_page, default: 10
32
32
  option :page, default: 0
33
33
  option :model_array
34
+ option :query, default: ''
34
35
 
36
+ attr_accessor :filtered_model_array
35
37
  attr_accessor :refined_model_array
36
- attr_reader :table_proxy, :page_text_proxy
38
+ attr_reader :table_proxy, :page_text_proxy, :first_button_proxy, :previous_button_proxy, :next_button_proxy, :last_button_proxy
37
39
 
38
40
  before_body do
41
+ self.query ||= ''
39
42
  self.model_array ||= []
43
+ self.filtered_model_array = []
40
44
  self.refined_model_array = []
41
45
  end
42
46
 
@@ -47,12 +51,12 @@ module Glimmer
47
51
  @data_bound = true
48
52
  model_binding = new_widget_binding.model_binding
49
53
  observe(self, :model_array) do
50
- paginate
54
+ filter_and_paginate
51
55
  end
52
56
  @table_proxy.content {
53
57
  items(dsl: true) <=> [self, :refined_model_array, model_binding.binding_options.merge(read_only: true)]
54
58
  }
55
- paginate
59
+ filter_and_paginate
56
60
  end
57
61
  end
58
62
  end.observe(body_root.widget_bindings)
@@ -60,76 +64,112 @@ module Glimmer
60
64
 
61
65
  body {
62
66
  composite {
63
- composite {
67
+ text(:search, :border) {
64
68
  layout_data(:fill, :center, true, false)
65
69
 
66
- fill_layout(:horizontal)
70
+ text <=> [self, :query, after_write: -> { filter_and_paginate }]
71
+ }
72
+
73
+ pagination
74
+
75
+ @children_owner = @table_proxy = table(swt_style) {
76
+ layout_data(:fill, :fill, true, true)
77
+ }
78
+ }
79
+ }
80
+
81
+ def pagination
82
+ composite {
83
+ layout_data(:fill, :center, true, false)
84
+
85
+ fill_layout(:horizontal)
86
+
87
+ @first_button_proxy = button {
88
+ text '<<'
89
+ enabled <= [self, :page, on_read: ->(value) {value > first_page}]
67
90
 
68
- button {
69
- text '<<'
70
-
71
- on_widget_selected do
72
- self.page = first_page
73
- paginate
74
- end
75
- }
91
+ on_widget_selected do
92
+ self.page = first_page
93
+ filter_and_paginate
94
+ end
95
+ }
96
+
97
+ @previous_button_proxy = button {
98
+ text '<'
99
+ enabled <= [self, :page, on_read: ->(value) {value > first_page}]
76
100
 
77
- button {
78
- text '<'
79
-
80
- on_widget_selected do
81
- self.page -= 1
82
- paginate
83
- end
84
- }
101
+ on_widget_selected do
102
+ self.page -= 1
103
+ filter_and_paginate
104
+ end
105
+ }
106
+
107
+ @page_text_proxy = text(:border, :center) {
108
+ text <= [self, :page, on_read: ->(value) { "#{value} of #{page_count}" }]
85
109
 
86
- @page_text_proxy = text(:border, :center) {
87
- text <= [self, :page, on_read: ->(value) { "#{value} of #{page_count}" }]
88
-
89
- on_focus_gained do
90
- @page_text_proxy.select_all
91
- end
92
-
93
- on_focus_lost do
94
- self.page = @page_text_proxy.text.to_i
95
- paginate
96
- end
97
-
98
- on_key_pressed do |key_event|
99
- if key_event.keyCode == swt(:cr)
100
- self.page = @page_text_proxy.text.to_i
101
- paginate
102
- end
103
- end
104
- }
110
+ on_focus_gained do
111
+ @page_text_proxy.select_all
112
+ end
105
113
 
106
- button {
107
- text '>'
108
-
109
- on_widget_selected do
110
- self.page += 1
111
- paginate
112
- end
113
- }
114
+ on_focus_lost do
115
+ self.page = @page_text_proxy.text.to_i
116
+ filter_and_paginate
117
+ end
114
118
 
115
- button {
116
- text '>>'
117
-
118
- on_widget_selected do
119
- self.page = last_page
120
- paginate
119
+ on_key_pressed do |key_event|
120
+ if key_event.keyCode == swt(:cr)
121
+ self.page = @page_text_proxy.text.to_i
122
+ filter_and_paginate
121
123
  end
122
- }
124
+ end
123
125
  }
124
126
 
125
- @children_owner = @table_proxy = table(swt_style)
127
+ @next_button_proxy = button {
128
+ text '>'
129
+ enabled <= [self, :page, on_read: ->(value) {value < last_page}]
130
+
131
+ on_widget_selected do
132
+ self.page += 1
133
+ filter_and_paginate
134
+ end
135
+ }
136
+
137
+ @last_button_proxy = button {
138
+ text '>>'
139
+ enabled <= [self, :page, on_read: ->(value) {value < last_page}]
140
+
141
+ on_widget_selected do
142
+ self.page = last_page
143
+ filter_and_paginate
144
+ end
145
+ }
126
146
  }
127
- }
147
+ end
128
148
 
129
149
  def table_block=(block)
130
150
  @table_proxy.content(&block)
131
151
  end
132
152
 
153
+ def page_text_block=(block)
154
+ @page_text_proxy.content(&block)
155
+ end
156
+
157
+ def first_button_block=(block)
158
+ @first_button_proxy.content(&block)
159
+ end
160
+
161
+ def previous_button_block=(block)
162
+ @previous_button_proxy.content(&block)
163
+ end
164
+
165
+ def next_button_block=(block)
166
+ @next_button_proxy.content(&block)
167
+ end
168
+
169
+ def last_button_block=(block)
170
+ @last_button_proxy.content(&block)
171
+ end
172
+
133
173
  def method_missing(method_name, *args, &block)
134
174
  dsl_mode = @dsl_mode || args.last.is_a?(Hash) && args.last[:dsl]
135
175
  if dsl_mode
@@ -153,28 +193,41 @@ module Glimmer
153
193
  end
154
194
 
155
195
  def page_count
156
- (model_array && (model_array.count / per_page.to_f).ceil) || 0
196
+ (filtered_model_array && (filtered_model_array.count / per_page.to_f).ceil) || 0
157
197
  end
158
198
 
159
199
  def corrected_page(initial_page_value = nil)
160
200
  correct_page = initial_page_value || page
161
201
  correct_page = [correct_page, page_count].min
162
202
  correct_page = [correct_page, 1].max
163
- correct_page = (model_array&.count.to_i > 0) ? (correct_page > 0 ? correct_page : 1) : 0
203
+ correct_page = (filtered_model_array&.count.to_i > 0) ? (correct_page > 0 ? correct_page : 1) : 0
164
204
  correct_page
165
205
  end
166
206
 
167
207
  def first_page
168
- (model_array&.count.to_i > 0) ? 1 : 0
208
+ (filtered_model_array&.count.to_i > 0) ? 1 : 0
169
209
  end
170
210
 
171
211
  def last_page
172
212
  page_count
173
213
  end
174
214
 
215
+ def filter_and_paginate
216
+ filter
217
+ paginate
218
+ end
219
+
220
+ def filter
221
+ self.filtered_model_array = model_array.select do |model|
222
+ @table_proxy.cells_for(model).any? do |cell_text|
223
+ cell_text.to_s.downcase.include?(query.to_s.downcase)
224
+ end
225
+ end
226
+ end
227
+
175
228
  def paginate
176
229
  self.page = corrected_page(page)
177
- self.refined_model_array = model_array[(page - 1) * per_page, per_page]
230
+ self.refined_model_array = filtered_model_array[(page - 1) * per_page, per_page]
178
231
  end
179
232
  end
180
233
  end
@@ -247,6 +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
251
  alias column_attributes= column_properties=
251
252
  alias editable? editable
252
253
 
@@ -122,7 +122,7 @@ class ContactManager
122
122
  }
123
123
  }
124
124
 
125
- table(:editable, :multi) { |table_proxy|
125
+ table(:editable, :border) { |table_proxy|
126
126
  layout_data {
127
127
  horizontal_alignment :fill
128
128
  vertical_alignment :fill
@@ -23,7 +23,7 @@ class KlondikeSolitaire
23
23
  else
24
24
  @game.dealt_pile.push!(playing_card)
25
25
  end
26
- end
26
+ end
27
27
 
28
28
  def playing_cards
29
29
  @playing_cards ||= []
@@ -27,7 +27,6 @@ class KlondikeSolitaire
27
27
  card_source_model = card_parent_pile.model
28
28
  cards = card_source_model.remove!(card)
29
29
  cards[1..-1].each { |card| model.add!(card) } if cards.is_a?(Array) # if it is a column pile
30
- drop_event.dragged_shape.dispose
31
30
  rescue => e
32
31
  Glimmer::Config.logger.debug { "Error encountered on drop of a card to a column pile: #{e.full_message}" }
33
32
  drop_event.doit = false
@@ -28,6 +28,10 @@ class KlondikeSolitaire
28
28
  body {
29
29
  shape(pile_x, pile_y) {
30
30
  hidden_playing_card
31
+
32
+ on_mouse_up do |event|
33
+ model.deal!
34
+ end
31
35
  }
32
36
  }
33
37
 
@@ -18,11 +18,9 @@ class KlondikeSolitaire
18
18
  empty_playing_card
19
19
  }
20
20
  else
21
- body_root.shapes.each { |shape| shape.drag_source = false }
22
21
  before_last_shape = body_root.shapes[-2] && body_root.shapes[-2].get_data('custom_shape').respond_to?(:model) && body_root.shapes[-2].get_data('custom_shape').model
23
22
  if model.playing_cards.last == before_last_shape # happens when dragging card out
24
23
  body_root.shapes.last.dispose
25
- body_root.shapes.last.drag_source = true
26
24
  else
27
25
  body_root.content {
28
26
  playing_card(model: model.playing_cards.last, parent_pile: self) {
@@ -42,7 +42,6 @@ class KlondikeSolitaire
42
42
  raise 'Cannot accept multiple cards' if card_source_model.playing_cards.index(card) != (card_source_model.playing_cards.size - 1)
43
43
  model.add!(card)
44
44
  card_source_model.remove!(card)
45
- drop_event.dragged_shape.dispose
46
45
  rescue => e
47
46
  Glimmer::Config.logger.debug { "Error encountered on drop of a card to a foundation pile: #{e.full_message}" }
48
47
  drop_event.doit = false
@@ -27,12 +27,6 @@ class KlondikeSolitaire
27
27
  @column_piles = 7.times.map do |n|
28
28
  column_pile(pile_x: MARGIN + n*(PLAYING_CARD_WIDTH + PLAYING_CARD_SPACING), pile_y: PLAYING_CARD_HEIGHT + PLAYING_CARD_SPACING, model: game.column_piles[n])
29
29
  end
30
-
31
- on_mouse_up do |event|
32
- if @dealing_pile.body_root.include?(event.x, event.y)
33
- game.dealing_pile.deal!
34
- end
35
- end
36
30
  }
37
31
  }
38
32
 
@@ -1,3 +1,24 @@
1
+ # Copyright (c) 2007-2022 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-dsl-swt'
2
23
 
3
24
  require_relative 'klondike_solitaire/model/game'
@@ -30,3 +30,4 @@ Hello, Custom Widget!: aJHLo5yLDZc
30
30
  Hello, Custom Shell!: c8Eb8GWM_XQ
31
31
  Hello, Custom Shape!: H3J8ecp30Ak
32
32
  Battleship: b00OWeLZOt8
33
+ Klondike Solitaire: qOzgiz9X3sI
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.0
4
+ version: 4.24.4.3
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-05 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -344,17 +344,17 @@ dependencies:
344
344
  version: 0.14.1.cr2
345
345
  description: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI
346
346
  cross-platform desktop development library written in JRuby, an OS-threaded faster
347
- JVM version of Ruby. It includes SWT 4.22 (released November 24, 2021). Glimmer's
348
- main innovation is a declarative Ruby DSL that enables productive and efficient
349
- authoring of desktop application user-interfaces by relying on the robust Eclipse
350
- SWT library. Glimmer additionally innovates by having built-in data-binding support,
351
- which greatly facilitates synchronizing the GUI with domain models, thus achieving
352
- true decoupling of object oriented components and enabling developers to solve business
353
- problems (test-first) without worrying about GUI concerns, or alternatively drive
354
- development GUI-first, and then write clean business models (test-first) afterwards.
355
- Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing
356
- Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers
357
- scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable
347
+ JVM version of Ruby. It includes SWT 4.24 (released June 7, 2022). Glimmer's main
348
+ innovation is a declarative Ruby DSL that enables productive and efficient authoring
349
+ of desktop application user-interfaces by relying on the robust Eclipse SWT library.
350
+ Glimmer additionally innovates by having built-in data-binding support, which greatly
351
+ facilitates synchronizing the GUI with domain models, thus achieving true decoupling
352
+ of object oriented components and enabling developers to solve business problems
353
+ (test-first) without worrying about GUI concerns, or alternatively drive development
354
+ GUI-first, and then write clean business models (test-first) afterwards. Not only
355
+ does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas
356
+ Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding
357
+ options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable
358
358
  packaging support, sorely lacking in other libraries, thus enabling the delivery
359
359
  of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac, MSI/EXE
360
360
  files on Windows, and DEB/RPM files on Linux. Glimmer was the first Ruby gem to