glimmer-dsl-swt 4.17.8.3 → 4.17.9.0

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: 05bc3d6096231cccf821c2aaf5d42a2ef28b23f999d058bc2b2ad2cbf19a1a32
4
- data.tar.gz: b10d240123f7e7ccd7994c9493abf5d51062c402e96dc6ddd357f6809645c77a
3
+ metadata.gz: 3915e615b5248813ee6a9ca415c1be065f9d0ff9192e87a4a410146e0aae6f52
4
+ data.tar.gz: 98c2fa055457d36b53c840de96bad374dfeaec9fd21e36782090378d4439fffe
5
5
  SHA512:
6
- metadata.gz: a6b6e9c28482d8dbd6daadb3daab9820a091d961baef5ddd197b9c4198221130487ff44eed35285f5476e9a82c3dc41f89de4652c3375d382a19fb3ef35c6d2b
7
- data.tar.gz: 2663c8de064e9bbb6f94ac7703e80bb14bb1c5c7cad9ceab69265c84cbacc4d8ae5a87a5fb41533c3e46ba46bb6f3b897fac5091a1108168d216a183faf4d585
6
+ metadata.gz: 31978beac188701c12a27dd742452cb62c52b913dd7fd485dc1c4bd19ab52d9dea9a30a84b867691b81ac7ff23adc2cf7874bcb8718ca058526c143158d9f16f
7
+ data.tar.gz: 2c1e46b47851006dbbf0187e9ba215db83c3e603d058e9fd3e8a1c2476f944c66deae8391b714e918632e7bcf0c59556edccfcc28c726698850d57e331cd0423
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.9.0
4
+
5
+ - Add table style :editable to hook editing listener on mouse click automatically (instead of manually via on_widget_selected)
6
+ - Support table editing via `spinner` for integer values
7
+ - date_time widget official data-binding support of date_time, date, time, year, month, day, hours, minutes, and seconds
8
+ - date widget alias for date_time(:date)
9
+ - time widget alias for date_time(:time)
10
+ - calendar widget alias for date_time(:calendar)
11
+ - date_drop_down widget alias for date_time(:date, :drop_down)
12
+ - Hello, Date Time! Sample
13
+
3
14
  ### 4.17.8.3
4
15
 
