glimmer 0.9.3 → 0.9.4

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: 6255c2aed0be3512fb9e8e1892232ee9f8ad35efb308ea2dc814f5ff86e69265
4
- data.tar.gz: 1c6a024b3ddfed3e296644ec54ce57f38816feb2656a05f2c6daf557cde22b16
3
+ metadata.gz: 11d28368bdf3ae26dcee4ddc661bdeee07fdf932f7c7c8fb45c27de98d4f43dc
4
+ data.tar.gz: b30a42a8f18f74fca414937f068ebcaeee31ba4f76c3afb1be866b9958647426
5
5
  SHA512:
6
- metadata.gz: f39bf5895a97510fe0e40b463b0e77224b7ff09bd695686cf1f38fecdf0e01c1ff86a23ab25a4dbcc3b297906b905be1ad6eb5e8e9fb3fe8e985b39fbda0f80e
7
- data.tar.gz: 44068213c246dacc1763868175aba950a9bf78dc803dcb4b0269d3dd9b1ad76c9efd373cb35977b60d7bfcfbe03e8bd07b46ac32595cb89a796e6c9444ff6b0e
6
+ metadata.gz: 5f0728a1a263ff3c8c841a508d3b250910d2ddf548284029dcea23364522d436f408fe49b10683981241144d4e2bf6a20ab718ce75ed04244c6f9dc0ca51be07
7
+ data.tar.gz: 411965a314069222d27aaddfdbcbe129665725e73d082d6c15805adb188e1a1fc89d62578dc2712972684d8f5f59313b6868667b245cfdfee66f06ad6ef521e9
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
- # <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 /> Glimmer (Ruby Desktop Development GUI Library)
1
+ # <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 style="position: relative; top: 20px;" /> Glimmer (Ruby Desktop Development GUI Library)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer.svg)](http://badge.fury.io/rb/glimmer)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer)
4
+ [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
4
5
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
6
 
6
- **[Contributors Wanted!](#contributing)**
7
+ **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
7
8
 
8
9
  (The Original Glimmer Library Since 2007. Beware of Imitators!)
9
10
 
@@ -84,7 +85,7 @@ NOTE: Glimmer is in beta mode. Please help make better by [contributing](#contri
84
85
 
85
86
  ## Table of contents
86
87
 
87
- - [Glimmer - Ruby Desktop Development GUI Library](#-glimmer---ruby-desktop-development-gui-library)
88
+ - [Glimmer (Ruby Desktop Development GUI Library)](#-glimmer-ruby-desktop-development-gui-library)
88
89
  - [Examples](#examples)
89
90
  - [Hello, World!](#hello-world)
90
91
  - [Tic Tac Toe](#tic-tac-toe)
@@ -103,6 +104,13 @@ NOTE: Glimmer is in beta mode. Please help make better by [contributing](#contri
103
104
  - [Custom Widget](#custom-widget)
104
105
  - [Custom Shell Gem](#custom-shell-gem)
105
106
  - [Custom Widget Gem](#custom-widget-gem)
107
+ - [Gem Listing](#gem-listing)
108
+ - [Listing Custom Shell Gems](#listing-custom-shell-gems)
109
+ - [Listing Custom Widget Gems](#listing-custom-widget-gems)
110
+ - [Listing DSL Gems](#listing-dsl-gems)
111
+ - [Packaging](#packaging)
112
+ - [Raw JRuby Command](#raw-jruby-command)
113
+ - [Mac Support](#mac-support)
106
114
  - [Girb (Glimmer irb) Command](#girb-glimmer-irb-command)
107
115
  - [Glimmer DSL Syntax](#glimmer-dsl-syntax)
108
116
  - [Widgets](#widgets)
@@ -136,25 +144,38 @@ NOTE: Glimmer is in beta mode. Please help make better by [contributing](#contri
136
144
  - [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
137
145
  - [Gotcha](#gotcha)
138
146
  - [Custom Shells](#custom-shells)
147
+ - [Drag and Drop](#drag-and-drop)
139
148
  - [Miscellaneous](#miscellaneous)
140
149
  - [Multi-DSL Support](#multi-dsl-support)
141
150
  - [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
142
151
  - [App Name and Version](#app-name-and-version)
143
152
  - [Video Widget](#video-widget)
144
153
  - [Browser Widget](#browser-widget)
154
+ - [Glimmer Configuration](#glimmer-configuration)
155
+ - [logger](#logger)
156
+ - [import_swt_packages](#import_swt_packages)
157
+ - [loop_max_count](#loop_max_count)
145
158
  - [Glimmer Style Guide](#glimmer-style-guide)
159
+ - [SWT Reference](#swt-reference)
146
160
  - [Samples](#samples)
147
161
  - [Hello Samples](#hello-samples)
162
+ - [Hello, World!](#hello-world-sample)
163
+ - [Hello, Tab!](#hello-tab)
164
+ - [Hello, Combo!](#hello-combo)
165
+ - [Hello, List Single Selection!](#hello-list-single-selection)
166
+ - [Hello, List Multi Selection!](#hello-list-multi-selection)
167
+ - [Hello, Computed!](#hello-computed)
168
+ - [Hello, Message Box!](#hello-message-box)
169
+ - [Hello, Browser!](#hello-browser)
170
+ - [Hello, Drag and Drop!](#hello-drag-and-drop)
148
171
  - [Elaborate Samples](#elaborate-samples)
172
+ - [Login](#login)
173
+ - [Tic Tac Toe](#tic-tac-toe-sample)
174
+ - [Contact Manager](#contact-manager)
149
175
  - [External Samples](#external-samples)
150
176
  - [Glimmer Calculator](#glimmer-calculator)
151
177
  - [Gladiator](#gladiator)
152
178
  - [In Production](#in-production)
153
- - [SWT Reference](#swt-reference)
154
- - [SWT Packages](#swt-packages)
155
- - [Logging](#logging)
156
- - [Raw JRuby Command](#raw-jruby-command)
157
- - [Mac Support](#mac-support)
158
179
  - [Packaging & Distribution](#packaging--distribution)
159
180
  - [Packaging Defaults](#packaging-defaults)
160
181
  - [Packaging Configuration](#packaging-configuration)
@@ -196,14 +217,14 @@ https://www.eclipse.org/swt/faq.php
196
217
  ## Pre-requisites
197
218
 
198
219
  - SWT 4.15 (comes included in Glimmer gem)
199
- - JRuby 9.2.11.1 (supporting Ruby 2.5.x syntax) (find at [https://www.jruby.org/download](https://www.jruby.org/download))
220
+ - JRuby 9.2.12.0 (supporting Ruby 2.5.x syntax) (find at [https://www.jruby.org/download](https://www.jruby.org/download))
200
221
  - JDK 8 - 10 (find at [https://www.oracle.com/java/technologies/javase-downloads.html](https://www.oracle.com/java/technologies/javase-downloads.html))
201
222
  - (Optional) RVM is needed for [Scaffolding](#scaffolding) only (find at [https://rvm.io/](https://rvm.io/))
202
223
 
203
224
  On **Mac** and **Linux**, an easy way to obtain JRuby is through [RVM](http://rvm.io) by running:
204
225
 
205
226
  ```bash
206
- rvm install jruby-9.2.11.1
227
+ rvm install jruby-9.2.12.0
207
228
  ```
208
229
 
209
230
  Glimmer might still work on lower versions of Java, JRuby and SWT, but there are no guarantees, so it is best to stick to the pre-requisites outlined above.
@@ -212,22 +233,36 @@ Glimmer might still work on lower versions of Java, JRuby and SWT, but there are
212
233
 
213
234
  Please follow these instructions to make the `glimmer` command available on your system via the [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem.
214
235
 
215
- ### Option 1: Direct Install
236
+ If you intend to learn the basics of Glimmer but are not ready to build a Glimmer app yet, pick Option 1 ([Direct Install](#option-1-direct-install)).
237
+
238
+ If you intend to build a Glimmer app from scratch on the Mac, pick Option 1 ([Direct Install](#option-1-direct-install)) to leverage [Glimmer Scaffolding](#scaffolding) (only available on the Mac).
239
+
240
+ Otherwise, Option 2 ([Bundler](#option-2-bundler)) is recommended for building Glimmer apps on other platforms (Windows and Linux).
241
+
242
+ ### Option 1: Direct Install
243
+ (Use for [Scaffolding](#scaffolding) on the Mac)
216
244
 
217
245
  Run this command to install directly:
218
246
  ```
219
- jgem install glimmer-dsl-swt -v 0.1.3
247
+ jgem install glimmer-dsl-swt -v 0.2.2
220
248
  ```
221
249
 
222
250
  `jgem` is JRuby's version of `gem` command.
223
251
  RVM allows running `gem` as an alias.
224
252
  Otherwise, you may also run `jruby -S gem install ...`
225
253
 
226
- ### Option 2: Bundler
254
+ If you are new to Glimmer and would like to continue learning the basics, you may continue to the [Glimmer Command](https://github.com/AndyObtiva/glimmer#glimmer-command) section.
255
+
256
+ Otherwise, if you are ready to build a Glimmer app on the Mac, you can jump to the [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer#scaffolding) section next.
257
+
258
+ Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
259
+
260
+ ### Option 2: Bundler
261
+ (Use for Manual App Creation)
227
262
 
228
263
  Add the following to `Gemfile`:
229
264
  ```
230
- gem 'glimmer-dsl-swt', '~> 0.1.3'
265
+ gem 'glimmer-dsl-swt', '~> 0.2.2'
231
266
  ```
232
267
 
233
268
  And, then run:
@@ -235,10 +270,16 @@ And, then run:
235
270
  jruby -S bundle install
236
271
  ```
237
272
 
273
+ Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
274
+
238
275
  You may learn more about other Glimmer related gems ([`glimmer-dsl-opal`](https://github.com/AndyObtiva/glimmer-dsl-opal), [`glimmer-dsl-xml`](https://github.com/AndyObtiva/glimmer-dsl-xml), and [`glimmer-dsl-css`](https://github.com/AndyObtiva/glimmer-dsl-css)) at [Multi-DSL Support](#multi-dsl-support)
239
276
 
240
277
  ## Glimmer Command
241
278
 
279
+ The `glimmer` command allows you to run, scaffold, package, and list Glimmer applications/gems.
280
+
281
+ If you are new to Glimmer, you may read the Basic Usage section and skip the rest until you have gone through [Girb (Glimmer irb) Command](#girb-glimmer-irb-command), [Glimmer DSL Syntax](#glimmer-dsl-syntax), and [Samples](#samples).
282
+
242
283
  ### Basic Usage
243
284
 
244
285
  ```
@@ -275,6 +316,9 @@ Either a single task or one or more applications may be specified.
275
316
  When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
276
317
 
277
318
  Available tasks are below (you may also lookup by adding `require 'glimmer/rake_task'` in Rakefile and running rake -T):
319
+ glimmer list:custom_shell_gems[query] # List Glimmer custom shell gems available at rubygems.org (query is optional)
320
+ glimmer list:custom_widget_gems[query] # List Glimmer custom widget gems available at rubygems.org (query is optional)
321
+ glimmer list:dsl_gems[query] # List Glimmer DSL gems available at rubygems.org (query is optional)
278
322
  glimmer package # Package app for distribution (generating config, jar, and native files)
279
323
  glimmer package:config # Generate JAR config file
280
324
  glimmer package:jar # Generate JAR file
@@ -373,6 +417,10 @@ Eventually, it will launch an advanced "Hello, World!" app window having the tit
373
417
 
374
418
  ![Glimmer Scaffold App](images/glimmer-scaffolding-app.png)
375
419
 
420
+ On the Mac, it also comes with a boilerplate Preferences dialog.
421
+
422
+ ![Glimmer Scaffold App Preferences](images/glimmer-scaffolding-app-preferences.png)
423
+
376
424
  #### Custom Shell
377
425
 
378
426
  To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
@@ -430,6 +478,125 @@ Only official Glimmer gems created by the Glimmer project committers will have n
430
478
 
431
479
  Example: [https://github.com/AndyObtiva/glimmer-cw-video](https://github.com/AndyObtiva/glimmer-cw-video)
432
480
 
481
+ ### Gem Listing
482
+
483
+ The `glimmer` command comes with tasks for listing Glimmer related gems to make it easy to find Glimmer Custom Shells, Custom Widgets, and DSLs published by others in the Glimmer community on [rubygems.org](http://www.rubygems.org).
484
+
485
+ #### Listing Custom Shell Gems
486
+
487
+ The following command lists available Glimmer [Custom Shell Gems](#custom-shell-gem) (prefixed with "glimmer-cs-" by scaffolding convention) created by the the Glimmer community and published on [rubygems.org](http://www.rubygems.org):
488
+
489
+ ```
490
+ glimmer list:custom_shell_gems[query] # List Glimmer custom shell gems available at rubygems.org (query is optional)
491
+ ```
492
+
493
+ Example:
494
+
495
+ ```
496
+ glimmer list:custom_shell_gems
497
+ ```
498
+
499
+ Output:
500
+
501
+ ```
502
+
503
+ Glimmer Custom Shell Gems at rubygems.org:
504
+
505
+ Name Gem Version Author Description
506
+
507
+ Calculator glimmer-cs-calculator 1.0.1 Andy Maleh Calculator - Glimmer Custom Shell
508
+ Gladiator glimmer-cs-gladiator 0.2.0 Andy Maleh Gladiator (Glimmer Editor) - Glimmer Custom Shell
509
+
510
+ ```
511
+
512
+ #### Listing Custom Widget Gems
513
+
514
+ The following command lists available Glimmer [Custom Widget Gems](#custom-widget-gem) (prefixed with "glimmer-cw-" by scaffolding convention) created by the the Glimmer community and published on [rubygems.org](http://www.rubygems.org):
515
+
516
+ ```
517
+ glimmer list:custom_widget_gems[query] # List Glimmer custom widget gems available at rubygems.org (query is optional)
518
+ ```
519
+
520
+ Example:
521
+
522
+ Check if there is a custom video widget for Glimmer.
523
+
524
+ ```
525
+ glimmer list:custom_widget_gems[video]
526
+ ```
527
+
528
+ Output:
529
+
530
+ ```
531
+
532
+ Glimmer Custom Widget Gems matching [video] at rubygems.org:
533
+
534
+ Name Gem Version Author Description
535
+
536
+ Video glimmer-cw-video 0.1.1 Andy Maleh Glimmer Custom Widget - Video
537
+
538
+ ```
539
+
540
+ #### Listing DSL Gems
541
+
542
+ The following command lists available Glimmer [DSL Gems](#multi-dsl-support) (prefixed with "glimmer-dsl-" by convention) created by the the Glimmer community and published on [rubygems.org](http://www.rubygems.org):
543
+
544
+ ```
545
+ glimmer list:dsl_gems[query] # List Glimmer DSL gems available at rubygems.org (query is optional)
546
+ ```
547
+
548
+ Example:
549
+
550
+ ```
551
+ glimmer list:dsl_gems
552
+ ```
553
+
554
+ Output:
555
+
556
+ ```
557
+
558
+ Glimmer DSL Gems at rubygems.org:
559
+
560
+ Name Gem Version Author Description
561
+
562
+ Css glimmer-dsl-css 0.1.0 AndyMaleh Glimmer DSL for CSS
563
+ Opal glimmer-dsl-opal 0.0.9 AndyMaleh Glimmer DSL for Opal
564
+ Swt glimmer-dsl-swt 0.2.2 AndyMaleh Glimmer DSL for SWT
565
+ Xml glimmer-dsl-xml 0.1.0 AndyMaleh Glimmer DSL for XML
566
+
567
+ ```
568
+
569
+ ### Packaging
570
+
571
+ Glimmer packaging tasks are detailed under [Packaging & Distribution](#packaging--distribution).
572
+
573
+ ### Raw JRuby Command
574
+
575
+ If there is a need to run Glimmer directly via the `jruby` command, you
576
+ may run the following:
577
+
578
+ ```
579
+ jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
580
+ ```
581
+
582
+ The `-J-classpath` option specifies the `swt.jar` file path, which can be a
583
+ manually downloaded version of SWT, or otherwise the one included in the gem. You can lookup the one included in the gem by running `jgem which glimmer` to find the gem path and then look through the `vendor` directory.
584
+
585
+ The `-r` option preloads (requires) the `glimmer` library in Ruby.
586
+
587
+ The `-S` option specifies a script to run.
588
+
589
+ #### Mac Support
590
+
591
+ The Mac is well supported with the `glimmer` command. The advice below is not needed if you are using it.
592
+
593
+ However, if there is a reason to use the raw `jruby` command directly instead of the `glimmer` command, you need to pass an extra option (`-J-XstartOnFirstThread`) to JRuby on the Mac (Glimmer automatically passes it for you when using the `glimmer` command).
594
+
595
+ Example:
596
+ ```
597
+ jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
598
+ ```
599
+
433
600
  ## Girb (Glimmer irb) Command
434
601
 
435
602
  With `glimmer-dsl-swt` installed, you may want to run `girb` instead of standard `irb` to have SWT preloaded and the Glimmer library required and included for quick Glimmer coding/testing.
@@ -452,13 +619,13 @@ Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-
452
619
 
453
620
  Glimmer DSL syntax consists of static keywords and dynamic keywords to build and bind user-interface objects.
454
621
 
455
- Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `rgb`, and `bind`.
622
+ Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `message_box`, `async_exec`, and `bind`.
456
623
 
457
- Dynamic keywords are dynamically figured out from available SWT widgets, custom widgets, and properties. Examples are: `label`, `combo`, and `text`.
624
+ Dynamic keywords are dynamically figured out from available SWT widgets, custom widgets, and properties. Examples are: `label`, `combo`, and `list`.
458
625
 
459
- The only reason to distinguish between both types of Glimmer DSL keywords is to realize that importing new Java SWT custom widget libraries and Ruby custom widgets automatically expands Glimmer's available DSL syntax via new dynamic keywords.
626
+ The only reason to distinguish between the two types of Glimmer DSL keywords is to realize that importing new Glimmer [custom widgets](#custom-widgets) and Java SWT custom widget libraries automatically expands Glimmer's DSL vocabulary via new dynamic keywords.
460
627
 
461
- For example, if a project adds this custom SWT library:
628
+ For example, if a project adds this custom Java SWT library:
462
629
 
463
630
  https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php?page=operation
464
631
 
@@ -638,27 +805,34 @@ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
638
805
  @shell.open
639
806
  ```
640
807
 
641
- ##### `#swt_widget`
808
+ ##### `message_box`
642
809
 
643
- Glimmer widget objects come with an instance method `#swt_widget` that returns the actual SWT `Widget` object wrapped by the Glimmer widget object. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
810
+ The Glimmer DSL `message_box` keyword is similar to `shell`, but renders a modal dialog with a title `text` property and main body `message` property. It may also be opened via the `#open` method.
644
811
 
645
812
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
646
813
 
647
814
  ```ruby
815
+ include Glimmer
816
+
648
817
  @shell = shell {
818
+ text 'Hello, Message Box!'
649
819
  button {
650
- text "Press Me"
820
+ text 'Please Click To Win a Surprise'
651
821
  on_widget_selected {
652
- message_box = MessageBox.new(@shell.swt_widget) # passing SWT Shell widget
653
- message_box.setText("Surprise")
654
- message_box.setMessage("You have won $1,000,000!")
655
- message_box.open
822
+ message_box(@shell) {
823
+ text 'Surprise'
824
+ message "Congratulations!\n\nYou have won $1,000,000!"
825
+ }.open
656
826
  }
657
827
  }
658
828
  }
659
829
  @shell.open
660
830
  ```
661
831
 
832
+ ##### `#swt_widget`
833
+
834
+ Glimmer widget objects come with an instance method `#swt_widget` that returns the actual SWT `Widget` object wrapped by the Glimmer widget object. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
835
+
662
836
  ##### Shell widget proxy methods
663
837
 
664
838
  Shell widget proxy has extra methods specific to SWT Shell:
@@ -686,7 +860,7 @@ Glimmer DSL provides support for SWT Menu and MenuItem widgets.
686
860
 
687
861
  There are 2 main types of menus in SWT:
688
862
  - Menu Bar (shows up on top)
689
- - Pop Up Menu (shows up when right-clicking a widget)
863
+ - Pop Up Context Menu (shows up when right-clicking a widget)
690
864
 
691
865
  Underneath both types, there can be a 3rd menu type called Drop Down.
692
866
 
@@ -694,39 +868,63 @@ Glimmer provides special support for Drop Down menus as it automatically instant
694
868
 
695
869
  The ampersand symbol indicates the keyboard shortcut key for the menu item (e.g. '&Help' can be triggered on Windows by hitting ALT+H)
696
870
 
697
- Example [Menu Bar] (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
871
+ Example of a Menu Bar (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
698
872
 
699
873
  ```ruby
700
- shell {
874
+ shell { |shell_proxy|
875
+ text 'Hello, Menu Bar!'
876
+ grid_layout
877
+ label(:center) {
878
+ font height: 16
879
+ text 'Check Out The File Menu and History Menu in The Menu Bar Above!'
880
+ }
701
881
  menu_bar {
702
882
  menu {
703
- text "&File"
883
+ text '&File'
704
884
  menu_item {
705
- text "E&xit"
885
+ text 'E&xit'
706
886
  }
707
887
  menu_item(0) {
708
- text "&New"
888
+ text '&New'
889
+ on_widget_selected {
890
+ message_box(shell_proxy) {
891
+ text 'New File'
892
+ message 'New File Contents'
893
+ }.open
894
+ }
709
895
  }
710
896
  menu(1) {
711
- text "&Options"
897
+ text '&Options'
712
898
  menu_item(:radio) {
713
- text "Option 1"
899
+ text 'Option 1'
714
900
  }
715
901
  menu_item(:separator)
716
902
  menu_item(:check) {
717
- text "Option 3"
903
+ text 'Option 3'
718
904
  }
719
905
  }
720
906
  }
721
907
  menu {
722
- text "&History"
908
+ text '&History'
723
909
  menu {
724
- text "&Recent"
910
+ text '&Recent'
725
911
  menu_item {
726
- text "File 1"
912
+ text 'File 1'
913
+ on_widget_selected {
914
+ message_box(shell_proxy) {
915
+ text 'File 1'
916
+ message 'File 1 Contents'
917
+ }.open
918
+ }
727
919
  }
728
920
  menu_item {
729
- text "File 2"
921
+ text 'File 2'
922
+ on_widget_selected {
923
+ message_box(shell_proxy) {
924
+ text 'File 2'
925
+ message 'File 2 Contents'
926
+ }.open
927
+ }
730
928
  }
731
929
  }
732
930
  }
@@ -734,22 +932,37 @@ shell {
734
932
  }.open
735
933
  ```
736
934
 
737
- Example [Pop Up Menu] (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
935
+ Example of a Pop Up Context Menu (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
738
936
 
739
937
  ```ruby
740
- shell {
938
+ shell { |shell_proxy|
939
+ text 'Hello, Pop Up Context Menu!'
940
+ grid_layout
741
941
  label {
742
- text 'Right-Click Me'
942
+ font height: 16
943
+ text 'Right-Click To Pop Up a Context Menu'
743
944
  menu {
744
945
  menu {
745
946
  text '&History'
746
947
  menu {
747
- text "&Recent"
948
+ text '&Recent'
748
949
  menu_item {
749
- text "File 1"
950
+ text 'File 1'
951
+ on_widget_selected {
952
+ message_box(shell_proxy) {
953
+ text 'File 1'
954
+ message 'File 1 Contents'
955
+ }.open
956
+ }
750
957
  }
751
958
  menu_item {
752
- text "File 2"
959
+ text 'File 2'
960
+ on_widget_selected {
961
+ message_box(shell_proxy) {
962
+ text 'File 2'
963
+ message 'File 2 Contents'
964
+ }.open
965
+ }
753
966
  }
754
967
  }
755
968
  }
@@ -1008,7 +1221,7 @@ Here is a more sophisticated example taken from [hello_computed.rb](samples/hell
1008
1221
 
1009
1222
  ```ruby
1010
1223
  shell {
1011
- text "Hello Computed"
1224
+ text 'Hello, Computed!'
1012
1225
  composite {
1013
1226
  grid_layout {
1014
1227
  num_columns 2
@@ -1016,44 +1229,44 @@ shell {
1016
1229
  horizontal_spacing 20
1017
1230
  vertical_spacing 10
1018
1231
  }
1019
- label {text "First &Name: "}
1232
+ label {text 'First &Name: '}
1020
1233
  text {
1021
1234
  text bind(@contact, :first_name)
1022
1235
  layout_data {
1023
- horizontalAlignment :fill
1024
- grabExcessHorizontalSpace true
1236
+ horizontal_alignment :fill
1237
+ grab_excess_horizontal_space true
1025
1238
  }
1026
1239
  }
1027
- label {text "&Last Name: "}
1240
+ label {text '&Last Name: '}
1028
1241
  text {
1029
1242
  text bind(@contact, :last_name)
1030
1243
  layout_data {
1031
- horizontalAlignment :fill
1032
- grabExcessHorizontalSpace true
1244
+ horizontal_alignment :fill
1245
+ grab_excess_horizontal_space true
1033
1246
  }
1034
1247
  }
1035
- label {text "&Year of Birth: "}
1248
+ label {text '&Year of Birth: '}
1036
1249
  text {
1037
1250
  text bind(@contact, :year_of_birth)
1038
1251
  layout_data {
1039
- horizontalAlignment :fill
1040
- grabExcessHorizontalSpace true
1252
+ horizontal_alignment :fill
1253
+ grab_excess_horizontal_space true
1041
1254
  }
1042
1255
  }
1043
- label {text "Name: "}
1256
+ label {text 'Name: '}
1044
1257
  label {
1045
1258
  text bind(@contact, :name, computed_by: [:first_name, :last_name])
1046
1259
  layout_data {
1047
- horizontalAlignment :fill
1048
- grabExcessHorizontalSpace true
1260
+ horizontal_alignment :fill
1261
+ grab_excess_horizontal_space true
1049
1262
  }
1050
1263
  }
1051
- label {text "Age: "}
1264
+ label {text 'Age: '}
1052
1265
  label {
1053
1266
  text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
1054
1267
  layout_data {
1055
- horizontalAlignment :fill
1056
- grabExcessHorizontalSpace true
1268
+ horizontal_alignment :fill
1269
+ grab_excess_horizontal_space true
1057
1270
  }
1058
1271
  }
1059
1272
  }
@@ -1196,6 +1409,10 @@ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you
1196
1409
 
1197
1410
  #### Combo
1198
1411
 
1412
+ The `combo` widget provides a dropdown of options. By default, it also allows typing in a new option. To disable that behavior, you may use with the `:read_only` SWT style.
1413
+
1414
+ When data-binding a `combo` widget, Glimmer can automatically deduce available options from data-bound model by convention: `{attribute_name}_options` method.
1415
+
1199
1416
  ![Hello Combo](images/glimmer-hello-combo.png)
1200
1417
 
1201
1418
  ![Hello Combo](images/glimmer-hello-combo-expanded.png)
@@ -1237,7 +1454,7 @@ end
1237
1454
  HelloCombo.new.launch
1238
1455
  ```
1239
1456
 
1240
- `combo` widget is data-bound to the country of a person. Note that it expects `person` object to have `:country` attribute and `:country_options` attribute containing all available countries.
1457
+ `combo` widget is data-bound to the country of a person. Note that it expects the `person` object to have the `:country` attribute and `:country_options` attribute containing all available countries (aka options). Glimmer reads these attributes by convention.
1241
1458
 
1242
1459
  #### List
1243
1460
 
@@ -1549,7 +1766,7 @@ class TicTacToe
1549
1766
  end
1550
1767
  ```
1551
1768
 
1552
- Observers can be a good mechanism for displaying dialog messages in Glimmer (using SWT's `MessageBox`).
1769
+ Observers can be a good mechanism for displaying dialog messages in Glimmer (using SWT's [`MessageBox`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/MessageBox.html) class).
1553
1770
 
1554
1771
  Look at [`samples/elaborate/tictactoe/tic_tac_toe.rb`](samples/tictactoe/tic_tac_toe.rb) for more details starting with the code included below.
1555
1772
 
@@ -1575,10 +1792,10 @@ class TicTacToe
1575
1792
  end
1576
1793
 
1577
1794
  def display_game_over_message(message)
1578
- message_box = MessageBox.new(@shell.swt_widget)
1579
- message_box.setText("Game Over")
1580
- message_box.setMessage(message)
1581
- message_box.open
1795
+ message_box(@shell) {
1796
+ text 'Game Over'
1797
+ message message_text
1798
+ }.open
1582
1799
  @tic_tac_toe_board.reset
1583
1800
  end
1584
1801
  # ...
@@ -1750,6 +1967,11 @@ body {
1750
1967
 
1751
1968
  The `text` method invoked in the custom widget body will call the one you defined above it. To avoid this gotcha, simply name the text property above something else, like `custom_text`.
1752
1969
 
1970
+ #### Final Notes
1971
+
1972
+ 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:
1973
+ [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)
1974
+
1753
1975
  ### Custom Shells
1754
1976
 
1755
1977
  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.
@@ -1815,6 +2037,62 @@ shell { |app_shell|
1815
2037
  }.open
1816
2038
  ```
1817
2039
 
2040
+ ### Drag and Drop
2041
+
2042
+ Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
2043
+
2044
+ You may learn more about SWT Drag and Drop support over here: [https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html](https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html)
2045
+
2046
+ To get started, simply follow these steps:
2047
+ 1. On the drag source widget, add `on_drag_set_data` [DragSourceListener](https://help.eclipse.org/2020-03/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DragSourceListener.html) event handler block at minimum (you may also add `on_drag_start` and `on_drag_finished` if needed)
2048
+ 1. Set `event.data` to transfer via drag and drop inside the `on_drag_set_data` event handler block (defaults to `transfer` type of `:text`, as in a Ruby String)
2049
+ 1. On the drop target widget, add `on_drop` [DropTargetListener](https://help.eclipse.org/2020-03/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DropTargetListener.html) event handler block at minimum (you may also add `on_drag_enter` [must set [`event.detail`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DropTargetEvent.html#detail) if added], `on_drag_over`, `on_drag_leave`, `on_drag_operation_changed` and `on_drop_accept` if needed)
2050
+ 1. Read `event.data` and consume it (e.g. change widget text) inside the `on_drop` event handler block.
2051
+
2052
+ Example (taken from [samples/hello/hello_drag_and_drop.rb](#hello-drag-and-drop) / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2053
+
2054
+ ```ruby
2055
+ class Location
2056
+ attr_accessor :country
2057
+
2058
+ def country_options
2059
+ %w[USA Canada Mexico Columbia UK Australia Germany Italy Spain]
2060
+ end
2061
+ end
2062
+
2063
+ @location = Location.new
2064
+
2065
+ include Glimmer
2066
+
2067
+ shell {
2068
+ text 'Hello, Drag and Drop!'
2069
+ list {
2070
+ selection bind(@location, :country)
2071
+ on_drag_set_data { |event|
2072
+ list = event.widget.getControl
2073
+ event.data = list.getSelection.first
2074
+ }
2075
+ }
2076
+ label(:center) {
2077
+ text 'Drag a country here!'
2078
+ font height: 20
2079
+ on_drop { |event|
2080
+ event.widget.getControl.setText(event.data)
2081
+ }
2082
+ }
2083
+ }.open
2084
+ ```
2085
+
2086
+ ![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
2087
+
2088
+ Optional steps:
2089
+ - Set a `transfer` property (defaults to `:text`). Values may be: :text (default), :html :image, :rtf, :url, and :file, or an array of multiple values. The `transfer` property will automatically convert your option into a [Transfer](https://help.eclipse.org/2020-03/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/Transfer.html) object as per the SWT API.
2090
+ - Specify `drag_source_style` operation (may be: :drop_copy (default), :drop_link, :drop_move, :drop_none, or an array of multiple operations)
2091
+ - Specify `drag_source_effect` (Check [DragSourceEffect](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DragSourceEffect.html) SWT API for details)
2092
+ - Specify `drop_target_style` operation (may be: :drop_copy (default), :drop_link, :drop_move, :drop_none, or an array of multiple operations)
2093
+ - Specify `drop_target_effect` (Check [DropTargetEffect](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/dnd/DropTargetEffect.html) SWT API for details)
2094
+ - Set drag operation in `event.detail` (e.g. DND::DROP_COPY) inside `on_drag_enter`
2095
+
1818
2096
  ### Miscellaneous
1819
2097
 
1820
2098
  #### Multi-DSL Support
@@ -1970,10 +2248,10 @@ class Example
1970
2248
  def initialize
1971
2249
  display {
1972
2250
  on_about {
1973
- message_box = MessageBox.new(@shell_proxy.swt_widget)
1974
- message_box.setText("About")
1975
- message_box.setMessage("About Application")
1976
- message_box.open
2251
+ message_box(@shell_proxy) {
2252
+ text 'About'
2253
+ message 'About Application'
2254
+ }.open
1977
2255
  }
1978
2256
  on_preferences {
1979
2257
  preferences_dialog = dialog {
@@ -2049,7 +2327,7 @@ You may obtain via `glimmer-cw-video` gem.
2049
2327
 
2050
2328
  ![Hello Browser](images/glimmer-hello-browser.png)
2051
2329
 
2052
- Glimmer supports SWT Browser widget, which can load URLs or render HTML. It can even be instrumented with JavaScript when needed (though highly discouraged in Glimmer except for rare cases when leveraging a pre-existing web codebase in a desktop app).
2330
+ Glimmer supports the SWT Browser widget, which can load URLs or render HTML. It can even be instrumented with JavaScript when needed (though highly discouraged since it defeats the purpose of using Ruby except in very rare cases like leveraging a pre-existing web codebase in a desktop app).
2053
2331
 
2054
2332
  Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2055
2333
 
@@ -2085,6 +2363,101 @@ shell {
2085
2363
 
2086
2364
  This relies on Glimmer's [Multi-DSL Support](#multi-dsl-support) for building the HTML text using [Glimmer XML DSL](https://github.com/AndyObtiva/glimmer-dsl-xml).
2087
2365
 
2366
+ ## Glimmer Configuration
2367
+
2368
+ Glimmer configuration may be done via the `Glimmer::Config` module.
2369
+
2370
+ ### logger
2371
+
2372
+ Glimmer supports logging via a Ruby Logger configurable with the `Glimmer::Config.logger` config option.
2373
+ It is disabled by default to ensure not affecting desktop app performance.
2374
+ It may be enabled via `Glimmer::Config.enable_logging`
2375
+ When enabled, the Glimmer logger level defaults to `:warn` (aka `Logger::WARN`)
2376
+ It may be configured to show a different level of logging via `Glimmer::Config.logger.level` just ike with any Ruby Logger.
2377
+
2378
+ Example:
2379
+
2380
+ ```ruby
2381
+ Glimmer::Config.enable_logging
2382
+ Glimmer::Config.logger.level = Logger::DEBUG
2383
+ ```
2384
+ This results in more verbose debug loggging to `STDOUT`, which is very helpful in troubleshooting Glimmer DSL syntax when needed.
2385
+
2386
+ Example log:
2387
+ ```
2388
+ D, [2017-07-21T19:23:12.587870 #35707] DEBUG -- : method: shell and args: []
2389
+ D, [2017-07-21T19:23:12.594405 #35707] DEBUG -- : ShellCommandHandler will handle command: shell with arguments []
2390
+ D, [2017-07-21T19:23:12.844775 #35707] DEBUG -- : method: composite and args: []
2391
+ D, [2017-07-21T19:23:12.845388 #35707] DEBUG -- : parent is a widget: true
2392
+ D, [2017-07-21T19:23:12.845833 #35707] DEBUG -- : on listener?: false
2393
+ D, [2017-07-21T19:23:12.864395 #35707] DEBUG -- : WidgetCommandHandler will handle command: composite with arguments []
2394
+ D, [2017-07-21T19:23:12.864893 #35707] DEBUG -- : widget styles are: []
2395
+ D, [2017-07-21T19:23:12.874296 #35707] DEBUG -- : method: list and args: [:multi]
2396
+ D, [2017-07-21T19:23:12.874969 #35707] DEBUG -- : parent is a widget: true
2397
+ D, [2017-07-21T19:23:12.875452 #35707] DEBUG -- : on listener?: false
2398
+ D, [2017-07-21T19:23:12.878434 #35707] DEBUG -- : WidgetCommandHandler will handle command: list with arguments [:multi]
2399
+ D, [2017-07-21T19:23:12.878798 #35707] DEBUG -- : widget styles are: [:multi]
2400
+ ```
2401
+
2402
+ ### import_swt_packages
2403
+
2404
+ Glimmer automatically imports all SWT Java packages upon adding `include Glimmer`, `include Glimmer::UI::CustomWidget`, or `include Glimmer::UI::CustomShell` to a class or module. It relies on JRuby's `include_package` for lazy-importing upon first reference of a Java class.
2405
+
2406
+ As a result, you may call SWT Java classes from Glimmer Ruby code without mentioning Java package references explicitly.
2407
+
2408
+ For example, `org.eclipse.swt.graphics.Color` can be referenced as just `Color`
2409
+
2410
+ The Java packages imported come from the [`Glimmer::Config.import_swt_packages`](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/lib/ext/glimmer/config.rb) config option, which defaults to `Glimmer::Config::DEFAULT_IMPORT_SWT_PACKAGES`, importing the following Java packages:
2411
+ ```
2412
+ org.eclipse.swt.*
2413
+ org.eclipse.swt.widgets.*
2414
+ org.eclipse.swt.layout.*
2415
+ org.eclipse.swt.graphics.*
2416
+ org.eclipse.swt.browser.*
2417
+ org.eclipse.swt.custom.*
2418
+ org.eclipse.swt.dnd.*
2419
+ ```
2420
+
2421
+ If you need to import additional Java packages as extra Glimmer widgets, you may add more packages to [`Glimmer::Config.import_swt_packages`](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/lib/ext/glimmer/config.rb) by using the `+=` operator (or alternatively limit to certain packages via `=` operator).
2422
+
2423
+ Example:
2424
+
2425
+ ```ruby
2426
+ Glimmer::Config.import_swt_packages += [
2427
+ 'org.eclipse.nebula.widgets.ganttchart'
2428
+ ]
2429
+ ```
2430
+
2431
+ Another alternative is to simply add a `java_import` call to your code (e.g. `java_import 'org.eclipse.nebula.widgets.ganttchart.GanttChart'`). Glimmer will automatically take advantage of it (e.g. when invoking `gantt_chart` keyword)
2432
+
2433
+ Nonetheless, you can disable automatic Java package import if needed via this Glimmer configuration option:
2434
+
2435
+ ```ruby
2436
+ Glimmer::Config.import_swt_packages = false
2437
+ ```
2438
+
2439
+ Once disabled, to import SWT Java packages manually, you may simply:
2440
+
2441
+ 1. `include Glimmer::SWT::Packages`: lazily imports all SWT Java packages to your class, lazy-loading SWT Java class constants on first reference.
2442
+
2443
+ 2. `java_import swt_package_class_string`: immediately imports a specific Java class where `swt_package_class_string` is the Java full package reference of a Java class (e.g. `java_import 'org.eclipse.swt.SWT'`)
2444
+
2445
+ Note: Glimmer relies on [`nested_imported_jruby_include_package`](https://github.com/AndyObtiva/nested_inherited_jruby_include_package), which automatically brings packages to nested-modules/nested-classes and sub-modules/sub-classes.
2446
+
2447
+ You can learn more about importing Java packages into Ruby code at this JRuby WIKI page:
2448
+
2449
+ https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
2450
+
2451
+ ### loop_max_count
2452
+
2453
+ Glimmer has infinite loop detection support.
2454
+ It can detect when an infinite loop is about to occur in method_missing and stops it.
2455
+ It detects potential infinite loops when the same keyword and args repeat more than 100 times, which is unusual in a GUI app.
2456
+
2457
+ The max limit can be changed via the `Glimmer::Config::loop_max_count=(count)` config option.
2458
+
2459
+ Infinite loop detection may be disabled altogether if needed by setting `Glimmer::Config::loop_max_count` to `-1`
2460
+
2088
2461
  ## Glimmer Style Guide
2089
2462
 
2090
2463
  - Widgets are declared with underscored lowercase versions of their SWT names minus the SWT package name.
@@ -2100,6 +2473,38 @@ This relies on Glimmer's [Multi-DSL Support](#multi-dsl-support) for building th
2100
2473
  - Custom widget body, before_body, and after_body blocks open their blocks and close them with curly braces.
2101
2474
  - Custom widgets receive additional arguments to SWT style called options. These are passed as the last argument inside the parentheses, a hash of option names pointing to values.
2102
2475
 
2476
+ ## SWT Reference
2477
+
2478
+ https://www.eclipse.org/swt/docs.php
2479
+
2480
+ Here is the SWT API:
2481
+
2482
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/index.html
2483
+
2484
+ Here is a visual list of SWT widgets:
2485
+
2486
+ https://www.eclipse.org/swt/widgets/
2487
+
2488
+ Here is a textual list of SWT widgets:
2489
+
2490
+ https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
2491
+
2492
+ Here is a list of SWT style bits as used in widget declaration:
2493
+
2494
+ https://wiki.eclipse.org/SWT_Widget_Style_Bits
2495
+
2496
+ Here is a SWT style bit constant reference:
2497
+
2498
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
2499
+
2500
+ Here is an SWT Drag and Drop guide:
2501
+
2502
+ https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html
2503
+
2504
+ Here is an SWT Custom Widget guide:
2505
+
2506
+ https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
2507
+
2103
2508
  ## Samples
2104
2509
 
2105
2510
  Check the [samples](samples) directory in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) for examples on how to write Glimmer applications. To run a sample, make sure to install the `glimmer` gem first and then use the `glimmer` command to run it (alternatively, you may clone the repo, follow [CONTRIBUTING.md](CONTRIBUTING.md) instructions, and run samples locally with development glimmer command: `bin/glimmer`).
@@ -2112,220 +2517,226 @@ samples/launch
2112
2517
 
2113
2518
  ### Hello Samples
2114
2519
 
2115
- For "Hello, World!" type samples, check the following:
2520
+ For hello-type simple samples, check the following.
2521
+
2522
+ #### Hello, World! Sample
2523
+
2524
+ Run:
2116
2525
 
2117
2526
  ```
2118
2527
  glimmer samples/hello/hello_world.rb
2119
- glimmer samples/hello/hello_browser.rb # demonstrates browser widget
2120
- glimmer samples/hello/hello_tab.rb # demonstrates tabs
2121
- glimmer samples/hello/hello_combo.rb # demonstrates combo data-binding
2122
- glimmer samples/hello/hello_list_single_selection.rb # demonstrates list single-selection data-binding
2123
- glimmer samples/hello/hello_list_multi_selection.rb # demonstrates list multi-selection data-binding
2124
- glimmer samples/hello/hello_computed.rb # demonstrates computed data-binding
2125
2528
  ```
2126
2529
 
2127
- ### Elaborate Samples
2530
+ ![Hello World](images/glimmer-hello-world.png)
2128
2531
 
2129
- For more elaborate samples, check the following:
2532
+ #### Hello, Tab!
2130
2533
 
2131
- #### Login
2534
+ Run:
2132
2535
 
2133
2536
  ```
2134
- glimmer samples/elaborate/login.rb # demonstrates basic data-binding
2537
+ glimmer samples/hello/hello_tab.rb
2135
2538
  ```
2136
2539
 
2137
- ![Login](images/glimmer-login.png)
2138
- ![Login Filled In](images/glimmer-login-filled-in.png)
2139
- ![Login Logged In](images/glimmer-login-logged-in.png)
2540
+ ![Hello Tab English](images/glimmer-hello-tab-english.png)
2541
+ ![Hello Tab French](images/glimmer-hello-tab-french.png)
2140
2542
 
2141
- #### Tic Tac Toe
2543
+ #### Hello, Combo!
2544
+
2545
+ This sample demonstrates combo data-binding.
2546
+
2547
+ Run:
2142
2548
 
2143
2549
  ```
2144
- glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
2550
+ glimmer samples/hello/hello_combo.rb
2145
2551
  ```
2146
2552
 
2147
- ![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
2148
- ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
2149
- ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
2553
+ ![Hello Combo](images/glimmer-hello-combo.png)
2554
+ ![Hello Combo Expanded](images/glimmer-hello-combo-expanded.png)
2150
2555
 
2151
- #### Contact Manager
2556
+ #### Hello, List Single Selection!
2557
+
2558
+ This sample demonstrates list single-selection data-binding.
2559
+
2560
+ Run:
2152
2561
 
2153
2562
  ```
2154
- glimmer samples/elaborate/contact_manager.rb # demonstrates table data-binding
2563
+ glimmer samples/hello/hello_list_single_selection.rb
2155
2564
  ```
2156
2565
 
2157
- Contact Manager
2566
+ ![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
2158
2567
 
2159
- ![Contact Manager](images/glimmer-contact-manager.png)
2568
+ #### Hello, List Multi Selection!
2160
2569
 
2161
- Contact Manager - Find
2570
+ This sample demonstrates list multi-selection data-binding.
2162
2571
 
2163
- ![Contact Manager](images/glimmer-contact-manager-find.png)
2572
+ Run:
2164
2573
 
2165
- Contact Manager - Edit Started
2574
+ ```
2575
+ glimmer samples/hello/hello_list_multi_selection.rb
2576
+ ```
2166
2577
 
2167
- ![Contact Manager](images/glimmer-contact-manager-edit-started.png)
2578
+ ![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
2168
2579
 
2169
- Contact Manager - Edit In Progress
2580
+ #### Hello, Computed!
2170
2581
 
2171
- ![Contact Manager](images/glimmer-contact-manager-edit-in-progress.png)
2582
+ This sample demonstrates computed data-binding.
2172
2583
 
2173
- Contact Manager - Edit Done
2584
+ Run:
2174
2585
 
2175
- ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
2586
+ ```
2587
+ glimmer samples/hello/hello_computed.rb
2588
+ ```
2176
2589
 
2177
- ### External Samples
2590
+ ![Hello Browser](images/glimmer-hello-computed.png)
2178
2591
 
2179
- #### Glimmer Calculator
2592
+ #### Hello, Message Box!
2180
2593
 
2181
- [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/v1.0.0/glimmer-cs-calculator-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-calculator)
2594
+ This sample demonstrates a `message_box` dialog.
2182
2595
 
2183
- [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample project demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
2596
+ Run:
2184
2597
 
2185
- #### Gladiator
2598
+ ```
2599
+ glimmer samples/hello/hello_message_box.rb
2600
+ ```
2186
2601
 
2187
- [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/v0.1.5/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
2602
+ ![Hello Message Box](images/glimmer-hello-message-box.png)
2603
+ ![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
2188
2604
 
2189
- [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
2190
- You may check it out to learn how to build a Glimmer Custom Shell gem.
2605
+ #### Hello, Browser!
2191
2606
 
2192
- Gladiator is a good demonstration of:
2193
- - MVP Pattern
2194
- - Tree data-binding
2195
- - List data-binding
2196
- - Text selection data-binding
2197
- - Tabs
2198
- - Context menus
2199
- - Custom Shell
2200
- - Custom widget
2607
+ This sample demonstrates the `browser` widget.
2201
2608
 
2202
- ## In Production
2609
+ Run:
2203
2610
 
2204
- The following production apps have been built with Glimmer:
2611
+ ```
2612
+ glimmer samples/hello/hello_browser.rb
2613
+ ```
2205
2614
 
2206
- [<img alt="Math Bowling Logo" src="https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/images/math-bowling-logo.png" width="40" />Math Bowling](https://github.com/AndyObtiva/MathBowling): an educational math game for elementary level kids
2615
+ ![Hello Browser](images/glimmer-hello-browser.png)
2207
2616
 
2208
- If you have a Glimmer app you would like referenced here, please mention in a Pull Request.
2617
+ #### Hello, Drag and Drop!
2209
2618
 
2210
- ## SWT Reference
2619
+ This sample demonstrates drag and drop in Glimmer.
2211
2620
 
2212
- https://www.eclipse.org/swt/docs.php
2621
+ Run:
2213
2622
 
2214
- Here is the SWT API:
2623
+ ```
2624
+ glimmer samples/hello/hello_drag_and_drop.rb
2625
+ ```
2215
2626
 
2216
- https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/index.html
2627
+ ![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
2217
2628
 
2218
- Here is a visual list of SWT widgets:
2629
+ #### Hello, Menu Bar!
2219
2630
 
2220
- https://www.eclipse.org/swt/widgets/
2631
+ This sample demonstrates menus in Glimmer.
2221
2632
 
2222
- Here is a textual list of SWT widgets:
2633
+ Run:
2223
2634
 
2224
- https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
2635
+ ```
2636
+ glimmer samples/hello/hello_menu_bar.rb
2637
+ ```
2225
2638
 
2226
- Here is a list of SWT style bits as used in widget declaration:
2639
+ ![Hello Menu Bar](images/glimmer-hello-menu-bar.png)
2640
+ ![Hello Menu Bar File Menu](images/glimmer-hello-menu-bar-file-menu.png)
2641
+ ![Hello Menu Bar History Menu](images/glimmer-hello-menu-bar-history-menu.png)
2227
2642
 
2228
- https://wiki.eclipse.org/SWT_Widget_Style_Bits
2643
+ #### Hello, Pop Up Context Menu!
2229
2644
 
2230
- Here is a SWT style bit constant reference:
2645
+ This sample demonstrates pop up context menus in Glimmer.
2231
2646
 
2232
- https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
2647
+ Run:
2233
2648
 
2234
- ## SWT Packages
2649
+ ```
2650
+ glimmer samples/hello/hello_pop_up_context_menu.rb
2651
+ ```
2652
+
2653
+ ![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
2654
+ ![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
2655
+
2656
+ ### Elaborate Samples
2657
+
2658
+ For more elaborate samples, check the following:
2235
2659
 
2236
- Glimmer automatically imports all SWT Java packages upon adding `include Glimmer` to a class or module.
2660
+ #### Login
2237
2661
 
2238
- Here are the Java packages imported:
2239
2662
  ```
2240
- org.eclipse.swt.*
2241
- org.eclipse.swt.widgets.*
2242
- org.eclipse.swt.layout.*
2243
- org.eclipse.swt.graphics.*
2244
- org.eclipse.swt.browser.*
2245
- org.eclipse.swt.custom.*
2663
+ glimmer samples/elaborate/login.rb # demonstrates basic data-binding
2246
2664
  ```
2247
2665
 
2248
- This allows you to call SWT Java classes from Ruby without mentioning Java package references.
2666
+ ![Login](images/glimmer-login.png)
2667
+ ![Login Filled In](images/glimmer-login-filled-in.png)
2668
+ ![Login Logged In](images/glimmer-login-logged-in.png)
2249
2669
 
2250
- For example, after imports, `org.eclipse.swt.graphics.Color` can be referenced by just `Color`
2670
+ #### Tic Tac Toe Sample
2251
2671
 
2252
- Nonetheless, you can disable automatic import if needed via this Glimmer configuration option:
2672
+ ```
2673
+ glimmer samples/elaborate/tic_tac_toe.rb # demonstrates a full MVC application
2674
+ ```
2253
2675
 
2254
- ```ruby
2255
- Glimmer::Config.import_swt_packages = false
2676
+ ![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
2677
+ ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
2678
+ ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
2679
+
2680
+ #### Contact Manager
2681
+
2682
+ ```
2683
+ glimmer samples/elaborate/contact_manager.rb # demonstrates table data-binding
2256
2684
  ```
2257
2685
 
2258
- To import SWT Java packages manually instead, you have 2 options:
2686
+ Contact Manager
2259
2687
 
2260
- 1. `include Glimmer::SwtPackages`: lazily imports all SWT Java packages to your class, lazy-loading SWT Java class constants on first reference.
2688
+ ![Contact Manager](images/glimmer-contact-manager.png)
2261
2689
 
2262
- 2. `java_import swt_package_class_string`: immediately imports a specific Java class where `swt_package_class_string` is the Java full package reference of a Java class (e.g. `java_import 'org.eclipse.swt.SWT'`)
2690
+ Contact Manager - Find
2263
2691
 
2264
- Note: Glimmer relies on [`nested_imported_jruby_include_package`](https://github.com/AndyObtiva/nested_inherited_jruby_include_package), which automatically brings packages to nested-modules/nested-classes and sub-modules/sub-classes.
2692
+ ![Contact Manager](images/glimmer-contact-manager-find.png)
2265
2693
 
2266
- You can learn more about importing Java packages into Ruby code at this JRuby WIKI page:
2694
+ Contact Manager - Edit Started
2267
2695
 
2268
- https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
2696
+ ![Contact Manager](images/glimmer-contact-manager-edit-started.png)
2269
2697
 
2270
- ## Infinite Loop Detection
2698
+ Contact Manager - Edit In Progress
2271
2699
 
2272
- Glimmer can detect if an infinite loop occurs with method_missing by ensuring it does not loop with the same keyword and args more than 100 times.
2700
+ ![Contact Manager](images/glimmer-contact-manager-edit-in-progress.png)
2273
2701
 
2274
- The max limit can be changed via the `Glimmer::Config::loop_max_count=(count)` method.
2702
+ Contact Manager - Edit Done
2275
2703
 
2276
- Infinite loop detection may be disabled by setting `Glimmer::Config::loop_max_count` to `-1`
2704
+ ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
2277
2705
 
2278
- ## Logging
2706
+ ### External Samples
2279
2707
 
2280
- Glimmer comes with a Ruby Logger accessible via `Glimmer::Config.logger`
2281
- Its level of logging defaults to `Logger::WARN`
2282
- It may be configured to show a different level of logging as follows:
2283
- ```ruby
2284
- Glimmer::Config.enable_logging
2285
- Glimmer::Config.logger.level = Logger::DEBUG
2286
- ```
2287
- This results in more verbose debugging log to `STDOUT`, which is helpful in troubleshooting Glimmer DSL syntax when needed.
2708
+ #### Glimmer Calculator
2288
2709
 
2289
- Example log:
2290
- ```
2291
- D, [2017-07-21T19:23:12.587870 #35707] DEBUG -- : method: shell and args: []
2292
- D, [2017-07-21T19:23:12.594405 #35707] DEBUG -- : ShellCommandHandler will handle command: shell with arguments []
2293
- D, [2017-07-21T19:23:12.844775 #35707] DEBUG -- : method: composite and args: []
2294
- D, [2017-07-21T19:23:12.845388 #35707] DEBUG -- : parent is a widget: true
2295
- D, [2017-07-21T19:23:12.845833 #35707] DEBUG -- : on listener?: false
2296
- D, [2017-07-21T19:23:12.864395 #35707] DEBUG -- : WidgetCommandHandler will handle command: composite with arguments []
2297
- D, [2017-07-21T19:23:12.864893 #35707] DEBUG -- : widget styles are: []
2298
- D, [2017-07-21T19:23:12.874296 #35707] DEBUG -- : method: list and args: [:multi]
2299
- D, [2017-07-21T19:23:12.874969 #35707] DEBUG -- : parent is a widget: true
2300
- D, [2017-07-21T19:23:12.875452 #35707] DEBUG -- : on listener?: false
2301
- D, [2017-07-21T19:23:12.878434 #35707] DEBUG -- : WidgetCommandHandler will handle command: list with arguments [:multi]
2302
- D, [2017-07-21T19:23:12.878798 #35707] DEBUG -- : widget styles are: [:multi]
2303
- ```
2710
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/v1.0.0/glimmer-cs-calculator-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-calculator)
2304
2711
 
2305
- ## Raw JRuby Command
2712
+ [Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample project demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
2306
2713
 
2307
- If there is a need to run Glimmer directly via the `jruby` command, you
2308
- may run the following:
2714
+ #### Gladiator
2309
2715
 
2310
- ```
2311
- jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
2312
- ```
2716
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
2313
2717
 
2314
- The `-J-classpath` option specifies the `swt.jar` file path, which can be a
2315
- manually downloaded version of SWT, or otherwise the one included in the gem. You can lookup the one included in the gem by running `jgem which glimmer` to find the gem path and then look through the `vendor` directory.
2718
+ [Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
2719
+ You may check it out to learn how to build a Glimmer Custom Shell gem.
2316
2720
 
2317
- The `-r` option preloads (requires) the `glimmer` library in Ruby.
2721
+ Gladiator is a good demonstration of:
2722
+ - MVP Pattern
2723
+ - Tree data-binding
2724
+ - List data-binding
2725
+ - Text selection data-binding
2726
+ - Tabs
2727
+ - Context menus
2728
+ - Custom Shell
2729
+ - Custom widget
2318
2730
 
2319
- The `-S` option specifies a script to run.
2731
+ ## In Production
2732
+
2733
+ The following production apps have been built with Glimmer:
2320
2734
 
2321
- ### Mac Support
2735
+ [<img alt="Math Bowling Logo" src="https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/images/math-bowling-logo.png" width="40" />Math Bowling](https://github.com/AndyObtiva/MathBowling): an educational math game for elementary level kids
2322
2736
 
2323
- Mac is well supported with the `glimmer` command. However, if there is a reason to use the raw jruby command, you need to pass an extra option (`-J-XstartOnFirstThread`) to JRuby on the Mac.
2737
+ [<img alt="Are We There Yet Logo" src="https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-logo.svg" width="40" />Are We There Yet?](https://github.com/AndyObtiva/are-we-there-yet): A tool that helps you learn when your small projects will finish
2324
2738
 
2325
- Example:
2326
- ```
2327
- jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
2328
- ```
2739
+ If you have a Glimmer app you would like referenced here, please mention in a Pull Request.
2329
2740
 
2330
2741
  ## Packaging & Distribution
2331
2742
 
@@ -2333,7 +2744,7 @@ Glimmer apps may be packaged and distributed on the Mac, Windows, and Linux via
2333
2744
  - Warbler (https://github.com/jruby/warbler): Enables bundling a Glimmer app into a JAR file
2334
2745
  - javapackager (https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html): Enables packaging a JAR file as a DMG file on Mac, EXE on Windows, and multiple Linux supported formats on Linux.
2335
2746
 
2336
- Glimmer simplifies the process of Mac packaging via the `glimmer package` command. It works out of the box for any application generated by [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer/blob/master/README.md#scaffolding):
2747
+ Glimmer simplifies the process of Mac packaging via the `glimmer package` command. It works out of the box for any application generated by [Glimmer Scaffolding](#scaffolding):
2337
2748
 
2338
2749
  ```
2339
2750
  glimmer package
@@ -2512,6 +2923,12 @@ Glimmer DSL Engine specific tasks are at:
2512
2923
 
2513
2924
  If you would like to contribute to Glimmer, please study up on Glimmer and [SWT](#swt-reference), run all Glimmer [samples](#samples), and build a small sample app to add to [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) Hello or Elaborate samples via a Pull Request. Once done, contact me on [Chat](#chat).
2514
2925
 
2926
+ You may apply for contributing to any of these Glimmer DSL gems whether you prefer to focus on the desktop or web:
2927
+ - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
2928
+ - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
2929
+ - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
2930
+ - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
2931
+
2515
2932
  [CONTRIBUTING.md](CONTRIBUTING.md)
2516
2933
 
2517
2934
  ## Contributors
@@ -2521,6 +2938,10 @@ If you would like to contribute to Glimmer, please study up on Glimmer and [SWT]
2521
2938
 
2522
2939
  [Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer/graphs/contributors)
2523
2940
 
2941
+ ## Hire Me
2942
+
2943
+ If your company would like to invest fulltime in further development of the Glimmer open-source project, [hire me](https://www.linkedin.com/in/andymaleh/).
2944
+
2524
2945
  ## License
2525
2946
 
2526
2947
  Copyright (c) 2007-2020 Andy Maleh.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 0.9.4
@@ -56,9 +56,9 @@ module Glimmer
56
56
  method(property_writer_name)
57
57
  ensure_array_object_observer(property_name, send(property_name))
58
58
  begin
59
- method("__original_#{property_writer_name}")
59
+ singleton_method("__original_#{property_writer_name}")
60
60
  rescue
61
- old_method = self.class.instance_method(property_writer_name)
61
+ old_method = self.class.instance_method(property_writer_name) rescue self.method(property_writer_name)
62
62
  define_singleton_method("__original_#{property_writer_name}", old_method)
63
63
  define_singleton_method(property_writer_name) do |value|
64
64
  old_value = self.send(property_name)
@@ -69,7 +69,7 @@ module Glimmer
69
69
  end
70
70
  end
71
71
  rescue => e
72
- # ignore writing if no property writer exists
72
+ #ignore writing if no property writer exists
73
73
  Glimmer::Config.logger&.debug "No need to observe property writer: #{property_writer_name}\n#{e.message}\n#{e.backtrace.join("\n")}"
74
74
  end
75
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-27 00:00:00.000000000 Z
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement