glimmer-dsl-swt 0.6.8 → 4.17.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +269 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +3975 -24
  5. data/VERSION +1 -1
  6. data/bin/girb +21 -0
  7. data/bin/girb_runner.rb +21 -0
  8. data/bin/glimmer +21 -0
  9. data/glimmer-dsl-swt.gemspec +185 -0
  10. data/lib/ext/glimmer.rb +21 -0
  11. data/lib/ext/glimmer/config.rb +21 -5
  12. data/lib/glimmer-dsl-swt.rb +21 -0
  13. data/lib/glimmer/Rakefile +21 -0
  14. data/lib/glimmer/data_binding/list_selection_binding.rb +21 -0
  15. data/lib/glimmer/data_binding/observable_widget.rb +21 -0
  16. data/lib/glimmer/data_binding/shine.rb +22 -1
  17. data/lib/glimmer/data_binding/table_items_binding.rb +21 -0
  18. data/lib/glimmer/data_binding/tree_items_binding.rb +21 -0
  19. data/lib/glimmer/data_binding/widget_binding.rb +21 -0
  20. data/lib/glimmer/dsl/swt/async_exec_expression.rb +21 -0
  21. data/lib/glimmer/dsl/swt/bind_expression.rb +21 -0
  22. data/lib/glimmer/dsl/swt/block_property_expression.rb +21 -0
  23. data/lib/glimmer/dsl/swt/color_expression.rb +21 -0
  24. data/lib/glimmer/dsl/swt/column_properties_expression.rb +21 -0
  25. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +21 -0
  26. data/lib/glimmer/dsl/swt/cursor_expression.rb +21 -0
  27. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +20 -0
  28. data/lib/glimmer/dsl/swt/data_binding_expression.rb +21 -0
  29. data/lib/glimmer/dsl/swt/dialog_expression.rb +21 -0
  30. data/lib/glimmer/dsl/swt/display_expression.rb +21 -0
  31. data/lib/glimmer/dsl/swt/dnd_expression.rb +21 -0
  32. data/lib/glimmer/dsl/swt/dsl.rb +21 -0
  33. data/lib/glimmer/dsl/swt/exec_expression.rb +28 -1
  34. data/lib/glimmer/dsl/swt/font_expression.rb +21 -0
  35. data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
  36. data/lib/glimmer/dsl/swt/layout_data_expression.rb +21 -0
  37. data/lib/glimmer/dsl/swt/layout_expression.rb +21 -0
  38. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +21 -0
  39. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +21 -0
  40. data/lib/glimmer/dsl/swt/menu_expression.rb +21 -0
  41. data/lib/glimmer/dsl/swt/message_box_expression.rb +21 -0
  42. data/lib/glimmer/dsl/swt/observe_expression.rb +21 -0
  43. data/lib/glimmer/dsl/swt/property_expression.rb +21 -0
  44. data/lib/glimmer/dsl/swt/rgb_expression.rb +21 -0
  45. data/lib/glimmer/dsl/swt/rgba_expression.rb +21 -0
  46. data/lib/glimmer/dsl/swt/shell_expression.rb +21 -0
  47. data/lib/glimmer/dsl/swt/swt_expression.rb +21 -0
  48. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +21 -0
  49. data/lib/glimmer/dsl/swt/tab_item_expression.rb +21 -0
  50. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +21 -0
  51. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +21 -0
  52. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +21 -0
  53. data/lib/glimmer/dsl/swt/widget_expression.rb +21 -0
  54. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +21 -0
  55. data/lib/glimmer/launcher.rb +28 -8
  56. data/lib/glimmer/rake_task.rb +66 -87
  57. data/lib/glimmer/rake_task/list.rb +25 -1
  58. data/lib/glimmer/rake_task/package.rb +128 -0
  59. data/lib/glimmer/rake_task/sample.rb +115 -0
  60. data/lib/glimmer/rake_task/scaffold.rb +661 -0
  61. data/lib/glimmer/swt/color_proxy.rb +21 -0
  62. data/lib/glimmer/swt/cursor_proxy.rb +21 -0
  63. data/lib/glimmer/swt/display_proxy.rb +21 -0
  64. data/lib/glimmer/swt/dnd_proxy.rb +21 -0
  65. data/lib/glimmer/swt/font_proxy.rb +21 -0
  66. data/lib/glimmer/swt/image_proxy.rb +21 -0
  67. data/lib/glimmer/swt/layout_data_proxy.rb +21 -0
  68. data/lib/glimmer/swt/layout_proxy.rb +21 -0
  69. data/lib/glimmer/swt/menu_proxy.rb +21 -0
  70. data/lib/glimmer/swt/message_box_proxy.rb +21 -0
  71. data/lib/glimmer/swt/packages.rb +21 -0
  72. data/lib/glimmer/swt/scrolled_composite_proxy.rb +21 -0
  73. data/lib/glimmer/swt/shell_proxy.rb +22 -0
  74. data/lib/glimmer/swt/style_constantizable.rb +21 -0
  75. data/lib/glimmer/swt/swt_proxy.rb +21 -0
  76. data/lib/glimmer/swt/tab_item_proxy.rb +21 -0
  77. data/lib/glimmer/swt/table_column_proxy.rb +21 -0
  78. data/lib/glimmer/swt/table_proxy.rb +27 -4
  79. data/lib/glimmer/swt/tree_proxy.rb +21 -0
  80. data/lib/glimmer/swt/widget_listener_proxy.rb +21 -0
  81. data/lib/glimmer/swt/widget_proxy.rb +54 -24
  82. data/lib/glimmer/ui/custom_shell.rb +21 -0
  83. data/lib/glimmer/ui/custom_widget.rb +22 -0
  84. data/lib/glimmer/util/proc_tracker.rb +23 -0
  85. data/samples/elaborate/contact_manager.rb +21 -0
  86. data/samples/elaborate/contact_manager/contact.rb +21 -0
  87. data/samples/elaborate/contact_manager/contact_manager_presenter.rb +21 -0
  88. data/samples/elaborate/contact_manager/contact_repository.rb +21 -0
  89. data/samples/elaborate/login.rb +20 -2
  90. data/samples/elaborate/tic_tac_toe.rb +21 -0
  91. data/samples/elaborate/tic_tac_toe/board.rb +21 -0
  92. data/samples/elaborate/tic_tac_toe/cell.rb +21 -0
  93. data/samples/elaborate/user_profile.rb +21 -0
  94. data/samples/hello/hello_browser.rb +22 -1
  95. data/samples/hello/hello_combo.rb +21 -0
  96. data/samples/hello/hello_computed.rb +21 -0
  97. data/samples/hello/hello_computed/contact.rb +21 -0
  98. data/samples/hello/hello_drag_and_drop.rb +21 -0
  99. data/samples/hello/hello_list_multi_selection.rb +21 -0
  100. data/samples/hello/hello_list_single_selection.rb +21 -0
  101. data/samples/hello/hello_menu_bar.rb +21 -0
  102. data/samples/hello/hello_message_box.rb +21 -0
  103. data/samples/hello/hello_pop_up_context_menu.rb +21 -0
  104. data/samples/hello/hello_tab.rb +21 -0
  105. data/samples/hello/hello_world.rb +21 -0
  106. data/vendor/swt/linux/swt.jar +0 -0
  107. data/vendor/swt/mac/swt.jar +0 -0
  108. data/vendor/swt/windows/swt.jar +0 -0
  109. metadata +50 -61
  110. data/lib/glimmer/package.rb +0 -91
  111. data/lib/glimmer/scaffold.rb +0 -631
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f75e570d4a595c012b464d8dffa7149200385d8053dc39640d5be59d8f4980c
4
- data.tar.gz: 1fbd61272f851ffa8aa1f6dbcf0afa57e898147c3982f69a180018a2d5d0e6c3
3
+ metadata.gz: a632c93d02fd21c0de17a1d631befd7731af8cfb7abf8724d73a053296838064
4
+ data.tar.gz: ee501db9d342c5dffa2fbc789f59df68088dd00c89bb27034800c18f1f327ee1
5
5
  SHA512:
6
- metadata.gz: 3c78fc793f87813acaf59b2732a362fc37da683c79b2610dc7d9d74c37ddd56ee1ac5d33209ee509d2cc1a3c62a0fb5db56b8275d88a93b6c4d7e8c5906511b0
7
- data.tar.gz: 90941e2906ecc6c87e6685f8c8ff62fda790a43c3af519761011cefa56466336e5705e8deb49e25eeef60020a7cf6ab65c19c7c3f1c1a0f325158053bcf778c4
6
+ metadata.gz: 5a556565e268e0d681b2d2985d2eadc295607dfa70b08dafbbb7682e6e55460ce707ba170e15d184f295b46235db92351143a438d53acd2fb0d46ec6b4f6e252
7
+ data.tar.gz: 827f6459043b84f7370e5e4f71ac3dac570a1ade25e1005ca8978340ff5bdead383244b77e4884166f1d9eb0dd76c4797cc793365fc8c4ee35c64b0233fd6da4
@@ -0,0 +1,269 @@
1
+ # Change Log
2
+
3
+ ### 4.17.2.0
4
+
5
+ - `glimmer` command --bundler option to run with bundler/setup (instead of picking gems directly)
6
+ - Remove Gemfile dependency on Juwelier since it does not relate to GUI (delaying install of it till scaffolding)
7
+ - Remove Gemfile dependency on Warbler since it does not relate to GUI (delaying install of it till packaging)
8
+ - Move Package and Scaffold classes under Glimmer::RakeTask (Glimmer::Package.javapackager_extra_args is now Glimmer::RakeTask::Package.javapackager_extra_args)
9
+ - Fixed issue with scaffolding spec/spec_helper.rb with Juwelier (since it changed from Jeweler)
10
+
11
+ ### 4.17.1.1
12
+
13
+ - Fixed issue with showing glimmer command tasks twice
14
+
15
+ ### 4.17.1.0
16
+
17
+ - Switch to Juwelier gem (from Jeweler)
18
+ - Load samples from Glimmer gems automatically (no need for configuration)
19
+ - Empty body validation in CustomWidget (and CustomShell by inheritance)
20
+ - require 'bundler/setup' in `glimmer` command if a `Gemfile` is present (disabled with GLIMMER_BUNDLER_SETUP=false env var)
21
+ - Upgrade to rvm-tui version 0.2.2
22
+
23
+ ### 4.17.0.0
24
+
25
+ - Upgrade to SWT (Standard Widget Toolkit) 4.17 and sync version with SWT going forward
26
+ - Upgrade to Glimmer (DSL Engine) 1.0.0
27
+ - Sync version number with the SWT version number (first two numbers, leaving the last two as minor and patch)
28
+
29
+ ### 0.6.9
30
+
31
+ - Log error messages when running inside sync_exec or async_exec (since you cannot rescue their errors from outside them)
32
+ - Exclude gladiator from required libraries during sample listing/running/code-display
33
+ - Ensured creating a widget with swt_widget keyword arg doesn't retrigger initializers on its parents if already initialized
34
+ - Extract `WidgetProxy#interpret_style` to make it possible to extend with further styles with less code (e.g. CDateTimeProxy adds CDT styles by overriding method)
35
+
36
+ ### 0.6.8
37
+
38
+ - Support external configuration of `WidgetProxy::KEYWORD_ALIASES` (e.g. `radio` is an alias for `button(:radio)`)
39
+ - Support external configuration of `Glimmer::Config::SAMPLE_DIRECTORIES` for the `glimmer sample` commands from Glimmer gems
40
+
41
+ ### 0.6.7
42
+
43
+ - Fix issue with re-initializing layout for already initialized swt_widget being wrapped by WidgetProxy via swt_widget keyword args
44
+ - Change naming of scaffolded app bundle for mac to start with a capital letter (e.g. com.evernote.Evernote not com.evernote.evernote)
45
+
46
+ ### 0.6.6
47
+
48
+ - Add User Profile sample from DZone article
49
+ - Colored Ruby syntax highlighting for sample:code and sample:run tasks courtesy of tty-markdown
50
+ - Support `check` as alias to `checkbox` DSL keyword for Button widget with :check style.
51
+ - Validate scaffolded custom shell gem name to ensure it doesn't clash with a built in Ruby method
52
+ - GLIMMER_LOGGER_ASYNC env var for disabling async logging when needed for immediate troubleshooting purposes
53
+ - Fix issue with table equivalent sort edge case (that is two sorts that are equivalent causing an infinite loop of resorting since the table is not correctly identified as sorted already)
54
+
55
+ ### 0.6.5
56
+
57
+ - Added the [rake-tui](https://github.com/AndyObtiva/rake-tui) gem as a productivity tool for arrow key navigation/text-filtering/quick-triggering of rake tasks
58
+ - Use rake-tui gem in `glimmer` command by default on Mac and Linux
59
+
60
+ ### 0.6.4
61
+
62
+ - Display glimmer-dsl-swt gem version in glimmer command usage
63
+ - Include Glimmer Samples in Gem and provide access via `glimmer samples:list`, `glimmer samples:run`, and `glimmer samples:code` commands
64
+ - Fix issue with glimmer not listing commands in usage without having a Rakefile
65
+ - Fix issue with passing --log-level or --debug to the `girb` command
66
+
67
+ ### 0.6.3
68
+
69
+ **Scaffolding:**
70
+
71
+ - Add mnemonic to Preferences menu in scaffolding
72
+ - Make bin/glimmer, bin/girb, and scaffolded bin/script files call jruby instead of ruby in the shebang
73
+ - Launch scaffolded app on Linux without using packaging (via `glimmer bin/app_script`)
74
+ - Add all of Mac, Windows, and Linux icons upon scaffolding (not just for the OS we are on)
75
+
76
+ **Packaging:**
77
+
78
+ - Perform gemspec:generate first during packaging
79
+ - Ensure lock_jars step happens before package:jar to have vendor jar-dependencies packaged inside JAR file
80
+ - Change lock_jar vendor-dir to vendor/jars and add it to .gitignore
81
+ - Handle naming of -Bwin.menuGroup properly for Windows in scaffolded custom shell gems (and apps) (e.g. instead of Glimmer Cs Timer set to Timer only or namespace when available in a CustomShell)
82
+ - Support passing javapackager extra args after `glimmer package:native` command inside double-quotes (e.g. `glimmer package:native "-title 'CarMaker'"`)
83
+ - JDK14 experimental `jpackage` support as a packaging alternative to `javapackager` (Not recommended for production use and must specify JDK8 as JRE with an additional option since SWT doesn't support JDK14 yet)
84
+
85
+ **GUI:**
86
+
87
+ - Add radio and checkbox table editors
88
+ - Add `content` method to DisplayProxy
89
+ - Add `content` method to MessageBox
90
+ - WidgetProxy now supports taking a fully constructed swt_widget argument instead of init_args
91
+
92
+ **CI:**
93
+
94
+ - Add Windows to Travis-CI
95
+
96
+ **Issues:**
97
+
98
+ - Fix issue with TableProxy editor rejecting false and nil values set on items
99
+ - Fix issue with message_box getting stuck upon closing when no parent in its args
100
+ - Fix transient issue with git bash not interpretting glimmer package[msi] as a rake task (yet as packages instead as it resolves [msi] by picking s to match packages local directory)
101
+ - Fix issue with getting "Namespace is required!" when running `glimmer scaffold[app_name]` or `glimmer scaffold:gem:customshell[name,namespace]` (https://github.com/AndyObtiva/glimmer/issues/5)
102
+
103
+ ### 0.6.2
104
+
105
+ - Set default margins on layouts (FilLayout, RowLayout, GridLayout, and any layout that responds to marginWidth and marginHeight)
106
+ - Have scrolled_composite autoset min width and min height based on parent size
107
+ - Add `radio`, `toggle`, `checkbox`, and `arrow` widgets as shortcuts to `button` widget with different styles
108
+ - Add parent_proxy method to WidgetProxy
109
+ - Add post_add_content hook method to WidgetProxy
110
+ - Add `image` keyword to create an ImageProxy and be able to scale it
111
+ - Fix issue with ImageProxy not being scalable before swt_image is called
112
+
113
+ ### 0.6.1
114
+
115
+ - Lock JARs task for jar-dependencies as part of packaging
116
+ - Add 'vendor' to require_paths for custom shell gem
117
+ - Add Windows icon to scaffold
118
+ - Generate scaffolded app/custom-shell-gem gemspec as part of packaging (useful for jar-dependencies)
119
+ - Support a package:native type option for specifying native type
120
+ - Add a preferences menu for Windows (since it does not have one out of the box)
121
+ - Fix app scaffold on Windows by having it generate jeweler gem first (to have gemspec for jar-dependencies)
122
+ - Fix girb for Windows
123
+
124
+ ### 0.6.0
125
+
126
+ - Upgrade to JRuby 9.2.13.0
127
+ - Upgrade to SWT 4.16
128
+ - Support `font` keyword
129
+ - Support cursor setting via SWT style symbols directly
130
+ - Support `cursor` keyword
131
+
132
+ ### 0.5.6
133
+
134
+ - Fixed issue with excluding on_swt_* listeners from Glimmer DSL engine processing in CustomWidget
135
+ - Add shell minimum_size to Tic Tac Toe sample for Linux
136
+
137
+ ### 0.5.5
138
+
139
+ - Add 'package' directory to 'config/warble.rb' for packaging in JAR file
140
+ - Fix issue with image path conversion to imagedata on Mac vs Windows
141
+
142
+ ### 0.5.4
143
+
144
+ - Fix issue with uri:classloader paths generated by JRuby when using File.expand_path inside packaged JAR files
145
+
146
+ ### 0.5.3
147
+
148
+ - Set widget `image`/`images` property via string file path(s) just like `background_image`
149
+
150
+ ### 0.5.2
151
+
152
+ - Added :full_selection to table widget default SWT styles
153
+
154
+ ### 0.5.1
155
+
156
+ - Made packaging -BsystemWide option true on the Mac only
157
+
158
+ ### 0.5.0
159
+
160
+ - Upgrade to glimmer 0.10.1 to take advantage of the new logging library
161
+ - Make Glimmer commands support acronym, dash and no separator (default) alternatives
162
+ - Support scaffold commands for gems with `scaffold:gem:cw` pattern (`cs` as other suffix)
163
+ - Support listing commands with `list:gems:cw` pattern (`cs` as other suffix)
164
+ - Add -BinstalldirChooser=true / -Bcopyright=string / -Bvendor=string / -Bwin.menuGroup=string to Package class to support Windows packaging
165
+ - Configure 'logging' gem to generate log files on Windows/Linux/Mac and syslog where available
166
+ - Configure 'logging' gem to do async buffered logging via a thread to avoid impacting app performance with logging
167
+ - Make GLIMMER_LOGGER_LEVEL env var work with logging gem
168
+ - Update all logger calls to be lazy blocks
169
+ - Add logging formatter (called layout in logging library)
170
+ - Support legacy rake tasks for package and scaffold (the ones without gem/gems nesting)
171
+ - GLIMMER_LOGGER_LEVEL env var disables async logging in logging gem to help with immediate troubleshooting
172
+ - Create 'log' directory if :file logging device is specified
173
+ - Remember log level when reseting logger after the first time
174
+ - Dispose all tree items when removed
175
+ - Dispose all table items when removed
176
+ - Remove table model collection observers when updating
177
+ - Make message_box instantiate a shell if none passed in
178
+ - Eliminate unimportant (false negative) log messages getting reported as ERROR when running test suite
179
+ - Sort table on every change to maintain its sort according to its sorted column
180
+
181
+ ### 0.4.1
182
+
183
+ - Fixed an issue with async_exec and sync_exec keywords not working when used from a module that mixes Glimmer
184
+
185
+ ### 0.4.0
186
+
187
+ - Support SWT listener events that take multiple-args (as in custom libraries like Nebula GanttChart)
188
+ - Drop on_event_* keywords in favor of on_swt_* for SWT constant events
189
+ - Remove Table#table_editor_text_proxy in favor of Table#table_editor_widget_proxy
190
+ - Set WidgetProxy/ShellProxy/DisplayProxy data('proxy') objects
191
+ - Set CustomWidget data('custom_widget') objects
192
+ - Set CustomShell data('custom_shell') objects
193
+ - Delegate all WidgetProxy/ShellProxy/DisplayProxy/CustomWidget/CustomShell methods to wrapped SWT object on method_missing
194
+
195
+ ### 0.3.1
196
+
197
+ - Support multiple widgets for editing table items
198
+
199
+ ## 0.3.0
200
+
201
+ - Update API for table column sorting to pass models not properties to sorting blocks
202
+ - Support table multi-column sort_property
203
+ - Support table additional_sort_properties array
204
+ - Display table column sorting direction sign
205
+ - Update Scaffold MessageBox reference to message_box DSL keyword
206
+ - Fix issue with different sorting blocks not reseting each other on different table columns
207
+
208
+ ## 0.2.4
209
+
210
+ - Make table auto-sortable
211
+ - Configure custom sorters for table columns
212
+ - Support for ScrolledComposite smart default behavior (auto setting of content, h_scroll/v_scroll styles, and horizontal/vertical expand)
213
+
214
+ ## 0.2.3
215
+
216
+ - Upgraded to Glimmer 0.9.4
217
+ - Add vendor directory to warble config for glimmer package command.
218
+ - Make WidgetProxy register only the nearest ancestor property observer, calling on_modify_text and on_widget_selected for widgets that support these listeners, or otherwise the widget specific customizations
219
+ - Add glimmer package:clean command
220
+ - Make scaffolding gems fail when no namespace is specified
221
+ - Add a hello menu samples
222
+
223
+ ## 0.2.2
224
+
225
+ - Support Combo custom-text-entry data-binding
226
+ - Remove Gemfile.lock from .gitignore in scaffolding apps/gems
227
+
228
+ ## 0.2.1
229
+
230
+ - Support latest JRuby 9.2.12.0
231
+ - Support extra args (other than style) in WidgetProxy just like ShellProxy
232
+ - Specify additional Java packages to import when including Glimmer via Glimmer::Config::import_swt_packages=(packages)
233
+ - Add compatibility for ActiveSupport (automatically call ActiveSupport::Dependencies.unhook! if ActiveSupport is loaded)
234
+ - Fix bug with table items data binding ignoring bind converters
235
+
236
+ ## 0.2.0
237
+
238
+ - Simplified Drag and Drop API by being able to attach drag and drop event listener handlers directly on widgets
239
+ - Support drag and drop events implicitly on all widgets without explicit drag source and drop target declarations
240
+ - Set drag and drop transfer property to :text by default if not specified
241
+ - Automatically set `event.detail` inside `on_drag_enter` to match the first operation specified in `drop_target` (make sure it doesn't cause problems if source and target have differnet operations, denying drop gracefully)
242
+ - Support `dnd` keyword for easily setting `event.detail` (e.g. dnd(:drop_copy)) inside `on_drag_enter` (and consider supporting symbol directly as well)
243
+ - Support Drag and Drop on Custom Widgets
244
+ - Fix hello_computed.rb sample (convert camelcase to underscore case for layout data properties)
245
+
246
+ ## 0.1.3
247
+
248
+ - Added 'org.eclipse.swt.dnd' to glimmer auto-included Java packages
249
+ - Updated Tic Tac Toe sample to use new `message_box` keyword
250
+ - Add DragSource and DropTarget transfer expression that takes a symbol or symbol array representing one or more of the following: FileTransfer, HTMLTransfer, ImageTransfer, RTFTransfer, TextTransfer, URLTransfer
251
+ - Set default style DND::DROP_COPY in DragSource and DropTarget widgets
252
+ - Support Glimmer::SWT::DNDProxy for handling Drop & Drop styles
253
+ - Implemented list:* rake tasks for listing Glimmer custom widget gems, custom shell gems, and dsl gems
254
+ - Support querying for Glimmer gems (not just listing them)
255
+ - Fix bug with table edit remaining when sorting table or re-listing (in contact_manager.rb sample)
256
+ - Update icon of scaffolded apps to Glimmer logo
257
+
258
+ ## 0.1.2
259
+
260
+ - Extracted common model data-binding classes into glimmer
261
+
262
+ ## 0.1.1
263
+
264
+ - Fixed issue with packaging after generating gemspec
265
+ - Fixed issue with enabling development mode in glimmer command
266
+
267
+ ## 0.1.0
268
+
269
+ - Extracted Glimmer DSL for SWT (glimmer-dsl-swt gem) from Glimmer
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Andy Maleh
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
data/README.md CHANGED
@@ -1,50 +1,3981 @@
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 0.6.8 (JRuby Desktop GUI)
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
2
+ ## JRuby Desktop Development GUI Library
2
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
3
4
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/aaf1cba142dd351f84bd/maintainability)](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-swt/maintainability)
6
7
  [![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)
7
8
 
8
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [SWT](https://www.eclipse.org/swt/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer) in [JRuby](https://www.jruby.org/).
9
+ **[Contributors Wanted! (Submit a Glimmer App Sample to Get Started)](#contributing)**
9
10
 
10
- [Glimmer](https://github.com/AndyObtiva/glimmer) is a native-GUI cross-platform desktop development library written in Ruby. Glimmer's main innovation is a JRuby DSL that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support to greatly facilitate synchronizing the GUI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models test-first afterwards.
11
+ (The Original Glimmer Library Since 2007. Beware of Imitators!)
11
12
 
12
- You may find full setup/usage instructions at the main [Glimmer project page](https://github.com/AndyObtiva/glimmer).
13
+ [**Glimmer**](https://rubygems.org/gems/glimmer) is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://rubygems.org/gems/glimmer)'s main innovation is a declarative [Ruby DSL](#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust [Eclipse SWT library](https://www.eclipse.org/swt/). [Glimmer](https://rubygems.org/gems/glimmer) additionally innovates by having built-in [data-binding](#data-binding) support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns. To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](#scaffolding) options for [Apps](#in-production), [Gems](#custom-shell-gem), and [Custom Widgets](#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](#packaging--distribution) support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in [Ruby](https://www.ruby-lang.org/en/) as truly native DMG/PKG/APP files on the [Mac](https://www.apple.com/ca/macos) + [App Store](https://developer.apple.com/macos/distribution/) and MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows).
13
14
 
14
- Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
15
+ [Glimmer receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer](https://rubygems.org/gems/glimmer) with your Ruby desktop GUI development needs.
16
+
17
+ NOTE: Glimmer is in beta mode. Please make better by providing feedback and [contributing](#contributing) when possible. The more feedback and issues you report the better.
18
+
19
+ [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
20
+ Featured in<br />JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do)
21
+
22
+ Glimmer DSL gems:
23
+ - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop GUI)
24
+ - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop GUI)
15
25
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
16
26
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
17
- - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
18
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop GUI)
27
+ - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
28
+
29
+ ## Examples
30
+
31
+ ### Hello, World!
32
+
33
+ Glimmer code (from [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)):
34
+ ```ruby
35
+ include Glimmer
36
+
37
+ shell {
38
+ text "Glimmer"
39
+ label {
40
+ text "Hello, World!"
41
+ }
42
+ }.open
43
+ ```
44
+
45
+ Run:
46
+ ```
47
+ glimmer sample:run[hello_world]
48
+ ```
49
+
50
+ Glimmer app:
51
+
52
+ ![Hello World](images/glimmer-hello-world.png)
53
+
54
+ ### Tic Tac Toe
55
+
56
+ Glimmer code (from [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)):
57
+
58
+ ```ruby
59
+ # ...
60
+ @tic_tac_toe_board = Board.new
61
+
62
+ @shell = shell {
63
+ text "Tic-Tac-Toe"
64
+ minimum_size 150, 178
65
+ composite {
66
+ grid_layout 3, true
67
+ (1..3).each { |row|
68
+ (1..3).each { |column|
69
+ button {
70
+ layout_data :fill, :fill, true, true
71
+ text bind(@tic_tac_toe_board[row, column], :sign)
72
+ enabled bind(@tic_tac_toe_board[row, column], :empty)
73
+ font style: :bold, height: 20
74
+ on_widget_selected {
75
+ @tic_tac_toe_board.mark(row, column)
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ observe(@tic_tac_toe_board, :game_status) { |game_status|
84
+ display_win_message if game_status == Board::WIN
85
+ display_draw_message if game_status == Board::DRAW
86
+ }
87
+ # ...
88
+ ```
89
+
90
+ Run:
91
+
92
+ ```
93
+ glimmer sample:run[tic_tac_toe]
94
+ ```
95
+
96
+ Glimmer app:
97
+
98
+ ![Tic Tac Toe](images/glimmer-tic-tac-toe-in-progress.png)
99
+
100
+ ### Contact Manager
101
+
102
+ Glimmer code (from [samples/elaborate/contact_manager.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/contact_manager.rb)):
103
+
104
+ ```ruby
105
+ # ...
106
+ shell {
107
+ text "Contact Manager"
108
+ composite {
109
+ group {
110
+ grid_layout(2, false) {
111
+ margin_width 0
112
+ margin_height 0
113
+ }
114
+ layout_data :fill, :center, true, false
115
+ text 'Lookup Contacts'
116
+ font height: 24
117
+
118
+ label {
119
+ layout_data :right, :center, false, false
120
+ text "First &Name: "
121
+ font height: 16
122
+ }
123
+ text {
124
+ layout_data :fill, :center, true, false
125
+ text bind(@contact_manager_presenter, :first_name)
126
+ on_key_pressed {|key_event|
127
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
128
+ }
129
+ }
130
+
131
+ label {
132
+ layout_data :right, :center, false, false
133
+ text "&Last Name: "
134
+ font height: 16
135
+ }
136
+ text {
137
+ layout_data :fill, :center, true, false
138
+ text bind(@contact_manager_presenter, :last_name)
139
+ on_key_pressed {|key_event|
140
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
141
+ }
142
+ }
143
+
144
+ label {
145
+ layout_data :right, :center, false, false
146
+ text "&Email: "
147
+ font height: 16
148
+ }
149
+ text {
150
+ layout_data :fill, :center, true, false
151
+ text bind(@contact_manager_presenter, :email)
152
+ on_key_pressed {|key_event|
153
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
154
+ }
155
+ }
156
+
157
+ composite {
158
+ row_layout {
159
+ margin_width 0
160
+ margin_height 0
161
+ }
162
+ layout_data(:right, :center, false, false) {
163
+ horizontal_span 2
164
+ }
165
+
166
+ button {
167
+ text "&Find"
168
+ on_widget_selected { @contact_manager_presenter.find }
169
+ on_key_pressed {|key_event|
170
+ @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
171
+ }
172
+ }
173
+
174
+ button {
175
+ text "&List All"
176
+ on_widget_selected { @contact_manager_presenter.list }
177
+ on_key_pressed {|key_event|
178
+ @contact_manager_presenter.list if key_event.keyCode == swt(:cr)
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ table(:multi) { |table_proxy|
185
+ layout_data {
186
+ horizontal_alignment :fill
187
+ vertical_alignment :fill
188
+ grab_excess_horizontal_space true
189
+ grab_excess_vertical_space true
190
+ height_hint 200
191
+ }
192
+ table_column {
193
+ text "First Name"
194
+ width 80
195
+ }
196
+ table_column {
197
+ text "Last Name"
198
+ width 80
199
+ }
200
+ table_column {
201
+ text "Email"
202
+ width 200
203
+ }
204
+ items bind(@contact_manager_presenter, :results),
205
+ column_properties(:first_name, :last_name, :email)
206
+ on_mouse_up { |event|
207
+ table_proxy.edit_table_item(event.table_item, event.column_index)
208
+ }
209
+ }
210
+ }
211
+ }.open
212
+ # ...
213
+ ```
214
+
215
+ Run:
216
+
217
+ ```
218
+ glimmer sample:run[contact_manager]
219
+ ```
220
+
221
+ Glimmer App:
222
+
223
+ ![Contact Manager](images/glimmer-contact-manager.png)
224
+
225
+ ### Desktop Apps Built with Glimmer DSL for SWT
226
+
227
+ [<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) - Small Project Tracking App
228
+
229
+ [![Are We There Yet? App Screenshot](https://raw.githubusercontent.com/AndyObtiva/are-we-there-yet/master/are-we-there-yet-screenshot-windows.png)](https://github.com/AndyObtiva/are-we-there-yet)
230
+
231
+ [<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) - Elementary Level Math Game Featuring Bowling Rules
232
+
233
+ [![Math Bowling App Screenshot](https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/Math-Bowling-Screenshot.png)](https://github.com/AndyObtiva/MathBowling)
234
+
235
+ ## Table of contents
236
+
237
+ - [Glimmer (Ruby Desktop Development GUI Library)](#-glimmer-ruby-desktop-development-gui-library)
238
+ - [Examples](#examples)
239
+ - [Hello, World!](#hello-world)
240
+ - [Tic Tac Toe](#tic-tac-toe)
241
+ - [Contact Manager](#contact-manager)
242
+ - [Table of contents](#table-of-contents)
243
+ - [Background](#background)
244
+ - [Platform Support](#platform-support)
245
+ - [Pre-requisites](#pre-requisites)
246
+ - [Setup](#setup)
247
+ - [Option 1: Direct Install](#option-1-direct-install)
248
+ - [Option 2: Bundler](#option-2-bundler)
249
+ - [Glimmer Command](#glimmer-command)
250
+ - [Basic Usage](#basic-usage)
251
+ - [Advanced Usage](#advanced-usage)
252
+ - [Sample List/Run/Code](#sample-listruncode)
253
+ - [Sample List](#sample-list)
254
+ - [Sample Run](#sample-run)
255
+ - [Sample Code](#sample-code)
256
+ - [Scaffolding](#scaffolding)
257
+ - [App](#app)
258
+ - [Custom Shell](#custom-shell)
259
+ - [Custom Widget](#custom-widget)
260
+ - [Custom Shell Gem](#custom-shell-gem)
261
+ - [Custom Widget Gem](#custom-widget-gem)
262
+ - [Gem Listing](#gem-listing)
263
+ - [Listing Custom Shell Gems](#listing-custom-shell-gems)
264
+ - [Listing Custom Widget Gems](#listing-custom-widget-gems)
265
+ - [Listing DSL Gems](#listing-dsl-gems)
266
+ - [Packaging](#packaging)
267
+ - [Raw JRuby Command](#raw-jruby-command)
268
+ - [Mac Support](#mac-support)
269
+ - [Girb (Glimmer irb) Command](#girb-glimmer-irb-command)
270
+ - [Glimmer GUI DSL Syntax](#glimmer-gui-dsl-syntax)
271
+ - [DSL Auto-Expansion](#dsl-auto-expansion)
272
+ - [Widgets](#widgets)
273
+ - [Display](#display)
274
+ - [SWT Proxies](#swt-proxies)
275
+ - [Dialog](#dialog)
276
+ - [Menus](#menus)
277
+ - [ScrolledComposite](#scrolledcomposite)
278
+ - [Widget Styles](#widget-styles)
279
+ - [Explicit SWT Style Bit](#explicit-swt-style-bit)
280
+ - [Negative SWT Style Bits](#negative-swt-style-bits)
281
+ - [Extra SWT Styles](#extra-swt-styles)
282
+ - [Widget Properties](#widget-properties)
283
+ - [Color](#color)
284
+ - [Font](#font)
285
+ - [Cursor](#cursor)
286
+ - [Layouts](#layouts)
287
+ - [Layout Data](#layout-data)
288
+ - [Data-Binding](#data-binding)
289
+ - [General Examples](#general-examples)
290
+ - [Combo](#combo)
291
+ - [List](#list)
292
+ - [Table](#table)
293
+ - [Tree](#tree)
294
+ - [Observer](#observer)
295
+ - [Observing Widgets](#observing-widgets)
296
+ - [Observing Models](#observing-models)
297
+ - [Custom Widgets](#custom-widgets)
298
+ - [Simple Example](#simple-example)
299
+ - [Lifecycle Hook Example](#lifecycle-hook-example)
300
+ - [Custom Widget API](#custom-widget-api)
301
+ - [Content/Options Example](#contentoptions-example)
302
+ - [Custom Widget Lifecycle Hooks](#custom-widget-lifecycle-hooks)
303
+ - [Gotcha](#gotcha)
304
+ - [Final Notes](#final-notes)
305
+ - [Custom Shells](#custom-shells)
306
+ - [Drag and Drop](#drag-and-drop)
307
+ - [Miscellaneous](#miscellaneous)
308
+ - [Multi-DSL Support](#multi-dsl-support)
309
+ - [Application Menu Items (About/Preferences)](#application-menu-items-aboutpreferences)
310
+ - [App Name and Version](#app-name-and-version)
311
+ - [Video Widget](#video-widget)
312
+ - [Browser Widget](#browser-widget)
313
+ - [Glimmer Configuration](#glimmer-configuration)
314
+ - [logger](#logger)
315
+ - [logging_devices](#loggingdevices)
316
+ - [logging_device_file_options](#loggingdevicefileoptions)
317
+ - [logging_appender_options](#loggingappenderoptions)
318
+ - [logging_layout](#logginglayout)
319
+ - [import_swt_packages](#importswtpackages)
320
+ - [loop_max_count](#loopmaxcount)
321
+ - [excluded_keyword_checkers](#excludedkeywordcheckers)
322
+ - [log_excluded_keywords](#logexcludedkeywords)
323
+ - [Glimmer Style Guide](#glimmer-style-guide)
324
+ - [SWT Reference](#swt-reference)
325
+ - [Samples](#samples)
326
+ - [Hello Samples](#hello-samples)
327
+ - [Hello, World! Sample](#hello-world-sample)
328
+ - [Hello, Tab!](#hello-tab)
329
+ - [Hello, Combo!](#hello-combo)
330
+ - [Hello, List Single Selection!](#hello-list-single-selection)
331
+ - [Hello, List Multi Selection!](#hello-list-multi-selection)
332
+ - [Hello, Computed!](#hello-computed)
333
+ - [Hello, Message Box!](#hello-message-box)
334
+ - [Hello, Browser!](#hello-browser)
335
+ - [Hello, Drag and Drop!](#hello-drag-and-drop)
336
+ - [Hello, Menu Bar!](#hello-menu-bar)
337
+ - [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
338
+ - [Elaborate Samples](#elaborate-samples)
339
+ - [User Profile](#user-profile)
340
+ - [Login](#login)
341
+ - [Tic Tac Toe Sample](#tic-tac-toe-sample)
342
+ - [Contact Manager Sample](#contact-manager-sample)
343
+ - [External Samples](#external-samples)
344
+ - [Glimmer Calculator](#glimmer-calculator)
345
+ - [Gladiator](#gladiator)
346
+ - [Timer](#timer)
347
+ - [In Production](#in-production)
348
+ - [Math Bowling](#math-bowling)
349
+ - [Are We There Yet?](#are-we-there-yet)
350
+ - [Garderie Rainbow Daily Agenda](#garderie-rainbow-daily-agenda)
351
+ - [Packaging & Distribution](#packaging--distribution)
352
+ - [Packaging Defaults](#packaging-defaults)
353
+ - [Packaging Configuration](#packaging-configuration)
354
+ - [javapackager Extra Arguments](#javapackager-extra-arguments)
355
+ - [Verbose Mode](#verbose-mode)
356
+ - [Windows Application Packaging](#windows-application-packaging)
357
+ - [Mac Application Distribution](#mac-application-distribution)
358
+ - [Self Signed Certificate](#self-signed-certificate)
359
+ - [Gotchas](#gotchas)
360
+ - [App Updates](#app-updates)
361
+ - [Glimmer Supporting Libraries](#glimmer-supporting-libraries)
362
+ - [Glimmer Process](#glimmer-process)
363
+ - [Resources](#resources)
364
+ - [Help](#help)
365
+ - [Issues](#issues)
366
+ - [Chat](#chat)
367
+ - [Feature Suggestions](#feature-suggestions)
368
+ - [Change Log](#change-log)
369
+ - [Contributing](#contributing)
370
+ - [Contributors](#contributors)
371
+ - [Hire Me](#hire-me)
372
+ - [License](#license)
373
+
374
+ ## Background
375
+
376
+ Ruby is a dynamically-typed object-oriented language, which provides great productivity gains due to its powerful expressive syntax and dynamic nature. While it is proven by the Ruby on Rails framework for web development, it currently lacks a robust platform-independent framework for building desktop applications. Given that Java libraries can now be utilized in Ruby code through JRuby, Eclipse technologies, such as SWT, JFace, and RCP can help fill the gap of desktop application development with Ruby.
377
+
378
+ ## Platform Support
379
+
380
+ Glimmer runs on the following platforms:
381
+ - Mac
382
+ - Windows
383
+ - Linux
384
+
385
+ Glimmer's GUI has the native look and feel of each operating system it runs on since it uses SWT behind the scenes, which leverages the following native libraries:
386
+ - Win32 on Windows
387
+ - Cocoa on Mac
388
+ - GTK on Linux
389
+
390
+ More info about the SWT GUI on various platforms can be found on the Eclipse WIKI and SWT FAQ:
391
+
392
+ https://wiki.eclipse.org/SWT/Devel/Gtk/Dev_guide#Win32.2FCocoa.2FGTK
393
+ https://www.eclipse.org/swt/faq.php
394
+
395
+ ## Pre-requisites
396
+
397
+ - JDK 8u241 (1.8.0_241) (find at https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html)
398
+ - JRuby 9.2.13.0 (supporting Ruby 2.5.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux or find at [https://www.jruby.org/download](https://www.jruby.org/download) for Windows)
399
+ - SWT 4.17 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem)
400
+
401
+ To obtain JRuby through [RVM](http://rvm.io), you may run:
402
+
403
+ ```bash
404
+ rvm install jruby-9.2.13.0
405
+ ```
406
+
407
+ Glimmer might still work on other versions of Java, JRuby and SWT, but there are no guarantees, so it is best to stick to the pre-requisites outlined above.
408
+
409
+ ## Setup
410
+
411
+ 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.
412
+
413
+ 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)).
414
+
415
+ If you intend to build a Glimmer app from scratch with [scaffolding](#scaffolding), pick Option 1 ([Direct Install](#option-1-direct-install)) as well.
416
+
417
+ Otherwise, Option 2 ([Bundler](#option-2-bundler)) can be followed in rare cases where you want to build an app without [scaffolding](#scaffolding).
418
+
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.
420
+
421
+ ### Option 1: Direct Install
422
+ (Use for [Scaffolding](#scaffolding))
423
+
424
+ Run this command to install directly:
425
+ ```
426
+ jgem install glimmer-dsl-swt
427
+ ```
428
+
429
+ Or this command if you want a specific version:
430
+ ```
431
+ jgem install glimmer-dsl-swt -v 4.17.2.0
432
+ ```
433
+
434
+ 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.
435
+
436
+ `jgem` is JRuby's version of `gem` command.
437
+ RVM allows running `gem install` directly as an alias.
438
+ Otherwise, you may also run `jruby -S gem install ...`
439
+
440
+ 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.
441
+
442
+ 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.
443
+
444
+ Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
445
+
446
+ ### Option 2: Bundler
447
+ (Use for Manual App Creation)
448
+
449
+ Add the following to `Gemfile`:
450
+ ```
451
+ gem 'glimmer-dsl-swt', '~> 4.17'
452
+ ```
453
+
454
+ And, then run:
455
+ ```
456
+ jruby -S bundle install
457
+ ```
458
+
459
+ Note: if you're using activerecord or activesupport, keep in mind that Glimmer unhooks ActiveSupport::Dependencies as it does not rely on it.
460
+
461
+ 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)
462
+
463
+ ## Glimmer Command
464
+
465
+ The `glimmer` command allows you to run, scaffold, package, and list Glimmer applications/gems.
466
+
467
+ You can bring up usage instructions by running the `glimmer` command without arguments:
468
+
469
+ ```
470
+ glimmer
471
+ ```
472
+
473
+ On Mac and Linux, it additionally brings up a TUI (Text-based User Interface) for interactive navigation and execution of Glimmer tasks (courtesy of [rake-tui](https://github.com/AndyObtiva/rake-tui)).
474
+
475
+ On Windows, it simply lists the available Glimmer tasks at the end (courtsey of [rake](https://github.com/ruby/rake)).
476
+
477
+ 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 GUI DSL Syntax](#glimmer-gui-dsl-syntax), and [Samples](#samples).
478
+
479
+ Note: If you encounter an issue running the `glimmer` command, run `bundle exec glimmer` instead.
480
+
481
+ ### Basic Usage
482
+
483
+ ```
484
+ glimmer application.rb
485
+ ```
486
+
487
+ Runs a Glimmer application using JRuby, automatically preloading
488
+ the glimmer ruby gem and SWT jar dependency.
489
+
490
+ Example:
491
+ ```
492
+ glimmer sample:run[hello_world]
493
+ ```
494
+ This runs the Glimmer "Hello, World!" sample.
495
+
496
+ If you cloned this project locally, you may run `bin/glimmer` instead.
497
+
498
+ Example:
499
+ ```
500
+ bin/glimmer sample:run[hello_world]
501
+ ```
502
+
503
+ ### Advanced Usage
504
+
505
+ Below are the full usage instructions that come up when running `glimmer` without args.
506
+
507
+ ```
508
+ Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.0
509
+
510
+ Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
511
+
512
+ Runs Glimmer applications and tasks.
513
+
514
+ When applications are specified, they are run using JRuby,
515
+ automatically preloading the glimmer Ruby gem and SWT jar dependency.
516
+
517
+ Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
518
+
519
+ Glimmer options:
520
+ - "--quiet" : Does not announce file path of Glimmer application being launched
521
+ - "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
522
+ - "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
523
+
524
+ Tasks are run via rake. Some tasks take arguments in square brackets.
525
+
526
+ Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
527
+
528
+ Select a Glimmer task to run: (Press ↑/↓ arrow to move, Enter to select and letters to filter)
529
+ ‣ glimmer list:gems:customshell[query] # List Glimmer custom shell gems available at rubygems.org (query is optional) [alt: list:gems:cs]
530
+ glimmer list:gems:customwidget[query] # List Glimmer custom widget gems available at rubygems.org (query is optional) [alt: list:gems:cw]
531
+ glimmer list:gems:dsl[query] # List Glimmer DSL gems available at rubygems.org (query is optional)
532
+ glimmer package[type] # Package app for distribution (generating config, jar, and native files) (type is optional)
533
+ glimmer package:clean # Clean by removing "dist" and "packages" directories
534
+ glimmer package:config # Generate JAR config file
535
+ glimmer package:jar # Generate JAR file
536
+ glimmer package:lock_jars # Lock JARs
537
+ glimmer package:native[type] # Generate Native files
538
+ glimmer sample:code[name] # Outputs code for a Glimmer internal sample [included in gem] (name is required)
539
+ glimmer sample:list[query] # Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)
540
+ glimmer sample:run[name] # Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples
541
+ glimmer scaffold[app_name] # Scaffold Glimmer application directory structure to build a new app
542
+ glimmer scaffold:customshell[name,namespace] # Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]
543
+ glimmer scaffold:customwidget[name,namespace] # Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]
544
+ glimmer scaffold:gem:customshell[name,namespace] # Scaffold Glimmer::UI::CustomShell subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:ge...
545
+ glimmer scaffold:gem:customwidget[name,namespace] # Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under its own Ruby gem project (namespace is required) [alt: scaffold:gem:cw]
546
+ ```
547
+
548
+ Example (Glimmer/JRuby option specified):
549
+ ```
550
+ glimmer --debug samples/hello/hello_world.rb
551
+ ```
552
+
553
+ Runs Glimmer application with JRuby debug option to enable JRuby debugging.
554
+
555
+ Example (Multiple apps):
556
+ ```
557
+ glimmer samples/hello/hello_world.rb samples/hello/hello_tab.rb
558
+ ```
559
+
560
+ Launches samples/hello/hello_world.rb and samples/hello_tab.rb at the same time, each in a separate JRuby thread.
561
+
562
+ ### Sample List/Run/Code
563
+
564
+ #### Sample List
565
+
566
+ You can list available Glimmer samples by running:
567
+
568
+ ```
569
+ glimmer sample:list
570
+ ```
571
+
572
+ This should output the following (providing the name of each sample, description, and command to run the sample and view its code):
573
+
574
+ ```
575
+ $ glimmer sample:list
576
+
577
+ Glimmer Hello Samples:
578
+
579
+ Name Description Run
580
+
581
+ hello_browser Hello Browser glimmer sample:run[hello_browser]
582
+ hello_combo Hello Combo glimmer sample:run[hello_combo]
583
+ hello_computed Hello Computed glimmer sample:run[hello_computed]
584
+ hello_drag_and_drop Hello Drag And Drop glimmer sample:run[hello_drag_and_drop]
585
+ hello_list_multi_selection Hello List Multi Selection glimmer sample:run[hello_list_multi_selection]
586
+ hello_list_single_selection Hello List Single Selection glimmer sample:run[hello_list_single_selection]
587
+ hello_menu_bar Hello Menu Bar glimmer sample:run[hello_menu_bar]
588
+ hello_message_box Hello Message Box glimmer sample:run[hello_message_box]
589
+ hello_pop_up_context_menu Hello Pop Up Context Menu glimmer sample:run[hello_pop_up_context_menu]
590
+ hello_tab Hello Tab glimmer sample:run[hello_tab]
591
+ hello_world Hello World glimmer sample:run[hello_world]
592
+
593
+
594
+ Glimmer Elaborate Samples:
595
+
596
+ Name Description Run
597
+
598
+ contact_manager Contact Manager glimmer sample:run[contact_manager]
599
+ login Login glimmer sample:run[login]
600
+ tic_tac_toe Tic Tac Toe glimmer sample:run[tic_tac_toe]
601
+ user_profile User Profile glimmer sample:run[user_profile]
602
+ ```
603
+
604
+ #### Sample Run
605
+
606
+ A sample may be run via `glimmer sample:run[name]`. This also outputs the sample code so that you could take a look at it and compare to the GUI that launches.
607
+
608
+ If the sample name is left empty (e.g. `glimmer sample:run`), then all samples are run.
609
+
610
+ Example:
611
+
612
+ ```
613
+ glimmer sample:run[hello_tab]
614
+ ```
615
+
616
+ This will run the hello_tab sample and output its code:
617
+
618
+ ```
619
+ $ glimmer sample:run[hello_tab]
620
+
621
+ # /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.0/samples/hello/hello_tab.rb
622
+
623
+ class HelloTab
624
+ include Glimmer
625
+ def launch
626
+ shell {
627
+ text "Hello, Tab!"
628
+ tab_folder {
629
+ tab_item {
630
+ text "English"
631
+ label {
632
+ text "Hello, World!"
633
+ }
634
+ }
635
+ tab_item {
636
+ text "French"
637
+ label {
638
+ text "Bonjour, Univers!"
639
+ }
640
+ }
641
+ }
642
+ }.open
643
+ end
644
+ end
645
+
646
+ HelloTab.new.launch
647
+
648
+ # # #
649
+ ```
650
+
651
+ ![Hello Tab English](images/glimmer-hello-tab-english.png)
652
+
653
+ #### Sample Code
654
+
655
+ You may output any sample code via this command: `glimmer sample:code[name]`
656
+
657
+ This is very similar to the sample run command, except the name is required.
658
+
659
+ It will not only output the main sample file, but any required supporting files as well.
660
+
661
+ Example:
662
+
663
+ ```
664
+ $ glimmer sample:code[tic_tac_toe]
665
+
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
667
+
668
+ require_relative "tic_tac_toe/board"
669
+
670
+ class TicTacToe
671
+ include Glimmer
672
+
673
+ def initialize
674
+ @tic_tac_toe_board = Board.new
675
+ @shell = shell {
676
+ text "Tic-Tac-Toe"
677
+ minimum_size 150, 178
678
+ composite {
679
+ grid_layout 3, true
680
+ (1..3).each { |row|
681
+ (1..3).each { |column|
682
+ button {
683
+ layout_data :fill, :fill, true, true
684
+ text bind(@tic_tac_toe_board[row, column], :sign)
685
+ enabled bind(@tic_tac_toe_board[row, column], :empty)
686
+ font style: :bold, height: 20
687
+ on_widget_selected {
688
+ @tic_tac_toe_board.mark(row, column)
689
+ }
690
+ }
691
+ }
692
+ }
693
+ }
694
+ }
695
+ observe(@tic_tac_toe_board, :game_status) { |game_status|
696
+ display_win_message if game_status == Board::WIN
697
+ display_draw_message if game_status == Board::DRAW
698
+ }
699
+ end
700
+
701
+ def display_win_message
702
+ display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
703
+ end
704
+
705
+ def display_draw_message
706
+ display_game_over_message("Draw!")
707
+ end
708
+
709
+ def display_game_over_message(message_text)
710
+ message_box(@shell) {
711
+ text 'Game Over'
712
+ message message_text
713
+ }.open
714
+ @tic_tac_toe_board.reset
715
+ end
716
+
717
+ def open
718
+ @shell.open
719
+ end
720
+ end
721
+
722
+ TicTacToe.new.open
723
+
724
+ # # #
725
+
726
+
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
728
+
729
+ class TicTacToe
730
+ class Cell
731
+ EMPTY = ""
732
+ attr_accessor :sign, :empty
733
+
734
+ def initialize
735
+ reset
736
+ end
737
+
738
+ def mark(sign)
739
+ self.sign = sign
740
+ end
741
+
742
+ def reset
743
+ self.sign = EMPTY
744
+ end
745
+
746
+ def sign=(sign_symbol)
747
+ @sign = sign_symbol
748
+ self.empty = sign == EMPTY
749
+ end
750
+
751
+ def marked
752
+ !empty
753
+ end
754
+ end
755
+ end
756
+
757
+ # # #
758
+
759
+
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
761
+
762
+ require_relative 'cell'
763
+
764
+ class TicTacToe
765
+ class Board
766
+ DRAW = :draw
767
+ IN_PROGRESS = :in_progress
768
+ WIN = :win
769
+ attr :winning_sign
770
+ attr_accessor :game_status
771
+
772
+ def initialize
773
+ @sign_state_machine = {nil => "X", "X" => "O", "O" => "X"}
774
+ build_grid
775
+ @winning_sign = Cell::EMPTY
776
+ @game_status = IN_PROGRESS
777
+ end
778
+
779
+ #row and column numbers are 1-based
780
+ def mark(row, column)
781
+ self[row, column].mark(current_sign)
782
+ game_over? #updates winning sign
783
+ end
784
+
785
+ def current_sign
786
+ @current_sign = @sign_state_machine[@current_sign]
787
+ end
788
+
789
+ def [](row, column)
790
+ @grid[row-1][column-1]
791
+ end
792
+
793
+ def game_over?
794
+ win? or draw?
795
+ end
796
+
797
+ def win?
798
+ win = (row_win? or column_win? or diagonal_win?)
799
+ self.game_status=WIN if win
800
+ win
801
+ end
802
+
803
+ def reset
804
+ (1..3).each do |row|
805
+ (1..3).each do |column|
806
+ self[row, column].reset
807
+ end
808
+ end
809
+ @winning_sign = Cell::EMPTY
810
+ @current_sign = nil
811
+ self.game_status=IN_PROGRESS
812
+ end
813
+
814
+ private
815
+
816
+ def build_grid
817
+ @grid = []
818
+ 3.times do |row_index| #0-based
819
+ @grid << []
820
+ 3.times { @grid[row_index] << Cell.new }
821
+ end
822
+ end
823
+
824
+ def row_win?
825
+ (1..3).each do |row|
826
+ if row_has_same_sign(row)
827
+ @winning_sign = self[row, 1].sign
828
+ return true
829
+ end
830
+ end
831
+ false
832
+ end
833
+
834
+ def column_win?
835
+ (1..3).each do |column|
836
+ if column_has_same_sign(column)
837
+ @winning_sign = self[1, column].sign
838
+ return true
839
+ end
840
+ end
841
+ false
842
+ end
843
+
844
+ #needs refactoring if we ever decide to make the board size dynamic
845
+ def diagonal_win?
846
+ if (self[1, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[3, 3].sign) and self[1, 1].marked
847
+ @winning_sign = self[1, 1].sign
848
+ return true
849
+ end
850
+ if (self[3, 1].sign == self[2, 2].sign) and (self[2, 2].sign == self[1, 3].sign) and self[3, 1].marked
851
+ @winning_sign = self[3, 1].sign
852
+ return true
853
+ end
854
+ false
855
+ end
856
+
857
+ def draw?
858
+ @board_full = true
859
+ 3.times do |x|
860
+ 3.times do |y|
861
+ @board_full = false if self[x, y].empty
862
+ end
863
+ end
864
+ self.game_status = DRAW if @board_full
865
+ @board_full
866
+ end
867
+
868
+ def row_has_same_sign(number)
869
+ row_sign = self[number, 1].sign
870
+ [2, 3].each do |column|
871
+ return false unless row_sign == (self[number, column].sign)
872
+ end
873
+ true if self[number, 1].marked
874
+ end
875
+
876
+ def column_has_same_sign(number)
877
+ column_sign = self[1, number].sign
878
+ [2, 3].each do |row|
879
+ return false unless column_sign == (self[row, number].sign)
880
+ end
881
+ true if self[1, number].marked
882
+ end
883
+
884
+ end
885
+ end
886
+
887
+ # # #
888
+ ```
889
+
890
+ ### Scaffolding
891
+
892
+ Glimmer borrows from Rails the idea of Scaffolding, that is generating a structure for your app files that
893
+ helps you get started just like true buildinThis g scaffolding helps construction workers, civil engineers, and architects.
894
+
895
+ Glimmer scaffolding goes beyond just scaffolding the app files that Rails does. It also packages it and launches it,
896
+ getting you to a running and delivered state of an advanced "Hello, World!" Glimmer application right off the bat.
897
+
898
+ This should greatly facilitate building a new Glimmer app by helping you be productive and focus on app details while
899
+ letting Glimmer scaffolding take care of initial app file structure concerns, such as adding:
900
+ - Main application class that includes Glimmer (`app/{app_name}.rb`)
901
+ - Main application view that houses main window content, menu, about dialog, and preferences dialog
902
+ - View and Model directories (`app/views` and `app/models`)
903
+ - Rakefile including Glimmer tasks (`Rakefile`)
904
+ - Version (`VERSION`)
905
+ - License (`LICENSE.txt`)
906
+ - Icon (under `package/{platform}/{App Name}.{icon_extension}` for `macosx` .icns, `windows` .ico, and `linux` .png)
907
+ - Bin file for starting application (`bin/{app_name}.rb`)
908
+
909
+ NOTE: Scaffolding supports Mac and Windows packaging at the moment.
910
+
911
+ #### App
912
+
913
+ Before you start, make sure you are in a JRuby environment with Glimmer gem installed as per "Direct Install" pre-requisites.
914
+
915
+ To scaffold a Glimmer app from scratch, run the following command:
916
+
917
+ ```
918
+ glimmer scaffold[AppName]
919
+ ```
920
+
921
+ This will generate an advanced "Hello, World!" app, package it as a Mac native file (DMG/PKG/APP), and launch it all in one fell swoop.
922
+
923
+ Suppose you run:
924
+
925
+ ```
926
+ glimmer scaffold[greeter]
927
+ ```
928
+
929
+ You should see output like the following:
930
+
931
+ ```
932
+ $ glimmer scaffold[greeter]
933
+ create .gitignore
934
+ create Rakefile
935
+ create Gemfile
936
+ create LICENSE.txt
937
+ create README.rdoc
938
+ create .document
939
+ create lib
940
+ create lib/greeter.rb
941
+ create spec
942
+ create spec/spec_helper.rb
943
+ create spec/greeter_spec.rb
944
+ create .rspec
945
+ Jeweler has prepared your gem in ./greeter
946
+ Created greeter/.gitignore
947
+ Created greeter/.ruby-version
948
+ Created greeter/.ruby-gemset
949
+ Created greeter/VERSION
950
+ Created greeter/LICENSE.txt
951
+ Created greeter/Gemfile
952
+ Created greeter/Rakefile
953
+ Created greeter/app/greeter.rb
954
+ Created greeter/app/views/greeter/app_view.rb
955
+ Created greeter/package/windows/Greeter.ico
956
+ Created greeter/package/macosx/Greeter.icns
957
+ Created greeter/package/linux/Greeter.png
958
+ Created greeter/bin/greeter
959
+ Created greeter/spec/spec_helper.rb
960
+ ...
961
+ ```
962
+
963
+ Eventually, it will launch an advanced "Hello, World!" app window having the title of your application ("Greeter").
964
+
965
+ ![Glimmer Scaffold App](images/glimmer-scaffolding-app.png)
966
+
967
+ It also comes with a boilerplate Preferences dialog.
968
+
969
+ ![Glimmer Scaffold App Preferences](images/glimmer-scaffolding-app-preferences.png)
970
+
971
+ Here is the Windows version of the scaffolded "Greeter" app:
972
+
973
+ ![Glimmer Scaffold App Windows](images/glimmer-scaffolding-app-windows.png)
974
+
975
+ And, here is the Windows version of the boilerplate Preferences dialog.
976
+
977
+ ![Glimmer Scaffold App Windows Preferences](images/glimmer-scaffolding-app-windows-preferences.png)
978
+
979
+ In order to run the app after making changes, you must run the `glimmer` command and pass it the generated script under the `bin` directory as an argument:
980
+
981
+ ```
982
+ glimmer bin/greeter
983
+ ```
984
+
985
+ #### Custom Shell
986
+
987
+ To scaffold a Glimmer custom shell (full window view) for an existing Glimmer app, run the following command:
988
+
989
+ ```
990
+ glimmer scaffold:customshell[name]
991
+ ```
992
+
993
+ Or the following alternative abbreviation:
994
+
995
+ ```
996
+ glimmer scaffold:cs[name]
997
+ ```
998
+
999
+ #### Custom Widget
1000
+
1001
+ To scaffold a Glimmer custom widget (part of a view) for an existing Glimmer app, run the following command:
1002
+
1003
+ ```
1004
+ glimmer scaffold:customwidget[name]
1005
+ ```
1006
+
1007
+ Or the following alternative abbreviation:
1008
+
1009
+ ```
1010
+ glimmer scaffold:cw[name]
1011
+ ```
1012
+
1013
+ #### Custom Shell Gem
1014
+
1015
+ Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
1016
+ They have everything scaffolded Glimmer apps come with in addition to gem content like a [jeweler](https://github.com/technicalpickles/jeweler) Rakefile that can build gemspec and release gems.
1017
+ Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
1018
+ They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
1019
+ Of course, you can just build a Ruby gem and disregard native executable packaging if you do not need it.
1020
+
1021
+ To scaffold a Glimmer custom shell gem (full window view distributed as a Ruby gem), run the following command:
1022
+
1023
+ ```
1024
+ glimmer scaffold:gem:customshell[name,namespace]
1025
+ ```
1026
+
1027
+ Or the following alternative abbreviation:
1028
+
1029
+ ```
1030
+ glimmer scaffold:gem:cs[name,namespace]
1031
+ ```
1032
+
1033
+ It is important to specify a namespace to avoid having your gem clash with existing gems.
1034
+
1035
+ The Ruby gem name will follow the convention "glimmer-cs-customwidgetname-namespace" (the 'cs' is for Custom Shell).
1036
+
1037
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cs-gladiator](https://rubygems.org/gems/glimmer-cs-gladiator) Ruby gem)
1038
+
1039
+ Since custom shell gems are both an app and a gem, they provide two ways to run:
1040
+ - Run the `glimmer` command and pass it the generated script under the `bin` directory that matches the gem name (e.g. run `glimmer bin/glimmer-cs-calculator`)
1041
+ - Run the executable binary file that ships with the gem directly (without `glimmer`). It intentionally has a shorter name for convenience since it is meant to be used on the command line (not in a package), so you can leave out the `glimmer-cs-` prefix (e.g. run `bin/calculator` directly)
1042
+
1043
+ Examples:
1044
+
1045
+ - [glimmer-cs-gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator): Gladiator (Glimmer Editor)
1046
+ - [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator): Glimmer Calculator
1047
+
1048
+ #### Custom Widget Gem
1049
+
1050
+ To scaffold a Glimmer custom widget gem (part of a view distributed as a Ruby gem), run the following command:
1051
+
1052
+ ```
1053
+ glimmer scaffold:gem:customwidget[name,namespace]
1054
+ ```
1055
+
1056
+ Or the following alternative abbreviation:
1057
+
1058
+ ```
1059
+ glimmer scaffold:gem:cw[name,namespace]
1060
+ ```
1061
+
1062
+
1063
+ It is important to specify a namespace to avoid having your gem clash with existing gems.
1064
+
1065
+ The Ruby gem name will follow the convention "glimmer-cw-customwidgetname-namespace" (the 'cw' is for Custom Widget)
1066
+
1067
+ Only official Glimmer gems created by the Glimmer project committers will have no namespace (e.g. [glimmer-cw-video](https://rubygems.org/gems/glimmer-cw-video) Ruby gem)
1068
+
1069
+ Examples:
1070
+
1071
+ - [glimmer-cw-video](https://github.com/AndyObtiva/glimmer-cw-video): Video Widget
1072
+ - [glimmer-cw-cdatetime-nebula](https://github.com/AndyObtiva/glimmer-cw-cdatetime-nebula): Nebula CDateTime Widget
1073
+
1074
+ ### Gem Listing
1075
+
1076
+ 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).
1077
+
1078
+ #### Listing Custom Shell Gems
1079
+
1080
+ 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):
1081
+
1082
+ ```
1083
+ glimmer list:gems:customshell[query]
1084
+ ```
1085
+
1086
+ Or the following alternative abbreviation:
1087
+
1088
+ ```
1089
+ glimmer list:gems:cs[query]
1090
+ ```
1091
+
1092
+ Example:
1093
+
1094
+ ```
1095
+ glimmer list:gems:cs
1096
+ ```
1097
+
1098
+ Output:
1099
+
1100
+ ```
1101
+
1102
+ Glimmer Custom Shell Gems at rubygems.org:
1103
+
1104
+ Name Gem Version Author Description
1105
+
1106
+ Calculator glimmer-cs-calculator 1.0.2 Andy Maleh Calculator - Glimmer Custom Shell
1107
+ Gladiator glimmer-cs-gladiator 0.2.4 Andy Maleh Gladiator (Glimmer Editor) - Glimmer Custom Shell
1108
+ Timer glimmer-cs-timer 1.0.0 Andy Maleh Timer - Glimmer Custom Shell
1109
+
1110
+ ```
1111
+
1112
+ #### Listing Custom Widget Gems
1113
+
1114
+ 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):
1115
+
1116
+ ```
1117
+ glimmer list:gems:customwidget[query]
1118
+ ```
1119
+
1120
+ Or the following alternative abbreviation:
1121
+
1122
+ ```
1123
+ glimmer list:gems:cw[query]
1124
+ ```
1125
+
1126
+ Example:
1127
+
1128
+ Check if there is a custom video widget for Glimmer.
1129
+
1130
+ ```
1131
+ glimmer list:gems:cw[video]
1132
+ ```
1133
+
1134
+ Output:
1135
+
1136
+ ```
1137
+
1138
+ Glimmer Custom Widget Gems matching [video] at rubygems.org:
1139
+
1140
+ Name Gem Version Author Description
1141
+
1142
+ Video glimmer-cw-video 1.0.0 Andy Maleh Glimmer Custom Widget - Video
1143
+
1144
+ ```
1145
+
1146
+ Example:
1147
+
1148
+ Check all custom widgets for Glimmer.
1149
+
1150
+ ```
1151
+ glimmer list:gems:cw
1152
+ ```
1153
+
1154
+ Output:
1155
+
1156
+ ```
1157
+
1158
+ Glimmer Custom Widget Gems at rubygems.org:
1159
+
1160
+ Name Gem Version Author Description
1161
+
1162
+ Browser (Chromium) glimmer-cw-browser-chromium 1.0.0 Andy Maleh Chromium Browser - Glimmer Custom Widget
1163
+ Cdatetime (Nebula) glimmer-cw-cdatetime-nebula 1.5.0.0.1 Andy Maleh Nebula CDateTime Widget - Glimmer Custom Widget
1164
+ Video glimmer-cw-video 1.0.0 Andy Maleh Glimmer Custom Widget - Video
1165
+
1166
+ ```
1167
+
1168
+ #### Listing DSL Gems
1169
+
1170
+ 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):
1171
+
1172
+ ```
1173
+ glimmer list:gems:dsl[query]
1174
+ ```
1175
+
1176
+ Example:
1177
+
1178
+ ```
1179
+ glimmer list:gems:dsl
1180
+ ```
1181
+
1182
+ Output:
1183
+
1184
+ ```
1185
+
1186
+ Glimmer DSL Gems at rubygems.org:
1187
+
1188
+ Name Gem Version Author Description
1189
+
1190
+ Css glimmer-dsl-css 0.2.0 AndyMaleh Glimmer DSL for CSS
1191
+ 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
1193
+ Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
1194
+ Xml glimmer-dsl-xml 0.2.0 AndyMaleh Glimmer DSL for XML
1195
+ ```
1196
+
1197
+ ### Packaging
1198
+
1199
+ Glimmer packaging tasks are detailed under [Packaging & Distribution](#packaging--distribution).
1200
+
1201
+ ### Raw JRuby Command
1202
+
1203
+ If there is a need to run Glimmer directly via the `jruby` command, you
1204
+ may run the following:
1205
+
1206
+ ```
1207
+ jruby -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
1208
+ ```
1209
+
1210
+ The `-J-classpath` option specifies the `swt.jar` file path, which can be a
1211
+ 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.
1212
+
1213
+ The `-r` option preloads (requires) the `glimmer` library in Ruby.
1214
+
1215
+ The `-S` option specifies a script to run.
1216
+
1217
+ #### Mac Support
1218
+
1219
+ The Mac is well supported with the `glimmer` command. The advice below is not needed if you are using it.
1220
+
1221
+ 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).
1222
+
1223
+ Example:
1224
+ ```
1225
+ jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
1226
+ ```
1227
+
1228
+ ## Girb (Glimmer irb) Command
1229
+
1230
+ 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.
1231
+
1232
+ ```
1233
+ girb
1234
+ ```
1235
+
1236
+ If you cloned [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) project locally, you may run `bin/girb` instead.
1237
+
1238
+ ```
1239
+ bin/girb
1240
+ ```
1241
+
1242
+ Watch out for hands-on examples in this README indicated by "you may copy/paste in [`girb`](#girb-glimmer-irb-command)"
1243
+
1244
+ Keep in mind that all samples live under [https://github.com/AndyObtiva/glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt)
1245
+
1246
+ ## Glimmer GUI DSL Syntax
1247
+
1248
+ Glimmer's core is a GUI DSL with a lightweight visual syntax that makes it easy to visualize the nesting of widgets in the GUI hierarchy tree.
1249
+
1250
+ It is available through mixing in the `Glimmer` module, which makes Glimmer GUI DSL keywords available to both the instance scope and class scope:
1251
+
1252
+ ```ruby
1253
+ include Glimmer
1254
+ ```
1255
+
1256
+ For example, here is the basic "Hello, World!" sample code (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1257
+
1258
+ ```ruby
1259
+ include Glimmer
1260
+
1261
+ shell {
1262
+ text "Glimmer"
1263
+ label {
1264
+ text "Hello, World!"
1265
+ }
1266
+ }.open
1267
+ ```
1268
+
1269
+ The `include Glimmer` declaration on top mixed the `Glimmer` module into the Ruby global main object making the Glimmer GUI DSL available at the top-level global scope.
1270
+
1271
+ While this works well enough for mini-samples, it is better to isolate Glimmer in a class or module during production application development to create a clean separation between view code (GUI) and model code (business domain). Here is the "Hello, World!" sample re-written in a class to illustrate how mixing in the `Glimmer` module (via `include Glimmer`) makes the Glimmer GUI DSL available in both the instance scope and class scope. That is clearly demonstrated by pre-initializing a color constant in the class scope and building the GUI in the `#open` instance method (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1272
+
1273
+ ```ruby
1274
+ class HelloWorld
1275
+ include Glimmer # makes the GUI DSL available in both the class scope and instance scope
1276
+
1277
+ COLOR_FOREGROUND_DEFAULT = rgb(255, 0, 0) # rgb is a GUI DSL keyword used in the class scope
1278
+
1279
+ def open
1280
+ # the following are GUI DSL keywords (shell, text, and label) used in the instance scope
1281
+ shell {
1282
+ text "Glimmer"
1283
+ label {
1284
+ text "Hello, World!"
1285
+ foreground COLOR_FOREGROUND_DEFAULT
1286
+ }
1287
+ }.open
1288
+ end
1289
+ end
1290
+
1291
+ HelloWorld.new.open
1292
+ ```
1293
+
1294
+ This renders "Hello, World!" with a red foreground color:
1295
+
1296
+ ![Hello World Red Foreground Color](images/glimmer-hello-world-red-foreground-color.png)
1297
+
1298
+ The GUI DSL intentionally avoids overly verbose syntax, requiring as little declarative code as possible to describe what GUI to render, how to style it, and what properties to data-bind to the Models.
1299
+
1300
+ As such, it breaks off from Ruby's convention of using `do end` for multi-line blocks, opting instead for the lightweight and visual `{ }` curly brace blocks everywhere inside the GUI DSL. More details about Glimmer's syntax conventions may be found in the [Glimmer Style Guide](#glimmer-style-guide)
1301
+
1302
+ Glimmer DSL syntax consists mainly of:
1303
+ - keywords (e.g. `table` for a table widget)
1304
+ - style/args (e.g. :multi as in `table(:multi)` for a multi-line selection table widget)
1305
+ - content (e.g. `{ table_column { text 'Name'} }` as in `table(:multi) { table_column { text 'name'} }` for a multi-line selection table widget with a table column having header text property `'Name'` as content)
1306
+
1307
+ ### DSL Auto-Expansion
1308
+
1309
+ Glimmer supports a new and radical Ruby DSL concept called DSL Auto-Expansion. It is explained by first mentioning the two types of Glimmer GUI DSL keywords: static and dynamic.
1310
+
1311
+ Static keywords are pre-identified keywords in the Glimmer DSL, such as `shell`, `display`, `message_box`, `async_exec`, `sync_exec`, and `bind`.
1312
+
1313
+ Dynamic keywords are dynamically figured out from currently imported (aka required/loaded) SWT widgets, custom widgets, and widget properties. Examples are: `label`, `combo`, and `list` for widgets and `enabled`, `text`, and `selection` for properties.
1314
+
1315
+ 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.
1316
+
1317
+ For example, if a project adds this custom Java SWT library:
1318
+
1319
+ https://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php?page=operation
1320
+
1321
+ Glimmer will automatically support using the keyword `c_date_time`
1322
+
1323
+ You will learn more about widgets next.
1324
+
1325
+ ### Widgets
1326
+
1327
+ Glimmer GUIs (user interfaces) are modeled with widgets, which are wrappers around the SWT library widgets found here:
1328
+
1329
+ https://www.eclipse.org/swt/widgets/
1330
+
1331
+ This screenshot taken from the link above should give a glimpse of how SWT widgets look and feel:
1332
+
1333
+ [![SWT Widgets](images/glimmer-swt-widgets.png)](https://www.eclipse.org/swt/widgets/)
1334
+
1335
+ In Glimmer DSL, widgets are declared with lowercase underscored names mirroring their SWT names minus the package name. For example, here are some Glimmer widgets and their SWT counterparts:
1336
+
1337
+ - `shell` instantiates `org.eclipse.swt.widgets.Shell`
1338
+ - `text` instantiates `org.eclipse.swt.widgets.Text`
1339
+ - `button` instantiates `org.eclipse.swt.widgets.Button`
1340
+ - `label` instantiates `org.eclipse.swt.widgets.Label`
1341
+ - `composite` instantiates `org.eclipse.swt.widgets.Composite`
1342
+ - `tab_folder` instantiates `org.eclipse.swt.widgets.TabFolder`
1343
+ - `tab_item` instantiates `org.eclipse.swt.widgets.TabItem`
1344
+ - `table` instantiates `org.eclipse.swt.widgets.Table`
1345
+ - `table_column` instantiates `org.eclipse.swt.widgets.TableColumn`
1346
+ - `tree` instantiates `org.eclipse.swt.widgets.Tree`
1347
+ - `combo` instantiates `org.eclipse.swt.widgets.Combo`
1348
+ - `list` instantiates `org.eclipse.swt.widgets.List`
1349
+
1350
+ Every **widget** is sufficiently declared by name, but may optionally be accompanied with:
1351
+ - SWT **style**/***arguments*** wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-style-guide) (see [next section](#widget-styles) for details).
1352
+ - Ruby block containing **content**, which may be **properties** (e.g. `enabled false`) or nested **widgets** (e.g. `table_column` nested inside `table`)
1353
+
1354
+ For example, if we were to revisit `samples/hello/hello_world.rb` above (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1355
+
1356
+ ```ruby
1357
+ shell {
1358
+ text "Glimmer"
1359
+ label {
1360
+ text "Hello, World!"
1361
+ }
1362
+ }.open
1363
+ ```
1364
+
1365
+ Note that `shell` instantiates the outer shell **widget**, in other words, the window that houses all of the desktop graphical user interface.
1366
+
1367
+ `shell` is then followed by a ***block*** that contains
1368
+
1369
+ ```ruby
1370
+ # ...
1371
+ text "Glimmer" # text property of shell
1372
+ label { # label widget declaration as content of shell
1373
+ text "Hello, World!" # text property of label
1374
+ }
1375
+ # ...
1376
+ ```
1377
+
1378
+ The first line declares a **property** called `text`, which sets the title of the shell (window) to `"Glimmer"`. **Properties** always have ***arguments*** (not wrapped by parenthesis according to [Glimmer Style Guide](#glimmer-style-guide)), such as the text `"Glimmer"` in this case, and do **NOT** have a ***block*** (this distinguishes them from **widget** declarations).
1379
+
1380
+ The second line declares the `label` **widget**, which is followed by a Ruby **content** ***block*** that contains its `text` **property** with value `"Hello, World!"`
1381
+
1382
+ The **widget** ***block*** may optionally receive an argument representing the widget proxy object that the block content is for. This is useful in rare cases when the content code needs to refer to parent widget during declaration. You may leave that argument out most of the time and only add when absolutely needed.
1383
+
1384
+ Example:
1385
+
1386
+ ```ruby
1387
+ shell {|shell_proxy|
1388
+ #...
1389
+ }
1390
+ ```
1391
+
1392
+ Remember that The `shell` widget is always the outermost widget containing all others in a Glimmer desktop windowed application.
1393
+
1394
+ After it is declared, a `shell` must be opened with the `#open` method, which can be called on the block directly as in the example above, or by capturing `shell` in a `@shell` variable (shown in example below), and calling `#open` on it independently (recommended in actual apps)
1395
+
1396
+ ```ruby
1397
+ @shell = shell {
1398
+ # properties and content
1399
+ # ...
1400
+ }
1401
+ @shell.open
1402
+ ```
1403
+
1404
+ It is centered upon initial display and has a minimum width of 130 (can be re-centered when needed with `@shell.center` method after capturing `shell` in a `@shell` variable as per samples)
1405
+
1406
+ Check out the [samples](samples) directory for more examples.
1407
+
1408
+ Example from [hello_tab.rb](samples/hello/hello_tab.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1409
+
1410
+ ![Hello Tab English](images/glimmer-hello-tab-english.png)
1411
+
1412
+ ![Hello Tab French](images/glimmer-hello-tab-french.png)
1413
+
1414
+ ```ruby
1415
+ shell {
1416
+ text "Hello, Tab!"
1417
+ tab_folder {
1418
+ tab_item {
1419
+ text "English"
1420
+ label {
1421
+ text "Hello, World!"
1422
+ }
1423
+ }
1424
+ tab_item {
1425
+ text "French"
1426
+ label {
1427
+ text "Bonjour Univers!"
1428
+ }
1429
+ }
1430
+ }
1431
+ }.open
1432
+ ```
1433
+
1434
+ If you are new to Glimmer, you have learned enough to start running some [samples](#samples). Go ahead and run all Glimmer [samples](#samples), and come back to read the rest in any order you like since this material is more organized like a reference.
1435
+
1436
+ #### Display
1437
+
1438
+ SWT Display is a singleton in Glimmer. It is used in SWT to represent your display device, allowing you to manage GUI globally
1439
+ and access available monitors.
1440
+ It is automatically instantiated upon first instantiation of a `shell` widget.
1441
+ Alternatively, for advanced use cases, it can be created explicitly with Glimmer `display` keyword. When a `shell` is later declared, it
1442
+ automatically uses the display created earlier without having to explicitly hook it.
1443
+
1444
+ ```ruby
1445
+ @display = display {
1446
+ cursor_location 300, 300
1447
+ on_swt_keydown {
1448
+ # ...
1449
+ }
1450
+ # ...
1451
+ }
1452
+ @shell = shell { # uses display created above
1453
+ }
1454
+ ```
1455
+ The benefit of instantiating an SWT Display explicitly is to set [Properties](#widget-properties) or [Observers](#observer).
1456
+ Although SWT Display is not technically a widget, it has similar APIs in SWT and similar DSL support in Glimmer.
1457
+
1458
+ #### SWT Proxies
1459
+
1460
+ Glimmer follows Proxy Design Pattern by having Ruby proxy wrappers for all SWT objects:
1461
+ - `Glimmer::SWT:WidgetProxy` wraps all descendants of `org.eclipse.swt.widgets.Widget` except the ones that have their own wrappers.
1462
+ - `Glimmer::SWT::ShellProxy` wraps `org.eclipse.swt.widgets.Shell`
1463
+ - `Glimmer::SWT:TabItemProxy` wraps `org.eclipse.swt.widget.TabItem` (also adds a composite to enable adding content under tab items directly in Glimmer)
1464
+ - `Glimmer::SWT:LayoutProxy` wraps all descendants of `org.eclipse.swt.widget.Layout`
1465
+ - `Glimmer::SWT:LayoutDataProxy` wraps all layout data objects
1466
+ - `Glimmer::SWT:DisplayProxy` wraps `org.eclipse.swt.widget.Display` (manages displaying GUI)
1467
+ - `Glimmer::SWT:ColorProxy` wraps `org.eclipse.swt.graphics.Color`
1468
+ - `Glimmer::SWT:FontProxy` wraps `org.eclipse.swt.graphics.Font`
1469
+ - `Glimmer::SWT::WidgetListenerProxy` wraps all widget listeners
1470
+
1471
+ These proxy objects have an API and provide some convenience methods, some of which are mentioned below.
1472
+
1473
+ ##### `#content { ... }`
1474
+
1475
+ Glimmer allows re-opening any widget and adding properties or extra content after it has been constructed already by using the `#content` method.
1476
+
1477
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1478
+
1479
+ ```ruby
1480
+ @shell = shell {
1481
+ text "Application"
1482
+ row_layout
1483
+ @label1 = label {
1484
+ text "Hello,"
1485
+ }
1486
+ }
1487
+ @shell.content {
1488
+ minimum_size 130, 130
1489
+ label {
1490
+ text "World!"
1491
+ }
1492
+ }
1493
+ @label1.content {
1494
+ foreground :red
1495
+ }
1496
+ @shell.open
1497
+ ```
1498
+
1499
+ ##### `message_box`
1500
+
1501
+ 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.
1502
+
1503
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1504
+
1505
+ ```ruby
1506
+ include Glimmer
1507
+
1508
+ @shell = shell {
1509
+ text 'Hello, Message Box!'
1510
+ button {
1511
+ text 'Please Click To Win a Surprise'
1512
+ on_widget_selected {
1513
+ message_box(@shell) {
1514
+ text 'Surprise'
1515
+ message "Congratulations!\n\nYou have won $1,000,000!"
1516
+ }.open
1517
+ }
1518
+ }
1519
+ }
1520
+ @shell.open
1521
+ ```
1522
+
1523
+ ![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
1524
+
1525
+ It is also possible to use `message_box` even before instantiating the first `shell` ([Glimmer](https://rubygems.org/gems/glimmer) builds a throwaway `shell` parent automatically for it):
1526
+
1527
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1528
+
1529
+ ```ruby
1530
+ include Glimmer
1531
+
1532
+ message_box {
1533
+ text 'Greeting'
1534
+ message "Hello, World!"
1535
+ }.open
1536
+ ```
1537
+
1538
+ ##### `#swt_widget`
1539
+
1540
+ 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.
1541
+
1542
+ ##### Shell widget proxy methods
1543
+
1544
+ Shell widget proxy has extra methods specific to SWT Shell:
1545
+ - `#open`: Opens the shell, making it visible and active, and starting the SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). If shell was already open, but hidden, it makes the shell visible.
1546
+ - `#show`: Alias for `#open`
1547
+ - `#hide`: Hides a shell setting "visible" property to false
1548
+ - `#close`: Closes the shell
1549
+ - `#center`: Centers the shell within monitor it is in
1550
+ - `#start_event_loop`: (happens as part of `#open`) Starts SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). This method is not needed except in rare circumstances where there is a need to start the SWT Event Loop before opening the shell.
1551
+ - `#visible?`: Returns whether a shell is visible
1552
+ - `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
1553
+ - `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
1554
+ - `#pack`: Packs contained widgets using SWT's `Shell#pack` method
1555
+ - `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
1556
+
1557
+ ##### Shell Icon
1558
+
1559
+ To set the shell icon, simply set the `image` property under the `shell` widget. This shows up in the operating system toolbar and app-switcher (e.g. CMD+TAB) (and application window top-left corner in Windows)
1560
+
1561
+ Example:
1562
+
1563
+ ```ruby
1564
+ shell {
1565
+ # ...
1566
+ image 'path/to/image.png'
1567
+ # ...
1568
+ }
1569
+ ```
1570
+
1571
+ ###### Shell Icon Tip for Packaging on Windows
1572
+
1573
+ When setting shell icon for a [packaged](#packaging--distribution) app, which has a JAR file at its core, you can reference the `ico` file that ships with the app by going one level up (e.g. `'../AppName.ico'`)
1574
+
1575
+ #### Dialog
1576
+
1577
+ Dialog is a variation on Shell. It is basically a shell that is modal (blocks what's behind it) and belongs to another shell. It only has a close button.
1578
+
1579
+ Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
1580
+
1581
+ #### Menus
1582
+
1583
+ Glimmer DSL provides support for SWT Menu and MenuItem widgets.
1584
+
1585
+ There are 2 main types of menus in SWT:
1586
+ - Menu Bar (shows up on top)
1587
+ - Pop Up Context Menu (shows up when right-clicking a widget)
1588
+
1589
+ Underneath both types, there can be a 3rd menu type called Drop Down.
1590
+
1591
+ Glimmer provides special support for Drop Down menus as it automatically instantiates associated Cascade menu items and wires together with proper parenting, swt styles, and calling setMenu.
1592
+
1593
+ The ampersand symbol indicates the keyboard shortcut key for the menu item (e.g. '&Help' can be triggered on Windows by hitting ALT+H)
1594
+
1595
+ Example of a Menu Bar (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1596
+
1597
+ ```ruby
1598
+ shell { |shell_proxy|
1599
+ text 'Hello, Menu Bar!'
1600
+ grid_layout
1601
+ label(:center) {
1602
+ font height: 16
1603
+ text 'Check Out The File Menu and History Menu in The Menu Bar Above!'
1604
+ }
1605
+ menu_bar {
1606
+ menu {
1607
+ text '&File'
1608
+ menu_item {
1609
+ text 'E&xit'
1610
+ }
1611
+ menu_item(0) {
1612
+ text '&New'
1613
+ on_widget_selected {
1614
+ message_box(shell_proxy) {
1615
+ text 'New File'
1616
+ message 'New File Contents'
1617
+ }.open
1618
+ }
1619
+ }
1620
+ menu(1) {
1621
+ text '&Options'
1622
+ menu_item(:radio) {
1623
+ text 'Option 1'
1624
+ }
1625
+ menu_item(:separator)
1626
+ menu_item(:check) {
1627
+ text 'Option 3'
1628
+ }
1629
+ }
1630
+ }
1631
+ menu {
1632
+ text '&History'
1633
+ menu {
1634
+ text '&Recent'
1635
+ menu_item {
1636
+ text 'File 1'
1637
+ on_widget_selected {
1638
+ message_box(shell_proxy) {
1639
+ text 'File 1'
1640
+ message 'File 1 Contents'
1641
+ }.open
1642
+ }
1643
+ }
1644
+ menu_item {
1645
+ text 'File 2'
1646
+ on_widget_selected {
1647
+ message_box(shell_proxy) {
1648
+ text 'File 2'
1649
+ message 'File 2 Contents'
1650
+ }.open
1651
+ }
1652
+ }
1653
+ }
1654
+ }
1655
+ }
1656
+ }.open
1657
+ ```
1658
+
1659
+ Example of a Pop Up Context Menu (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
1660
+
1661
+ ```ruby
1662
+ shell { |shell_proxy|
1663
+ text 'Hello, Pop Up Context Menu!'
1664
+ grid_layout
1665
+ label {
1666
+ font height: 16
1667
+ text 'Right-Click To Pop Up a Context Menu'
1668
+ menu {
1669
+ menu {
1670
+ text '&History'
1671
+ menu {
1672
+ text '&Recent'
1673
+ menu_item {
1674
+ text 'File 1'
1675
+ on_widget_selected {
1676
+ message_box(shell_proxy) {
1677
+ text 'File 1'
1678
+ message 'File 1 Contents'
1679
+ }.open
1680
+ }
1681
+ }
1682
+ menu_item {
1683
+ text 'File 2'
1684
+ on_widget_selected {
1685
+ message_box(shell_proxy) {
1686
+ text 'File 2'
1687
+ message 'File 2 Contents'
1688
+ }.open
1689
+ }
1690
+ }
1691
+ }
1692
+ }
1693
+ }
1694
+ }
1695
+ }.open
1696
+ ```
1697
+
1698
+ #### ScrolledComposite
1699
+
1700
+ Glimmer provides smart defaults for the `scrolled_composite` widget by:
1701
+ - Automatically setting the nested widget as its content (meaning use can just like a plain old `composite` to add scrolling)
1702
+ - Automatically setting the :h_scroll and :v_scroll SWT styles (can be set manually if only one of either :h_scroll or :v_scroll is desired )
1703
+ - Automatically setting the expand horizontal and expand vertical SWT properties to `true`
1704
+
1705
+ ### Widget Styles
1706
+
1707
+ SWT widgets receive `SWT` styles in their constructor as per this guide:
1708
+
1709
+ https://wiki.eclipse.org/SWT_Widget_Style_Bits
1710
+
1711
+ Glimmer DSL facilitates that by passing symbols representing `SWT` constants as widget method arguments (i.e. inside widget `()` parentheses according to [Glimmer Style Guide](#glimmer-style-guide). See example below) in lower case version (e.g. `SWT::MULTI` becomes `:multi`).
1712
+
1713
+ These styles customize widget look, feel, and behavior.
1714
+
1715
+ Example:
1716
+
1717
+ ```ruby
1718
+ # ...
1719
+ list(:multi) { # SWT styles go inside ()
1720
+ # ...
1721
+ }
1722
+ # ...
1723
+ ```
1724
+ Passing `:multi` to `list` widget enables list element multi-selection.
1725
+
1726
+ ```ruby
1727
+ # ...
1728
+ composite(:border) { # SWT styles go inside ()
1729
+ # ...
1730
+ }
1731
+ # ...
1732
+ ```
1733
+ Passing `:border` to `composite` widget ensures it has a border.
1734
+
1735
+ When you need to pass in **multiple SWT styles**, simply separate by commas.
1736
+
1737
+ Example:
1738
+
1739
+ ```ruby
1740
+ # ...
1741
+ text(:center, :border) { # Multiple SWT styles separated by comma
1742
+ # ...
1743
+ }
1744
+ # ...
1745
+ ```
1746
+
1747
+ Glimmer ships with SWT style **smart defaults** so you wouldn't have to set them yourself most of the time (albeit you can always override them):
1748
+
1749
+ - `text(:border)`
1750
+ - `table(:border, :virtual, :full_selection)`
1751
+ - `tree(:border, :virtual, :v_scroll, :h_scroll)`
1752
+ - `spinner(:border)`
1753
+ - `list(:border, :v_scroll)`
1754
+ - `button(:push)`
1755
+
1756
+ You may check out all available `SWT` styles here:
1757
+
1758
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
1759
+
1760
+ #### Explicit SWT Style Bit
1761
+
1762
+ When building a widget-related SWT object manually (e.g. `GridData.new(...)`), you are expected to use `SWT::CONSTANT` directly or BIT-OR a few SWT constants together like `SWT::BORDER | SWT::V_SCROLL`.
1763
+
1764
+ Glimmer facilitates that with `swt` keyword by allowing you to pass multiple styles as an argument array of symbols instead of dealing with BIT-OR.
1765
+ Example:
1766
+
1767
+ ```ruby
1768
+ style = swt(:border, :v_scroll)
1769
+ ```
1770
+
1771
+ #### Negative SWT Style Bits
1772
+
1773
+ In rare occasions, you might need to apply & with a negative (not) style bit to negate it from another style bit that includes it.
1774
+ Glimmer facilitates that by declaring the negative style bit via postfixing a symbol with `!`.
1775
+
1776
+ Example:
1777
+
1778
+ ```ruby
1779
+ style = swt(:shell_trim, :max!) # creates a shell trim style without the maximize button (negated)
1780
+ ```
1781
+
1782
+ #### Extra SWT Styles
1783
+
1784
+ ##### Non-resizable Window
1785
+
1786
+ SWT Shell widget by default is resizable. To make it non-resizable, one must pass a complicated style bit concoction like `swt(:shell_trim, :resize!, :max!)`.
1787
+
1788
+ Glimmer makes this easier by alternatively offering a `:no_resize` extra SWT style, added for convenience.
1789
+ This makes declaring a non-resizable window as easy as:
1790
+
1791
+ ```ruby
1792
+ shell(:no_resize) {
1793
+ # ...
1794
+ }
1795
+ ```
1796
+
1797
+ ### Widget Properties
1798
+
1799
+ Widget properties such as text value, enablement, visibility, and layout details are set within the widget block using methods matching SWT widget property names in lower snakecase. You may refer to SWT widget guide for details on available widget properties:
1800
+
1801
+ https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
1802
+
1803
+
1804
+ Code examples:
1805
+
1806
+ ```ruby
1807
+ # ...
1808
+ label {
1809
+ text "Hello, World!" # SWT properties go inside {} block
1810
+ }
1811
+ # ...
1812
+ ```
1813
+
1814
+ In the above example, the `label` widget `text` property was set to "Hello, World!".
1815
+
1816
+ ```ruby
1817
+ # ...
1818
+ button {
1819
+ enabled bind(@tic_tac_toe_board.box(row, column), :empty)
1820
+ }
1821
+ # ...
1822
+ ```
1823
+
1824
+ In the above example, the `text` widget `enabled` property was data-bound to `#empty` method on `@tic_tac_toe_board.box(row, column)` (learn more about data-binding below)
1825
+
1826
+ #### Color
1827
+
1828
+ Colors make up a subset of widget properties. SWT accepts color objects created with RGB (Red Green Blue) or RGBA (Red Green Blue Alpha). Glimmer supports constructing color objects using the `rgb` and `rgba` DSL keywords.
1829
+
1830
+ Example:
1831
+
1832
+ ```ruby
1833
+ # ...
1834
+ label {
1835
+ background rgb(144, 240, 244)
1836
+ foreground rgba(38, 92, 232, 255)
1837
+ }
1838
+ # ...
1839
+ ```
1840
+
1841
+ SWT also supports standard colors available as constants under the `SWT` namespace with the `COLOR_` prefix (e.g. `SWT::COLOR_BLUE`)
1842
+
1843
+ Glimmer supports constructing colors for these constants as lowercase Ruby symbols (with or without `color_` prefix) passed to `color` DSL keyword
1844
+
1845
+ Example:
1846
+
1847
+ ```ruby
1848
+ # ...
1849
+ label {
1850
+ background color(:black)
1851
+ foreground color(:yellow)
1852
+ }
1853
+ label {
1854
+ background color(:color_white)
1855
+ foreground color(:color_red)
1856
+ }
1857
+ # ...
1858
+ ```
1859
+
1860
+ You may check out all available standard colors in `SWT` over here (having `COLOR_` prefix):
1861
+
1862
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
1863
+
1864
+
1865
+ ##### `#swt_color`
1866
+
1867
+ Glimmer color objects come with an instance method `#swt_color` that returns the actual SWT `Color` object wrapped by the Glimmer color object. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
1868
+
1869
+ Example:
1870
+
1871
+ ```ruby
1872
+ color(:black).swt_color # returns SWT Color object
1873
+ ```
1874
+
1875
+ #### Font
1876
+
1877
+ Fonts are represented in Glimmer as a hash of name, height, and style keys.
1878
+
1879
+ The style can be one (or more) of 3 values: `:normal`, `:bold`, and `:italic`
1880
+
1881
+ Example:
1882
+
1883
+ ```ruby
1884
+ # ...
1885
+ label {
1886
+ font name: 'Arial', height: 36, style: :normal
1887
+ }
1888
+ # ...
1889
+ ```
1890
+
1891
+ Keys are optional, so some of them may be left off.
1892
+ When passing multiple styles, they are included in an array.
1893
+
1894
+ Example:
1895
+
1896
+ ```ruby
1897
+ # ...
1898
+ label {
1899
+ font style: [:bold, :italic]
1900
+ }
1901
+ # ...
1902
+ ```
1903
+
1904
+ You may simply use the standalone `font` keyword without nesting in a parent if there is a need to build a Font object to use in manual SWT programming outside of widget font property setting.
1905
+
1906
+ Example:
1907
+
1908
+ ```ruby
1909
+ @font = font(name: 'Arial', height: 36, style: :normal)
1910
+ ```
1911
+
1912
+ ### Cursor
1913
+
1914
+ SWT widget `cursor` property represents the mouse cursor you see on the screen when you hover over that widget.
1915
+
1916
+ The `Display` class provides a way to obtain standard system cursors matching of the SWT style constants starting with prefix `CURSOR_` (e.g. `SWT::CURSOR_HELP` shows a question mark mouse cursor)
1917
+
1918
+ Glimmer provides an easier way to obtain and set `cursor` property on a widget by simply mentioning the SWT style constant as an abbreviated symbol excluding the "CURSOR_" suffix.
1919
+
1920
+ Example:
1921
+
1922
+ ```ruby
1923
+ shell {
1924
+ minimum_size 128, 128
1925
+ cursor :appstarting
1926
+ }
1927
+ ```
1928
+
1929
+ This sets the shell `cursor` to that of `SWT::CURSOR_APPSTARTING`
1930
+
1931
+ ### Layouts
1932
+
1933
+ Glimmer lays widgets out visually using SWT layouts, which can only be set on composite widget and subclasses.
1934
+
1935
+ The most common SWT layouts are:
1936
+ - `FillLayout`: lays widgets out in equal proportion horizontally or vertically with spacing/margin options. This is the ***default*** layout for ***shell*** (with `:horizontal` option) in Glimmer.
1937
+ - `RowLayout`: lays widgets out horizontally or vertically in varying proportions with advanced spacing/margin/justify options
1938
+ - `GridLayout`: lays widgets out in a grid with advanced spacing/margin/alignment/indentation options. This is the **default** layout for **composite** in Glimmer. It is important to master.
1939
+
1940
+ In Glimmer DSL, just like widgets, layouts can be specified with lowercase underscored names followed by a block containing properties, also lowercase underscored names (e.g. `RowLayout` is `row_layout`).
1941
+
1942
+ Example:
1943
+
1944
+ ```ruby
1945
+ # ...
1946
+ composite {
1947
+ row_layout {
1948
+ wrap true
1949
+ pack false
1950
+ justify true
1951
+ type :vertical
1952
+ margin_left 1
1953
+ margin_top 2
1954
+ margin_right 3
1955
+ margin_bottom 4
1956
+ spacing 5
1957
+ }
1958
+ # ... widgets follow
1959
+ }
1960
+ # ...
1961
+ ```
1962
+
1963
+ If you data-bind any layout properties, when they change, the shell containing their widget re-packs its children (calls `#pack` method automatically) to ensure proper relayout of all widgets.
1964
+
1965
+ Alternatively, a layout may be constructed by following the SWT API for the layout object. For example, a `RowLayout` can be constructed by passing it an SWT style constant (Glimmer automatically accepts symbols (e.g. `:horizontal`) for SWT style arguments like `SWT::HORIZONTAL`.)
1966
+
1967
+ ```ruby
1968
+ # ...
1969
+ composite {
1970
+ row_layout :horizontal
1971
+ # ... widgets follow
1972
+ }
1973
+ # ...
1974
+ ```
1975
+
1976
+ Here is a more sophisticated example taken from [hello_computed.rb](samples/hello/hello_computed.rb) sample:
1977
+
1978
+ ![Hello Computed](images/glimmer-hello-computed.png)
1979
+
1980
+ ```ruby
1981
+ shell {
1982
+ text 'Hello, Computed!'
1983
+ composite {
1984
+ grid_layout {
1985
+ num_columns 2
1986
+ make_columns_equal_width true
1987
+ horizontal_spacing 20
1988
+ vertical_spacing 10
1989
+ }
1990
+ label {text 'First &Name: '}
1991
+ text {
1992
+ text bind(@contact, :first_name)
1993
+ layout_data {
1994
+ horizontal_alignment :fill
1995
+ grab_excess_horizontal_space true
1996
+ }
1997
+ }
1998
+ label {text '&Last Name: '}
1999
+ text {
2000
+ text bind(@contact, :last_name)
2001
+ layout_data {
2002
+ horizontal_alignment :fill
2003
+ grab_excess_horizontal_space true
2004
+ }
2005
+ }
2006
+ label {text '&Year of Birth: '}
2007
+ text {
2008
+ text bind(@contact, :year_of_birth)
2009
+ layout_data {
2010
+ horizontal_alignment :fill
2011
+ grab_excess_horizontal_space true
2012
+ }
2013
+ }
2014
+ label {text 'Name: '}
2015
+ label {
2016
+ text bind(@contact, :name, computed_by: [:first_name, :last_name])
2017
+ layout_data {
2018
+ horizontal_alignment :fill
2019
+ grab_excess_horizontal_space true
2020
+ }
2021
+ }
2022
+ label {text 'Age: '}
2023
+ label {
2024
+ text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
2025
+ layout_data {
2026
+ horizontal_alignment :fill
2027
+ grab_excess_horizontal_space true
2028
+ }
2029
+ }
2030
+ }
2031
+ }.open
2032
+ ```
2033
+
2034
+ Check out the samples directory for more advanced examples of layouts in Glimmer.
2035
+
2036
+ **Defaults**:
2037
+
2038
+ Glimmer composites always come with `grid_layout` by default, but you can still specify explicitly if you'd like to set specific properties on it.
2039
+
2040
+ Glimmer shell always comes with `fill_layout` having `:horizontal` type.
2041
+
2042
+ This is a great guide for learning more about SWT layouts:
2043
+
2044
+ https://www.eclipse.org/articles/Article-Understanding-Layouts/Understanding-Layouts.htm
2045
+
2046
+ Also, for a reference, check the SWT API:
2047
+
2048
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/index.html
2049
+
2050
+ ### Layout Data
2051
+
2052
+ Layouts organize widgets following common rules for all widgets directly under a composite. But, what if a specific widget needs its own rules. That's where layout data comes into play.
2053
+
2054
+ By convention, SWT layouts expect widgets to set layout data with a class matching their class name with the word "Data" replacing "Layout":
2055
+ - `GridLayout` on a composite demands `GridData` on contained widgets
2056
+ - `RowLayout` on a composite demands `RowData` on contained widgets
2057
+
2058
+ Not all layouts support layout data to further customize widget layouts. For example, `FillLayout` supports no layout data.
2059
+
2060
+ Unlike widgets and layouts in Glimmer DSL, layout data is simply specified with `layout_data` keyword nested inside a widget block body, and followed by arguments and/or a block of its own properties (lowercase underscored names).
2061
+
2062
+ Glimmer automatically deduces layout data class name by convention as per rule above, with the assumption that the layout data class lives under the same exact Java package as the layout (one can set custom layout data that breaks convention if needed in rare cases. See code below for an example)
2063
+
2064
+ Glimmer also automatically accepts symbols (e.g. `:fill`) for SWT style arguments like `SWT::FILL`.
2065
+
2066
+ Examples:
2067
+
2068
+ ```ruby
2069
+ # ...
2070
+ composite {
2071
+ row_layout :horizontal
2072
+ label {
2073
+ layout_data { # followed by properties
2074
+ width 50
2075
+ height 30
2076
+ }
2077
+ }
2078
+ # ... more widgets follow
2079
+ }
2080
+ # ...
2081
+ ```
2082
+
2083
+ ```ruby
2084
+ # ...
2085
+ composite {
2086
+ grid_layout 3, false # grid layout with 3 columns not of equal width
2087
+ label {
2088
+ # layout data followed by arguments passed to SWT GridData constructor
2089
+ layout_data :fill, :end, true, false
2090
+ }
2091
+ }
2092
+ # ...
2093
+ ```
2094
+
2095
+ ```ruby
2096
+ # ...
2097
+ composite {
2098
+ grid_layout 3, false # grid layout with 3 columns not of equal width
2099
+ label {
2100
+ # layout data set explicitly via an object (helps in rare cases that break convention)
2101
+ layout_data GridData.new(swt(:fill), swt(:end), true, false)
2102
+ }
2103
+ }
2104
+ # ...
2105
+ ```
2106
+
2107
+ If you data-bind any layout data properties, when they change, the shell containing their widget re-packs its children (calls `#pack` method automatically) to ensure proper relayout of all widgets.
2108
+
2109
+ **NOTE**: Layout data must never be reused between widgets. Always specify or clone again for every widget.
2110
+
2111
+ This is a great guide for learning more about SWT layouts:
2112
+
2113
+ https://www.eclipse.org/articles/Article-Understanding-Layouts/Understanding-Layouts.htm
2114
+
2115
+ Also, for a reference, check the SWT API:
2116
+
2117
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/index.html
2118
+
2119
+ ### Data-Binding
2120
+
2121
+ Data-binding is done with `bind` command following widget property to bind and taking model and bindable attribute as arguments.
2122
+
2123
+ #### General Examples
2124
+
2125
+ `text bind(contact, :first_name)`
2126
+
2127
+ This example binds the text property of a widget like `label` to the first name of a contact model.
2128
+
2129
+ `text bind(contact, 'address.street')`
2130
+
2131
+ This example binds the text property of a widget like `label` to the nested street of
2132
+ the address of a contact. This is called nested property data binding.
2133
+
2134
+ `text bind(contact, 'address.street', on_read: :upcase, on_write: :downcase)`
2135
+
2136
+ This example adds on the one above it by specifying converters on read and write of the model property, like in the case of a `text` widget. The text widget will then displays the street upper case and the model will store it lower case. When specifying converters, read and write operations must be symmetric (to avoid an infinite update loop between the widget and the model since the widget checks first if value changed before updating)
2137
+
2138
+ `text bind(contact, 'address.street', on_read: lambda { |s| s[0..10] })`
2139
+
2140
+ This example also specifies a converter on read of the model property, but via a lambda, which truncates the street to 10 characters only. Note that the read and write operations are assymetric. This is fine in the case of formatting data for a read-only widget like `label`
2141
+
2142
+ `text bind(contact, 'address.street') { |s| s[0..10] }`
2143
+
2144
+ This is a block shortcut version of the syntax above it. It facilitates formatting model data for read-only widgets since it's a very common view concern. It also saves the developer from having to create a separate formatter/presenter for the model when the view can be an active view that handles common simple formatting operations directly.
2145
+
2146
+ `text bind(contact, 'address.street', read_only: true)
2147
+
2148
+ This is read-ohly data-binding. It doesn't update contact.address.street when widget text property is changed.
2149
+
2150
+ `text bind(contact, 'addresses[1].street')`
2151
+
2152
+ This example binds the text property of a widget like `label` to the nested indexed address street of a contact. This is called nested indexed property data binding.
2153
+
2154
+ `text bind(contact, :age, computed_by: :date_of_birth)`
2155
+
2156
+ This example demonstrates computed value data binding whereby the value of `age` depends on changes to `date_of_birth`.
2157
+
2158
+ `text bind(contact, :name, computed_by: [:first_name, :last_name])`
2159
+
2160
+ This example demonstrates computed value data binding whereby the value of `name` depends on changes to both `first_name` and `last_name`.
2161
+
2162
+ `text bind(contact, 'profiles[0].name', computed_by: ['profiles[0].first_name', 'profiles[0].last_name'])`
2163
+
2164
+ This example demonstrates nested indexed computed value data binding whereby the value of `profiles[0].name` depends on changes to both nested `profiles[0].first_name` and `profiles[0].last_name`.
2165
+
2166
+ Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2167
+
2168
+ #### Combo
2169
+
2170
+ 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.
2171
+
2172
+ When data-binding a `combo` widget, Glimmer can automatically deduce available options from data-bound model by convention: `{attribute_name}_options` method.
2173
+
2174
+ ![Hello Combo](images/glimmer-hello-combo.png)
2175
+
2176
+ ![Hello Combo](images/glimmer-hello-combo-expanded.png)
2177
+
2178
+ ```ruby
2179
+ class Person
2180
+ attr_accessor :country, :country_options
2181
+
2182
+ def initialize
2183
+ self.country_options=["", "Canada", "US", "Mexico"]
2184
+ self.country = "Canada"
2185
+ end
2186
+
2187
+ def reset_country
2188
+ self.country = "Canada"
2189
+ end
2190
+ end
2191
+
2192
+ class HelloCombo
2193
+ include Glimmer
2194
+ def launch
2195
+ person = Person.new
2196
+ shell {
2197
+ composite {
2198
+ combo(:read_only) {
2199
+ selection bind(person, :country)
2200
+ }
2201
+ button {
2202
+ text "Reset"
2203
+ on_widget_selected do
2204
+ person.reset_country
2205
+ end
2206
+ }
2207
+ }
2208
+ }.open
2209
+ end
2210
+ end
2211
+
2212
+ HelloCombo.new.launch
2213
+ ```
2214
+
2215
+ `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.
2216
+
2217
+ #### List
2218
+
2219
+ Example from [samples/hello/hello_list_single_selection.rb](samples/hello_list_single_selection.rb) sample:
2220
+
2221
+ ![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
2222
+
2223
+ ```ruby
2224
+ shell {
2225
+ composite {
2226
+ list {
2227
+ selection bind(person, :country)
2228
+ }
2229
+ button {
2230
+ text "Reset"
2231
+ on_widget_selected do
2232
+ person.reset_country
2233
+ end
2234
+ }
2235
+ }
2236
+ }.open
2237
+ ```
2238
+
2239
+ `list` widget is also data-bound to the country of a person similarly to the combo widget. Not much difference here (the rest of the code not shown is the same).
2240
+
2241
+ Nonetheless, in the next example, a multi-selection list is declared instead allowing data-binding of multiple selection values to the bindable attribute on the model.
2242
+
2243
+ Example from [samples/hello/hello_list_multi_selection.rb](samples/hello_list_multi_selection.rb) sample (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2244
+
2245
+ ![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
2246
+
2247
+ ```ruby
2248
+ class Person
2249
+ attr_accessor :provinces, :provinces_options
2250
+
2251
+ def initialize
2252
+ self.provinces_options=[
2253
+ "",
2254
+ "Quebec",
2255
+ "Ontario",
2256
+ "Manitoba",
2257
+ "Saskatchewan",
2258
+ "Alberta",
2259
+ "British Columbia",
2260
+ "Nova Skotia",
2261
+ "Newfoundland"
2262
+ ]
2263
+ self.provinces = ["Quebec", "Manitoba", "Alberta"]
2264
+ end
2265
+
2266
+ def reset_provinces
2267
+ self.provinces = ["Quebec", "Manitoba", "Alberta"]
2268
+ end
2269
+ end
2270
+
2271
+ class HelloListMultiSelection
2272
+ include Glimmer
2273
+ def launch
2274
+ person = Person.new
2275
+ shell {
2276
+ composite {
2277
+ list(:multi) {
2278
+ selection bind(person, :provinces)
2279
+ }
2280
+ button {
2281
+ text "Reset"
2282
+ on_widget_selected do
2283
+ person.reset_provinces
2284
+ end
2285
+ }
2286
+ }
2287
+ }.open
2288
+ end
2289
+ end
2290
+
2291
+ HelloListMultiSelection.new.launch
2292
+ ```
2293
+
2294
+ The Glimmer code is not much different from above except for passing the `:multi` style to the `list` widget. However, the model code behind the scenes is quite different as it is a `provinces` array bindable to the selection of multiple values on a `list` widget. `provinces_options` contains all available province values just as expected by a single selection `list` and `combo`.
2295
+
2296
+ Note that in all the data-binding examples above, there was also an observer attached to the `button` widget to trigger an action on the model, which in turn triggers a data-binding update on the `list` or `combo`. Observers will be discussed in more details in the [next section](#observer).
2297
+
2298
+ You may learn more about Glimmer's data-binding syntax by reading the code under the [samples](samples) directory.
2299
+
2300
+ #### Table
2301
+
2302
+ The SWT Tree widget renders a multi-column data table, such as a contact listing or a sales report.
2303
+
2304
+ To data-bind a Table, you need the main model, the collection property, and the text display attribute for each table column.
2305
+
2306
+ This involves using the `bind` keyword mentioned above in addition to a special `column_properties` keyword that takes the table column text attribute methods.
2307
+
2308
+ It assumes you have defined the table columns via `table_column` widget.
2309
+
2310
+ Example:
2311
+
2312
+ ```ruby
2313
+ shell {
2314
+ @table = table {
2315
+ table_column {
2316
+ text "Name"
2317
+ width 120
2318
+ }
2319
+ table_column {
2320
+ text "Age"
2321
+ width 120
2322
+ }
2323
+ table_column {
2324
+ text "Adult"
2325
+ width 120
2326
+ }
2327
+ items bind(group, :people), column_properties(:name, :age, :adult)
2328
+ selection bind(group, :selected_person)
2329
+ on_mouse_up { |event|
2330
+ @table.edit_table_item(event.table_item, event.column_index)
2331
+ }
2332
+ }
2333
+ }
2334
+ ```
2335
+
2336
+ The code above includes two data-bindings:
2337
+ - Table `items`, which first bind to the model collection property (group.people), and then maps each column property (name, age, adult) for displaying each table item column.
2338
+ - Table `selection`, which binds the single table item selected by the user to the attribute denoted by the `bind` keyword (or binds multiple table items selected for a table with `:multi` SWT style)
2339
+ - The `on_mouse_up` event handler invokes `@table.edit_table_item(event.table_item, event.column_index)` to start edit mode on the clicked table item cell, and then saves or cancel depending on whether the user hits ENTER or ESC once done editing (or focus-out after either making a change or not making any changes.)
2340
+
2341
+ Additionally, Table `items` data-binding automatically stores each node model unto the SWT TableItem object via `setData` method. This enables things like searchability.
2342
+
2343
+ The table widget in Glimmer is represented by a subclass of `WidgetProxy` called `TableProxy`.
2344
+ TableProxy includes a `search` method that takes a block to look for a table item.
2345
+
2346
+ Example:
2347
+
2348
+ ```ruby
2349
+ found_array = @table.search { |table_item| table_item.getData == company.owner }
2350
+ ```
2351
+
2352
+ This finds a person. The array is a Java array. This enables easy passing of it to SWT `Table#setSelection` method, which expects a Java array of `TableItem` objects.
2353
+
2354
+ To edit a table, you must invoke `TableProxy#edit_selected_table_item(column_index, before_write: nil, after_write: nil, after_cancel: nil)` or `TableProxy#edit_table_item(table_item, column_index, before_write: nil, after_write: nil, after_cancel: nil)`.
2355
+ This automatically leverages the SWT TableEditor custom class behind the scenes, displaying a text widget to the user to change the selected or
2356
+ passed table item text into something else.
2357
+ It automatically persists the change to `items` data-bound model on ENTER/FOCUS-OUT or cancels on ESC/NO-CHANGE.
2358
+
2359
+ ##### Table Sorting
2360
+
2361
+ Glimmer automatically adds sorting support to the SWT `Table` widget.
2362
+
2363
+ Check out the [Contact Manager](#contact-manager) sample for an example.
2364
+ You may click on any column and it will sort by ascending order first and descending if you click again.
2365
+
2366
+ Glimmer automatic table sorting supports `String`, `Integer`, and `Float` columns out of the box as well as any column data that is comparable.
2367
+
2368
+ In cases where data is nil, depending on the data-type, it is automatically converted to `Float` with `to_f`, `Integer` with `to_i`, or `String` with `to_s`.
2369
+
2370
+ Should you have a special data type that could not be compared automatically, Glimmer offers the following 3 alternatives for custom sorting:
2371
+ - `sort_property`: this may be set to an alternative property to the one data-bound to the table column. For example, a table column called 'adult', which returns `true` or `false` may be sorted with `sort_property :dob` instead. This also support multi-property (aka multi-column) sorting (e.g. `sort_property :dob, :name`).
2372
+ - `sort_by(&block)`: this works just like Ruby `Enumerable` `sort_by`. The block receives the table column data as argument.
2373
+ - `sort(&comparator)`: this works just like Ruby `Enumerable` `sort`. The comparator block receives two objects from the table column data.
2374
+
2375
+ You may also set `additional_sort_properties` on the parent `table` widget to have secondary sorting applied. For example, if you set `additional_sort_properties :name, :project_name`, then whenever you sort by `:name`, it additionally sorts by `:project_name` afterwards, and vice versa. This only works for columns that either have no custom sort set or have a `sort_property` with one property only (but no sort or sort_by block)
2376
+
2377
+ Example:
2378
+
2379
+ ```ruby
2380
+ # ...
2381
+ table {
2382
+ table_column {
2383
+ text 'Task'
2384
+ width 120
2385
+ }
2386
+ table_column {
2387
+ text 'Project'
2388
+ width 120
2389
+ }
2390
+ table_column {
2391
+ text 'Duration (hours)'
2392
+ width 120
2393
+ sort_property :duration_in_hours
2394
+ }
2395
+ table_column {
2396
+ text 'Priority'
2397
+ width 120
2398
+ sort_by { |value| ['High', 'Medium', 'Low'].index(value) }
2399
+ }
2400
+ table_column {
2401
+ text 'Start Date'
2402
+ width 120
2403
+ sort { |d1, d2| d1.to_date <=> d2.to_date }
2404
+ }
2405
+ additional_sort_properties :project_name, :duration_in_hours, :name
2406
+ items bind(Task, :list), column_properties(:name, :project_name, :duration, :priority, :start_date)
2407
+ # ...
2408
+ }
2409
+ # ...
2410
+ ```
2411
+
2412
+ Here is an explanation of the example above:
2413
+ - Task and Project table columns are data-bound to the `:name` and `:project_name` properties and sorted through them automatically
2414
+ - Task Duration table column is data-bound to the `:duration` property, but sorted via the `:duration_in_hours` property instead
2415
+ - Task Priority table column has a custom sort_by block
2416
+ - Task Start Date table column has a custom sort comparator block
2417
+ - Additional (secondary) sort properties are applied when sorting by Task, Project, or Duration in the order specified
2418
+
2419
+
2420
+ #### Tree
2421
+
2422
+ The SWT Tree widget visualizes a tree data-structure, such as an employment or composition hierarchy.
2423
+
2424
+ To data-bind a Tree, you need the root model, the children querying method, and the text display attribute on each child.
2425
+
2426
+ This involves using the `bind` keyword mentioned above in addition to a special `tree_properties` keyword that takes the children and text attribute methods.
2427
+
2428
+ Example:
2429
+
2430
+ ```ruby
2431
+ shell {
2432
+ @tree = tree {
2433
+ items bind(company, :owner), tree_properties(children: :coworkers, text: :name)
2434
+ selection bind(company, :selected_coworker)
2435
+ }
2436
+ }
2437
+ ```
2438
+
2439
+ The code above includes two data-bindings:
2440
+ - Tree `items`, which first bind to the root node (company.owner), and then dig down via `coworkers` `children` method, using the `name` `text` attribute for displaying each tree item.
2441
+ - Tree `selection`, which binds the single tree item selected by the user to the attribute denoted by the `bind` keyword
2442
+
2443
+ Additionally, Tree `items` data-binding automatically stores each node model unto the SWT TreeItem object via `setData` method. This enables things like searchability.
2444
+
2445
+ The tree widget in Glimmer is represented by a subclass of `WidgetProxy` called `TreeProxy`.
2446
+ TreeProxy includes a `depth_first_search` method that takes a block to look for a tree item.
2447
+
2448
+ Example:
2449
+
2450
+ ```ruby
2451
+ found_array = @tree.depth_first_search { |tree_item| tree_item.getData == company.owner }
2452
+ ```
2453
+
2454
+ This finds the root node. The array is a Java array. This enables easy passing of it to SWT `Tree#setSelection` method, which expects a Java array of `TreeItem` objects.
2455
+
2456
+ 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
2457
+ 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.
2458
+
2459
+ ### Observer
2460
+
2461
+ 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.
2462
+
2463
+ #### Observing Widgets
2464
+
2465
+ Glimmer supports observing widgets with two main types of events:
2466
+ 1. `on_{swt-listener-method-name}`: where {swt-listener-method-name} is replaced with the lowercase underscored event method name on an SWT listener class (e.g. `on_verify_text` for `org.eclipse.swt.events.VerifyListener#verifyText`).
2467
+ 2. `on_swt_{swt-event-constant}`: where {swt-event-constant} is replaced with an [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) event constant (e.g. `on_swt_show` for `SWT.Show` to observe when widget becomes visible)
2468
+
2469
+ Additionally, there are two more types of events:
2470
+ - SWT `display` supports global listeners called filters that run on any widget. They are hooked via `on_swt_{swt-event-constant}`
2471
+ - SWT `display` supports Mac application menu item observers (`on_about` and `on_preferences`), which you can read about under [Miscellaneous](#miscellaneous).
2472
+
2473
+ Number 1 is more commonly used in SWT applications, so make it your starting point. Number 2 covers events not found in number 1, so look into it if you don't find an SWT listener you need in number 1.
2474
+
2475
+ **Regarding number 1**, to figure out what the available events for an SWT widget are, check out all of its `add***Listener` API methods, and then open the listener class argument to check its "event methods".
2476
+
2477
+ For example, if you look at the `Button` SWT API:
2478
+ https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fbrowser%2FBrowser.html
2479
+
2480
+ It has `addSelectionListener`. Additionally, under its `Control` super class, it has `addControlListener`, `addDragDetectListener`, `addFocusListener`, `addGestureListener`, `addHelpListener`, `addKeyListener`, `addMenuDetectListener`, `addMouseListener`, `addMouseMoveListener`, `addMouseTrackListener`, `addMouseWheelListener`, `addPaintListener`, `addTouchListener`, and `addTraverseListener`
2481
+
2482
+ Suppose, we select `addSelectionListener`, which is responsible for what happens when a user selects a button (clicks it). Then, open its argument `SelectionListener` SWT API, and you find the event (instance) methods: `widgetDefaultSelected` and `widgetSelected​`. Let's select the second one, which is what gets invoked when a button is clicked.
2483
+
2484
+ Now, Glimmer simplifies the process of hooking into that listener (observer) by neither requiring you to call the `addSelectionListener` method nor requiring you to implement/extend the `SelectionListener` API.
2485
+
2486
+ Instead, simply add a `on_widget_selected` followed by a Ruby block containing the logic to perform. Glimmer figures out the rest.
2487
+
2488
+ Let's revisit the Tic Tac Toe example shown near the beginning of the page:
2489
+
2490
+ ```ruby
2491
+ shell {
2492
+ text "Tic-Tac-Toe"
2493
+ minimum_size 150, 178
2494
+ composite {
2495
+ grid_layout 3, true
2496
+ (1..3).each { |row|
2497
+ (1..3).each { |column|
2498
+ button {
2499
+ layout_data :fill, :fill, true, true
2500
+ text bind(@tic_tac_toe_board[row, column], :sign)
2501
+ enabled bind(@tic_tac_toe_board[row, column], :empty)
2502
+ on_widget_selected {
2503
+ @tic_tac_toe_board.mark(row, column)
2504
+ }
2505
+ }
2506
+ }
2507
+ }
2508
+ }
2509
+ }
2510
+ ```
2511
+
2512
+ Note that every Tic Tac Toe grid cell has its `text` and `enabled` properties data-bound to the `sign` and `empty` attributes on the `TicTacToe::Board` model respectively.
2513
+
2514
+ Next however, each of these Tic Tac Toe grid cells, which are clickable buttons, have an `on_widget_selected` observer, which once triggered, marks the cell on the `TicTacToe::Board` to make a move.
2515
+
2516
+ **Regarding number 2**, you can figure out all available events by looking at the [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) API:
2517
+
2518
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
2519
+
2520
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2521
+
2522
+ `SWT.Show` - hooks a listener for showing a widget (using `on_swt_show` in Glimmer)
2523
+ `SWT.Hide` - hooks a listener for hiding a widget (using `on_swt_hide` in Glimmer)
2524
+
2525
+ ```ruby
2526
+ shell {
2527
+ @button1 = button {
2528
+ text "Show 2nd Button"
2529
+ visible true
2530
+ on_swt_show {
2531
+ @button2.swt_widget.setVisible(false)
2532
+ }
2533
+ on_widget_selected {
2534
+ @button2.swt_widget.setVisible(true)
2535
+ }
2536
+ }
2537
+ @button2 = button {
2538
+ text "Show 1st Button"
2539
+ visible false
2540
+ on_swt_show {
2541
+ @button1.swt_widget.setVisible(false)
2542
+ }
2543
+ on_widget_selected {
2544
+ @button1.swt_widget.setVisible(true)
2545
+ }
2546
+ }
2547
+ }.open
2548
+ ```
2549
+
2550
+ **Gotcha:** SWT.Resize event needs to be hooked using **`on_swt_Resize`** because [`org.eclipse.swt.SWT`](https://help.eclipse.org/2020-06/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html) has 2 constants for resize: `RESIZE` and `Resize`, so it cannot infer the right one automatically from the underscored version `on_swt_resize`
2551
+
2552
+ ##### Alternative Syntax
2553
+
2554
+ Instead of declaring a widget observer using `on_***` syntax inside a widget content block, you may also do so after the widget declaration by invoking directly on the widget object.
2555
+
2556
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2557
+
2558
+ ```
2559
+ @shell = shell {
2560
+ label {
2561
+ text "Hello, World!"
2562
+ }
2563
+ }
2564
+ @shell.on_shell_iconified {
2565
+ @shell.close
2566
+ }
2567
+ @shell.open
2568
+ ```
2569
+
2570
+ The shell declared above has been modified so that the minimize button works just like the close button. Once you minimize the shell (iconify it), it closes.
2571
+
2572
+ The alternative syntax can be helpful if you prefer to separate Glimmer observer declarations from Glimmer GUI declarations, or would like to add observers dynamically based on some logic later on.
2573
+
2574
+ #### Observing Models
2575
+
2576
+ Glimmer DSL includes an `observe` keyword used to register an observer by passing in the observable and the property(ies) to observe, and then specifying in a block what happens on notification.
2577
+
2578
+ ```ruby
2579
+ class TicTacToe
2580
+ include Glimmer
2581
+
2582
+ def initialize
2583
+ # ...
2584
+ observe(@tic_tac_toe_board, :game_status) { |game_status|
2585
+ display_win_message if game_status == Board::WIN
2586
+ display_draw_message if game_status == Board::DRAW
2587
+ }
2588
+ end
2589
+ # ...
2590
+ end
2591
+ ```
2592
+
2593
+ 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).
2594
+
2595
+ Look at [`samples/elaborate/tictactoe/tic_tac_toe.rb`](samples/tictactoe/tic_tac_toe.rb) for more details starting with the code included below.
2596
+
2597
+ ```ruby
2598
+ class TicTacToe
2599
+ include Glimmer
2600
+ include Observer
2601
+
2602
+ def initialize
2603
+ # ...
2604
+ observe(@tic_tac_toe_board, :game_status) { |game_status|
2605
+ display_win_message if game_status == Board::WIN
2606
+ display_draw_message if game_status == Board::DRAW
2607
+ }
2608
+ end
2609
+
2610
+ def display_win_message
2611
+ display_game_over_message("Player #{@tic_tac_toe_board.winning_sign} has won!")
2612
+ end
2613
+
2614
+ def display_draw_message
2615
+ display_game_over_message("Draw!")
2616
+ end
2617
+
2618
+ def display_game_over_message(message)
2619
+ message_box(@shell) {
2620
+ text 'Game Over'
2621
+ message message_text
2622
+ }.open
2623
+ @tic_tac_toe_board.reset
2624
+ end
2625
+ # ...
2626
+ end
2627
+ ```
2628
+
2629
+ ### Custom Widgets
2630
+
2631
+ Glimmer supports creating custom widgets with minimal code, which automatically extends Glimmer's DSL syntax with an underscored lowercase keyword.
2632
+
2633
+ Simply create a new class that includes `Glimmer::UI::CustomWidget` and put Glimmer DSL code in its `#body` block (its return value is stored in `#body_root` attribute). Glimmer will then automatically recognize this class by convention when it encounters a keyword matching the class name converted to underscored lowercase (and namespace double-colons `::` replaced with double-underscores `__`)
2634
+
2635
+ #### Simple Example
2636
+
2637
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
2638
+
2639
+ Definition:
2640
+ ```ruby
2641
+ class RedLabel
2642
+ include Glimmer::UI::CustomWidget
2643
+
2644
+ body {
2645
+ label(swt_style) {
2646
+ background :red
2647
+ }
2648
+ }
2649
+ end
2650
+ ```
2651
+
2652
+ Usage:
2653
+ ```ruby
2654
+ shell {
2655
+ red_label {
2656
+ text 'Red Label'
2657
+ }
2658
+ }.open
2659
+ ```
2660
+
2661
+ As you can see, `RedLabel` became Glimmer DSL keyword: `red_label`
2662
+
2663
+ #### Lifecycle Hook Example
2664
+
2665
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
2666
+
2667
+ Definition:
2668
+ ```ruby
2669
+ module Red
2670
+ class Composite
2671
+ include Glimmer::UI::CustomWidget
2672
+
2673
+ before_body {
2674
+ @color = :red
2675
+ }
2676
+
2677
+ body {
2678
+ composite(swt_style) {
2679
+ background @color
2680
+ }
2681
+ }
2682
+ end
2683
+ end
2684
+ ```
2685
+
2686
+ Usage:
2687
+ ```ruby
2688
+ shell {
2689
+ red__composite {
2690
+ label {
2691
+ foreground :white
2692
+ text 'This is showing inside a Red Composite'
2693
+ }
2694
+ }
2695
+ }.open
2696
+ ```
2697
+
2698
+ Notice how `Red::Composite` became `red__composite` with double-underscore, which is how Glimmer Custom Widgets signify namespaces by convention. Additionally, the `before_body` lifecycle hook was utilized to set a `@color` variable and use inside the `body`.
2699
+
2700
+ Keep in mind that namespaces are not needed to be specified if the Custom Widget class has a unique name, not clashing with a basic SWT widget or another custom widget name.
2701
+
2702
+ #### Custom Widget API
2703
+
2704
+ Custom Widgets have the following attributes available to call from inside the `#body` method:
2705
+ - `#parent`: Glimmer object parenting custom widget
2706
+ - `#swt_style`: SWT style integer. Can be useful if you want to allow consumers to customize a widget inside the custom widget body
2707
+ - `#options`: a hash of options passed in parentheses when declaring a custom widget (useful for passing in model data) (e.g. `calendar(events: events)`). Custom widget class can declare option names (array) with `::options` class method as shown below, which generates attribute accessors for every option (not to be confused with `#options` instance method for retrieving options hash containing names & values)
2708
+ - `#content`: nested block underneath custom widget. It will be automatically called at the end of processing the custom widget body. Alternatively, the custom widget body may call `content.call` at the place where the content is needed to show up as shown in the following example.
2709
+ - `#body_root`: top-most (root) widget returned from `#body` method.
2710
+ - `#swt_widget`: actual SWT widget for `body_root`
2711
+
2712
+ Additionally, custom widgets can call the following class methods:
2713
+ - `::options(*option_names)`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute accessors (e.g. `options :orientation, :bg_color` generates `#orientation`, `#orientation=(v)`, `#bg_color`, and `#bg_color=(v)` attribute accessors)
2714
+ - `::option(option_name, default: nil)`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `::options`)
2715
+
2716
+ #### Content/Options Example
2717
+
2718
+ (you may copy/paste in [`girb`](#girb-glimmer-irb-command))
2719
+
2720
+ Definition:
2721
+ ```ruby
2722
+ class Sandwich
2723
+ include Glimmer::UI::CustomWidget
2724
+
2725
+ options :orientation, :bg_color
2726
+ option :fg_color, default: :black
2727
+
2728
+ body {
2729
+ composite(swt_style) { # gets custom widget style
2730
+ fill_layout orientation # using orientation option
2731
+ background bg_color # using container_background option
2732
+ label {
2733
+ text 'SANDWICH TOP'
2734
+ }
2735
+ content.call # this is where content block is called
2736
+ label {
2737
+ text 'SANDWICH BOTTOM'
2738
+ }
2739
+ }
2740
+ }
2741
+ end
2742
+ ```
2743
+
2744
+ Usage:
2745
+ ```ruby
2746
+ shell {
2747
+ sandwich(:no_focus, orientation: :vertical, bg_color: :red) {
2748
+ label {
2749
+ background :green
2750
+ text 'SANDWICH CONTENT'
2751
+ }
2752
+ }
2753
+ }.open
2754
+ ```
2755
+
2756
+ 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
+
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
+ #### Gotcha
2765
+
2766
+ Beware of defining a custom attribute that is a common SWT widget property name.
2767
+ For example, if you define `text=` and `text` methods to accept a custom text and then later you write this body:
2768
+
2769
+ ```ruby
2770
+ # ...
2771
+ def text
2772
+ # ...
2773
+ end
2774
+
2775
+ def text=(value)
2776
+ # ...
2777
+ end
2778
+
2779
+ body {
2780
+ composite {
2781
+ label {
2782
+ text "Hello"
2783
+ }
2784
+ label {
2785
+ text "World"
2786
+ }
2787
+ }
2788
+ }
2789
+ # ...
2790
+ ```
2791
+
2792
+ 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`.
2793
+
2794
+ #### Final Notes
2795
+
2796
+ 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
+ [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
+
2799
+ ### Custom Shells
2800
+
2801
+ 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.
2802
+
2803
+ They may also be chained in a wizard fashion.
2804
+
2805
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2806
+
2807
+ ```ruby
2808
+ class WizardStep
2809
+ include Glimmer::UI::CustomShell
2810
+
2811
+ options :number, :step_count
2812
+
2813
+ before_body {
2814
+ @title = "Step #{number}"
2815
+ }
2816
+
2817
+ body {
2818
+ shell {
2819
+ text "Wizard - #{@title}"
2820
+ minimum_size 200, 100
2821
+ fill_layout :vertical
2822
+ label(:center) {
2823
+ text @title
2824
+ font height: 30
2825
+ }
2826
+ if number < step_count
2827
+ button {
2828
+ text "Go To Next Step"
2829
+ on_widget_selected {
2830
+ body_root.hide
2831
+ }
2832
+ }
2833
+ end
2834
+ }
2835
+ }
2836
+ end
2837
+
2838
+ shell { |app_shell|
2839
+ text "Wizard"
2840
+ minimum_size 200, 100
2841
+ @current_step_number = 1
2842
+ @wizard_steps = 5.times.map { |n|
2843
+ wizard_step(number: n+1, step_count: 5) {
2844
+ on_swt_hide {
2845
+ if @current_step_number < 5
2846
+ @current_step_number += 1
2847
+ app_shell.hide
2848
+ @wizard_steps[@current_step_number - 1].open
2849
+ end
2850
+ }
2851
+ }
2852
+ }
2853
+ button {
2854
+ text "Start"
2855
+ font height: 40
2856
+ on_widget_selected {
2857
+ app_shell.hide
2858
+ @wizard_steps[@current_step_number - 1].open
2859
+ }
2860
+ }
2861
+ }.open
2862
+ ```
2863
+
2864
+ ### Drag and Drop
2865
+
2866
+ Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
2867
+
2868
+ 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)
2869
+
2870
+ To get started, simply follow these steps:
2871
+ 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)
2872
+ 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)
2873
+ 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)
2874
+ 1. Read `event.data` and consume it (e.g. change widget text) inside the `on_drop` event handler block.
2875
+
2876
+ Example (taken from [samples/hello/hello_drag_and_drop.rb](#hello-drag-and-drop) / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2877
+
2878
+ ```ruby
2879
+ class Location
2880
+ attr_accessor :country
2881
+
2882
+ def country_options
2883
+ %w[USA Canada Mexico Columbia UK Australia Germany Italy Spain]
2884
+ end
2885
+ end
2886
+
2887
+ @location = Location.new
2888
+
2889
+ include Glimmer
2890
+
2891
+ shell {
2892
+ text 'Hello, Drag and Drop!'
2893
+ list {
2894
+ selection bind(@location, :country)
2895
+ on_drag_set_data { |event|
2896
+ list = event.widget.getControl
2897
+ event.data = list.getSelection.first
2898
+ }
2899
+ }
2900
+ label(:center) {
2901
+ text 'Drag a country here!'
2902
+ font height: 20
2903
+ on_drop { |event|
2904
+ event.widget.getControl.setText(event.data)
2905
+ }
2906
+ }
2907
+ }.open
2908
+ ```
2909
+
2910
+ ![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
2911
+
2912
+ Optional steps:
2913
+ - 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.
2914
+ - Specify `drag_source_style` operation (may be: :drop_copy (default), :drop_link, :drop_move, :drop_none, or an array of multiple operations)
2915
+ - 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)
2916
+ - Specify `drop_target_style` operation (may be: :drop_copy (default), :drop_link, :drop_move, :drop_none, or an array of multiple operations)
2917
+ - 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)
2918
+ - Set drag operation in `event.detail` (e.g. DND::DROP_COPY) inside `on_drag_enter`
2919
+
2920
+ ### Miscellaneous
2921
+
2922
+ #### Multi-DSL Support
2923
+
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)
2927
+ - [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
2928
+ - [XML](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML) - Useful with [SWT Browser Widget](#browser-widget)
2929
+ - [CSS](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets) - Useful with [SWT Browser Widget](#browser-widget)
2930
+
2931
+ Glimmer automatically recognizes top-level keywords in each DSL and activates DSL accordingly. Glimmer allows mixing DSLs, which comes in handy when doing things like using the SWT Browser widget with XML and CSS. Once done processing a nested DSL top-level keyword, Glimmer switches back to the prior DSL automatically.
2932
+
2933
+ ##### SWT
2934
+
2935
+ The SWT DSL was already covered in detail. However, for the sake of mixing DSLs, you need to know that the SWT DSL has the following top-level keywords:
2936
+ - `shell`
2937
+ - `display`
2938
+ - `color`
2939
+ - `observe`
2940
+ - `async_exec`
2941
+ - `sync_exec`
2942
+
2943
+ ##### Opal
2944
+
2945
+ Full instructions are found in the [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) DSL page.
2946
+
2947
+ The [Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) DSL is simply a web GUI adapter for desktop apps written in Glimmer. As such, it supports all the DSL keywords of the SWT DSL and shares the same top-level keywords.
2948
+
2949
+ ##### XML
2950
+
2951
+ Simply start with `html` keyword and add HTML inside its block using Glimmer DSL syntax.
2952
+ Once done, you may call `to_s`, `to_xml`, or `to_html` to get the formatted HTML output.
2953
+
2954
+ Here are all the Glimmer XML DSL top-level keywords:
2955
+ - `html`
2956
+ - `tag`: enables custom tag creation for exceptional cases by passing tag name as '_name' attribute
2957
+ - `name_space`: enables namespacing html tags
2958
+
2959
+ Element properties are typically passed as a key/value hash (e.g. `section(id: 'main', class: 'accordion')`) . However, for properties like "selected" or "checked", you must leave value `nil` or otherwise pass in front of the hash (e.g. `input(:checked, type: 'checkbox')` )
2960
+
2961
+ Example (basic HTML / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2962
+
2963
+ ```ruby
2964
+ @xml = html {
2965
+ head {
2966
+ meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
2967
+ }
2968
+ body {
2969
+ h1 { "Hello, World!" }
2970
+ }
2971
+ }
2972
+ puts @xml
2973
+ ```
2974
+
2975
+ Output:
2976
+
2977
+ ```
2978
+ <html><head><meta name="viewport" content="width=device-width, initial-scale=2.0" /></head><body><h1>Hello, World!</h1></body></html>
2979
+ ```
2980
+
2981
+ Example (explicit XML tag / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2982
+
2983
+ ```ruby
2984
+ puts tag(:_name => "DOCUMENT")
2985
+ ```
2986
+
2987
+ Output:
2988
+
2989
+ ```
2990
+ <DOCUMENT/>
2991
+ ```
2992
+
2993
+ Example (XML namespaces using `name_space` keyword / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
2994
+
2995
+ ```ruby
2996
+ @xml = name_space(:w3c) {
2997
+ html(:id => "thesis", :class => "document") {
2998
+ body(:id => "main") {
2999
+ }
3000
+ }
3001
+ }
3002
+ puts @xml
3003
+ ```
3004
+
3005
+ Output:
3006
+
3007
+ ```
3008
+ <w3c:html id="thesis" class="document"><w3c:body id="main"></w3c:body></w3c:html>
3009
+ ```
3010
+
3011
+ Example (XML namespaces using dot operator / you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3012
+
3013
+ ```ruby
3014
+ @xml = tag(:_name => "DOCUMENT") {
3015
+ document.body(document.id => "main") {
3016
+ }
3017
+ }
3018
+ puts @xml
3019
+ ```
3020
+
3021
+ Output:
3022
+
3023
+ ```
3024
+ <DOCUMENT><document:body document:id="main"></document:body></DOCUMENT>
3025
+ ```
3026
+
3027
+ ##### CSS
3028
+
3029
+ Simply start with `css` keyword and add stylesheet rule sets inside its block using Glimmer DSL syntax.
3030
+ Once done, you may call `to_s` or `to_css` to get the formatted CSS output.
3031
+
3032
+ `css` is the only top-level keyword in the Glimmer CSS DSL
3033
+
3034
+ Selectors may be specified by `s` keyword or HTML element keyword directly (e.g. `body`)
3035
+ Rule property values may be specified by `pv` keyword or underscored property name directly (e.g. `font_size`)
3036
+
3037
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3038
+
3039
+ ```ruby
3040
+ @css = css {
3041
+ body {
3042
+ font_size '1.1em'
3043
+ pv 'background', 'white'
3044
+ }
3045
+
3046
+ s('body > h1') {
3047
+ background_color :red
3048
+ pv 'font-size', '2em'
3049
+ }
3050
+ }
3051
+ puts @css
3052
+ ```
3053
+
3054
+ ##### Listing / Enabling / Disabling DSLs
3055
+
3056
+ Glimmer provides a number of methods on Glimmer::DSL::Engine to configure DSL support or inquire about it:
3057
+ - `Glimmer::DSL::Engine.dsls`: Lists available Glimmer DSLs
3058
+ - `Glimmer::DSL::Engine.disable_dsl(dsl_name)`: Disables a specific DSL. Useful when there is no need for certain DSLs in a certain application.
3059
+ - `Glimmer::DSL::Engine.disabled_dsls': Lists disabled DSLs
3060
+ - `Glimmer::DSL::Engine.enable_dsl(dsl_name)`: Re-enables disabled DSL
3061
+ - `Glimmer::DSL::Engine.enabled_dsls=(dsl_names)`: Disables all DSLs except the ones specified.
3062
+
3063
+ #### Application Menu Items (About/Preferences)
3064
+
3065
+ Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `display`:
3066
+ - `on_about`: executes code when user selects App Name -> About
3067
+ - `on_preferences`: executes code when user selects App Name -> Preferences or hits 'CMD+,' on the Mac
3068
+
3069
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3070
+
3071
+ ```ruby
3072
+ class Example
3073
+ def initialize
3074
+ display {
3075
+ on_about {
3076
+ message_box(@shell_proxy) {
3077
+ text 'About'
3078
+ message 'About Application'
3079
+ }.open
3080
+ }
3081
+ on_preferences {
3082
+ preferences_dialog = dialog {
3083
+ text 'Preferences'
3084
+ row_layout {
3085
+ type :vertical
3086
+ margin_left 15
3087
+ margin_top 15
3088
+ margin_right 15
3089
+ margin_bottom 15
3090
+ }
3091
+ label {
3092
+ text 'Check one of these options:'
3093
+ }
3094
+ button(:radio) {
3095
+ text 'Option 1'
3096
+ }
3097
+ button(:radio) {
3098
+ text 'Option 2'
3099
+ }
3100
+ }
3101
+ preferences_dialog.open
3102
+ }
3103
+ }
3104
+ @shell_proxy = shell {
3105
+ text 'Application Menu Items'
3106
+ fill_layout {
3107
+ margin_width 15
3108
+ margin_height 15
3109
+ }
3110
+ label {
3111
+ text 'Application Menu Items'
3112
+ font height: 30
3113
+ }
3114
+ }
3115
+ @shell_proxy.open
3116
+ end
3117
+ end
3118
+
3119
+ Example.new
3120
+ ```
3121
+
3122
+ #### App Name and Version
3123
+
3124
+ Application name (shows up on the Mac in top menu bar) and version may be specified upon [packaging](#packaging--distribution) by specifying "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
3125
+
3126
+ Still, if you would like proper application name to show up on the Mac top menu bar during development, you may do so by invoking the SWT Display.setAppName method before any Display object has been instantiated (i.e. before any Glimmer widget like shell has been declared).
3127
+
3128
+ Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3129
+
3130
+ ```ruby
3131
+ Display.setAppName('Glimmer Demo')
3132
+
3133
+ shell(:no_resize) {
3134
+ text "Glimmer"
3135
+ label {
3136
+ text "Hello, World!"
3137
+ }
3138
+ }.open
3139
+ ```
3140
+
3141
+ Also, you may invoke `Display.setAppVersion('1.0.0')` if needed for OS app version identification reasons during development, replacing `'1.0.0'` with your application version.
3142
+
3143
+ #### Video Widget
3144
+
3145
+ [![Video Widget](images/glimmer-video-widget.png)](https://github.com/AndyObtiva/glimmer-cw-video)
3146
+
3147
+ Glimmer supports a [video custom widget](https://github.com/AndyObtiva/glimmer-cw-video) not in SWT.
3148
+
3149
+ You may obtain via `glimmer-cw-video` gem.
3150
+
3151
+ #### Browser Widget
3152
+
3153
+ ![Hello Browser](images/glimmer-hello-browser.png)
3154
+
3155
+ 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).
3156
+
3157
+ Example loading a URL (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3158
+
3159
+ ```ruby
3160
+ shell {
3161
+ minimum_size 1024, 860
3162
+ browser {
3163
+ url 'http://brightonresort.com/about'
3164
+ }
3165
+ }.open
3166
+ ```
3167
+
3168
+ Example rendering HTML with JavaScript on document ready (you may copy/paste in [`girb`](#girb-glimmer-irb-command) provided you install and require [glimmer-dsl-xml gem](https://github.com/AndyObtiva/glimmer-dsl-xml)):
3169
+
3170
+ ```ruby
3171
+ shell {
3172
+ minimum_size 130, 130
3173
+ @browser = browser {
3174
+ text html {
3175
+ head {
3176
+ meta(name: "viewport", content: "width=device-width, initial-scale=2.0")
3177
+ }
3178
+ body {
3179
+ h1 { "Hello, World!" }
3180
+ }
3181
+ }
3182
+ on_completed { # on load of the page execute this JavaScript
3183
+ @browser.swt_widget.execute("alert('Hello, World!');")
3184
+ }
3185
+ }
3186
+ }.open
3187
+ ```
3188
+
3189
+ ##### SWT Browser Style Options
3190
+
3191
+ The `browser` widget can use a particular desktop browser by setting the SWT Style to:
3192
+ - `:webkit`: use the Webkit browser engine
3193
+ - `:chromium`: use the Chromium browser engine
3194
+
3195
+ Example using the Chromium browser (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
3196
+
3197
+ ```ruby
3198
+ shell {
3199
+ minimum_size 1024, 860
3200
+ browser(:chromium) {
3201
+ url 'http://brightonresort.com/about'
3202
+ }
3203
+ }.open
3204
+ ```
3205
+
3206
+ 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).
3207
+
3208
+ ## Glimmer Configuration
3209
+
3210
+ Glimmer configuration may be done via the `Glimmer::Config` module.
3211
+
3212
+ ### logger
3213
+
3214
+ The Glimmer DSL engine supports logging via a standard `STDOUT` Ruby `Logger` configured in the `Glimmer::Config.logger` config option.
3215
+ It is set to level Logger::ERROR by default.
3216
+ Log level may be adjusted via `Glimmer::Config.logger.level` just like any other Ruby Logger.
3217
+
3218
+ Example:
3219
+
3220
+ ```ruby
3221
+ Glimmer::Config.logger.level = :debug
3222
+ ```
3223
+ This results in more verbose debug loggging to `STDOUT`, which is very helpful in troubleshooting Glimmer DSL syntax when needed.
3224
+
3225
+ Example log:
3226
+ ```
3227
+ D, [2017-07-21T19:23:12.587870 #35707] DEBUG -- : method: shell and args: []
3228
+ D, [2017-07-21T19:23:12.594405 #35707] DEBUG -- : ShellCommandHandler will handle command: shell with arguments []
3229
+ D, [2017-07-21T19:23:12.844775 #35707] DEBUG -- : method: composite and args: []
3230
+ D, [2017-07-21T19:23:12.845388 #35707] DEBUG -- : parent is a widget: true
3231
+ D, [2017-07-21T19:23:12.845833 #35707] DEBUG -- : on listener?: false
3232
+ D, [2017-07-21T19:23:12.864395 #35707] DEBUG -- : WidgetCommandHandler will handle command: composite with arguments []
3233
+ D, [2017-07-21T19:23:12.864893 #35707] DEBUG -- : widget styles are: []
3234
+ D, [2017-07-21T19:23:12.874296 #35707] DEBUG -- : method: list and args: [:multi]
3235
+ D, [2017-07-21T19:23:12.874969 #35707] DEBUG -- : parent is a widget: true
3236
+ D, [2017-07-21T19:23:12.875452 #35707] DEBUG -- : on listener?: false
3237
+ D, [2017-07-21T19:23:12.878434 #35707] DEBUG -- : WidgetCommandHandler will handle command: list with arguments [:multi]
3238
+ D, [2017-07-21T19:23:12.878798 #35707] DEBUG -- : widget styles are: [:multi]
3239
+ ```
3240
+
3241
+ The `logger` instance may be replaced with a custom logger via `Glimmer::Config.logger = custom_logger`
3242
+
3243
+ To reset `logger` to the default instance, you may call `Glimmer::Config.reset_logger!`
3244
+
3245
+ All logging is done lazily via blocks (e.g. `logger.debug {message}`) to avoid affecting app performance with logging when below the configured logging level threshold.
3246
+
3247
+ [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) enhances Glimmer default logging support via the Ruby [`logging`](https://github.com/TwP/logging) gem, enabling buffered asynchronous logging in a separate thread, thus completely unhindering normal desktop app performance.
3248
+
3249
+ Other config options related to the [`logging`](https://github.com/TwP/logging) gem are mentioned below.
3250
+
3251
+ #### logging_devices
3252
+
3253
+ This is an array of these possible values: `:stdout` (default), `:stderr`, `:file`, `:syslog` (default), `:stringio`
3254
+
3255
+ It defaults to `[:stdout, :syslog]`
3256
+
3257
+ When `:file` is included, Glimmer creates a 'log' directory directly below the Glimmer app local directory.
3258
+ It may also be customized further via the `logging_device_file_options` option.
3259
+ This is useful on Windows as an alternative to `syslog`, which is not available on Windows by default.
3260
+
3261
+ #### logging_device_file_options
3262
+
3263
+ This is a hash of [`logging`](https://github.com/TwP/logging) gem options for the `:file` logging device.
3264
+
3265
+ Default: `{size: 1_000_000, age: 'daily', roll_by: 'number'}`
3266
+
3267
+ That ensures splitting log files at the 1MB size and daily, rolling them by unique number.
3268
+
3269
+ #### logging_appender_options
3270
+
3271
+ Appender options is a hash passed as options to every appender (logging device) used in the [`logging`](https://github.com/TwP/logging) gem.
3272
+
3273
+ Default: `{async: true, auto_flushing: 500, write_size: 500, flush_period: 60, immediate_at: [:error, :fatal], layout: logging_layout}`
3274
+
3275
+ That ensures asynchronous buffered logging that is flushed every 500 messages and 60 seconds, or immediately at error and fatal log levels
3276
+
3277
+ #### logging_layout
3278
+
3279
+ This is a [`logging`](https://github.com/TwP/logging) gem layout that formats the logging output.
3280
+
3281
+ Default:
3282
+
3283
+ ```
3284
+ Logging.layouts.pattern(
3285
+ pattern: '[%d] %-5l %c: %m\n',
3286
+ date_pattern: '%Y-%m-%d %H:%M:%S'
3287
+ )
3288
+ ```
3289
+
3290
+ ### import_swt_packages
3291
+
3292
+ 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.
3293
+
3294
+ As a result, you may call SWT Java classes from Glimmer Ruby code without mentioning Java package references explicitly.
3295
+
3296
+ For example, `org.eclipse.swt.graphics.Color` can be referenced as just `Color`
3297
+
3298
+ 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:
3299
+ ```
3300
+ org.eclipse.swt.*
3301
+ org.eclipse.swt.widgets.*
3302
+ org.eclipse.swt.layout.*
3303
+ org.eclipse.swt.graphics.*
3304
+ org.eclipse.swt.browser.*
3305
+ org.eclipse.swt.custom.*
3306
+ org.eclipse.swt.dnd.*
3307
+ ```
3308
+
3309
+ 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).
3310
+
3311
+ Example:
3312
+
3313
+ ```ruby
3314
+ Glimmer::Config.import_swt_packages += [
3315
+ 'org.eclipse.nebula.widgets.ganttchart'
3316
+ ]
3317
+ ```
3318
+
3319
+ 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)
3320
+
3321
+ Nonetheless, you can disable automatic Java package import if needed via this Glimmer configuration option:
3322
+
3323
+ ```ruby
3324
+ Glimmer::Config.import_swt_packages = false
3325
+ ```
3326
+
3327
+ Once disabled, to import SWT Java packages manually, you may simply:
3328
+
3329
+ 1. `include Glimmer::SWT::Packages`: lazily imports all SWT Java packages to your class, lazy-loading SWT Java class constants on first reference.
3330
+
3331
+ 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'`)
3332
+
3333
+ 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.
3334
+
3335
+ You can learn more about importing Java packages into Ruby code at this JRuby WIKI page:
3336
+
3337
+ https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
3338
+
3339
+ ### loop_max_count
3340
+
3341
+ Glimmer has infinite loop detection support.
3342
+ It can detect when an infinite loop is about to occur in method_missing and stops it.
3343
+ It detects potential infinite loops when the same keyword and args repeat more than 100 times, which is unusual in a GUI app.
3344
+
3345
+ The max limit can be changed via the `Glimmer::Config::loop_max_count=(count)` config option.
3346
+
3347
+ Infinite loop detection may be disabled altogether if needed by setting `Glimmer::Config::loop_max_count` to `-1`
3348
+
3349
+ ### excluded_keyword_checkers
3350
+
3351
+ Glimmer permits consumers to exclude keywords from DSL processing by its engine via the `excluded_keyword_checkers` config option.
3352
+
3353
+ To do so, add a proc to it that returns a boolean indicating if a keyword is excluded or not.
3354
+
3355
+ Note that this proc runs within the context of the Glimmer object (as in the object mixing in the Glimmer module), so checker can can pretend to run there with its `self` object assumption.
3356
+
3357
+ Example of keywords excluded by [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt):
3358
+
3359
+ ```ruby
3360
+ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
3361
+ method = method_symbol.to_s
3362
+ result = false
3363
+ result ||= method.start_with?('on_swt_') && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
3364
+ result ||= method == 'dispose' && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
3365
+ result ||= ['drag_source_proxy', 'drop_target_proxy'].include?(method) && is_a?(Glimmer::UI::CustomWidget)
3366
+ result ||= method == 'post_initialize_child'
3367
+ result ||= method.end_with?('=')
3368
+ result ||= ['finish_edit!', 'search', 'all_tree_items', 'depth_first_search'].include?(method) && is_a?(Glimmer::UI::CustomWidget) && body_root.respond_to?(method)
3369
+ end
3370
+ ```
3371
+
3372
+ ### log_excluded_keywords
3373
+
3374
+ This just tells Glimmer whether to log excluded keywords or not (at the debug level). It is off by default.
3375
+
3376
+ ## Glimmer Style Guide
3377
+
3378
+ - Widgets are declared with underscored lowercase versions of their SWT names minus the SWT package name.
3379
+ - Widget declarations may optionally have arguments and be followed by a block (to contain properties and content)
3380
+ - Widget blocks are always declared with curly braces
3381
+ - Widget arguments are always wrapped inside parentheses
3382
+ - Widget properties are declared with underscored lowercase versions of the SWT properties
3383
+ - Widget property declarations always have arguments and never take a block
3384
+ - Widget property arguments are never wrapped inside parentheses
3385
+ - Widget listeners are always declared starting with `on_` prefix and affixing listener event method name afterwards in underscored lowercase form
3386
+ - Widget listeners are always followed by a block using curly braces (Only when declared in DSL. When invoked on widget object directly outside of GUI declarations, standard Ruby conventions apply)
3387
+ - Data-binding is done via `bind` keyword, which always takes arguments wrapped in parentheses
3388
+ - Custom widget body, before_body, and after_body blocks open their blocks and close them with curly braces.
3389
+ - 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.
3390
+
3391
+ ## SWT Reference
3392
+
3393
+ https://www.eclipse.org/swt/docs.php
3394
+
3395
+ Here is the SWT API:
3396
+
3397
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/index.html
3398
+
3399
+ Here is a visual list of SWT widgets:
3400
+
3401
+ https://www.eclipse.org/swt/widgets/
3402
+
3403
+ Here is a textual list of SWT widgets:
3404
+
3405
+ https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.isv/guide/swt_widgets_controls.htm?cp=2_0_7_0_0
3406
+
3407
+ Here is a list of SWT style bits as used in widget declaration:
3408
+
3409
+ https://wiki.eclipse.org/SWT_Widget_Style_Bits
3410
+
3411
+ Here is a SWT style bit constant reference:
3412
+
3413
+ https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
3414
+
3415
+ Here is an SWT Drag and Drop guide:
3416
+
3417
+ https://www.eclipse.org/articles/Article-SWT-DND/DND-in-SWT.html
3418
+
3419
+ Here is an SWT Custom Widget guide:
3420
+
3421
+ https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm
3422
+
3423
+ ## Samples
3424
+
3425
+ 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`).
3426
+
3427
+ If you cloned the project and followed [CONTRIBUTING.md](CONTRIBUTING.md) instructions, you may run all samples in [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) at once via `samples/launch` command:
3428
+
3429
+ ```
3430
+ samples/launch
3431
+ ```
3432
+
3433
+ ### Hello Samples
3434
+
3435
+ For hello-type simple samples, check the following.
3436
+
3437
+ #### Hello, World! Sample
3438
+
3439
+ Code:
3440
+
3441
+ [samples/hello/hello_world.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_world.rb)
3442
+
3443
+ Run:
3444
+
3445
+ ```
3446
+ glimmer sample:run[hello_world]
3447
+ ```
3448
+
3449
+ ![Hello World](images/glimmer-hello-world.png)
3450
+
3451
+ #### Hello, Tab!
3452
+
3453
+ Code:
3454
+
3455
+ [samples/hello/hello_tab.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_tab.rb)
3456
+
3457
+ Run:
3458
+
3459
+ ```
3460
+ glimmer sample:run[hello_tab]
3461
+ ```
3462
+
3463
+ ![Hello Tab English](images/glimmer-hello-tab-english.png)
3464
+ ![Hello Tab French](images/glimmer-hello-tab-french.png)
3465
+
3466
+ #### Hello, Combo!
3467
+
3468
+ This sample demonstrates combo data-binding.
3469
+
3470
+ Code:
3471
+
3472
+ [samples/hello/hello_combo.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_combo.rb)
3473
+
3474
+ Run:
3475
+
3476
+ ```
3477
+ glimmer sample:run[hello_combo]
3478
+ ```
3479
+
3480
+ ![Hello Combo](images/glimmer-hello-combo.png)
3481
+ ![Hello Combo Expanded](images/glimmer-hello-combo-expanded.png)
3482
+
3483
+ #### Hello, List Single Selection!
3484
+
3485
+ This sample demonstrates list single-selection data-binding.
3486
+
3487
+ Code:
3488
+
3489
+ [samples/hello/hello_list_single_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_single_selection.rb)
3490
+
3491
+ Run:
3492
+
3493
+ ```
3494
+ glimmer sample:run[hello_list_single_selection]
3495
+ ```
3496
+
3497
+ ![Hello List Single Selection](images/glimmer-hello-list-single-selection.png)
3498
+
3499
+ #### Hello, List Multi Selection!
3500
+
3501
+ This sample demonstrates list multi-selection data-binding.
3502
+
3503
+ Code:
3504
+
3505
+ [samples/hello/hello_list_multi_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_list_multi_selection.rb)
3506
+
3507
+ Run:
3508
+
3509
+ ```
3510
+ glimmer sample:run[hello_list_multi_selection]
3511
+ ```
3512
+
3513
+ ![Hello List Multi Selection](images/glimmer-hello-list-multi-selection.png)
3514
+
3515
+ #### Hello, Computed!
3516
+
3517
+ This sample demonstrates computed data-binding.
3518
+
3519
+ Code:
3520
+
3521
+ [samples/hello/hello_computed.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_computed.rb)
3522
+
3523
+ Run:
3524
+
3525
+ ```
3526
+ glimmer sample:run[hello_computed]
3527
+ ```
3528
+
3529
+ ![Hello Browser](images/glimmer-hello-computed.png)
3530
+
3531
+ #### Hello, Message Box!
3532
+
3533
+ This sample demonstrates a `message_box` dialog.
3534
+
3535
+ Code:
3536
+
3537
+ [samples/hello/hello_message_box.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_message_box.rb)
3538
+
3539
+ Run:
3540
+
3541
+ ```
3542
+ glimmer sample:run[hello_message_box]
3543
+ ```
3544
+
3545
+ ![Hello Message Box](images/glimmer-hello-message-box.png)
3546
+ ![Hello Message Box Dialog](images/glimmer-hello-message-box-dialog.png)
3547
+
3548
+ #### Hello, Browser!
3549
+
3550
+ This sample demonstrates the `browser` widget.
3551
+
3552
+ Code:
3553
+
3554
+ [samples/hello/hello_browser.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_browser.rb)
3555
+
3556
+ Run:
3557
+
3558
+ ```
3559
+ glimmer sample:run[hello_browser]
3560
+ ```
3561
+
3562
+ ![Hello Browser](images/glimmer-hello-browser.png)
3563
+
3564
+ #### Hello, Drag and Drop!
3565
+
3566
+ This sample demonstrates drag and drop in Glimmer.
3567
+
3568
+ Code:
3569
+
3570
+ [samples/hello/hello_drag_and_drop.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_drag_and_drop.rb)
3571
+
3572
+ Run:
3573
+
3574
+ ```
3575
+ glimmer sample:run[hello_drag_and_drop]
3576
+ ```
3577
+
3578
+ ![Hello Drag and Drop](images/glimmer-hello-drag-and-drop.gif)
3579
+
3580
+ #### Hello, Menu Bar!
3581
+
3582
+ This sample demonstrates menus in Glimmer.
3583
+
3584
+ Code:
3585
+
3586
+ [samples/hello/hello_menu_bar.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_menu_bar.rb)
3587
+
3588
+ Run:
3589
+
3590
+ ```
3591
+ glimmer sample:run[hello_menu_bar]
3592
+ ```
3593
+
3594
+ ![Hello Menu Bar](images/glimmer-hello-menu-bar.png)
3595
+ ![Hello Menu Bar File Menu](images/glimmer-hello-menu-bar-file-menu.png)
3596
+ ![Hello Menu Bar History Menu](images/glimmer-hello-menu-bar-history-menu.png)
3597
+
3598
+ #### Hello, Pop Up Context Menu!
3599
+
3600
+ This sample demonstrates pop up context menus in Glimmer.
3601
+
3602
+ Code:
3603
+
3604
+ [samples/hello/hello_pop_up_context_menu.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_pop_up_context_menu.rb)
3605
+
3606
+ Run:
3607
+
3608
+ ```
3609
+ glimmer sample:run[hello_pop_up_context_menu]
3610
+ ```
3611
+
3612
+ ![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
3613
+ ![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
3614
+
3615
+ ### Elaborate Samples
3616
+
3617
+ For more elaborate samples, check the following:
3618
+
3619
+ #### User Profile
3620
+
3621
+ This sample was used in the [DZone Article about Glimmer](https://dzone.com/articles/an-introduction-glimmer), demonstrating Glimmer widgets in general.
3622
+
3623
+ Please note that the code has changed since that article was written (the GUI DSL has been improved/simplified), so use the code sample mentioned here instead as the correct version.
3624
+
3625
+ Code:
3626
+
3627
+ [samples/elaborate/user_profile.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/user_profile.rb)
3628
+
3629
+ Run:
3630
+
3631
+ ```
3632
+ glimmer sample:run[user_profile]
3633
+ ```
3634
+
3635
+ ![User Profile](images/glimmer-user-profile.png)
3636
+
3637
+ #### Login
3638
+
3639
+ This sample demonstrates basic data-binding, password and text fields, and field enablement data-binding.
3640
+
3641
+ Code:
3642
+
3643
+ [samples/elaborate/login.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/login.rb)
3644
+
3645
+ Run:
3646
+
3647
+ ```
3648
+ glimmer sample:run[login]
3649
+ ```
3650
+
3651
+ ![Login](images/glimmer-login.png)
3652
+ ![Login Filled In](images/glimmer-login-filled-in.png)
3653
+ ![Login Logged In](images/glimmer-login-logged-in.png)
3654
+
3655
+ #### Tic Tac Toe Sample
3656
+
3657
+ This sample demonstrates a full MVC application, including GUI layout, text and enablement data-binding, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/tic_tac_toe/board_spec.rb)).
3658
+
3659
+ Code:
3660
+
3661
+ (Please note that on some Linux instances where the display x-axis is set to double-scale, you need to set the `shell` `minimum_size` to `300, 178` instead of `150, 178`)
3662
+
3663
+ [samples/elaborate/tic_tac_toe.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/tic_tac_toe.rb)
3664
+
3665
+ Run:
3666
+
3667
+ ```
3668
+ glimmer sample:run[tic_tac_toe]
3669
+ ```
3670
+
3671
+ ![Tic Tac Toe](images/glimmer-tic-tac-toe.png)
3672
+ ![Tic Tac Toe In Progress](images/glimmer-tic-tac-toe-in-progress.png)
3673
+ ![Tic Tac Toe Game Over](images/glimmer-tic-tac-toe-game-over.png)
3674
+
3675
+ #### Contact Manager Sample
3676
+
3677
+ This sample demonstrates table data-binding, sorting, filtering, GUI layout, MVP pattern, and test-driven development (has [specs](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/spec/samples/elaborate/contact_manager/contact_manager_presenter_spec.rb)).
3678
+
3679
+ Code:
3680
+
3681
+ [samples/elaborate/contact_manager.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/elaborate/contact_manager.rb)
3682
+
3683
+ Run:
3684
+
3685
+ ```
3686
+ glimmer sample:run[contact_manager]
3687
+ ```
3688
+
3689
+ Contact Manager
3690
+
3691
+ ![Contact Manager](images/glimmer-contact-manager.png)
3692
+
3693
+ Contact Manager - Find
3694
+
3695
+ ![Contact Manager](images/glimmer-contact-manager-find.png)
3696
+
3697
+ Contact Manager - Edit Started
19
3698
 
20
- ## Example
3699
+ ![Contact Manager](images/glimmer-contact-manager-edit-started.png)
3700
+
3701
+ Contact Manager - Edit In Progress
3702
+
3703
+ ![Contact Manager](images/glimmer-contact-manager-edit-in-progress.png)
3704
+
3705
+ Contact Manager - Edit Done
3706
+
3707
+ ![Contact Manager](images/glimmer-contact-manager-edit-done.png)
3708
+
3709
+ ### External Samples
3710
+
3711
+ #### Glimmer Calculator
3712
+
3713
+ [<img alt="Glimmer Calculator Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-icon.png" height=40 /> Glimmer Calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) is a basic calculator sample app demonstrating data-binding and TDD (test-driven-development) with Glimmer following the MVP pattern (Model-View-Presenter).
3714
+
3715
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-calculator/master/glimmer-cs-calculator-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-calculator)
3716
+
3717
+ #### Gladiator
3718
+
3719
+ [<img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=40 /> Gladiator](https://github.com/AndyObtiva/glimmer-cs-gladiator) (short for Glimmer Editor) is a Glimmer sample project under on-going development.
3720
+ You may check it out to learn how to build a Glimmer Custom Shell gem.
3721
+
3722
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-gladiator.png" />](https://github.com/AndyObtiva/glimmer-cs-gladiator)
3723
+
3724
+ Gladiator is a good demonstration of:
3725
+ - MVP Pattern
3726
+ - Tree data-binding
3727
+ - List data-binding
3728
+ - Text selection data-binding
3729
+ - Tabs
3730
+ - Context menus
3731
+ - Custom Shell
3732
+ - Custom widget
3733
+
3734
+ #### Timer
3735
+
3736
+ [<img alt="Glimmer Timer Icon" src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Timer](https://github.com/AndyObtiva/glimmer-cs-timer) is a sample app demonstrating data-binding and multi-threading in a desktop application.
3737
+
3738
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
3739
+
3740
+ ## In Production
3741
+
3742
+ The following production apps have been built with Glimmer.
3743
+
3744
+ If you have a Glimmer app you would like referenced here, please mention in a Pull Request.
3745
+
3746
+ ### Math Bowling
3747
+
3748
+ [<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
3749
+
3750
+ ### Are We There Yet?
3751
+
3752
+ [<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
3753
+
3754
+ ### Garderie Rainbow Daily Agenda
3755
+
3756
+ [<img alt="Garderie Rainbow Daily Agenda Logo" src="https://github.com/AndyObtiva/garderie_rainbow_daily_agenda/raw/master/images/garderie_rainbow_daily_agenda_logo.png" width="40" />Garderie Rainbow Daily Agenda](https://github.com/AndyObtiva/garderie_rainbow_daily_agenda): A child nursery daily agenda reporting desktop app
3757
+
3758
+ ## Packaging & Distribution
3759
+
3760
+ Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
3761
+
3762
+ ```
3763
+ glimmer package
3764
+ ```
3765
+
3766
+ It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating all available packaging types on the current platform (e.g. `DMG`, `PKG`, `APP` on the Mac) and displaying a message indicating what pre-requisite setup tools are needed if not installed already (e.g. [Wix Toolset](https://wixtoolset.org/) to generate MSI files on Windows)
3767
+
3768
+ You may choose to generate a specific type of packaging instead by addionally passing in the `[type]` option. For example, this generates an MSI setup file on Windows:
3769
+
3770
+ ```
3771
+ glimmer package[msi]
3772
+ ```
3773
+
3774
+ - Available Mac packaging types are `dmg`, `pkg`, and `image` (image means a pure Mac `app` without a setup program)
3775
+ - Available Windows packaging types are `msi`, `exe`, and `image` (image means a Windows application directory without a setup program). Learn more about Windows packaging are [over here](#windows-application-packaging).
3776
+
3777
+ Note: if you are using Glimmer manually, to make the `glimmer package` command available, you must add the following line to your application `Rakefile` (automatically done for you if you scaffold an app or gem with `glimmer scaffold[AppName]` or `glimmer scaffold:gem:customshell[GemName]`):
21
3778
 
22
3779
  ```ruby
23
- include Glimmer
24
-
25
- shell {
26
- text 'Glimmer'
27
- label {
28
- text 'Hello, World!'
29
- }
30
- }.open
3780
+ require 'glimmer/rake_task'
3781
+ ```
3782
+
3783
+ The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
3784
+ 1. Generate gemspec via Jeweler (`rake gemspec:generate`): Having a gemspec is required by the [`jar-dependencies`](https://github.com/mkristian/jar-dependencies) JRuby gem, used by JRuby libraries to declare JAR dependencies.
3785
+ 1. Lock JAR versions (`glimmer package:lock_jars`): This locks versions of JAR dependencies leveraged by the `jar-dependencies` JRuby gem, downloading them into the `./vendor` directory so they would get inside the top-level Glimmer app/gem JAR file.
3786
+ 1. Generate [Warbler](https://github.com/jruby/warbler) config (`glimmer package:config`): Generates initial Warbler config file (under `./config/warble.rb`) to use for generating JAR file.
3787
+ 1. Generate JAR file using [Warbler](https://github.com/jruby/warbler) (`glimmer package:jar`): Enables bundling a Glimmer app into a JAR file under the `./dist` directory
3788
+ 1. Generate native executable using [javapackager](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html) (`glimmer package:native`): Enables packaging a JAR file as a DMG/PKG/APP file on Mac, MSI/EXE/APP on Windows, and DEB/RPM/APP on Linux (Glimmer does not officially support Linux with the `glimmer package` command yet, but it generates the JAR file successfully, and you could use `javapackager` manually afterwards if needed).
3789
+
3790
+ Those steps automatically ensure generating a JAR file under the `./dist` directory using [Warbler](https://github.com/jruby/warbler), which is then used to automatically generate a DMG/MSI file (and other executables) under the `./packages/bundles` directory using `javapackager`.
3791
+ The JAR file name will match your application local directory name (e.g. `MathBowling.jar` for `~/code/MathBowling`)
3792
+ The DMG file name will match the humanized local directory name + dash + application version (e.g. `Math Bowling-1.0.dmg` for `~/code/MathBowling` with version 1.0 or unspecified)
3793
+
3794
+ The `glimmer package` command will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
3795
+ You may override by configuring as an extra argument for javapackger (e.g. Glimmer::RakeTask::Package.javapackager_extra_args = " -Bmac.CFBundleIdentifier=org.andymaleh.application.MathBowling")
3796
+
3797
+ ### Packaging Defaults
3798
+
3799
+ Glimmer employs smart defaults in packaging.
3800
+
3801
+ The package application name (shows up in top menu bar on the Mac) will be a human form of the app root directory name (e.g. "Math Bowling" for "MathBowling" or "math_bowling" app root directory name). However, application name and version may be specified explicitly via "-Bmac.CFBundleName" and "-Bmac.CFBundleVersion" options.
3802
+
3803
+ Also, the package will only include these directories: app, config, db, lib, script, bin, docs, fonts, images, sounds, videos
3804
+
3805
+ After running once, you will find a `config/warble.rb` file. It has the JAR packaging configuration. You may adjust included directories in it if needed, and then rerun `glimmer package` and it will pick up your custom configuration. Alternatively, if you'd like to customize the included directories to begin with, don't run `glimmer package` right away. Run this command first:
3806
+
3807
+ ```
3808
+ glimmer package:config
3809
+ ```
3810
+
3811
+ This will generate `config/warble.rb`, which you may configure and then run `glimmer package` afterwards.
3812
+
3813
+ ### Packaging Configuration
3814
+
3815
+ - Ensure you have a Ruby script under `bin` directory that launches the application, preferably matching your project directory name (e.g. `bin/math_bowling`) :
3816
+ ```ruby
3817
+ require_relative '../app/my_application.rb'
3818
+ ```
3819
+ - Include Icon (Optional): If you'd like to include an icon for your app (.icns format on the Mac), place it under `package/macosx` matching the humanized application local directory name (e.g. 'Math Bowling.icns' [containing space] for MathBowling or math_bowling). You may generate your Mac icon easily using tools like Image2Icon (http://www.img2icnsapp.com/) or manually using the Mac terminal command `iconutil` (iconutil guide: https://applehelpwriter.com/tag/iconutil/)
3820
+ - Include DMG Background Icon (Optional): Simply place a .png file under `package/macosx/{HumanAppName}-background.png`
3821
+ - Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
3822
+ - Include License (Optional): Create a `LICENSE.txt` file in your application and fill it up with your license (e.g. MIT). It will show up to people when installing your app. Note that, you may optionally also specify license type, but you'd have to do so manually via `-BlicenseType=MIT` shown in an [example below](#javapackager-extra-arguments).
3823
+ - Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for javapackager: `Glimmer::RakeTask::Package.javapackager_extra_args = "..."` (Useful to avoid re-entering extra arguments on every run of rake task.). Read about them in [their section below](#javapackager-extra-arguments).
3824
+
3825
+ ### javapackager Extra Arguments
3826
+
3827
+ In order to explicitly configure javapackager, Mac package attributes, or sign your Mac app to distribute on the App Store, you can follow more advanced instructions for `javapackager` here:
3828
+ - https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
3829
+ - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html
3830
+ - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGICFDB
3831
+ - https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html
3832
+ - https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
3833
+
3834
+ The Glimmer rake task allows passing extra options to javapackager via:
3835
+ - `Glimmer::RakeTask::Package.javapackager_extra_args="..."` in your application Rakefile
3836
+ - Environment variable: `JAVAPACKAGER_EXTRA_ARGS`
3837
+
3838
+ Example (Rakefile):
3839
+
3840
+ ```ruby
3841
+ require 'glimmer/rake_task'
3842
+
3843
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
3844
+ ```
3845
+
3846
+ Note that `mac.category` defaults to "public.app-category.business", but can be overridden with one of the category UTI values mentioned here:
3847
+
3848
+ https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
3849
+
3850
+ Example (env var):
3851
+
3852
+ ```
3853
+ JAVAPACKAGER_EXTRA_ARGS='-Bmac.CFBundleName="Math Bowling Game"' glimmer package
3854
+ ```
3855
+
3856
+ That overrides the default application display name.
3857
+
3858
+ ### Verbose Mode
3859
+
3860
+ Pass `-v` to javapackager in `Glimmer::RakeTask::Package.javapackager_extra_args` or by running `glimmer package:native[type] -v` to learn more about further available customizations for the installer you are requesting to generate.
3861
+
3862
+ ### Windows Application Packaging
3863
+
3864
+ Windows offers two options for setup packaging:
3865
+ - `msi` (recommended): simpler packaging option. Requires [WiX Toolset](https://wixtoolset.org/) and [.NET Framework](https://dotnet.microsoft.com/download/dotnet-framework). Simply run `glimmer package[msi]` (or `glimmer package:native[msi]` if it's not your first time) and it will give you more details on the pre-requisites you need to install (e.g. [WiX Toolset](https://wixtoolset.org/) and [.NET Framework 3.5 SP1](https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1)).
3866
+ - `exe`: more advanced packaging option. Requires [Inno Setup](https://jrsoftware.org/isinfo.php). Simply run `glimmer package[exe]` (or `glimmer package:native[exe]` if it's not your first time) and it will tell you what you need to install.
3867
+
3868
+ If you just want to test out packaging into a native Windows app that is not packaged for Windows setup, just pass `image` to generate a native Windows app only.
3869
+
3870
+ ### Mac Application Distribution
3871
+
3872
+ Recent macOS versions (starting with Catalina) have very stringent security requirements requiring all applications to be signed before running (unless the user goes to System Preferences -> Privacy -> General tab and clicks "Open Anyway" after failing to open application the first time they run it). So, to release a desktop application on the Mac, it is recommended to enroll in the [Apple Developer Program](https://developer.apple.com/programs/) to distribute on the [Mac App Store](https://developer.apple.com/distribute/) or otherwise request [app notarization from Apple](https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution) to distribute independently.
3873
+
3874
+ Afterwards, you may add developer-id/signing-key arguments to `javapackager` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
3875
+
3876
+ DMG signing key argument:
3877
+ ```
3878
+ -Bmac.signing-key-developer-id-app="..."
3879
+ ```
3880
+
3881
+ PKG signing key argument:
3882
+ ```
3883
+ -Bmac.signing-key-developer-id-installer="..."
3884
+ ```
3885
+
3886
+ Mac App Store signing key arguments:
3887
+ ```
3888
+ -Bmac.signing-key-app="..."
3889
+ -Bmac.signing-key-pkg="..."
3890
+ ```
3891
+
3892
+ ### Self Signed Certificate
3893
+
3894
+ You may still release a signed DMG file without enrolling into the Apple Developer Program with the caveat that users will always fail in opening the app the first time, and have to go to System Preferences -> Privacy -> General tab to "Open Anyway".
3895
+
3896
+ To do so, you may follow these steps (abbreviated version from https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2):
3897
+ - Open Keychain Access
3898
+ - Choose Keychain Access > Certificate Assistant > Create Certificate ...
3899
+ - Enter Name (referred to below as "CertificateName")
3900
+ - Set 'Certificate Type' to 'Code Signing'
3901
+ - Create (if you alternatively override defaults, make sure to enable all capabilities)
3902
+ - Add the following option to javapackager: `-Bmac.signing-key-developer-id-app="CertificateName"` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS`
3903
+
3904
+ Example:
3905
+
3906
+ ```ruby
3907
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
31
3908
  ```
32
3909
 
33
- ![Glimmer DSL for SWT Hello World](https://github.com/AndyObtiva/glimmer/blob/master/images/glimmer-hello-world.png)
3910
+ Now, when you run `glimmer package`, it builds a self-signed DMG file. When you make available online, and users download, upon launching application, they are presented with your certificate, which they have to sign if they trust you in order to use the application.
34
3911
 
35
- Learn more at the main [Glimmer project page](https://github.com/AndyObtiva/glimmer).
3912
+ ### Gotchas
3913
+
3914
+ 1. Specifying License File
3915
+
3916
+ The javapackager documentation states that a license file may be specified with "-BlicenseFile" javapackager option. However, in order for that to work, one must specify as a source file via "-srcfiles" javapackager option.
3917
+ Keep that in mind if you are not going to rely on the default `LICENSE.txt` support.
3918
+
3919
+ Example:
3920
+
3921
+ ```ruby
3922
+ Glimmer::RakeTask::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="ACME.txt" -BlicenseType="ACME"'
3923
+ ```
3924
+
3925
+ 2. Mounted DMG Residue
3926
+
3927
+ If you run `glimmer package` multiple times, sometimes it leaves a mounted DMG project in your finder. Unmount before you run the command again or it might fail with an error saying: "Error: Bundler "DMG Installer" (dmg) failed to produce a bundle."
3928
+
3929
+ By the way, keep in mind that during normal operation, it does also indicate a false-negative while completing successfully similar to the following (please ignore):
3930
+
3931
+ ```
3932
+ Exec failed with code 2 command [[/usr/bin/SetFile, -c, icnC, /var/folders/4_/g1sw__tx6mjdgyh3mky7vydc0000gp/T/fxbundler4076750801763032201/images/MathBowling/.VolumeIcon.icns] in unspecified directory
3933
+ ```
3934
+
3935
+ ## App Updates
3936
+
3937
+ Glimmer already supports automatic (and manual) app updates via the Mac App Store for Mac apps. Simply run the `glimmer package` command with the Mac App Store keys configured as per [Mac Application Distribution](mac-application-distribution) instructions and you get automatic (and manual) app update support courtesy of the Mac App Store.
3938
+
3939
+ ## Glimmer Supporting Libraries
3940
+
3941
+ Here is a list of notable 3rd party gems used by Glimmer:
3942
+ - [jeweler](https://github.com/technicalpickles/jeweler): generates app gems during [Glimmer Scaffolding](#scaffolding)
3943
+ - [logging](https://github.com/TwP/logging): provides extra logging capabilities not available in Ruby Logger such as multi-threaded buffered asynchronous logging (to avoid affecting app performance) and support for multiple appenders such as stdout, syslog, and log files (the last one is needed on Windows where syslog is not supported)
3944
+ - [nested_inherited_jruby_include_package](https://github.com/AndyObtiva/nested_inherited_jruby_include_package): makes included [SWT](https://www.eclipse.org/swt/)/[Java](https://www.java.com/en/) packages available to all classes/modules that mix in the Glimmer module without having to manually reimport
3945
+ - [os](https://github.com/rdp/os): provides OS detection capabilities (e.g. `OS.mac?` or `OS.windows?`) to write cross-platform code inexpensively
3946
+ - [puts_debuggerer](https://github.com/AndyObtiva/puts_debuggerer): helps in troubleshooting when adding `require 'pd'` and using the `pd` command instead of `puts` or `p` (also `#pd_inspect` or `#pdi` instead of `#inspect`)
3947
+ - [rake](https://github.com/ruby/rake): used to implement and execute `glimmer` commands
3948
+ - [rake-tui](https://github.com/AndyObtiva/rake-tui): Rake Text-based User Interface. Allows navigating rake tasks with arrow keys and filtering task list by typing to quickly find an run a rake task.
3949
+ - [super_module](https://github.com/AndyObtiva/super_module): used to cleanly write the Glimmer::UI:CustomWidget and Glimmer::UI::CustomShell modules
3950
+ - [text-table](https://github.com/aptinio/text-table): renders textual data in a textual table for the command-line interface of Glimmer
3951
+ - [warbler](https://github.com/jruby/warbler): converts a Glimmer app into a Java JAR file during packaging
3952
+
3953
+ ## Glimmer Process
3954
+
3955
+ [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) is the lightweight software development process used for building Glimmer libraries and Glimmer apps, which goes beyond Agile, rendering all Agile processes obsolete. [Glimmer Process](PROCESS.md) is simply made up of 7 guidelines to pick and choose as necessary until software development needs are satisfied.
3956
+
3957
+ Learn more by reading the [GPG](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md) (Glimmer Process Guidelines)
3958
+
3959
+ ## Resources
3960
+
3961
+ * [Code Master Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
3962
+ * [JRuby Cookbook by Justin Edelson & Henry Liu](http://shop.oreilly.com/product/9780596519650.do)
3963
+ * [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
3964
+ * [DZone Tutorial](https://dzone.com/articles/an-introduction-glimmer)
3965
+ * [MountainWest RubyConf 2011 Video](https://confreaks.tv/videos/mwrc2011-whatever-happened-to-desktop-development-in-ruby)
3966
+ * [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
36
3967
 
37
3968
  ## Help
38
3969
 
39
3970
  ### Issues
40
3971
 
41
- You may submit [issues](https://github.com/AndyObtiva/glimmer/issues) on [GitHub](https://github.com/AndyObtiva/glimmer/issues).
3972
+ You may submit [issues](https://github.com/AndyObtiva/glimmer-dsl-swt/issues) on [GitHub](https://github.com/AndyObtiva/glimmer-dsl-swt/issues).
42
3973
 
43
- [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
3974
+ [Click here to submit an issue.](https://github.com/AndyObtiva/glimmer-dsl-swt/issues)
44
3975
 
45
3976
  ### Chat
46
3977
 
47
- If you need live help, try to [![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)
3978
+ If you need live help, try to [![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)
48
3979
 
49
3980
  ## Feature Suggestions
50
3981
 
@@ -52,26 +3983,46 @@ These features have been suggested. You might see them in a future version of Gl
52
3983
 
53
3984
  [TODO.md](TODO.md)
54
3985
 
3986
+ Glimmer DSL Engine specific tasks are at:
3987
+
3988
+ [glimmer/TODO.md](https://github.com/AndyObtiva/glimmer/blob/master/TODO.md)
3989
+
55
3990
  ## Change Log
56
3991
 
57
3992
  [CHANGELOG.md](CHANGELOG.md)
58
3993
 
3994
+ Also: [glimmer/CHANGELOG.md](https://github.com/AndyObtiva/glimmer/blob/master/CHANGELOG.md)
3995
+
59
3996
  ## Contributing
60
3997
 
3998
+ **Contributors Wanted!**
3999
+
4000
+ 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 (perhaps from [this TODO list](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/TODO.md#samples)) 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).
4001
+
4002
+ You may apply for contributing to any of these Glimmer DSL gems whether you prefer to focus on the desktop or web:
4003
+ - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
4004
+ - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
4005
+ - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
4006
+ - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
4007
+
61
4008
  [CONTRIBUTING.md](CONTRIBUTING.md)
62
4009
 
63
4010
  ## Contributors
64
4011
 
65
4012
  * [Andy Maleh](https://github.com/AndyObtiva) (Founder)
4013
+ * [Dennis Theisen](https://github.com/Soleone) (Contributor, originally in [Glimmer](https://github.com/AndyObtiva/glimmer/graphs/contributors) before splitting glimmer-dsl-swt)
66
4014
 
67
4015
  [Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-swt/graphs/contributors)
68
4016
 
4017
+ ## Hire Me
4018
+
4019
+ 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/).
4020
+
69
4021
  ## License
70
4022
 
71
- [MIT](https://opensource.org/licenses/MIT)
4023
+ [MIT](LICENSE.txt)
72
4024
 
73
- Copyright (c) 2020 - Andy Maleh.
74
- See [LICENSE.txt](LICENSE.txt) for further details.
4025
+ Copyright (c) 2007-2020 - Andy Maleh.
75
4026
 
76
4027
  --
77
4028