5
16
  - Hello, Table! Sample
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.8.3
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
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)
@@ -297,6 +297,7 @@ Glimmer App:
297
297
  - [List](#list)
298
298
  - [Table](#table)
299
299
  - [Tree](#tree)
300
+ - [DateTime](#datetime)
300
301
  - [Observer](#observer)
301
302
  - [Observing Widgets](#observing-widgets)
302
303
  - [Observing Models](#observing-models)
@@ -314,6 +315,8 @@ Glimmer App:
314
315
  - [Multi-DSL Support](#multi-dsl-support)
315
316
  - [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
316
317
  - [App Name and Version](#app-name-and-version)
318
+ - [Checkbox Group Widget](#checkbox-group-widget)
319
+ - [Radio Group Widget](#radio-group-widget)
317
320
  - [Code Text Widget](#code-text-widget)
318
321
  - [Video Widget](#video-widget)
319
322
  - [Sash Form Widget](#sash-form-widget)
@@ -350,11 +353,13 @@ Glimmer App:
350
353
  - [Hello, Expand Bar!](#hello-expand-bar)
351
354
  - [Hello, Radio!](#hello-radio)
352
355
  - [Hello, Radio Group!](#hello-radio-group)
356
+ - [Hello, Checkbox!](#hello-checkbox)
353
357
  - [Hello, Group!](#hello-group)
354
358
  - [Hello, Checkbox!](#hello-checkbox)
355
359
  - [Hello, Checkbox Group!](#hello-checkbox-group)
356
360
  - [Hello, Directory Dialog!](#hello-directory-dialog)
357
361
  - [Hello, File Dialog!](#hello-file-dialog)
362
+ - [Hello, Date Time!](#hello-date-time)
358
363
  - [Elaborate Samples](#elaborate-samples)
359
364
  - [User Profile](#user-profile)
360
365
  - [Login](#login)
@@ -448,7 +453,7 @@ jgem install glimmer-dsl-swt
448
453
 
449
454
  Or this command if you want a specific version:
450
455
  ```
451
- jgem install glimmer-dsl-swt -v 4.17.8.3
456
+ jgem install glimmer-dsl-swt -v 4.17.9.0
452
457
 
453
458
  ```
454
459
 
@@ -525,7 +530,7 @@ bin/glimmer samples
525
530
  Below are the full usage instructions that come up when running `glimmer` without args.
526
531
 
527
532
  ```
528
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.8.3
533
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.9.0
529
534
 
530
535
 
531
536
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
@@ -1003,7 +1008,7 @@ Output:
1003
1008
 
1004
1009
  Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
1005
1010
  Opal glimmer-dsl-opal 0.4.0 AndyMaleh Glimmer DSL for Opal
1006
- Swt glimmer-dsl-swt 4.17.8.3
1011
+ Swt glimmer-dsl-swt 4.17.9.0
1007
1012
  AndyMaleh Glimmer DSL for SWT
1008
1013
  Tk glimmer-dsl-tk 0.0.6 AndyMaleh Glimmer DSL for Tk
1009
1014
  Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
@@ -2364,6 +2369,29 @@ This finds the root node. The array is a Java array. This enables easy passing o
2364
2369
  To edit a tree, you must invoke `TreeProxy#edit_selected_tree_item` or `TreeProxy#edit_tree_item`. This automatically leverages the SWT TreeEditor custom class behind the scenes, displaying
2365
2370
  a text widget to the user to change the selected or passed tree item text into something else. It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
2366
2371
 
2372
+ #### DateTime
2373
+
2374
+ `date_time` represents the SWT DateTime widget.
2375
+
2376
+ Glimmer offers the following alias keywords for it for convenience:
2377
+ - `date`: `date_time(:date)`
2378
+ - `date_drop_down`: `date_time(:date, :drop_down)`
2379
+ - `time`: `date_time(:time)`
2380
+ - `calendar`: `date_time(:calendar)`
2381
+
2382
+ You can data-bind any of these properties:
2383
+ - `date_time bind(model, :property)`: produces a Ruby DateTime object
2384
+ - `date bind(model, :property)`: produces a Ruby Date object
2385
+ - `time bind(model, :property)`: produces a Ruby Time object
2386
+ - `year bind(model, :property)`: produces an integer
2387
+ - `month bind(model, :property)`: produces an integer
2388
+ - `day bind(model, :property)`: produces an integer
2389
+ - `hours bind(model, :property)`: produces an integer
2390
+ - `minutes bind(model, :property)`: produces an integer
2391
+ - `seconds bind(model, :property)`: produces an integer
2392
+
2393
+ Learn more at the [Hello, Date Time!](#hello-date-time) sample.
2394
+
2367
2395
  ### Observer
2368
2396
 
2369
2397
  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.
@@ -3813,6 +3841,18 @@ Hello, File Dialog! Selected File
3813
3841
 
3814
3842
  ![Hello File Dialog](images/glimmer-hello-file-dialog-selected-file.png)
3815
3843
 
3844
+ #### Hello, Date Time!
3845
+
3846
+ This sample demonstrates the use of [date_time](#datetime) widget keywords in Glimmer: `date`, `date_drop_down`, `time`, and `calendar`
3847
+
3848
+ Code:
3849
+
3850
+ [samples/hello/hello_date_time.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_date_time.rb)
3851
+
3852
+ Hello, Date Time!
3853
+
3854
+ ![Hello Date Time](images/glimmer-hello-date-time.png)
3855
+
3816
3856
  ### Elaborate Samples
3817
3857
 
3818
3858
  For more elaborate samples, check the following:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.8.3
1
+ 4.17.9.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.8.3 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.9.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.8.3"
9
+ s.version = "4.17.9.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-05"
14
+ s.date = "2020-11-07"
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]
@@ -92,6 +92,7 @@ Gem::Specification.new do |s|
92
92
  "lib/glimmer/swt/custom/checkbox_group.rb",
93
93
  "lib/glimmer/swt/custom/code_text.rb",
94
94
  "lib/glimmer/swt/custom/radio_group.rb",
95
+ "lib/glimmer/swt/date_time_proxy.rb",
95
96
  "lib/glimmer/swt/directory_dialog_proxy.rb",
96
97
  "lib/glimmer/swt/display_proxy.rb",
97
98
  "lib/glimmer/swt/dnd_proxy.rb",
@@ -137,6 +138,7 @@ Gem::Specification.new do |s|
137
138
  "samples/hello/hello_computed/contact.rb",
138
139
  "samples/hello/hello_custom_shell.rb",
139
140
  "samples/hello/hello_custom_widget.rb",
141
+ "samples/hello/hello_date_time.rb",
140
142
  "samples/hello/hello_directory_dialog.rb",
141
143
  "samples/hello/hello_drag_and_drop.rb",
142
144
  "samples/hello/hello_expand_bar.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
@@ -35,6 +35,7 @@ require 'logging'
35
35
  require 'nested_inherited_jruby_include_package'
36
36
  require 'super_module'
37
37
  require 'rouge'
38
+ require 'date'
38
39
 
39
40
  # Internal requires
40
41
  require 'ext/glimmer/config'
@@ -58,3 +58,4 @@ require 'glimmer/swt/table_proxy'
58
58
  require 'glimmer/swt/table_column_proxy'
59
59
  require 'glimmer/swt/sash_form_proxy'
60
60
  require 'glimmer/swt/styled_text_proxy'
61
+ require 'glimmer/swt/date_time_proxy'
@@ -0,0 +1,87 @@
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
+ require 'date'
23
+ require 'glimmer/swt/widget_proxy'
24
+
25
+ module Glimmer
26
+ module SWT
27
+ # Proxy for org.eclipse.swt.widgets.DateTime
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class DateTimeProxy < WidgetProxy
31
+ CUSTOM_ATTRIBUTES = %w[date_time date time month]
32
+
33
+ def date_time
34
+ DateTime.new(year, month, day, hours, minutes, seconds)
35
+ end
36
+
37
+ def date_time=(date_time_value)
38
+ self.time = date_time_value.to_time
39
+ end
40
+
41
+ def date
42
+ date_time.to_date
43
+ end
44
+
45
+ def date=(date_value)
46
+ self.year = date_value.year
47
+ self.month = date_value.month
48
+ self.day = date_value.day
49
+ end
50
+
51
+ def time
52
+ date_time.to_time
53
+ end
54
+
55
+ def time=(time_value)
56
+ self.date = time_value.to_date
57
+ self.hours = time_value.hour
58
+ self.minutes = time_value.min
59
+ self.seconds = time_value.sec
60
+ end
61
+
62
+ def month
63
+ swt_widget.month + 1
64
+ end
65
+
66
+ def month=(new_value)
67
+ swt_widget.month = new_value - 1
68
+ end
69
+
70
+ def set_attribute(attribute_name, *args)
71
+ if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
72
+ send(ruby_attribute_setter(attribute_name), args.first)
73
+ else
74
+ super(attribute_name, *args)
75
+ end
76
+ end
77
+
78
+ def get_attribute(attribute_name)
79
+ if CUSTOM_ATTRIBUTES.include?(attribute_name.to_s)
80
+ send(attribute_name)
81
+ else
82
+ super(attribute_name)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ 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
@@ -59,7 +59,7 @@ module Glimmer
59
59
 
60
60
  def content(&block)
61
61
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
62
- end
62
+ end
63
63
 
64
64
  def method_missing(method, *args, &block)
65
65
  if can_handle_observation_request?(method)
@@ -73,8 +73,8 @@ module Glimmer
73
73
  end
74
74
 
75
75
  def respond_to?(method, *args, &block)
76
- super ||
77
- can_handle_observation_request?(method) ||
76
+ super ||
77
+ can_handle_observation_request?(method) ||
78
78
  swt_display.respond_to?(method, *args, &block)
79
79
  end
80
80
 
@@ -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,15 +26,15 @@ module Glimmer
26
26
  # Proxy for org.eclipse.swt.dnd.DND
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
- class DNDProxy
30
- include StyleConstantizable
29
+ class DNDProxy
30
+ include StyleConstantizable
31
31
 
32
32
  class << self
33
33
  JAVA_IMPORT = 'org.eclipse.swt.dnd.DND'
34
34
 
35
35
  java_import JAVA_IMPORT
36
36
 
37
- def constant_java_import
37
+ def constant_java_import
38
38
  JAVA_IMPORT
39
39
  end
40
40
 
@@ -45,10 +45,6 @@ module Glimmer
45
45
  def constant_value_none
46
46
  DND::DROP_NONE
47
47
  end
48
-
49
- def extra_styles
50
- {}
51
- end
52
48
  end
53
49
  end
54
50
  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
@@ -38,7 +38,7 @@ module Glimmer
38
38
  if parent.nil?
39
39
  @temporary_parent = parent = Glimmer::SWT::ShellProxy.new.swt_widget
40
40
  end
41
- @swt_widget = MessageBox.new(parent, style)
41
+ @swt_widget = MessageBox.new(parent, style)
42
42
  end
43
43
 
44
44
  def open
@@ -49,7 +49,7 @@ module Glimmer
49
49
 
50
50
  def content(&block)
51
51
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::MessageBoxExpression.new, &block)
52
- end
52
+ end
53
53
 
54
54
  # TODO refactor the following methods to put in a JavaBean mixin or somethin (perhaps contribute to OSS project too)
55
55
 
@@ -81,9 +81,9 @@ module Glimmer
81
81
  end
82
82
 
83
83
  def respond_to?(method, *args, &block)
84
- super ||
84
+ super ||
85
85
  swt_widget.respond_to?(method, *args, &block)
86
- end
86
+ end
87
87
  end
88
88
  end
89
89
  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
@@ -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,9 +43,9 @@ module Glimmer
43
43
  raise 'Not implemented! Mixer must implement!'
44
44
  end
45
45
 
46
- # hash of extra styles (i.e. new style combinations)
46
+ # hash of extra composite styles (i.e. style combinations defined under new style names)
47
47
  def extra_styles
48
- raise 'Not implemented! Mixer must implement!'
48
+ {}
49
49
  end
50
50
 
51
51
  def error_message_invalid_style
@@ -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,15 +26,15 @@ module Glimmer
26
26
  # Proxy for org.eclipse.swt.SWT
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
- class SWTProxy
30
- include StyleConstantizable
29
+ class SWTProxy
30
+ include StyleConstantizable
31
31
 
32
32
  class << self
33
33
  JAVA_IMPORT = 'org.eclipse.swt.SWT'
34
34
 
35
35
  java_import JAVA_IMPORT
36
36
 
37
- def constant_java_import
37
+ def constant_java_import
38
38
  JAVA_IMPORT
39
39
  end
40
40
 
@@ -53,8 +53,7 @@ module Glimmer
53
53
 
54
54
  EXTRA_STYLES = {
55
55
  NO_RESIZE: self[:shell_trim, :resize!, :max!],
56
- NO_SORT: -7,
57
- }
56
+ }
58
57
  end
59
58
  end
60
59
  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
@@ -23,7 +23,9 @@ require 'glimmer/swt/widget_proxy'
23
23
 
24
24
  module Glimmer
25
25
  module SWT
26
- class TableColumnProxy < Glimmer::SWT::WidgetProxy
26
+ # A proxy object representing SWT TableColumn
27
+ # Accepts a :no_sort custom style to disable sorting on this column
28
+ class TableColumnProxy < Glimmer::SWT::WidgetProxy
27
29
  attr_reader :no_sort, :sort_property, :editor
28
30
  alias no_sort? no_sort
29
31
  attr_accessor :sort_block, :sort_by_block
@@ -155,20 +155,56 @@ module Glimmer
155
155
  }
156
156
  }
157
157
  end,
158
- }
158
+ },
159
+ spinner: {
160
+ widget_value_property: :selection,
161
+ editor_gui: lambda do |args, model, property, table_proxy|
162
+ first_time = true
163
+ table_proxy.table_editor.minimumHeight = 25
164
+ table_editor_widget_proxy = spinner(*args) {
165
+ selection model.send(property)
166
+ focus true
167
+ on_focus_lost {
168
+ table_proxy.finish_edit!
169
+ }
170
+ on_key_pressed { |key_event|
171
+ if key_event.keyCode == swt(:cr)
172
+ table_proxy.finish_edit!
173
+ elsif key_event.keyCode == swt(:esc)
174
+ table_proxy.cancel_edit!
175
+ end
176
+ }
177
+ # on_widget_selected {
178
+ # if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
179
+ # table_proxy.finish_edit!
180
+ # end
181
+ # }
182
+ }
183
+ table_editor_widget_proxy
184
+ end,
185
+ },
159
186
  }
160
187
  end
161
188
  end
162
189
 
163
- attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor
190
+ attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor, :editable
164
191
  attr_accessor :column_properties
192
+ alias editable? editable
165
193
 
166
194
  def initialize(underscored_widget_name, parent, args)
195
+ @editable = args.delete(:editable)
167
196
  super
168
197
  @table_editor = TableEditor.new(swt_widget)
169
198
  @table_editor.horizontalAlignment = SWTProxy[:left]
170
199
  @table_editor.grabHorizontal = true
171
200
  @table_editor.minimumHeight = 20
201
+ if editable?
202
+ content {
203
+ on_mouse_up { |event|
204
+ edit_table_item(event.table_item, event.column_index)
205
+ }
206
+ }
207
+ end
172
208
  end
173
209
 
174
210
  def model_binding
@@ -63,6 +63,9 @@ module Glimmer
63
63
  'tool_bar' => [:push],
64
64
  'tool_item' => [:push],
65
65
  'tree' => [:virtual, :border, :h_scroll, :v_scroll],
66
+ 'date_drop_down' => [:date, :drop_down],
67
+ 'time' => [:time],
68
+ 'calendar' => [:calendar],
66
69
  }
67
70
 
68
71
  DEFAULT_INITIALIZERS = {
@@ -96,6 +99,10 @@ module Glimmer
96
99
  'check' => 'button',
97
100
  'radio' => 'button',
98
101
  'toggle' => 'button',
102
+ 'date' => 'date_time',
103
+ 'date_drop_down' => 'date_time',
104
+ 'time' => 'date_time',
105
+ 'calendar' => 'date_time',
99
106
  }
100
107
 
101
108
  class << self
@@ -224,8 +231,11 @@ module Glimmer
224
231
  else
225
232
  @swt_widget.send(widget_custom_attribute[:getter][:name])
226
233
  end
227
- else
234
+ elsif @swt_widget.respond_to?(attribute_getter(attribute_name))
228
235
  @swt_widget.send(attribute_getter(attribute_name))
236
+ else
237
+ pd attribute_name
238
+ send(attribute_name)
229
239
  end
230
240
  end
231
241
 
@@ -408,12 +418,29 @@ module Glimmer
408
418
  }
409
419
  end
410
420
  },
421
+ Java::OrgEclipseSwtWidgets::DateTime =>
422
+ [:year, :month, :day, :hours, :minutes, :seconds, :date_time, :date, :time].reduce({}) do |hash, attribute|
423
+ hash.merge(
424
+ attribute => lambda do |observer|
425
+ on_widget_selected { |selection_event|
426
+ observer.call(get_attribute(attribute))
427
+ }
428
+ end
429
+ )
430
+ end,
411
431
  }
412
432
  end
413
433
 
414
434
  def self.widget_exists?(underscored_widget_name)
415
435
  !!swt_widget_class_for(underscored_widget_name)
416
436
  end
437
+
438
+ # Manual entries of SWT widget classes that conflict with Ruby classes
439
+ def self.swt_widget_class_manual_entries
440
+ {
441
+ 'date_time' => Java::OrgEclipseSwtWidgets::DateTime
442
+ }
443
+ end
417
444
 
418
445
  # This supports widgets in and out of basic SWT
419
446
  def self.swt_widget_class_for(underscored_widget_name)
@@ -421,8 +448,11 @@ module Glimmer
421
448
  swt_widget_name = underscored_widget_name.camelcase(:upper)
422
449
  swt_widget_class = eval(swt_widget_name)
423
450
  unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
424
- Glimmer::Config.logger.debug {"Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget"}
425
- return nil
451
+ swt_widget_class = swt_widget_class_manual_entries[underscored_widget_name]
452
+ if swt_widget_class.nil?
453
+ Glimmer::Config.logger.debug {"Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget"}
454
+ return nil
455
+ end
426
456
  end
427
457
  swt_widget_class
428
458
  rescue SyntaxError, NameError => e
@@ -0,0 +1,63 @@
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 HelloDateTime
23
+ class Person
24
+ attr_accessor :date_of_birth
25
+ end
26
+
27
+ include Glimmer
28
+
29
+ def launch
30
+ person = Person.new
31
+ person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
32
+
33
+ shell {
34
+ row_layout :vertical
35
+
36
+ text 'Hello, Date Time!'
37
+ minimum_size 180, 180
38
+
39
+ label {
40
+ text 'Date of Birth'
41
+ font height: 16, style: :bold
42
+ }
43
+
44
+ date { # alias for date_time(:date)
45
+ date_time bind(person, :date_of_birth)
46
+ }
47
+
48
+ date_drop_down { # alias for date_time(:date, :drop_down)
49
+ date_time bind(person, :date_of_birth)
50
+ }
51
+
52
+ time { # alias for date_time(:time)
53
+ date_time bind(person, :date_of_birth)
54
+ }
55
+
56
+ calendar { # alias for date_time(:calendar)
57
+ date_time bind(person, :date_of_birth)
58
+ }
59
+ }.open
60
+ end
61
+ end
62
+
63
+ HelloDateTime.new.launch
@@ -24,16 +24,16 @@ class HelloTable
24
24
  class << self
25
25
  def schedule
26
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)),
27
+ new(Time.new(2037, 10, 6, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 5, 7),
28
+ new(Time.new(2037, 10, 7, 12, 0), 'Chicago Cubs', 'Milwaukee Brewers', 11, 7),
29
+ new(Time.new(2037, 10, 8, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 2, 3),
30
+ new(Time.new(2037, 10, 9, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 1, 0),
31
+ new(Time.new(2037, 10, 10, 12, 0), 'Milwaukee Brewers', 'Chicago Cubs', 9, 10),
32
+ new(Time.new(2037, 10, 6, 18, 0), 'Chicago White Sox', 'St Louis Cardinals', 2, 4),
33
+ new(Time.new(2037, 10, 7, 18, 0), 'Chicago White Sox', 'St Louis Cardinals', 5, 6),
34
+ new(Time.new(2037, 10, 8, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 0, 7),
35
+ new(Time.new(2037, 10, 9, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 3, 4),
36
+ new(Time.new(2037, 10, 10, 18, 0), 'St Louis Cardinals', 'Chicago White Sox', 11, 13),
37
37
  ]
38
38
  end
39
39
 
@@ -51,12 +51,14 @@ class HelloTable
51
51
  'St Louis Cardinals' => 'Busch Stadium'
52
52
  }
53
53
 
54
- attr_accessor :home_team, :away_team, :date_time, :ballpark
54
+ attr_accessor :home_team, :away_team, :date_time, :ballpark, :home_team_runs, :away_team_runs
55
55
 
56
- def initialize(home_team, away_team, date_time)
56
+ def initialize(date_time, home_team, away_team, home_team_runs, away_team_runs)
57
+ self.date_time = date_time
57
58
  self.home_team = home_team
58
59
  self.away_team = away_team
59
- self.date_time = date_time
60
+ self.home_team_runs = home_team_runs
61
+ self.away_team_runs = away_team_runs
60
62
  end
61
63
 
62
64
  def home_team=(home_team_value)
@@ -90,7 +92,7 @@ class HelloTable
90
92
  def launch
91
93
  shell {
92
94
  text 'Hello, Table!'
93
- table { |table_proxy|
95
+ table(:editable) { |table_proxy|
94
96
  table_column {
95
97
  text 'Game Date/Time'
96
98
  width 150
@@ -102,11 +104,21 @@ class HelloTable
102
104
  width 150
103
105
  editor :combo, :read_only
104
106
  }
107
+ table_column {
108
+ text 'Home Team Runs'
109
+ width 100
110
+ editor :spinner
111
+ }
105
112
  table_column {
106
113
  text 'Away Team'
107
114
  width 150
108
115
  editor :combo, :read_only
109
116
  }
117
+ table_column {
118
+ text 'Away Team Runs'
119
+ width 100
120
+ editor :spinner
121
+ }
110
122
  table_column {
111
123
  text 'Ballpark'
112
124
  width 150
@@ -114,14 +126,10 @@ class HelloTable
114
126
  }
115
127
 
116
128
  # 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)
129
+ items bind(BaseballGame, :schedule), column_properties(:game_date_time, :home_team, :home_team_runs, :away_team, :away_team_runs, :ballpark)
118
130
 
119
131
  # 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
- }
132
+ additional_sort_properties :date_time, :home_team, :away_team, :ballpark, :home_team_runs, :away_team_runs
125
133
  }
126
134
  }.open
127
135
  end
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.3
4
+ version: 4.17.9.0
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-05 00:00:00.000000000 Z
11
+ date: 2020-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -392,6 +392,7 @@ files:
392
392
  - lib/glimmer/swt/custom/checkbox_group.rb
393
393
  - lib/glimmer/swt/custom/code_text.rb
394
394
  - lib/glimmer/swt/custom/radio_group.rb
395
+ - lib/glimmer/swt/date_time_proxy.rb
395
396
  - lib/glimmer/swt/directory_dialog_proxy.rb
396
397
  - lib/glimmer/swt/display_proxy.rb
397
398
  - lib/glimmer/swt/dnd_proxy.rb
@@ -437,6 +438,7 @@ files:
437
438
  - samples/hello/hello_computed/contact.rb
438
439
  - samples/hello/hello_custom_shell.rb
439
440
  - samples/hello/hello_custom_widget.rb
441
+ - samples/hello/hello_date_time.rb
440
442
  - samples/hello/hello_directory_dialog.rb
441
443
  - samples/hello/hello_drag_and_drop.rb
442
444
  - samples/hello/hello_expand_bar.rb