glimmer-dsl-swt 4.17.0.0 → 4.17.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +167 -45
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +187 -0
- data/lib/ext/glimmer/config.rb +0 -5
- data/lib/glimmer-dsl-swt.rb +6 -0
- data/lib/glimmer/launcher.rb +16 -11
- data/lib/glimmer/rake_task.rb +45 -85
- data/lib/glimmer/rake_task/list.rb +4 -1
- data/lib/glimmer/rake_task/package.rb +128 -0
- data/lib/glimmer/rake_task/sample.rb +115 -0
- data/lib/glimmer/rake_task/scaffold.rb +661 -0
- data/lib/glimmer/swt/shell_proxy.rb +1 -0
- data/lib/glimmer/swt/widget_proxy.rb +3 -0
- data/lib/glimmer/ui/custom_widget.rb +8 -4
- data/lib/glimmer/util/proc_tracker.rb +2 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +3 -99
- data/samples/hello/hello_browser.rb +1 -1
- data/samples/hello/hello_combo.rb +10 -6
- data/samples/hello/hello_custom_shell.rb +155 -0
- data/samples/hello/hello_custom_widget.rb +86 -0
- data/samples/hello/hello_tab.rb +10 -5
- data/samples/hello/hello_world.rb +2 -2
- metadata +52 -62
- data/lib/glimmer/package.rb +0 -112
- data/lib/glimmer/scaffold.rb +0 -652
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7523b15b5a850c249c3aff9ad499861ee10ecd051de1084221fbbe456237330
|
4
|
+
data.tar.gz: 5ac2fcb76137fe377268c8f38fd09f37fe94193351629213a30d1cc8b4b4707b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf5035466675f7cb5b3151950c7d244a6deda09c0e0a0a7b516ca6a67a673f371377f706ec8377db62c0e1eb5a983789ac1e4e3627a660ba88322596af72388
|
7
|
+
data.tar.gz: 14a95141c001e279b305cee7ed90295bc620e1bb08fa897f5e72b90dc283d50abc242b7c71896d65c6c981de6785ab69f2d94c927c5fdc5320e793541f97d1fb
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,42 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 4.17.2.2
|
4
|
+
|
5
|
+
- Small updates/refactorings in samples
|
6
|
+
- Fix issue with displaying `glimmer` command tasks on Windows
|
7
|
+
|
8
|
+
### 4.17.2.1
|
9
|
+
|
10
|
+
- Add `--bundler=group` option to `glimmer` command
|
11
|
+
- Add `--pd` option to `glimmer` command
|
12
|
+
- Hello, Custom Widget! sample
|
13
|
+
- Hello, Custom Shell! sample
|
14
|
+
|
15
|
+
### 4.17.2.0
|
16
|
+
|
17
|
+
- `glimmer` command --bundler option to run with bundler/setup (instead of picking gems directly)
|
18
|
+
- Remove Gemfile dependency on Juwelier since it does not relate to GUI (delaying install of it till scaffolding)
|
19
|
+
- Remove Gemfile dependency on Warbler since it does not relate to GUI (delaying install of it till packaging)
|
20
|
+
- Move Package and Scaffold classes under Glimmer::RakeTask (Glimmer::Package.javapackager_extra_args is now Glimmer::RakeTask::Package.javapackager_extra_args)
|
21
|
+
- Fixed issue with scaffolding spec/spec_helper.rb with Juwelier (since it changed from Jeweler)
|
22
|
+
|
23
|
+
### 4.17.1.1
|
24
|
+
|
25
|
+
- Fixed issue with showing glimmer command tasks twice
|
26
|
+
|
27
|
+
### 4.17.1.0
|
28
|
+
|
29
|
+
- Switch to Juwelier gem (from Jeweler)
|
30
|
+
- Load samples from Glimmer gems automatically (no need for configuration)
|
31
|
+
- Empty body validation in CustomWidget (and CustomShell by inheritance)
|
32
|
+
- require 'bundler/setup' in `glimmer` command if a `Gemfile` is present (disabled with GLIMMER_BUNDLER_SETUP=false env var)
|
33
|
+
- Upgrade to rvm-tui version 0.2.2
|
34
|
+
|
3
35
|
### 4.17.0.0
|
4
36
|
|
5
37
|
- Upgrade to SWT (Standard Widget Toolkit) 4.17 and sync version with SWT going forward
|
6
38
|
- Upgrade to Glimmer (DSL Engine) 1.0.0
|
39
|
+
- Sync version number with the SWT version number (first two numbers, leaving the last two as minor and patch)
|
7
40
|
|
8
41
|
### 0.6.9
|
9
42
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 4.17.
|
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.2
|
2
2
|
## JRuby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
4
4
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
@@ -10,11 +10,9 @@
|
|
10
10
|
|
11
11
|
(The Original Glimmer Library Since 2007. Beware of Imitators!)
|
12
12
|
|
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/)
|
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/), MSI/EXE files on [Windows](https://www.microsoft.com/en-ca/windows), and [Gem Packaged Shell Scripts](#custom-shell-gem) on [Linux](https://www.linux.org/).
|
14
14
|
|
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.
|
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. Please make [Glimmer](https://rubygems.org/gems/glimmer) even better by providing feedback and [contributing](#contributing) when possible.
|
18
16
|
|
19
17
|
[<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
|
20
18
|
Featured in<br />JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do)
|
@@ -335,6 +333,8 @@ Glimmer App:
|
|
335
333
|
- [Hello, Drag and Drop!](#hello-drag-and-drop)
|
336
334
|
- [Hello, Menu Bar!](#hello-menu-bar)
|
337
335
|
- [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
|
336
|
+
- [Hello, Custom Widget!](#hello-custom-widget)
|
337
|
+
- [Hello, Custom Shell!](#hello-custom-shell)
|
338
338
|
- [Elaborate Samples](#elaborate-samples)
|
339
339
|
- [User Profile](#user-profile)
|
340
340
|
- [Login](#login)
|
@@ -416,6 +416,8 @@ If you intend to build a Glimmer app from scratch with [scaffolding](#scaffoldin
|
|
416
416
|
|
417
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
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 install a previous version instead from the list of [Glimmer Releases](https://rubygems.org/gems/glimmer-dsl-swt/versions).
|
420
|
+
|
419
421
|
### Option 1: Direct Install
|
420
422
|
(Use for [Scaffolding](#scaffolding))
|
421
423
|
|
@@ -426,7 +428,7 @@ jgem install glimmer-dsl-swt
|
|
426
428
|
|
427
429
|
Or this command if you want a specific version:
|
428
430
|
```
|
429
|
-
jgem install glimmer-dsl-swt -v 4.17.
|
431
|
+
jgem install glimmer-dsl-swt -v 4.17.2.2
|
430
432
|
```
|
431
433
|
|
432
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.
|
@@ -446,7 +448,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
|
|
446
448
|
|
447
449
|
Add the following to `Gemfile`:
|
448
450
|
```
|
449
|
-
gem 'glimmer-dsl-swt', '~> 4.17
|
451
|
+
gem 'glimmer-dsl-swt', '~> 4.17'
|
450
452
|
```
|
451
453
|
|
452
454
|
And, then run:
|
@@ -474,6 +476,8 @@ On Windows, it simply lists the available Glimmer tasks at the end (courtsey of
|
|
474
476
|
|
475
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).
|
476
478
|
|
479
|
+
Note: If you encounter an issue running the `glimmer` command, run `bundle exec glimmer` instead.
|
480
|
+
|
477
481
|
### Basic Usage
|
478
482
|
|
479
483
|
```
|
@@ -501,9 +505,9 @@ bin/glimmer sample:run[hello_world]
|
|
501
505
|
Below are the full usage instructions that come up when running `glimmer` without args.
|
502
506
|
|
503
507
|
```
|
504
|
-
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.
|
508
|
+
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v4.17.2.2
|
505
509
|
|
506
|
-
Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
510
|
+
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
507
511
|
|
508
512
|
Runs Glimmer applications and tasks.
|
509
513
|
|
@@ -513,7 +517,9 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
|
|
513
517
|
Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
|
514
518
|
|
515
519
|
Glimmer options:
|
516
|
-
- "--
|
520
|
+
- "--bundler=GROUP" : Activates gems in Bundler default group in Gemfile
|
521
|
+
- "--pd=BOOLEAN" : Requires puts_debuggerer to enable pd method
|
522
|
+
- "--quiet=BOOLEAN" : Does not announce file path of Glimmer application being launched
|
517
523
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
518
524
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
519
525
|
|
@@ -614,7 +620,7 @@ This will run the hello_tab sample and output its code:
|
|
614
620
|
```
|
615
621
|
$ glimmer sample:run[hello_tab]
|
616
622
|
|
617
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.
|
623
|
+
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/hello/hello_tab.rb
|
618
624
|
|
619
625
|
class HelloTab
|
620
626
|
include Glimmer
|
@@ -659,7 +665,7 @@ Example:
|
|
659
665
|
```
|
660
666
|
$ glimmer sample:code[tic_tac_toe]
|
661
667
|
|
662
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.
|
668
|
+
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe.rb
|
663
669
|
|
664
670
|
require_relative "tic_tac_toe/board"
|
665
671
|
|
@@ -720,7 +726,7 @@ TicTacToe.new.open
|
|
720
726
|
# # #
|
721
727
|
|
722
728
|
|
723
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.
|
729
|
+
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/cell.rb
|
724
730
|
|
725
731
|
class TicTacToe
|
726
732
|
class Cell
|
@@ -753,7 +759,7 @@ end
|
|
753
759
|
# # #
|
754
760
|
|
755
761
|
|
756
|
-
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.
|
762
|
+
# /Users/User/.rvm/gems/jruby-9.2.13.0@glimmerapp/gems/glimmer-dsl-swt-4.17.2.2/samples/elaborate/tic_tac_toe/board.rb
|
757
763
|
|
758
764
|
require_relative 'cell'
|
759
765
|
|
@@ -938,7 +944,7 @@ $ glimmer scaffold[greeter]
|
|
938
944
|
create spec/spec_helper.rb
|
939
945
|
create spec/greeter_spec.rb
|
940
946
|
create .rspec
|
941
|
-
|
947
|
+
Juwelier has prepared your gem in ./greeter
|
942
948
|
Created greeter/.gitignore
|
943
949
|
Created greeter/.ruby-version
|
944
950
|
Created greeter/.ruby-gemset
|
@@ -1009,7 +1015,7 @@ glimmer scaffold:cw[name]
|
|
1009
1015
|
#### Custom Shell Gem
|
1010
1016
|
|
1011
1017
|
Custom shell gems are self-contained Glimmer apps as well as reusable custom shells.
|
1012
|
-
They have everything scaffolded Glimmer apps come with in addition to gem content like a [
|
1018
|
+
They have everything scaffolded Glimmer apps come with in addition to gem content like a [Juwelier](https://rubygems.org/gems/juwelier) Rakefile that can build gemspec and release gems.
|
1013
1019
|
Unlike scaffolded Glimmer apps, custom shell gem content lives under the `lib` directory (not `app`).
|
1014
1020
|
They can be packaged as both a native executable (e.g. Mac DMG/PKG/APP) and a Ruby gem.
|
1015
1021
|
Of course, you can just build a Ruby gem and disregard native executable packaging if you do not need it.
|
@@ -1135,10 +1141,32 @@ Output:
|
|
1135
1141
|
|
1136
1142
|
Name Gem Version Author Description
|
1137
1143
|
|
1138
|
-
Video glimmer-cw-video 0.
|
1144
|
+
Video glimmer-cw-video 1.0.0 Andy Maleh Glimmer Custom Widget - Video
|
1139
1145
|
|
1140
1146
|
```
|
1141
1147
|
|
1148
|
+
Example:
|
1149
|
+
|
1150
|
+
Check all custom widgets for Glimmer.
|
1151
|
+
|
1152
|
+
```
|
1153
|
+
glimmer list:gems:cw
|
1154
|
+
```
|
1155
|
+
|
1156
|
+
Output:
|
1157
|
+
|
1158
|
+
```
|
1159
|
+
|
1160
|
+
Glimmer Custom Widget Gems at rubygems.org:
|
1161
|
+
|
1162
|
+
Name Gem Version Author Description
|
1163
|
+
|
1164
|
+
Browser (Chromium) glimmer-cw-browser-chromium 1.0.0 Andy Maleh Chromium Browser - Glimmer Custom Widget
|
1165
|
+
Cdatetime (Nebula) glimmer-cw-cdatetime-nebula 1.5.0.0.1 Andy Maleh Nebula CDateTime Widget - Glimmer Custom Widget
|
1166
|
+
Video glimmer-cw-video 1.0.0 Andy Maleh Glimmer Custom Widget - Video
|
1167
|
+
|
1168
|
+
```
|
1169
|
+
|
1142
1170
|
#### Listing DSL Gems
|
1143
1171
|
|
1144
1172
|
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):
|
@@ -1161,17 +1189,21 @@ Output:
|
|
1161
1189
|
|
1162
1190
|
Name Gem Version Author Description
|
1163
1191
|
|
1164
|
-
Css glimmer-dsl-css
|
1165
|
-
Opal glimmer-dsl-opal 0.
|
1166
|
-
Swt glimmer-dsl-swt 4.17.
|
1192
|
+
Css glimmer-dsl-css 1.1.0 AndyMaleh Glimmer DSL for CSS
|
1193
|
+
Opal glimmer-dsl-opal 0.3.0 AndyMaleh Glimmer DSL for Opal
|
1194
|
+
Swt glimmer-dsl-swt 4.17.2.2 AndyMaleh Glimmer DSL for SWT
|
1167
1195
|
Tk glimmer-dsl-tk 0.0.5 AndyMaleh Glimmer DSL for Tk
|
1168
|
-
Xml glimmer-dsl-xml
|
1196
|
+
Xml glimmer-dsl-xml 1.1.0 AndyMaleh Glimmer DSL for XML
|
1169
1197
|
```
|
1170
1198
|
|
1171
1199
|
### Packaging
|
1172
1200
|
|
1201
|
+
Glimmer supports packaging applications as native files on Mac and Windows.
|
1202
|
+
|
1173
1203
|
Glimmer packaging tasks are detailed under [Packaging & Distribution](#packaging--distribution).
|
1174
1204
|
|
1205
|
+
On Linux, the Glimmer [Custom Shell Gem](#custom-shell-gem) approach provides a [Gem Packaged Shell Script](#custom-shell-gem) (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem)
|
1206
|
+
|
1175
1207
|
### Raw JRuby Command
|
1176
1208
|
|
1177
1209
|
If there is a need to run Glimmer directly via the `jruby` command, you
|
@@ -2602,12 +2634,43 @@ end
|
|
2602
2634
|
|
2603
2635
|
### Custom Widgets
|
2604
2636
|
|
2605
|
-
Glimmer
|
2637
|
+
Custom widgets are brand new Glimmer DSL keywords that represent aggregates of existing widgets (e.g. `address_form`), customized existing widgets (e.g. `greeting_label`), or brand new widgets (e.g. `oscilloscope`)
|
2606
2638
|
|
2607
|
-
|
2639
|
+
Glimmer supports two ways of creating custom widgets with minimal code:
|
2640
|
+
1. Method-based Custom Widgets (for single-view-internal reuse): Extract a method containing Glimmer DSL widget syntax. Useful for quickly eliminating redundant code within a single view.
|
2641
|
+
2. Class-based Custom Widgets (for multiple-view-external reuse): Create a class that includes the `Glimmer::UI::CustomWidget` module and Glimmer DSL widget syntax in a `body {}` block. This will automatically extend Glimmer's DSL syntax with an underscored lowercase keyword matching the class name by convention. Useful in making a custom widget available in many views.
|
2642
|
+
|
2643
|
+
Approach #1 is a casual Ruby-based approach. Approach #2 is the official Glimmer approach. Typically, when referring to Custom Widgets, we are talking about Class-based Custom Widgets.
|
2644
|
+
|
2645
|
+
A developer might start with approach #1 to eliminate duplication in a view and later upgrade it to approach #2 when needing to export a custom widget to make it available in many views.
|
2646
|
+
|
2647
|
+
Class-based Custom Widgets offer a number of benefits over method-based custom widgets, such as built-in support for passing SWT style, nested block of extra widgets and properties, and `before_body`/`after_body` hooks.
|
2608
2648
|
|
2609
2649
|
#### Simple Example
|
2610
2650
|
|
2651
|
+
##### Method-Based Custom Widget Example
|
2652
|
+
|
2653
|
+
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
2654
|
+
|
2655
|
+
Definition and usage in the same file:
|
2656
|
+
```ruby
|
2657
|
+
def red_label(label_text)
|
2658
|
+
label {
|
2659
|
+
text label_text
|
2660
|
+
background :red
|
2661
|
+
}
|
2662
|
+
end
|
2663
|
+
|
2664
|
+
shell {
|
2665
|
+
red_label('Red Label')
|
2666
|
+
}.open
|
2667
|
+
```
|
2668
|
+
|
2669
|
+
|
2670
|
+
##### Class-Based Custom Widget Example
|
2671
|
+
|
2672
|
+
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 `__`)
|
2673
|
+
|
2611
2674
|
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
2612
2675
|
|
2613
2676
|
Definition:
|
@@ -2626,15 +2689,22 @@ end
|
|
2626
2689
|
Usage:
|
2627
2690
|
```ruby
|
2628
2691
|
shell {
|
2629
|
-
red_label {
|
2630
|
-
text 'Red Label'
|
2692
|
+
red_label(:center) {
|
2693
|
+
text 'Red Label'
|
2694
|
+
foreground :green
|
2631
2695
|
}
|
2632
2696
|
}.open
|
2633
2697
|
```
|
2634
2698
|
|
2635
|
-
As you can see, `RedLabel` became Glimmer DSL keyword
|
2699
|
+
As you can see, `RedLabel` became the Glimmer DSL keyword `red_label` and worked just like a standard label by taking in SWT style and nested properties. As such, it is a first-class citizen of the Glimmer GUI DSL.
|
2700
|
+
|
2701
|
+
#### Custom Widget Lifecycle Hooks
|
2702
|
+
|
2703
|
+
You may execute code before or after evaluating the body with these lifecycle hooks:
|
2704
|
+
- `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`
|
2705
|
+
- `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.
|
2636
2706
|
|
2637
|
-
#### Lifecycle
|
2707
|
+
#### Lifecycle Hooks Example
|
2638
2708
|
|
2639
2709
|
(you may copy/paste in [`girb`](#girb-glimmer-irb-command))
|
2640
2710
|
|
@@ -2729,12 +2799,6 @@ shell {
|
|
2729
2799
|
|
2730
2800
|
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'`
|
2731
2801
|
|
2732
|
-
#### Custom Widget Lifecycle Hooks
|
2733
|
-
|
2734
|
-
Last but not least, these are the available lifecycle hooks:
|
2735
|
-
- `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`
|
2736
|
-
- `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.
|
2737
|
-
|
2738
2802
|
#### Gotcha
|
2739
2803
|
|
2740
2804
|
Beware of defining a custom attribute that is a common SWT widget property name.
|
@@ -2770,6 +2834,8 @@ The `text` method invoked in the custom widget body will call the one you define
|
|
2770
2834
|
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:
|
2771
2835
|
[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)
|
2772
2836
|
|
2837
|
+
Also, you may check out [Hello, Custom Widget!](#hello-custom-widget) for another example.
|
2838
|
+
|
2773
2839
|
### Custom Shells
|
2774
2840
|
|
2775
2841
|
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.
|
@@ -2835,6 +2901,8 @@ shell { |app_shell|
|
|
2835
2901
|
}.open
|
2836
2902
|
```
|
2837
2903
|
|
2904
|
+
You may check out [Hello, Custom Shell!](#hello-custom-shell) for another example.
|
2905
|
+
|
2838
2906
|
### Drag and Drop
|
2839
2907
|
|
2840
2908
|
Glimmer offers Drag and Drop support, thanks to [SWT](https://www.eclipse.org/swt/) and Glimmer's lightweight [DSL syntax](#glimmer-dsl-syntax).
|
@@ -3159,6 +3227,23 @@ shell {
|
|
3159
3227
|
}.open
|
3160
3228
|
```
|
3161
3229
|
|
3230
|
+
##### SWT Browser Style Options
|
3231
|
+
|
3232
|
+
The `browser` widget can use a particular desktop browser by setting the SWT Style to:
|
3233
|
+
- `:webkit`: use the Webkit browser engine
|
3234
|
+
- `:chromium`: use the Chromium browser engine
|
3235
|
+
|
3236
|
+
Example using the Chromium browser (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
3237
|
+
|
3238
|
+
```ruby
|
3239
|
+
shell {
|
3240
|
+
minimum_size 1024, 860
|
3241
|
+
browser(:chromium) {
|
3242
|
+
url 'http://brightonresort.com/about'
|
3243
|
+
}
|
3244
|
+
}.open
|
3245
|
+
```
|
3246
|
+
|
3162
3247
|
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).
|
3163
3248
|
|
3164
3249
|
## Glimmer Configuration
|
@@ -3568,6 +3653,41 @@ glimmer sample:run[hello_pop_up_context_menu]
|
|
3568
3653
|
![Hello Pop Up Context Menu](images/glimmer-hello-pop-up-context-menu.png)
|
3569
3654
|
![Hello Pop Up Context Menu Popped Up](images/glimmer-hello-pop-up-context-menu-popped-up.png)
|
3570
3655
|
|
3656
|
+
#### Hello, Custom Widget!
|
3657
|
+
|
3658
|
+
This sample demonstrates the use of a custom widget in Glimmer.
|
3659
|
+
|
3660
|
+
Code:
|
3661
|
+
|
3662
|
+
[samples/hello/hello_custom_widget.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_widget.rb)
|
3663
|
+
|
3664
|
+
Run:
|
3665
|
+
|
3666
|
+
```
|
3667
|
+
glimmer sample:run[hello_custom_widget]
|
3668
|
+
```
|
3669
|
+
|
3670
|
+
![Hello Custom Widget](images/glimmer-hello-custom-widget.gif)
|
3671
|
+
|
3672
|
+
#### Hello, Custom Shell!
|
3673
|
+
|
3674
|
+
This sample demonstrates the use of a custom shell (aka custom window) in Glimmer.
|
3675
|
+
|
3676
|
+
Code:
|
3677
|
+
|
3678
|
+
[samples/hello/hello_custom_shell.rb](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/samples/hello/hello_custom_shell.rb)
|
3679
|
+
|
3680
|
+
Run:
|
3681
|
+
|
3682
|
+
```
|
3683
|
+
glimmer sample:run[hello_custom_shell]
|
3684
|
+
```
|
3685
|
+
|
3686
|
+
![Hello Custom Shell](images/glimmer-hello-custom-shell.png)
|
3687
|
+
![Hello Custom Shell Email1](images/glimmer-hello-custom-shell-email1.png)
|
3688
|
+
![Hello Custom Shell Email2](images/glimmer-hello-custom-shell-email2.png)
|
3689
|
+
![Hello Custom Shell Email3](images/glimmer-hello-custom-shell-email3.png)
|
3690
|
+
|
3571
3691
|
### Elaborate Samples
|
3572
3692
|
|
3573
3693
|
For more elaborate samples, check the following:
|
@@ -3689,7 +3809,7 @@ Gladiator is a good demonstration of:
|
|
3689
3809
|
|
3690
3810
|
#### Timer
|
3691
3811
|
|
3692
|
-
[<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
|
3812
|
+
[<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, multi-threading, and Java (Sound) library integration in a desktop application.
|
3693
3813
|
|
3694
3814
|
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/glimmer-timer-screenshot.png" />](https://github.com/AndyObtiva/glimmer-cs-timer)
|
3695
3815
|
|
@@ -3713,6 +3833,8 @@ If you have a Glimmer app you would like referenced here, please mention in a Pu
|
|
3713
3833
|
|
3714
3834
|
## Packaging & Distribution
|
3715
3835
|
|
3836
|
+
Note: this section mostly applies to Mac and Windows. On Linux, the Glimmer [Custom Shell Gem](#custom-shell-gem) approach provides a [Gem Packaged Shell Script](#custom-shell-gem) (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem)
|
3837
|
+
|
3716
3838
|
Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
|
3717
3839
|
|
3718
3840
|
```
|
@@ -3737,7 +3859,7 @@ require 'glimmer/rake_task'
|
|
3737
3859
|
```
|
3738
3860
|
|
3739
3861
|
The Glimmer packaging process done in the `glimmer package` command consists of the following steps:
|
3740
|
-
1. Generate gemspec via
|
3862
|
+
1. Generate gemspec via [Juwelier](https://rubygems.org/gems/juwelier) (`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.
|
3741
3863
|
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.
|
3742
3864
|
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.
|
3743
3865
|
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
|
@@ -3748,7 +3870,7 @@ The JAR file name will match your application local directory name (e.g. `MathBo
|
|
3748
3870
|
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)
|
3749
3871
|
|
3750
3872
|
The `glimmer package` command will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
|
3751
|
-
You may override by configuring as an extra argument for javapackger (e.g. Glimmer::Package.javapackager_extra_args = " -Bmac.CFBundleIdentifier=org.andymaleh.application.MathBowling")
|
3873
|
+
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")
|
3752
3874
|
|
3753
3875
|
### Packaging Defaults
|
3754
3876
|
|
@@ -3776,7 +3898,7 @@ require_relative '../app/my_application.rb'
|
|
3776
3898
|
- Include DMG Background Icon (Optional): Simply place a .png file under `package/macosx/{HumanAppName}-background.png`
|
3777
3899
|
- Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
|
3778
3900
|
- 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).
|
3779
|
-
- Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for javapackager: `Glimmer::
|
3901
|
+
- 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).
|
3780
3902
|
|
3781
3903
|
### javapackager Extra Arguments
|
3782
3904
|
|
@@ -3788,7 +3910,7 @@ In order to explicitly configure javapackager, Mac package attributes, or sign y
|
|
3788
3910
|
- https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
|
3789
3911
|
|
3790
3912
|
The Glimmer rake task allows passing extra options to javapackager via:
|
3791
|
-
- `Glimmer::
|
3913
|
+
- `Glimmer::RakeTask::Package.javapackager_extra_args="..."` in your application Rakefile
|
3792
3914
|
- Environment variable: `JAVAPACKAGER_EXTRA_ARGS`
|
3793
3915
|
|
3794
3916
|
Example (Rakefile):
|
@@ -3796,7 +3918,7 @@ Example (Rakefile):
|
|
3796
3918
|
```ruby
|
3797
3919
|
require 'glimmer/rake_task'
|
3798
3920
|
|
3799
|
-
Glimmer::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
|
3921
|
+
Glimmer::RakeTask::Package.javapackager_extra_args = '-BlicenseType="MIT" -Bmac.category="public.app-category.business" -Bmac.signing-key-developer-id-app="Andy Maleh"'
|
3800
3922
|
```
|
3801
3923
|
|
3802
3924
|
Note that `mac.category` defaults to "public.app-category.business", but can be overridden with one of the category UTI values mentioned here:
|
@@ -3813,7 +3935,7 @@ That overrides the default application display name.
|
|
3813
3935
|
|
3814
3936
|
### Verbose Mode
|
3815
3937
|
|
3816
|
-
Pass `-v` to javapackager in `Glimmer::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.
|
3938
|
+
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.
|
3817
3939
|
|
3818
3940
|
### Windows Application Packaging
|
3819
3941
|
|
@@ -3827,7 +3949,7 @@ If you just want to test out packaging into a native Windows app that is not pac
|
|
3827
3949
|
|
3828
3950
|
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.
|
3829
3951
|
|
3830
|
-
Afterwards, you may add developer-id/signing-key arguments to `javapackager` via `Glimmer::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
|
3952
|
+
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
|
3831
3953
|
|
3832
3954
|
DMG signing key argument:
|
3833
3955
|
```
|
@@ -3855,12 +3977,12 @@ To do so, you may follow these steps (abbreviated version from https://developer
|
|
3855
3977
|
- Enter Name (referred to below as "CertificateName")
|
3856
3978
|
- Set 'Certificate Type' to 'Code Signing'
|
3857
3979
|
- Create (if you alternatively override defaults, make sure to enable all capabilities)
|
3858
|
-
- Add the following option to javapackager: `-Bmac.signing-key-developer-id-app="CertificateName"` via `Glimmer::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS`
|
3980
|
+
- Add the following option to javapackager: `-Bmac.signing-key-developer-id-app="CertificateName"` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS`
|
3859
3981
|
|
3860
3982
|
Example:
|
3861
3983
|
|
3862
3984
|
```ruby
|
3863
|
-
Glimmer::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
|
3985
|
+
Glimmer::RakeTask::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
|
3864
3986
|
```
|
3865
3987
|
|
3866
3988
|
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.
|
@@ -3875,7 +3997,7 @@ Keep that in mind if you are not going to rely on the default `LICENSE.txt` supp
|
|
3875
3997
|
Example:
|
3876
3998
|
|
3877
3999
|
```ruby
|
3878
|
-
Glimmer::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="ACME.txt" -BlicenseType="ACME"'
|
4000
|
+
Glimmer::RakeTask::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="ACME.txt" -BlicenseType="ACME"'
|
3879
4001
|
```
|
3880
4002
|
|
3881
4003
|
2. Mounted DMG Residue
|
@@ -3895,7 +4017,7 @@ Glimmer already supports automatic (and manual) app updates via the Mac App Stor
|
|
3895
4017
|
## Glimmer Supporting Libraries
|
3896
4018
|
|
3897
4019
|
Here is a list of notable 3rd party gems used by Glimmer:
|
3898
|
-
- [
|
4020
|
+
- [juwelier](https://rubygems.org/gems/juwelier): generates app gems during [Glimmer Scaffolding](#scaffolding)
|
3899
4021
|
- [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)
|
3900
4022
|
- [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
|
3901
4023
|
- [os](https://github.com/rdp/os): provides OS detection capabilities (e.g. `OS.mac?` or `OS.windows?`) to write cross-platform code inexpensively
|