glimmer-dsl-swt 4.17.2.0 → 4.17.2.1

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: a632c93d02fd21c0de17a1d631befd7731af8cfb7abf8724d73a053296838064
4
- data.tar.gz: ee501db9d342c5dffa2fbc789f59df68088dd00c89bb27034800c18f1f327ee1
3
+ metadata.gz: c16edb19554a8b68798a5b63dc573094b6381c3c7528a490d1094c5b9c28be6a
4
+ data.tar.gz: 3c5c5a19894d9dd1dfe00619fbfee22cb109c20c252530bb717898c22f520867
5
5
  SHA512:
6
- metadata.gz: 5a556565e268e0d681b2d2985d2eadc295607dfa70b08dafbbb7682e6e55460ce707ba170e15d184f295b46235db92351143a438d53acd2fb0d46ec6b4f6e252
7
- data.tar.gz: 827f6459043b84f7370e5e4f71ac3dac570a1ade25e1005ca8978340ff5bdead383244b77e4884166f1d9eb0dd76c4797cc793365fc8c4ee35c64b0233fd6da4
6
+ metadata.gz: cd4a6c25743aaec88b0638c1e869fe980f3a3c96f9674fd54497859485690b23a00b128cd7a310a29c6c29182e1f9766f2c847687c218b29dc33cbf19d77936d
7
+ data.tar.gz: 35133834f642a0e90c665c5811540c3fa50e22164ee7db560edf7b0243cc5650bcf70ad1d196442a0eb6c090a35a455412131bc50ac97ead0089aba1007a04cd
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.17.2.1
4
+
5
+ - Add `--bundler=group` option to `glimmer` command
6
+ - Add `--pd` option to `glimmer` command
7
+ - Hello, Custom Widget! sample
8
+ - Hello, Custom Shell! sample
9
+
3
10
  ### 4.17.2.0
4
11
 
