glimmer-dsl-swt 4.17.9.0 → 4.17.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3915e615b5248813ee6a9ca415c1be065f9d0ff9192e87a4a410146e0aae6f52
4
- data.tar.gz: 98c2fa055457d36b53c840de96bad374dfeaec9fd21e36782090378d4439fffe
3
+ metadata.gz: e98b64d0a38325d6474b61a1a411d910418fcf47448fe9d6a2c88742bc2109ed
4
+ data.tar.gz: dff1f5b21cc4b594be8f5b6eac5337e4ee4d072b1fb2bf87c3eb0e6728e1eb41
5
5
  SHA512:
6
- metadata.gz: 31978beac188701c12a27dd742452cb62c52b913dd7fd485dc1c4bd19ab52d9dea9a30a84b867691b81ac7ff23adc2cf7874bcb8718ca058526c143158d9f16f
7
- data.tar.gz: 2c1e46b47851006dbbf0187e9ba215db83c3e603d058e9fd3e8a1c2476f944c66deae8391b714e918632e7bcf0c59556edccfcc28c726698850d57e331cd0423
6
+ metadata.gz: 62c570e832502b5dcde331cc9ef6774d1a15353d7f33066641ce7b07fa3f5a278cb4b1031a1266996fc9d09e37aa1884523ffb57100e47605cc4c54225b1b0b0
7
+ data.tar.gz: acf8dd65d70769f0f7c27873715f1360f6847ad0ffe3f1eed4c5af0c58768ec2c8ca6d4d1e337c88bca2ecb771025ded162130ed48aa0eec57c04c32590eda91
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.10.0
4
+
5
+ - Support table editing via `date_time` for date/time values
6
+ - Support table default sort configuration via sort_property
7
+ - Support table default sort configuration via sort block
8
+ - Support table default sort configuration via sort_by block
9
+ - Hello, Table! Sample editor :date_time, property: :date_time in
10
+ - Hello, Table! Sample label for (Baseball Game Schedule)
11
+ - Hello, Table! Sample combo for selecting nlds, nlcs, alds, alcs, world series
12
+ - Hello, Table! Sample promotion field that indicates things like Free Bobblehead, Free Towel, Free Umbrella, etc...
13
+ - ShellProxy#include_focus_control?
14
+ - Fix issue with table selection data-binding when in single selection mode vs multi
15
+ - Hello, Spinner! Sample
16
+
3
17
  ### 4.17.9.0
4
18
 
5
19
  - Add table style :editable to hook editing listener on mouse click automatically (instead of manually via on_widget_selected)
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.17.9.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.17.10.0
2
2
 
