glimmer-dsl-swt 4.20.15.3 → 4.21.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +12 -11
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +107 -101
- data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +80 -90
- data/docs/reference/GLIMMER_STYLE_GUIDE.md +1 -2
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -0
- data/lib/glimmer/rake_task/package.rb +20 -22
- data/lib/glimmer/rake_task/scaffold.rb +45 -28
- data/lib/glimmer/swt/custom/shape/oval.rb +0 -4
- data/lib/glimmer/swt/image_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +5 -0
- data/samples/hello/hello_canvas.rb +25 -25
- data/samples/hello/hello_canvas_path.rb +10 -10
- data/samples/hello/hello_tray_item.rb +8 -8
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/linux_aarch64/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/mac_aarch64/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +23 -9
@@ -1,8 +1,8 @@
|
|
1
1
|
## Glimmer Packaging and Distribution
|
2
2
|
|
3
|
-
Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem). On Windows, ensure system PATH includes Java bin directory
|
3
|
+
Note: this section mostly applies to Mac and Windows. On Linux, you can just run `glimmer package:gem` and after installing the gem, you get an executable matching the name of the app/custom-shell-gem you are building (e.g. `calculator` command becomes available after installing the [glimmer-cs-calculator](https://github.com/AndyObtiva/glimmer-cs-calculator) gem). On Windows, ensure system PATH includes Java bin directory `"C:\Program Files\Java\jdk-16.0.2\bin"` at the top for `jpackage` command to work during packaging Glimmer applications.
|
4
4
|
|
5
|
-
Note 2: Glimmer packaging has a strong dependency on
|
5
|
+
Note 2: Glimmer packaging has a strong dependency on JDK16 since it includes the packaging tool `jpackage`.
|
6
6
|
|
7
7
|
Glimmer simplifies the process of native-executable packaging and distribution on Mac and Windows via a single `glimmer package` command:
|
8
8
|
|
@@ -10,9 +10,7 @@ Glimmer simplifies the process of native-executable packaging and distribution o
|
|
10
10
|
glimmer package
|
11
11
|
```
|
12
12
|
|
13
|
-
It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating
|
14
|
-
|
15
|
-
(note: if you see this error on the Mac 'Error: Bundler "DMG Installer" (dmg) failed to produce a bundle.', ignore it as it should have produced a bundle anyways. It is a harmless issue in 3rd party dependency: javapackager.)
|
13
|
+
It works out of the box for any application scaffolded by [Glimmer Scaffolding](#scaffolding), generating default packaging type on the current platform if not specified (i.e. `app-image`) 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). If you install Wix, make sure it is on the system PATH by adding for example "C:\Program Files (x86)\WiX Toolset v3.11\bin" to the Windows Environment Variables.
|
16
14
|
|
17
15
|
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:
|
18
16
|
|
@@ -20,14 +18,21 @@ You may choose to generate a specific type of packaging instead by addionally pa
|
|
20
18
|
glimmer package[msi]
|
21
19
|
```
|
22
20
|
|
21
|
+
This generates a DMG file on the Mac:
|
22
|
+
|
23
|
+
```
|
24
|
+
glimmer package[dmg]
|
25
|
+
```
|
26
|
+
|
23
27
|
Make sure to surround with double-quotes when running from ZShell (zsh):
|
24
28
|
|
25
29
|
```
|
26
|
-
glimmer "package[
|
30
|
+
glimmer "package[dmg]"
|
27
31
|
```
|
28
32
|
|
29
|
-
- Available Mac packaging types are `dmg`, `pkg`, and `image` (image means a pure Mac `app` without a setup program). Keep in mind that the packages you produce are compatible with the same MacOS you are on or older.
|
30
|
-
- 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).
|
33
|
+
- Available Mac packaging types are `dmg`, `pkg`, and `app-image` (image means a pure Mac `app` without a setup program). Keep in mind that the packages you produce are compatible with the same MacOS you are on or older.
|
34
|
+
- Available Windows packaging types are `msi`, `exe`, and `app-image` (image means a Windows application directory without a setup program). Learn more about Windows packaging are [over here](#windows-application-packaging).
|
35
|
+
- Available Linux packaging types are `deb`, `rpm`, and `app-image` (Note: Linux native packaging has not been tested successfully, which is why `glimmer package:gem` is recommended on Linux instead. If you get it working, please contribute to this doc file with a Pull Request).
|
31
36
|
|
32
37
|
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]`):
|
33
38
|
|
@@ -40,20 +45,20 @@ The Glimmer packaging process done in the `glimmer package` command consists of
|
|
40
45
|
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.
|
41
46
|
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.
|
42
47
|
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
|
43
|
-
1. Generate native executable using [
|
48
|
+
1. Generate native executable using [jpackage](https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf) (`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 `jpackage` manually afterwards if needed).
|
44
49
|
|
45
|
-
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 `
|
50
|
+
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 `jpackage`.
|
46
51
|
The JAR file name will match your application local directory name (e.g. `MathBowling.jar` for `~/code/MathBowling`)
|
47
52
|
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)
|
48
53
|
|
49
54
|
The `glimmer package` command will automatically set "mac.CFBundleIdentifier" to ="org.#{project_name}.application.#{project_name}".
|
50
|
-
You may override by configuring as an extra argument for javapackger (e.g. Glimmer::RakeTask::Package.
|
55
|
+
You may override by configuring as an extra argument for javapackger (e.g. Glimmer::RakeTask::Package.jpackage_extra_args = " --mac-package-identifier org.andymaleh.application.MathBowling")
|
51
56
|
|
52
57
|
### Packaging Defaults
|
53
58
|
|
54
59
|
Glimmer employs smart defaults in packaging.
|
55
60
|
|
56
|
-
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 "-
|
61
|
+
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 "--name", "--mac-package-name" and "--version" options.
|
57
62
|
|
58
63
|
Also, the package will only include these directories: app, config, db, lib, script, bin, docs, fonts, images, sounds, videos
|
59
64
|
|
@@ -74,47 +79,41 @@ require_relative '../app/my_application.rb'
|
|
74
79
|
- 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/)
|
75
80
|
- Include DMG Background Icon (Optional): Simply place a .png file under `package/macosx/{HumanAppName}-background.png`
|
76
81
|
- Include Version (Optional): Create a `VERSION` file in your application and fill it your app version on one line (e.g. `1.1.0`)
|
77
|
-
- 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
|
78
|
-
- Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for
|
82
|
+
- 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 `--license-file LICENSE.txt` shown in an [example below](#jpackage-extra-arguments).
|
83
|
+
- Extra args (Optional): You may optionally add the following to `Rakefile` to configure extra arguments for jpackage: `Glimmer::RakeTask::Package.jpackage_extra_args = "..."` (Useful to avoid re-entering extra arguments on every run of rake task.). Read about them in [their section below](#jpackage-extra-arguments).
|
79
84
|
|
80
|
-
###
|
85
|
+
### jpackage Extra Arguments
|
81
86
|
|
82
|
-
(note: currently `Glimmer::RakeTask::Package.
|
87
|
+
(note: currently `Glimmer::RakeTask::Package.jpackage_extra_args` is only honored when packaging from bash, not zsh)
|
83
88
|
|
84
|
-
In order to explicitly configure
|
85
|
-
-
|
86
|
-
- https://docs.oracle.com/
|
87
|
-
- https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#BCGICFDB
|
88
|
-
- https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html
|
89
|
+
In order to explicitly configure jpackage, Mac package attributes, or sign your Mac app to distribute on the App Store, you can follow more advanced instructions for `jpackage` here:
|
90
|
+
- Run `jpackage --help` for more info
|
91
|
+
- https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
|
89
92
|
- https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
|
90
93
|
|
91
|
-
The Glimmer rake task allows passing extra options to
|
92
|
-
- `Glimmer::RakeTask::Package.
|
93
|
-
- Environment variable: `
|
94
|
+
The Glimmer rake task allows passing extra options to jpackage via:
|
95
|
+
- `Glimmer::RakeTask::Package.jpackage_extra_args="..."` in your application Rakefile
|
96
|
+
- Environment variable: `JPACKAGE_EXTRA_ARGS`
|
94
97
|
|
95
98
|
Example (Rakefile):
|
96
99
|
|
97
100
|
```ruby
|
98
101
|
require 'glimmer/rake_task'
|
99
102
|
|
100
|
-
Glimmer::RakeTask::Package.
|
103
|
+
Glimmer::RakeTask::Package.jpackage_extra_args = '--license-file LICENSE.txt --mac-sign --mac-signing-key-user-name "Andy Maleh"'
|
101
104
|
```
|
102
105
|
|
103
|
-
Note that `mac.category` defaults to "public.app-category.business", but can be overridden with one of the category UTI values mentioned here:
|
104
|
-
|
105
|
-
https://developer.apple.com/library/archive/releasenotes/General/SubmittingToMacAppStore/index.html#//apple_ref/doc/uid/TP40010572-CH16-SW8
|
106
|
-
|
107
106
|
Example (env var):
|
108
107
|
|
109
108
|
```
|
110
|
-
|
109
|
+
JPACKAGE_EXTRA_ARGS='--mac-package-name "Math Bowling Game"' glimmer package
|
111
110
|
```
|
112
111
|
|
113
112
|
That overrides the default application display name.
|
114
113
|
|
115
114
|
### Verbose Mode
|
116
115
|
|
117
|
-
Pass `-v` to
|
116
|
+
Pass `-v` to jpackage in `Glimmer::RakeTask::Package.jpackage_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.
|
118
117
|
|
119
118
|
### Windows Application Packaging
|
120
119
|
|
@@ -128,83 +127,74 @@ If you just want to test out packaging into a native Windows app that is not pac
|
|
128
127
|
|
129
128
|
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.
|
130
129
|
|
131
|
-
Afterwards, you may add
|
130
|
+
Afterwards, you may add signing arguments to `jpackage` via `Glimmer::RakeTask::Package.jpackage_extra_args` or `JPACKAGE_EXTRA_ARGS` according to this webpage: https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
|
132
131
|
|
133
|
-
DMG signing key argument:
|
134
132
|
```
|
135
|
-
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
### Self Signed Certificate
|
150
|
-
|
151
|
-
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".
|
152
|
-
|
153
|
-
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):
|
154
|
-
- Open Keychain Access
|
155
|
-
- Choose Keychain Access > Certificate Assistant > Create Certificate ...
|
156
|
-
- Enter Name (referred to below as "CertificateName")
|
157
|
-
- Set 'Certificate Type' to 'Code Signing'
|
158
|
-
- Create (if you alternatively override defaults, make sure to enable all capabilities)
|
159
|
-
- Add the following option to javapackager: `-Bmac.signing-key-developer-id-app="CertificateName"` via `Glimmer::RakeTask::Package.javapackager_extra_args` or `JAVAPACKAGER_EXTRA_ARGS`
|
160
|
-
|
161
|
-
Example:
|
162
|
-
|
163
|
-
```ruby
|
164
|
-
Glimmer::RakeTask::Package.javapackager_extra_args = '-Bmac.signing-key-developer-id-app="Andy Maleh"'
|
133
|
+
--mac-package-signing-prefix <prefix string>
|
134
|
+
When signing the application package, this value is prefixed
|
135
|
+
to all components that need to be signed that don't have
|
136
|
+
an existing package identifier.
|
137
|
+
--mac-sign
|
138
|
+
Request that the package be signed
|
139
|
+
--mac-signing-keychain <file path>
|
140
|
+
Path of the keychain to search for the signing identity
|
141
|
+
(absolute path or relative to the current directory).
|
142
|
+
If not specified, the standard keychains are used.
|
143
|
+
--mac-signing-key-user-name <team name>
|
144
|
+
Team name portion in Apple signing identities' names.
|
145
|
+
For example "Developer ID Application: "
|
165
146
|
```
|
166
147
|
|
167
|
-
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.
|
168
|
-
|
169
148
|
### Packaging Gotchas
|
170
149
|
|
171
|
-
1.
|
172
|
-
|
173
|
-
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.
|
174
|
-
Keep that in mind if you are not going to rely on the default `LICENSE.txt` support.
|
175
|
-
|
176
|
-
Example:
|
177
|
-
|
178
|
-
```ruby
|
179
|
-
Glimmer::RakeTask::Package.javapackager_extra_args = '-srcfiles "ACME.txt" -BlicenseFile="ACME.txt" -BlicenseType="ACME"'
|
180
|
-
```
|
150
|
+
1. Zsh (Z Shell)
|
181
151
|
|
182
|
-
|
152
|
+
Currently, `Glimmer::RakeTask::Package.jpackage_extra_args` is only honored when packaging from bash, not zsh.
|
183
153
|
|
184
|
-
|
185
|
-
|
186
|
-
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):
|
154
|
+
You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
|
187
155
|
|
188
156
|
```
|
189
|
-
|
157
|
+
bash -c 'source ~/.glimmer_source; glimmer package'
|
190
158
|
```
|
191
159
|
|
192
|
-
|
193
|
-
|
194
|
-
Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored when packaging from bash, not zsh.
|
160
|
+
2. unsupported Java version "16", defaulting to 1.7
|
195
161
|
|
196
|
-
|
162
|
+
If you get this error while packaging:
|
197
163
|
|
198
164
|
```
|
199
|
-
|
165
|
+
unsupported Java version "16", defaulting to 1.7
|
166
|
+
[ERROR] Internal error: org.jruby.exceptions.RaiseException: (LoadError) library `java' could not be loaded: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @138caeca -> [Help 1]
|
167
|
+
org.apache.maven.InternalErrorException: Internal error: org.jruby.exceptions.RaiseException: (LoadError) library `java' could not be loaded: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @138caeca
|
168
|
+
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
|
169
|
+
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
|
170
|
+
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
|
171
|
+
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
|
172
|
+
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
173
|
+
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
|
174
|
+
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
175
|
+
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
|
176
|
+
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
|
177
|
+
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
|
178
|
+
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
|
179
|
+
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
|
180
|
+
Caused by: org.jruby.exceptions.RaiseException: (LoadError) library `java' could not be loaded: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @138caeca
|
181
|
+
[ERROR]
|
182
|
+
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
|
183
|
+
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
|
184
|
+
[ERROR]
|
185
|
+
[ERROR] For more information about the errors and possible solutions, please read the following articles:
|
186
|
+
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
|
200
187
|
```
|
201
188
|
|
202
|
-
|
189
|
+
Please ignore. It should be harmless. If you get blocked by it for any reason, please open an Issue about it.
|
203
190
|
|
204
|
-
|
205
|
-
|
191
|
+
3. Java on Windows System PATH
|
192
|
+
|
193
|
+
If you get any errors running Java on Windows, keep in mind that you need to have the Java binaries "C:\Program Files\Java\jdk-16.0.2\bin" on the Windows System PATH environment variable.
|
206
194
|
|
207
195
|
The problem is Oracle seems to be adding an indirect Java path junction in later versions of their installer:
|
208
|
-
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
|
196
|
+
`C:\Program Files (x86)\Common Files\Oracle\Java\javapath`
|
197
|
+
|
198
|
+
Simply replace it with the simple path mentioned above (`"C:\Program Files\Java\jdk-16.0.2\bin"` matching your correct version number)
|
209
199
|
|
210
|
-
|
200
|
+
Lastly, reinstall JRuby to ensure it is using Java from the right path.
|
@@ -8,8 +8,7 @@
|
|
8
8
|
- Widget property declarations always have arguments and never take a block
|
9
9
|
- Widget property arguments are never wrapped inside parentheses
|
10
10
|
- Widget listeners are always declared starting with `on_` prefix and affixing listener event method name afterwards in underscored lowercase form. Their multi-line blocks rely on the `do; end` style.
|
11
|
-
-
|
12
|
-
- Data-binding is done via `bind` keyword, which always takes arguments wrapped in parentheses
|
11
|
+
- Data-binding can be done via `bind` keyword, which always takes arguments wrapped in parentheses, or using `<=>` and `<=` operators, which expect an array of model/property/options as arguments.
|
13
12
|
- Custom widget/shell/shape `body` blocks open and close with curly braces.
|
14
13
|
- Custom widget/shell/shape `before_body` and `after_body` blocks are declared as `do; end` blocks.
|
15
14
|
- Custom widgets receive additional keyword arguments called options, which come after the SWT styles.
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
@@ -26,8 +26,7 @@ module Glimmer
|
|
26
26
|
module RakeTask
|
27
27
|
module Package
|
28
28
|
class << self
|
29
|
-
attr_accessor :
|
30
|
-
alias jpackage_extra_args javapackager_extra_args
|
29
|
+
attr_accessor :jpackage_extra_args
|
31
30
|
|
32
31
|
def clean
|
33
32
|
require 'fileutils'
|
@@ -89,12 +88,12 @@ module Glimmer
|
|
89
88
|
end
|
90
89
|
|
91
90
|
def native(native_type=nil, native_extra_args)
|
92
|
-
puts "Generating native executable with
|
91
|
+
puts "Generating native executable with jpackage..."
|
93
92
|
java_version = `jruby -v`
|
94
|
-
if java_version.include?('
|
95
|
-
puts "Java Version
|
93
|
+
if java_version.include?('16.0.2')
|
94
|
+
puts "Java Version 16.0.2 Detected!"
|
96
95
|
else
|
97
|
-
puts "WARNING! Glimmer Packaging Pre-Requisite Java Version
|
96
|
+
puts "WARNING! Glimmer Packaging Pre-Requisite Java Version 16.0.2 Is Not Found!"
|
98
97
|
end
|
99
98
|
require 'facets/string/titlecase'
|
100
99
|
require 'facets/string/underscore'
|
@@ -106,28 +105,27 @@ module Glimmer
|
|
106
105
|
license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
|
107
106
|
copyright = license.split("\n").first
|
108
107
|
human_name = project_name.underscore.titlecase
|
109
|
-
icon = "
|
110
|
-
if
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
command
|
115
|
-
command += "
|
116
|
-
command += " -
|
117
|
-
|
118
|
-
command
|
119
|
-
command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows?
|
108
|
+
icon = "icons/#{OS.mac? ? 'macosx' : (OS.linux? ? 'linux' : 'windows')}/#{human_name}.#{OS.mac? ? 'icns' : (OS.linux? ? 'png' : 'ico')}"
|
109
|
+
native_type = 'app-image' if native_type.to_s.strip.empty?
|
110
|
+
if (`jpackage`.to_s.include?('Usage: jpackage') rescue nil)
|
111
|
+
FileUtils.rm_rf("packages/bundles")
|
112
|
+
FileUtils.mkdir_p('packages/bundles')
|
113
|
+
command = "jpackage"
|
114
|
+
command += " --type #{native_type}"
|
115
|
+
command += " --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --java-options '-Dproject_name=#{project_name}' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' "
|
116
|
+
command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows? && native_type != 'app-image'
|
117
|
+
command += " --linux-menu-group '#{human_name}' " if OS.linux? && native_type != 'app-image'
|
120
118
|
command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac?
|
121
119
|
command += " --app-version \"#{version}\" " if version
|
122
|
-
command += " --license-file LICENSE.txt " if license
|
120
|
+
command += " --license-file LICENSE.txt " if license && native_type != 'app-image'
|
123
121
|
command += " --copyright \"#{copyright}\" " if copyright
|
124
122
|
else
|
125
|
-
puts "
|
123
|
+
puts "jpackage does not exist in your Java installation. Please ensure jpackage is available in PATH environment variable."
|
126
124
|
return
|
127
125
|
end
|
128
|
-
Rake.application.load_rakefile # make sure to load potential
|
129
|
-
command += " #{
|
130
|
-
command += " #{ENV['
|
126
|
+
Rake.application.load_rakefile # make sure to load potential jpackage_extra_args config in app Rakefile
|
127
|
+
command += " #{jpackage_extra_args} " if jpackage_extra_args
|
128
|
+
command += " #{ENV['JPACKAGE_EXTRA_ARGS']} " if ENV['JPACKAGE_EXTRA_ARGS']
|
131
129
|
command += " #{native_extra_args} " if native_extra_args
|
132
130
|
puts command
|
133
131
|
system command
|
@@ -167,20 +167,25 @@ module Glimmer
|
|
167
167
|
custom_shell('AppView', current_dir_name, shell_type)
|
168
168
|
end
|
169
169
|
|
170
|
-
mkdir_p '
|
171
|
-
icon_file = "
|
170
|
+
mkdir_p 'icons/windows'
|
171
|
+
icon_file = "icons/windows/#{human_name(app_name)}.ico"
|
172
172
|
cp File.expand_path('../../../../icons/scaffold_app.ico', __FILE__), icon_file
|
173
173
|
puts "Created #{current_dir_name}/#{icon_file}"
|
174
174
|
|
175
|
-
mkdir_p '
|
176
|
-
icon_file = "
|
175
|
+
mkdir_p 'icons/macosx'
|
176
|
+
icon_file = "icons/macosx/#{human_name(app_name)}.icns"
|
177
177
|
cp File.expand_path('../../../../icons/scaffold_app.icns', __FILE__), icon_file
|
178
178
|
puts "Created #{current_dir_name}/#{icon_file}"
|
179
179
|
|
180
|
-
mkdir_p '
|
181
|
-
icon_file = "
|
180
|
+
mkdir_p 'icons/linux'
|
181
|
+
icon_file = "icons/linux/#{human_name(app_name)}.png"
|
182
182
|
cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
|
183
183
|
puts "Created #{current_dir_name}/#{icon_file}"
|
184
|
+
|
185
|
+
write "Resource.java", resource_java_file(app_name)
|
186
|
+
cd '..'
|
187
|
+
system "javac #{file_name(app_name)}/Resource.java"
|
188
|
+
cd gem_name
|
184
189
|
|
185
190
|
mkdir_p "app/#{file_name(app_name)}"
|
186
191
|
write "app/#{file_name(app_name)}/launch.rb", app_launch_file(app_name)
|
@@ -195,14 +200,14 @@ module Glimmer
|
|
195
200
|
end
|
196
201
|
write 'spec/spec_helper.rb', spec_helper_file
|
197
202
|
if OS.windows?
|
198
|
-
system "glimmer
|
203
|
+
system "glimmer package" # TODO handle Windows with batch file
|
199
204
|
system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
|
200
205
|
else
|
201
206
|
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
|
202
207
|
if OS.mac?
|
203
|
-
system "
|
208
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
|
204
209
|
else
|
205
|
-
system "glimmer run"
|
210
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
|
206
211
|
end
|
207
212
|
end
|
208
213
|
end
|
@@ -278,30 +283,35 @@ module Glimmer
|
|
278
283
|
end
|
279
284
|
write 'spec/spec_helper.rb', spec_helper_file
|
280
285
|
|
281
|
-
mkdir_p '
|
282
|
-
icon_file = "
|
286
|
+
mkdir_p 'icons/windows'
|
287
|
+
icon_file = "icons/windows/#{human_name(custom_shell_name)}.ico"
|
283
288
|
cp File.expand_path('../../../../icons/scaffold_app.ico', __FILE__), icon_file
|
284
289
|
puts "Created #{current_dir_name}/#{icon_file}"
|
285
290
|
|
286
|
-
mkdir_p '
|
287
|
-
icon_file = "
|
291
|
+
mkdir_p 'icons/macosx'
|
292
|
+
icon_file = "icons/macosx/#{human_name(custom_shell_name)}.icns"
|
288
293
|
cp File.expand_path('../../../../icons/scaffold_app.icns', __FILE__), icon_file
|
289
294
|
puts "Created #{current_dir_name}/#{icon_file}"
|
290
295
|
|
291
|
-
mkdir_p '
|
292
|
-
icon_file = "
|
296
|
+
mkdir_p 'icons/linux'
|
297
|
+
icon_file = "icons/linux/#{human_name(custom_shell_name)}.png"
|
293
298
|
cp File.expand_path('../../../../icons/scaffold_app.png', __FILE__), icon_file
|
294
299
|
puts "Created #{current_dir_name}/#{icon_file}"
|
295
300
|
|
301
|
+
write "Resource.java", resource_java_file(custom_shell_name)
|
302
|
+
cd '..'
|
303
|
+
system "javac #{file_name(custom_shell_name)}/Resource.java"
|
304
|
+
cd gem_name
|
305
|
+
|
296
306
|
if OS.windows?
|
297
|
-
system "glimmer package
|
307
|
+
system "glimmer package" # TODO handle windows properly with batch file
|
298
308
|
system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
|
299
309
|
else
|
300
310
|
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
|
301
311
|
if OS.mac?
|
302
|
-
system "
|
312
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n JRUBY_OPTS=\"$JRUBY_OPTS -J-XstartOnFirstThread\" glimmer run\n'"
|
303
313
|
else
|
304
|
-
system "glimmer run"
|
314
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer run\n'"
|
305
315
|
end
|
306
316
|
end
|
307
317
|
puts "Finished creating #{gem_name} Ruby gem."
|
@@ -485,6 +495,16 @@ module Glimmer
|
|
485
495
|
#{class_name(app_name)}::View::AppView.launch
|
486
496
|
MULTI_LINE_STRING
|
487
497
|
end
|
498
|
+
|
499
|
+
def resource_java_file(app_name)
|
500
|
+
<<~MULTI_LINE_STRING
|
501
|
+
package #{file_name(app_name)};
|
502
|
+
|
503
|
+
/** The soul purpose of this class is to retrieve icons for uri:classloader paths used from JAR */
|
504
|
+
class Resource {
|
505
|
+
}
|
506
|
+
MULTI_LINE_STRING
|
507
|
+
end
|
488
508
|
|
489
509
|
def app_bin_command_file(app_name_or_gem_name, custom_shell_name=nil, namespace=nil)
|
490
510
|
if custom_shell_name.nil?
|
@@ -525,7 +545,7 @@ module Glimmer
|
|
525
545
|
lines.insert(require_rake_line_index, "require 'glimmer/launcher'")
|
526
546
|
gem_files_line_index = lines.index(lines.detect {|l| l.include?('# dependencies defined in Gemfile') })
|
527
547
|
if custom_shell_name
|
528
|
-
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', '
|
548
|
+
lines.insert(gem_files_line_index, " gem.files = Dir['Resource.class', 'VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', 'script/**/*', 'sounds/**/*', 'vendor/**/*', 'videos/**/*']")
|
529
549
|
# the second executable is needed for warbler as it matches the gem name, which is the default expected file (alternatively in the future, we could do away with it and configure warbler to use the other file)
|
530
550
|
lines.insert(gem_files_line_index+1, " gem.require_paths = ['vendor', 'lib', 'app']")
|
531
551
|
lines.insert(gem_files_line_index+2, " gem.executables = ['#{file_name(custom_shell_name)}']") if custom_shell_name
|
@@ -538,14 +558,10 @@ module Glimmer
|
|
538
558
|
file_content = lines.join("\n")
|
539
559
|
if custom_shell_name
|
540
560
|
file_content << <<~MULTI_LINE_STRING
|
541
|
-
Glimmer::RakeTask::Package.
|
542
|
-
"
|
543
|
-
"
|
544
|
-
|
545
|
-
" -Bmac.CFBundleIdentifier='org.#{namespace ? compact_name(namespace) : compact_name(custom_shell_name)}.application.#{compact_name(custom_shell_name).camelcase(:upper)}'"
|
546
|
-
# " -BlicenseType=" +
|
547
|
-
# " -Bmac.category=" +
|
548
|
-
# " -Bmac.signing-key-developer-id-app="
|
561
|
+
Glimmer::RakeTask::Package.jpackage_extra_args =
|
562
|
+
" --name '#{human_name(custom_shell_name)}'" +
|
563
|
+
" --description '#{human_name(custom_shell_name)}'"
|
564
|
+
# You can add more options from https://docs.oracle.com/en/java/javase/14/jpackage/packaging-tool-user-guide.pdf
|
549
565
|
MULTI_LINE_STRING
|
550
566
|
end
|
551
567
|
file_content
|
@@ -643,7 +659,8 @@ module Glimmer
|
|
643
659
|
shell#{'(:fill_screen)' if shell_type == :desktopify} {
|
644
660
|
# Replace example content below with custom shell content
|
645
661
|
minimum_size #{shell_type == :desktopify ? '768, 432' : '420, 240'}
|
646
|
-
image File.join(APP_ROOT, '
|
662
|
+
image File.join(APP_ROOT, 'icons', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
|
663
|
+
image File.join(APP_ROOT, 'icons', 'linux', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.png") unless OS.windows?
|
647
664
|
text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
|
648
665
|
|
649
666
|
MULTI_LINE_STRING
|
@@ -33,10 +33,6 @@ module Glimmer
|
|
33
33
|
# That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
|
34
34
|
class Shape
|
35
35
|
class Oval < Shape
|
36
|
-
def parameter_names
|
37
|
-
[:x, :y, :width, :height]
|
38
|
-
end
|
39
|
-
|
40
36
|
# checks if shape contains the point denoted by x and y
|
41
37
|
def contain?(x, y)
|
42
38
|
x, y = inverse_transform_point(x, y)
|
@@ -122,9 +122,9 @@ module Glimmer
|
|
122
122
|
def input_stream
|
123
123
|
if @file_path.start_with?('uri:classloader')
|
124
124
|
@jar_file_path = @file_path
|
125
|
-
file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '
|
126
|
-
|
127
|
-
file_input_stream =
|
125
|
+
file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '') # the latter sub is needed for Mac
|
126
|
+
project_name = java.lang.System.getProperty('project_name')
|
127
|
+
file_input_stream = java_import("#{project_name}.Resource").last.java_class.resource_as_stream(file_path)
|
128
128
|
else
|
129
129
|
file_input_stream = java.io.FileInputStream.new(@file_path)
|
130
130
|
end
|
@@ -192,6 +192,7 @@ module Glimmer
|
|
192
192
|
observer_registrations.clear
|
193
193
|
end
|
194
194
|
end
|
195
|
+
post_add_content if content.nil?
|
195
196
|
end
|
196
197
|
|
197
198
|
# Subclasses may override to perform post initialization work on an added child
|
@@ -199,6 +200,10 @@ module Glimmer
|
|
199
200
|
# No Op by default
|
200
201
|
end
|
201
202
|
|
203
|
+
def post_add_content
|
204
|
+
Glimmer::UI::CustomWidget.current_custom_widgets.delete(self)
|
205
|
+
end
|
206
|
+
|
202
207
|
def observer_registrations
|
203
208
|
@observer_registrations ||= []
|
204
209
|
end
|