5
12
  - `glimmer` command --bundler option to run with bundler/setup (instead of picking gems directly)
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.2.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.2.1
2
2
  ## JRuby Desktop Development GUI Library
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)
@@ -335,6 +335,8 @@ Glimmer App:
335
335
  - [Hello, Drag and Drop!](#hello-drag-and-drop)
336
336
  - [Hello, Menu Bar!](#hello-menu-bar)
337
337
  - [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
338
+ - [Hello, Custom Widget!](#hello-custom-widget)
339
+ - [Hello, Custom Shell!](#hello-custom-shell)
338
340
  - [Elaborate Samples](#elaborate-samples)
339
341
  - [User Profile](#user-profile)
340
342
  - [Login](#login)
@@ -416,7 +418,7 @@ If you intend to build a Glimmer app from scratch with [scaffolding](#scaffoldin
416
418
 
417
419
  Otherwise, Option 2 ([Bundler](#option-2-bundler)) can be followed in rare cases where you want to build an app without [scaffolding](#scaffolding).
418
420
 
419
- Note: if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then go back in the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions) until you find one that works for you.
421
+ Note: if you encounter any [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues), please [report](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) and then install a previous version instead from the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions).
420
422
 
421
423
  ### Option 1: Direct Install
422
424
  (Use for [Scaffolding](#scaffolding))
@@ -428,7 +430,7 @@ jgem install glimmer-dsl-swt
428
430
 
429
431
  Or this command if you want a specific version:
430
432
  ```
431
- jgem install glimmer-dsl-swt -v 4.17.2.0
433
+ jgem install glimmer-dsl-swt -v 4.17.2.1
432
434
  ```
433
435
 
434
436
  Note: 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.
@@ -505,9 +507,9 @@ bin/glimmer sample:run[hello_world]
505
507
  Below are the full usage instructions that come up when running `glimmer` without args.
506
508
 
507
509
  ```
508
- Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.0
510
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.1
509
511
 
510
- Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
512
+ Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
511
513
 
512
514
  Runs Glimmer applications and tasks.
513
515
 
@@ -517,7 +519,9 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
517
519
  Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
518
520
 
519
521
  Glimmer options:
520
- - "--quiet" : Does not announce file path of Glimmer application being launched
522
+ - "--bundler=GROUP" : Activates gems in Bundler default group in Gemfile
523
+ - "--pd=BOOLEAN" : Requires puts_debuggerer to enable pd method
524
+ - "--quiet=BOOLEAN" : Does not announce file path of Glimmer application being launched
521
525
  - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
522
526
  - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
523
527
 
@@ -618,7 +622,7 @@ This will run the hello_tab sample and output its code:
618
622
  ```
619
623
  $ glimmer sample:run[hello_tab]
620
624
 
621
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/hello/hello_tab.rb
625
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/hello/hello_tab.rb
622
626
 
623
627
  class HelloTab
624
628
  include Glimmer
@@ -663,7 +667,7 @@ Example:
663
667
  ```
664
668
  $ glimmer sample:code[tic_tac_toe]
665
669
 
666
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe.rb
670
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe.rb
667
671
 
668
672
  require_relative "tic_tac_toe/board"
669
673
 
@@ -724,7 +728,7 @@ TicTacToe.new.open
724
728
  # # #
725
729
 
726
730
 
727
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe/cell.rb
731
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/cell.rb
728
732
 
729
733
  class TicTacToe
730
734
  class Cell
@@ -757,7 +761,7 @@ end
757
761
  # # #
758
762
 
759
763
 
760
- # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/elaborate/tic_tac_toe/board.rb
764
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.1/samples/elaborate/tic_tac_toe/board.rb
761
765
 
762
766
  require_relative 'cell'
763
767
 
@@ -1189,7 +1193,7 @@ Output:
1189
1193
 
1190
1194
  Css glimmer-dsl-css 0.2.0 AndyMaleh Glimmer DSL for CSS
1191
1195
  Opal glimmer-dsl-opal 0.1.0 AndyMaleh Glimmer DSL for Opal
1192
- Swt glimmer-dsl-swt 4.17.2.0 AndyMaleh Glimmer DSL for SWT
1196
+ Swt glimmer-dsl-swt 4.17.2.1 AndyMaleh Glimmer DSL for SWT
1193
1197
  Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
1194
1198
  Xml glimmer-dsl-xml 0.2.0 AndyMaleh Glimmer DSL for XML
1195
1199
  ```
@@ -2660,7 +2664,13 @@ shell {
2660
2664
 
2661
2665
  As you can see, `RedLabel` became Glimmer DSL keyword: `red_label`
2662
2666
 
2663
- #### Lifecycle Hook Example
2667
+ #### Custom Widget Lifecycle Hooks
2668
+
2669
+ You may execute code before or after evaluating the body with these lifecycle hooks:
2670
+ - `before_body`: takes a block that executes in the custom widget instance scope before calling `body`. Useful for initializing variables to later use in `body`
2671
+ - `after_body`: takes a block that executes in the custom widget instance scope after calling `body`. Useful for setting up observers on widgets built in `body` (set in instance variables) and linking to other shells.
2672
+
2673
+ #### Lifecycle Hooks Example
2664
2674
 
2665
2675
  (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
2666
2676
 
@@ -2755,12 +2765,6 @@ shell {
2755
2765
 
2756
2766
  Notice how `:no_focus` was the `swt_style` value, followed by the `options` hash `{orientation: :horizontal, bg_color: :white}`, and finally the `content` block containing the label with `'SANDWICH CONTENT'`
2757
2767
 
2758
- #### Custom Widget Lifecycle Hooks
2759
-
2760
- Last but not least, these are the available lifecycle hooks:
2761
- - `before_body`: takes a block that executes in the custom widget instance scope before calling `body`. Useful for initializing variables to later use in `body`
2762
- - `after_body`: takes a block that executes in the custom widget instance scope after calling `body`. Useful for setting up observers on widgets built in `body` (set in instance variables) and linking to other shells.
2763
-
2764
2768
  #### Gotcha
2765
2769
 
2766
2770
  Beware of defining a custom attribute that is a common SWT widget property name.
@@ -2796,6 +2800,8 @@ The `text` method invoked in the custom widget body will call the one you define
2796
2800
  This [Eclipse guide](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm) for how to write custom SWT widgets is also applicable to Glimmer Custom Widgets written in Ruby. I recommend reading it:
2797
2801
  [https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm](https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm)
2798
2802
 
2803
+ Also, you may check out [Hello, Custom Widget!](#hello-custom-widget) for another example.
2804
+
2799
2805
  ### Custom Shells
2800
2806
 
2801
2807
  Custom shells are a kind of custom widgets that have shells only as the body root. They can be self-contained applications that may be opened and hidden/closed independently of the main app.
@@ -2861,6 +2867,8 @@ shell { |app_shell|
2861
2867
  }.open
2862
2868
  ```
2863
2869
 
2870
+ You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
2871
+
2864
2872
  ### Drag and Drop
2865
2873
 
2866
2874
  Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
@@ -2921,9 +2929,8 @@ Optional steps:
2921
2929
 
2922
2930
  #### Multi-DSL Support
2923
2931
 
2924
- Glimmer is a DSL Framework that supports multiple DSLs (Domain Specific Languages):
2925
- - [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Library)
2926
- - [Tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
2932
+ Glimmer is a DSL engine that supports multiple DSLs (Domain Specific Languages):
2933
+ - [SWT](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
2927
2934
  - [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
2928
2935
  - [XML](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML) - Useful with [SWT Browser Widget](#browser-widget)
2929
2936
  - [CSS](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) - Useful with [SWT Browser Widget](#browser-widget)
@@ -3612,6 +3619,41 @@ glimmer sample:run[hello_pop_up_context_menu]
3612
3619
  ![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
3613
3620
  ![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
3614
3621
 
3622
+ #### Hello, Custom Widget!
3623
+
3624
+ This sample demonstrates the use of a custom widget in Glimmer.
3625
+
3626
+ Code:
3627
+
3628
+ [samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
3629
+
3630
+ Run:
3631
+
3632
+ ```
3633
+ glimmer sample:run[hello_custom_widget]
3634
+ ```
3635
+
3636
+ ![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
3637
+
3638
+ #### Hello, Custom Shell!
3639
+
3640
+ This sample demonstrates the use of a custom shell (aka custom window) in Glimmer.
3641
+
3642
+ Code:
3643
+
3644
+ [samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
3645
+
3646
+ Run:
3647
+
3648
+ ```
3649
+ glimmer sample:run[hello_custom_shell]
3650
+ ```
3651
+
3652
+ ![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
3653
+ ![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
3654
+ ![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
3655
+ ![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
3656
+
3615
3657
  ### Elaborate Samples
3616
3658
 
3617
3659
  For more elaborate samples, check the following:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.2.0
1
+ 4.17.2.1
@@ -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.2.0 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.2.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.2.0"
9
+ s.version = "4.17.2.1"
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-09-25"
14
+ s.date = "2020-10-02"
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]
@@ -120,6 +120,8 @@ Gem::Specification.new do |s|
120
120
  "samples/hello/hello_combo.rb",
121
121
  "samples/hello/hello_computed.rb",
122
122
  "samples/hello/hello_computed/contact.rb",
123
+ "samples/hello/hello_custom_shell.rb",
124
+ "samples/hello/hello_custom_widget.rb",
123
125
  "samples/hello/hello_drag_and_drop.rb",
124
126
  "samples/hello/hello_list_multi_selection.rb",
125
127
  "samples/hello/hello_list_single_selection.rb",
@@ -22,6 +22,12 @@
22
22
  $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
23
23
 
24
24
  # External requires
25
+ if !['', 'false'].include?(ENV['GLIMMER_BUNDLER_SETUP'].to_s.strip.downcase)
26
+ bundler_group = ENV['GLIMMER_BUNDLER_SETUP'].to_s.strip.downcase
27
+ bundler_group = 'default' if bundler_group == 'true'
28
+ require 'bundler'
29
+ Bundler.setup(bundler_group)
30
+ end
25
31
  require 'java'
26
32
  require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
27
33
  require 'glimmer'
@@ -19,7 +19,10 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- require 'bundler/setup' if ARGV.include?('--bundler') && File.exist?(File.expand_path('./Gemfile'))
22
+ if ARGV.include?('--bundler') && File.exist?(File.expand_path('./Gemfile'))
23
+ require 'bundler'
24
+ Bundler.setup(:default)
25
+ end
23
26
  require 'fileutils'
24
27
  require 'os'
25
28
 
@@ -29,7 +32,7 @@ module Glimmer
29
32
 
30
33
  TEXT_USAGE = <<~MULTI_LINE_STRING
31
34
  Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
32
- Usage: glimmer [--bundler] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
35
+ Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
33
36
 
34
37
  Runs Glimmer applications and tasks.
35
38
 
@@ -39,8 +42,9 @@ module Glimmer
39
42
  Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
40
43
 
41
44
  Glimmer options:
42
- - "--bundler" : Activates Glimmer gems with `bundler/setup` to ensure they match Gemfile (passes -G to jruby on app run)
43
- - "--quiet" : Does not announce file path of Glimmer application being launched
45
+ - "--bundler=GROUP" : Activates gems in Bundler default group in Gemfile
46
+ - "--pd=BOOLEAN" : Requires puts_debuggerer to enable pd method
47
+ - "--quiet=BOOLEAN" : Does not announce file path of Glimmer application being launched
44
48
  - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
45
49
  - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
46
50
 
@@ -52,9 +56,11 @@ module Glimmer
52
56
 
53
57
  GLIMMER_LIB_LOCAL = File.expand_path(File.join('lib', 'glimmer-dsl-swt.rb'))
54
58
  GLIMMER_LIB_GEM = 'glimmer-dsl-swt'
55
- GLIMMER_OPTIONS = %w[--log-level --quiet --bundler]
59
+ GLIMMER_OPTIONS = %w[--log-level --quiet --bundler --pd]
56
60
  GLIMMER_OPTION_ENV_VAR_MAPPING = {
57
- '--log-level' => 'GLIMMER_LOGGER_LEVEL'
61
+ '--log-level' => 'GLIMMER_LOGGER_LEVEL' ,
62
+ '--bundler' => 'GLIMMER_BUNDLER_SETUP' ,
63
+ '--pd' => 'PD' ,
58
64
  }
59
65
  REGEX_RAKE_TASK_WITH_ARGS = /^([^\[]+)\[?([^\]]*)\]?$/
60
66
 
@@ -105,7 +111,6 @@ module Glimmer
105
111
 
106
112
  def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
107
113
  jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
108
- bundler_require = '-G' if glimmer_options['--bundler']
109
114
  env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
110
115
  env_vars_string = env_vars.map do |k,v|
111
116
  if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
@@ -137,7 +142,7 @@ module Glimmer
137
142
  @@mutex.synchronize do
138
143
  puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
139
144
  end
140
- command = "#{env_vars_string} jruby #{bundler_require} #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
145
+ command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
141
146
  if !env_vars_string.empty? && OS.windows?
142
147
  command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
143
148
  command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
@@ -678,6 +678,9 @@ module Glimmer
678
678
  end
679
679
  # TODO consider detecting type on widget method and automatically invoking right converter (e.g. :to_s for String, :to_i for Integer)
680
680
  @property_type_converters ||= {
681
+ alignment: -> (*value) {
682
+ SWTProxy[*value]
683
+ },
681
684
  :background => color_converter,
682
685
  :background_image => lambda do |value|
683
686
  image_proxy = nil
@@ -211,9 +211,9 @@ module Glimmer
211
211
 
212
212
  # This method ensures it has an instance method not coming from Glimmer DSL
213
213
  def has_instance_method?(method_name)
214
- respond_to?(method_name) &&
215
- !swt_widget.respond_to?(method_name) &&
216
- !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') &&
214
+ respond_to?(method_name) and
215
+ !swt_widget&.respond_to?(method_name) and
216
+ !method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
217
217
  !method(method_name)&.source_location&.first&.include?('glimmer/swt/widget_proxy.rb')
218
218
  end
219
219
 
@@ -273,7 +273,10 @@ module Glimmer
273
273
 
274
274
  def execute_hooks(hook_name)
275
275
  self.class.instance_variable_get("@#{hook_name}_blocks")&.each do |hook_block|
276
- instance_exec(&hook_block)
276
+ temp_method_name = "#{hook_name}_block_#{hook_block.hash.abs}_#{(Time.now.to_f * 1_000_000).to_i}"
277
+ singleton_class.define_method(temp_method_name, &hook_block)
278
+ send(temp_method_name)
279
+ singleton_class.send(:remove_method, temp_method_name)
277
280
  end
278
281
  end
279
282
  end
@@ -0,0 +1,134 @@
1
+ require 'date'
2
+
3
+ # This class declares an `email_shell` custom shell, aka custom window (by convention)
4
+ # Used to view an email message
5
+ class EmailShell
6
+ include Glimmer::UI::CustomShell
7
+
8
+ # multiple options without default values
9
+ options :date, :subject, :from, :message
10
+
11
+ # single option with default value
12
+ option :to, default: '"John Irwin" <john.irwin@example.com>'
13
+
14
+ before_body {
15
+ @swt_style |= swt(:shell_trim, :modeless)
16
+ }
17
+
18
+ body {
19
+ # pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
20
+ shell(swt_style) {
21
+ grid_layout(2, false)
22
+
23
+ text subject
24
+
25
+ label {
26
+ text 'Date:'
27
+ }
28
+ label {
29
+ text date
30
+ }
31
+
32
+ label {
33
+ text 'From:'
34
+ }
35
+ label {
36
+ text from
37
+ }
38
+
39
+ label {
40
+ text 'To:'
41
+ }
42
+ label {
43
+ text to
44
+ }
45
+
46
+ label {
47
+ text 'Subject:'
48
+ }
49
+ label {
50
+ text subject
51
+ }
52
+
53
+ label {
54
+ layout_data(:fill, :fill, true, true) {
55
+ horizontal_span 2
56
+ verticalIndent 10
57
+ }
58
+
59
+ background :white
60
+ text message
61
+ }
62
+ }
63
+ }
64
+
65
+ end
66
+
67
+ class HelloCustomShell
68
+ # including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget
69
+ include Glimmer
70
+
71
+ Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
72
+ EmailSystem = Struct.new(:emails, keyword_init: true)
73
+
74
+ def initialize
75
+ @email_system = EmailSystem.new(
76
+ emails: [
77
+ Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
78
+ Email.new(date: DateTime.new(2029, 10, 21, 8, 1, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v100.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 100.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
79
+ Email.new(date: DateTime.new(2029, 10, 19, 16, 58, 0).strftime('%F %I:%M %p'), subject: 'Christmas Party', from: '"Lisa Ferreira" <lisa.ferreira@example.com>', message: "Merry Christmas,\n\nAll office Christmas Party arrangements have been set\n\nMake sure to bring a Secret Santa gift\n\nBest regards,\n\nLisa Ferreira"),
80
+ Email.new(date: DateTime.new(2029, 10, 16, 9, 43, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v99.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 99.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
81
+ Email.new(date: DateTime.new(2029, 10, 15, 11, 2, 0).strftime('%F %I:%M %p'), subject: '2nd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
82
+ Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
83
+ ]
84
+ )
85
+ end
86
+
87
+ def launch
88
+ shell {
89
+ grid_layout
90
+
91
+ text 'Hello, Custom Shell!'
92
+
93
+ label {
94
+ font height: 24, style: :bold
95
+ text 'Emails:'
96
+ }
97
+
98
+ label {
99
+ font height: 18
100
+ text 'Click an email to view its message'
101
+ }
102
+
103
+ table {
104
+ layout_data :fill, :fill, true, true
105
+
106
+ table_column {
107
+ text 'Date:'
108
+ width 180
109
+ }
110
+ table_column {
111
+ text 'Subject:'
112
+ width 180
113
+ }
114
+ table_column {
115
+ text 'From:'
116
+ width 360
117
+ }
118
+
119
+ items bind(@email_system, :emails), column_properties(:date, :subject, :from)
120
+
121
+ on_mouse_up { |event|
122
+ email = event.table_item.get_data
123
+ Thread.new do
124
+ async_exec {
125
+ email_shell(date: email.date, subject: email.subject, from: email.from, message: email.message).open
126
+ }
127
+ end
128
+ }
129
+ }
130
+ }.open
131
+ end
132
+ end
133
+
134
+ HelloCustomShell.new.launch
@@ -0,0 +1,65 @@
1
+ # This class declares a `greeting_label` custom widget (by convention)
2
+ class GreetingLabel
3
+ include Glimmer::UI::CustomWidget
4
+
5
+ # multiple options without default values
6
+ options :name, :colors
7
+
8
+ # single option with default value
9
+ option :greeting, default: 'Hello'
10
+
11
+ # internal attribute (not a custom widget option)
12
+ attr_accessor :color
13
+
14
+ before_body {
15
+ @font = {height: 24, style: :bold}
16
+ @color = :black
17
+ }
18
+
19
+ after_body {
20
+ return if colors.nil?
21
+
22
+ Thread.new {
23
+ colors.cycle { |color|
24
+ async_exec {
25
+ self.color = color
26
+ }
27
+ sleep(1)
28
+ }
29
+ }
30
+ }
31
+
32
+ body {
33
+ # pass received swt_style through to label to customize (e.g. :center to center text)
34
+ label(swt_style) {
35
+ text "#{greeting}, #{name}!"
36
+ font @font
37
+ foreground bind(self, :color)
38
+ }
39
+ }
40
+
41
+ end
42
+
43
+ # including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `greeting_label` custom widget
44
+ include Glimmer
45
+
46
+ shell {
47
+ fill_layout :vertical
48
+
49
+ minimum_size 215, 215
50
+ text 'Hello, Custom Widget!'
51
+
52
+ # custom widget options are passed in a hash
53
+ greeting_label(name: 'Sean')
54
+
55
+ # pass :center SWT style followed by custom widget options hash
56
+ greeting_label(:center, name: 'Laura', greeting: 'Aloha') #
57
+
58
+ greeting_label(:right, name: 'Rick') {
59
+ # you can nest attributes under custom widgets just like any standard widget
60
+ foreground :red
61
+ }
62
+
63
+ # the colors option cycles between colors for the label foreground every second
64
+ greeting_label(:center, name: 'Mary', greeting: 'Aloha', colors: [:red, :dark_green, :blue])
65
+ }.open
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.2.0
4
+ version: 4.17.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -420,6 +420,8 @@ files:
420
420
  - samples/hello/hello_combo.rb
421
421
  - samples/hello/hello_computed.rb
422
422
  - samples/hello/hello_computed/contact.rb
423
+ - samples/hello/hello_custom_shell.rb
424
+ - samples/hello/hello_custom_widget.rb
423
425
  - samples/hello/hello_drag_and_drop.rb
424
426
  - samples/hello/hello_list_multi_selection.rb
425
427
  - samples/hello/hello_list_single_selection.rb