3
3
  ## JRuby Desktop Development GUI Library
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
@@ -360,6 +360,8 @@ Glimmer App:
360
360
  - [Hello, Directory Dialog!](#hello-directory-dialog)
361
361
  - [Hello, File Dialog!](#hello-file-dialog)
362
362
  - [Hello, Date Time!](#hello-date-time)
363
+ - [Hello, Spinner!](#hello-spinner)
364
+ - [Hello, Table!](#hello-table)
363
365
  - [Elaborate Samples](#elaborate-samples)
364
366
  - [User Profile](#user-profile)
365
367
  - [Login](#login)
@@ -453,7 +455,7 @@ jgem install glimmer-dsl-swt
453
455
 
454
456
  Or this command if you want a specific version:
455
457
  ```
456
- jgem install glimmer-dsl-swt -v 4.17.9.0
458
+ jgem install glimmer-dsl-swt -v 4.17.10.0
457
459
 
458
460
  ```
459
461
 
@@ -530,7 +532,7 @@ bin/glimmer samples
530
532
  Below are the full usage instructions that come up when running `glimmer` without args.
531
533
 
532
534
  ```
533
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.9.0
535
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.10.0
534
536
 
535
537
 
536
538
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
@@ -1008,7 +1010,7 @@ Output:
1008
1010
 
1009
1011
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1010
1012
  Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
1011
- Swt glimmer-dsl-swt 4.17.9.0
1013
+ Swt glimmer-dsl-swt 4.17.10.0
1012
1014
  AndyMaleh Glimmer DSL for SWT
1013
1015
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1014
1016
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
@@ -2269,6 +2271,117 @@ This automatically leverages the SWT TableEditor custom class behind the scenes,
2269
2271
  passed table item text into something else.
2270
2272
  It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
2271
2273
 
2274
+ ##### Table Selection
2275
+
2276
+ Table Selection data-binding is simply done via the `selection` property.
2277
+
2278
+ ```ruby
2279
+ selection bind(group, :selected_person)
2280
+ ```
2281
+
2282
+ If it's a multi-selection table (`table(:multi)`), then the data-bound model property oughta be a collection.
2283
+
2284
+ ```ruby
2285
+ selection bind(group, :selected_people)
2286
+ ```
2287
+
2288
+ ##### Table Editing
2289
+
2290
+ Glimmer provides a custom SWT style for table editing called `:editable` to obviate the need for an `on_mouse_up` listener.
2291
+
2292
+ For example, the code above could be simplified as:
2293
+
2294
+ ```ruby
2295
+ shell {
2296
+ @table = table(:editable) {
2297
+ table_column {
2298
+ text "Name"
2299
+ width 120
2300
+ }
2301
+ table_column {
2302
+ text "Age"
2303
+ width 120
2304
+ }
2305
+ table_column {
2306
+ text "Adult"
2307
+ width 120
2308
+ }
2309
+ items bind(group, :people), column_properties(:name, :age, :adult)
2310
+ selection bind(group, :selected_person)
2311
+ }
2312
+ }
2313
+ ```
2314
+
2315
+ Additionally, Glimmer supports the idea of custom editors or no editor per column.
2316
+
2317
+ Example:
2318
+
2319
+ ```ruby
2320
+ shell {
2321
+ @table = table(:editable) {
2322
+ table_column {
2323
+ text "Name"
2324
+ width 120
2325
+ }
2326
+ table_column {
2327
+ text "Age"
2328
+ width 120
2329
+ editor :spinner
2330
+ }
2331
+ table_column {
2332
+ text "Adult"
2333
+ width 120
2334
+ editor :checkbox
2335
+ }
2336
+ items bind(group, :people), column_properties(:name, :age, :adult)
2337
+ selection bind(group, :selected_person)
2338
+ }
2339
+ }
2340
+ ```
2341
+
2342
+ The example above uses a `spinner` widget editor for the age column since it's an `Integer` and
2343
+ a `checkbox` widget (`button(:check)`) editor for the adult column since it's a `Boolean`
2344
+
2345
+ Here are all the supported types of table editors:
2346
+ - `text`: expects a `String` property
2347
+ - `combo`: expects a `String` property accompanied by a matching `property_options` property by convention to provide items to present in the `combo`
2348
+ - `checkbox`: expects a `Boolean` property
2349
+ - `radio`: expects a `Boolean` property
2350
+ - `spinner`: expects an `Integer` property
2351
+ - `date`: expects a `DateTime` property
2352
+ - `date_drop_down`: expects a `DateTime` property
2353
+ - `time`: expects a `DateTime` property
2354
+
2355
+ An editor may also take additional arguments (SWT styles such as :long for the date field) that are passed to the editor widget, as well as hash options to
2356
+ customize the property being used for editing (e.g. property: :raw_name for a :formatted_name field) in case it differs from the property used to display
2357
+ the data in the table.
2358
+
2359
+ Example:
2360
+
2361
+ ```ruby
2362
+ shell {
2363
+ @table = table(:editable) {
2364
+ table_column {
2365
+ text "Date of Birth"
2366
+ width 120
2367
+ editor :date_drop_down, property: :date_time
2368
+ }
2369
+ table_column {
2370
+ text "Industry"
2371
+ width 120
2372
+ # assume there is a `Person#industry_options` property method on the model to provide items to the `combo`
2373
+ editor :combo, :read_only # passes :ready_only SWT style to `combo` widget
2374
+ }
2375
+ items bind(group, :people), column_properties(:formatted_date, :industry)
2376
+ selection bind(group, :selected_person)
2377
+ }
2378
+ }
2379
+ ```
2380
+
2381
+ Check out [Hello, Table!](#hello-table) for an actual example including table editors.
2382
+
2383
+ [Are We There Yet?](#are-we-there-yet) is an actual production Glimmer application that takes full advantage of table capabilities.
2384
+
2272
2385
  ##### Table Sorting
2273
2386
 
2274
2387
  Glimmer automatically adds sorting support to the SWT `Table` widget.
@@ -2285,6 +2398,8 @@ Should you have a special data type that could not be compared automatically, Gl
2285
2398
  - `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
2286
2399
  - `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
2287
2400
 
2401
+ These alternatives could be used inside `table_column` for column-clicked sorting or in the `table` body directly to set the initial default sort.
2402
+
2288
2403
  You may also set `additional_sort_properties` on the parent `table` widget to have secondary sorting applied. For example, if you set `additional_sort_properties :name, :project_name`, then whenever you sort by `:name`, it additionally sorts by `:project_name` afterwards, and vice versa. This only works for columns that either have no custom sort set or have a `sort_property` with one property only (but no sort or sort_by block)
2289
2404
 
2290
2405
  Example:
@@ -2392,6 +2507,8 @@ You can data-bind any of these properties:
2392
2507
 
2393
2508
  Learn more at the [Hello, Date Time!](#hello-date-time) sample.
2394
2509
 
2510
+ If you need a better widget with the ability to customize the date format pattern, check out the [Nebula CDateTime Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula)
2511
+
2395
2512
  ### Observer
2396
2513
 
2397
2514
  Glimmer comes with `Observer` module, which is used internally for data-binding, but can also be used externally for custom use of the Observer Pattern. It is hidden when observing widgets, and used explicitly when observing models.
@@ -3853,6 +3970,66 @@ Hello, Date Time!
3853
3970
 
3854
3971
  ![Hello Date Time](images/glimmer-hello-date-time.png)
3855
3972
 
3973
+ #### Hello, Spinner!
3974
+
3975
+ This sample demonstrates the use of `spinner` widget in Glimmer
3976
+
3977
+ Code:
3978
+
3979
+ [samples/hello/hello_spinner.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_spinner.rb)
3980
+
3981
+ Hello, Spinner!
3982
+
3983
+ ![Hello Spinner](images/glimmer-hello-spinner.png)
3984
+
3985
+ #### Hello, Table!
3986
+
3987
+ This sample demonstrates the use of [table](#table) widget in Glimmer, including data-binding, multi-type editing, sorting, and filtering.
3988
+
3989
+ Code:
3990
+
3991
+ [samples/hello/hello_table.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_table.rb)
3992
+
3993
+ Hello, Table!
3994
+
3995
+ ![Hello Table](images/glimmer-hello-table.png)
3996
+
3997
+ Hello, Table! Editing Game Date
3998
+
3999
+ ![Hello Table](images/glimmer-hello-table-editing-game-date.png)
4000
+
4001
+ Hello, Table! Editing Game Time
4002
+
4003
+ ![Hello Table](images/glimmer-hello-table-editing-game-time.png)
4004
+
4005
+ Hello, Table! Editing Home Team
4006
+
4007
+ ![Hello Table](images/glimmer-hello-table-editing-home-team.png)
4008
+
4009
+ Hello, Table! Sorted Game Date Ascending
4010
+
4011
+ ![Hello Table](images/glimmer-hello-table-sorted-game-date-ascending.png)
4012
+
4013
+ Hello, Table! Sorted Game Date Descending
4014
+
4015
+ ![Hello Table](images/glimmer-hello-table-sorted-game-date-descending.png)
4016
+
4017
+ Hello, Table! Playoff Type Combo
4018
+
4019
+ ![Hello Table](images/glimmer-hello-table-playoff-type-combo.png)
4020
+
4021
+ Hello, Table! Playoff Type Changed
4022
+
4023
+ ![Hello Table](images/glimmer-hello-table-playoff-type-changed.png)
4024
+
4025
+ Hello, Table! Game Booked
4026
+
4027
+ ![Hello Table](images/glimmer-hello-table-game-booked.png)
4028
+
4029
+ Hello, Table! Context Menu
4030
+
4031
+ ![Hello Table](images/glimmer-hello-table-context-menu.png)
4032
+
3856
4033
  ### Elaborate Samples
3857
4034
 
3858
4035
  For more elaborate samples, check the following:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.9.0
1
+ 4.17.10.0
@@ -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.9.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.10.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.9.0"
9
+ s.version = "4.17.10.0"
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-07"
14
+ s.date = "2020-11-10"
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_radio.rb",
153
153
  "samples/hello/hello_radio_group.rb",
154
154
  "samples/hello/hello_sash_form.rb",
155
+ "samples/hello/hello_spinner.rb",
155
156
  "samples/hello/hello_styled_text.rb",
156
157
  "samples/hello/hello_tab.rb",
157
158
  "samples/hello/hello_table.rb",
@@ -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
@@ -61,7 +61,7 @@ module Glimmer
61
61
  add_dependent(@table_observer_registration => @table_items_observer_registration)
62
62
  @model_collection = new_model_collection
63
63
  end
64
- populate_table(@model_collection, @table, @column_properties)
64
+ populate_table(@model_collection, @table, @column_properties)
65
65
  end
66
66
 
67
67
  def populate_table(model_collection, parent, column_properties)
@@ -79,7 +79,7 @@ module Glimmer
79
79
  selected_table_items = parent.search {|item| selected_table_item_models.include?(item.getData) }
80
80
  selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
81
81
  parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
82
- parent.sort
82
+ parent.sort!
83
83
  parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
84
84
  end
85
85
  end
@@ -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
@@ -88,18 +88,26 @@ module Glimmer
88
88
 
89
89
  # Opens shell and starts SWT's UI thread event loop
90
90
  def open
91
+ open_only
92
+ start_event_loop unless nested?
93
+ end
94
+ alias show open
95
+
96
+ # Opens without starting the event loop.
97
+ def open_only
91
98
  if @opened_before
92
99
  @swt_widget.setVisible(true)
93
- # notify_observers('visible')
94
100
  else
95
101
  @opened_before = true
96
102
  @swt_widget.pack
97
103
  center
98
104
  @swt_widget.open
99
- start_event_loop
100
105
  end
101
106
  end
102
- alias show open
107
+
108
+ def nested?
109
+ !parent.nil?
110
+ end
103
111
 
104
112
  def hide
105
113
  @swt_widget.setVisible(false)
@@ -113,6 +121,10 @@ module Glimmer
113
121
  def visible=(visibility)
114
122
  visibility ? show : hide
115
123
  end
124
+
125
+ def include_focus_control?
126
+ DisplayProxy.instance.focus_control&.shell == swt_widget
127
+ end
116
128
 
117
129
  def pack
118
130
  @swt_widget.pack
@@ -169,6 +181,9 @@ module Glimmer
169
181
  super
170
182
  end
171
183
  end
184
+
172
185
  end
186
+
173
187
  end
188
+
174
189
  end
@@ -39,6 +39,7 @@ module Glimmer
39
39
  #
40
40
  # Follows the Proxy Design Pattern
41
41
  class TabItemProxy < WidgetProxy
42
+ ATTRIBUTES = %w[text image]
42
43
  include_package 'org.eclipse.swt.widgets'
43
44
 
44
45
  attr_reader :widget_proxy, :swt_tab_item
@@ -51,7 +52,7 @@ module Glimmer
51
52
  end
52
53
 
53
54
  def has_attribute?(attribute_name, *args)
54
- if attribute_name.to_s == "text"
55
+ if ATTRIBUTES.include?(attribute_name.to_s)
55
56
  true
56
57
  else
57
58
  super(attribute_name, *args)
@@ -63,6 +64,8 @@ module Glimmer
63
64
  if attribute_name.to_s == "text"
64
65
  text_value = args[0]
65
66
  @swt_tab_item.setText text_value
67
+ elsif attribute_name.to_s == "image"
68
+ widget_proxy.set_attribute('image', *args)
66
69
  else
67
70
  super(attribute_name, *args)
68
71
  end
@@ -71,6 +74,8 @@ module Glimmer
71
74
  def get_attribute(attribute_name)
72
75
  if attribute_name.to_s == "text"
73
76
  @swt_tab_item.getText
77
+ elsif attribute_name.to_s == "image"
78
+ widget_proxy.get_attribute('image')
74
79
  else
75
80
  super(attribute_name)
76
81
  end
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/swt/widget_proxy'
23
+ require 'glimmer/swt/swt_proxy'
23
24
 
24
25
  module Glimmer
25
26
  module SWT
@@ -34,7 +35,7 @@ module Glimmer
34
35
  @no_sort = args.delete(:no_sort)
35
36
  super
36
37
  on_widget_selected do |event|
37
- parent.sort_by_column(self)
38
+ parent.sort_by_column!(self)
38
39
  end unless no_sort?
39
40
  end
40
41
 
@@ -42,10 +43,15 @@ module Glimmer
42
43
  @sort_property = args unless args.empty?
43
44
  end
44
45
 
46
+ # Sets editor (e.g. combo)
45
47
  def editor=(args)
46
48
  @editor = args
47
49
  end
48
50
 
51
+ def editable?
52
+ !@editor&.include?(:none)
53
+ end
54
+
49
55
  end
50
56
  end
51
57
  end