glimmer-dsl-swt 4.19.0.2 → 4.20.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +14 -19
  4. data/RUBY_VERSION +1 -1
  5. data/VERSION +1 -1
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +33 -8
  7. data/glimmer-dsl-swt.gemspec +0 -0
  8. data/lib/glimmer/data_binding/shine.rb +41 -26
  9. data/lib/glimmer/dsl/swt/dsl.rb +2 -1
  10. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
  11. data/lib/glimmer/launcher.rb +6 -0
  12. data/lib/glimmer/swt/custom/code_text.rb +13 -9
  13. data/samples/elaborate/contact_manager.rb +7 -5
  14. data/samples/elaborate/login.rb +7 -7
  15. data/samples/elaborate/mandelbrot_fractal.rb +2 -2
  16. data/samples/elaborate/metronome.rb +3 -3
  17. data/samples/elaborate/tic_tac_toe.rb +2 -2
  18. data/samples/hello/hello_button.rb +1 -1
  19. data/samples/hello/hello_c_combo.rb +2 -1
  20. data/samples/hello/hello_c_tab.rb +1 -0
  21. data/samples/hello/hello_canvas.rb +5 -5
  22. data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
  23. data/samples/hello/hello_canvas_data_binding.rb +16 -16
  24. data/samples/hello/hello_checkbox.rb +4 -4
  25. data/samples/hello/hello_code_text.rb +3 -57
  26. data/samples/hello/hello_color_dialog.rb +1 -1
  27. data/samples/hello/hello_combo.rb +1 -1
  28. data/samples/hello/hello_computed.rb +5 -5
  29. data/samples/hello/hello_custom_widget.rb +1 -1
  30. data/samples/hello/hello_date_time.rb +4 -4
  31. data/samples/hello/hello_dialog.rb +3 -2
  32. data/samples/hello/hello_drag_and_drop.rb +1 -1
  33. data/samples/hello/hello_file_dialog.rb +1 -1
  34. data/samples/hello/hello_font_dialog.rb +3 -3
  35. data/samples/hello/hello_group.rb +6 -6
  36. data/samples/hello/hello_link.rb +56 -50
  37. data/samples/hello/hello_list_multi_selection.rb +1 -1
  38. data/samples/hello/hello_list_single_selection.rb +1 -1
  39. data/samples/hello/hello_progress_bar.rb +10 -10
  40. data/samples/hello/hello_radio.rb +6 -6
  41. data/samples/hello/hello_sash_form.rb +4 -4
  42. data/samples/hello/hello_spinner.rb +6 -2
  43. data/samples/hello/hello_styled_text.rb +11 -11
  44. data/vendor/swt/linux/swt.jar +0 -0
  45. data/vendor/swt/linux_aarch64/swt.jar +0 -0
  46. data/vendor/swt/mac/swt.jar +0 -0
  47. data/vendor/swt/mac_aarch64/swt.jar +0 -0
  48. data/vendor/swt/windows/swt.jar +0 -0
  49. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93ec7af6cbc39ea5df42b33602473d8f8577cd1f1370e794f684ce059dab41ee
4
- data.tar.gz: 0ade71e71e6c2255b3583737ef65264a3f1518de9e135abcca354b648b66e045
3
+ metadata.gz: 21989f606fc509c36ef0be6f2429ef43082f60a0aa800ad42fbe956e39168333
4
+ data.tar.gz: 3307a4cc805b6e72eefa059c984584464ac9f759f4e0c3c0968b0e151fb7bbd0
5
5
  SHA512:
6
- metadata.gz: 523b11fe2143376f5fe395c2b3eb3ca440fcf16851176874d0ea87c7f533d5f87251acab138ab81fa6c5c75f535de43c4fe5cb315c8a4f945e5d58b470a7ed3c
7
- data.tar.gz: f16f441f4e2861de3b899d3992c83f99b4ec7da30a3f077f0191708ba8a7797c01bc3b68ee5a6b430b0e972d55005715277a0c445c323fff4bd99f44dcf9ae13
6
+ metadata.gz: bb070bb78b470ba5be916cd0c58917b91d757b0174ddd37992dc92d6b9238e5697e144292c13b48de70b6e2f8bc77206786a6c7ddfe9b7ad47f83ed03fbbe4c7
7
+ data.tar.gz: 0fe369459de55d705acb992c40345e4f0ff12b4931ad32af7e103c0c850ca4b3c7cdfd465899246ecb998b694a23c1a4356afc173296bc45e47abb10571d4db9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ### 4.20.0.0
4
+
5
+ - Upgrade to SWT 4.20, supporting AARCH64 experimentally
6
+ - Upgrade to JRuby 9.2.19.0
7
+ - Shine syntax for data-binding
8
+ - Tweak/Fix Samples
9
+
3
10
  ### 4.19.0.2
4
11
 
5
12
  - Fixed issue with Meta-Sample code editing not showing changes properly (although recording them)
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.19.0.2
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.20.0.0
2
2
  ## JRuby Desktop Development GUI Framework
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,14 +10,16 @@
10
10
 
11
11
  **(The Original Glimmer Library Handling the World’s Ruby GUI Needs Since 2007. Beware of Imitators!)**
12
12
 
13
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for SWT is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by 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](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#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, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) 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](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/). [Glimmer](https://github.com/AndyObtiva/glimmer) was the [first Ruby gem](https://rubygems.org/gems/glimmer) to bring [SWT](https://www.eclipse.org/swt/) (Standard Widget Toolkit) to [Ruby](https://www.ruby-lang.org/en/), thanks to its creator [Andy Maleh](https://andymaleh.blogspot.com/), an EclipseCon/EclipseWorld/RubyConf speaker and expert.
13
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for SWT is a native-GUI cross-platform desktop development library written in [JRuby](https://www.jruby.org/), an OS-threaded faster JVM version of [Ruby](https://www.ruby-lang.org/en/). [Glimmer](https://github.com/AndyObtiva/glimmer)'s main innovation is a declarative [Ruby DSL](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-dsl-syntax) that enables productive and efficient authoring of desktop application user-interfaces by 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](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#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, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI [widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#widgets), but it also supports drawing Canvas Graphics like [Shapes](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-shape-dsl) and [Animations](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#canvas-animation-dsl). To get started quickly, [Glimmer](https://rubygems.org/gems/glimmer) offers [scaffolding](docs/reference/GLIMMER_COMMAND.md#scaffolding) options for [Apps](#in-production), [Gems](docs/reference/GLIMMER_COMMAND.md#custom-shell-gem), and [Custom Widgets](docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#custom-widgets). [Glimmer](https://rubygems.org/gems/glimmer) also includes native-executable [packaging](docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md) 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](docs/reference/GLIMMER_COMMAND.md#packaging) on [Linux](https://www.linux.org/). [Glimmer](https://github.com/AndyObtiva/glimmer) was the [first Ruby gem](https://rubygems.org/gems/glimmer) to bring [SWT](https://www.eclipse.org/swt/) (Standard Widget Toolkit) to [Ruby](https://www.ruby-lang.org/en/), thanks to creator [Andy Maleh](https://andymaleh.blogspot.com/), an EclipseCon/EclipseWorld/RubyConf speaker and expert.
14
14
 
15
15
  [<img src="https://covers.oreillystatic.com/images/9780596519650/lrg.jpg" width=105 /><br />
16
16
  Featured in JRuby Cookbook](http://shop.oreilly.com/product/9780596519650.do) and [Chalmers/Gothenburg University Software Engineering Master's Lecture Material](http://www.cse.chalmers.se/~bergert/slides/guest_lecture_DSLs.pdf)
17
17
 
18
- [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.19.0.2 includes [SWT 4.19](https://download.eclipse.org/eclipse/downloads/drops4/R-4.19-202103031800/), which was released on March 3, 2021. 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.
18
+ [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) 4.20.0.0 includes [SWT 4.20](https://download.eclipse.org/eclipse/downloads/drops4/R-4.20-202106111600/), which was released on June 11, 2021. 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. Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested in Glimmer DSL for SWT yet, so deem its support experimental for the time being without guarantees for functionality until declared otherwise (report any issues you may encounter).
19
19
 
20
- [Glimmer DSL for SWT receives two updates per month](https://rubygems.org/gems/glimmer-dsl-swt/versions). You can trust [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) with your Ruby desktop GUI development needs! [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) brings great ideas to the table, such as declarative programming via domain specific languages, currently under-utilized in the GUI domain. That said, it may not be feature complete enough for everybody's needs, so please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) even better by providing feedback and [contributing](#contributing) when possible. The project is very active, so any feature suggestions that are accepted could be implemented within weeks if not days. Also, you are welcome to [hire me](#hire-me) full-time if you want long-term development of [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) for your project needs.
20
+ **Starting in version 4.20.0.0, [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) comes with the new [***Shine***](/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#shine) syntax** for highly intuitive and visually expressive View/Model Attribute Mapping, relying on `<=>` for bidirectional (two-way) data-binding and `<=` for unidirectional (one-way) data-binding, providing an alternative to the `bind` keyword (keep in mind that it is still an early alpha, so default back to `bind` whenever needed).
21
+
22
+ Please help make [Glimmer DSL for SWT](https://rubygems.org/gems/glimmer-dsl-swt) better by providing feedback and [contributing](#contributing) whenever possible. Any feature suggestions that are accepted could be implemented within weeks if not days.
21
23
 
22
24
  Glimmer DSL gems:
23
25
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -308,18 +310,15 @@ https://www.eclipse.org/swt/faq.php
308
310
  ## Pre-requisites
309
311
 
310
312
  - JDK 8u241 (1.8.0_241) (find at https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html / On Windows, ensure PATH includes Java bin directory like C:\Program Files\Java\jdk1.8.0_241\bin for javapackager to work during packaging Glimmer applications)
311
- - JRuby 9.2.17.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)
312
- - SWT 4.19 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem)
313
+ - [RVM](http://rvm.io) on Mac & Linux (not available on Windows)
314
+ - JRuby 9.2.19.0 (supporting Ruby 2.5.x syntax) (get via [RVM](http://rvm.io) on Mac and Linux by running `rvm install jruby-9.2.19.0`; On Windows, find at [https://www.jruby.org/download](https://www.jruby.org/download))
315
+ - SWT 4.20 (already included in the [glimmer-dsl-swt](https://rubygems.org/gems/glimmer-dsl-swt) gem). Note that SWT now supports AARCH64 on Mac and Linux, but it is not fully tested with Glimmer DSL for SWT yet, so it is considered experimental until declared otherwise.
313
316
  - Git (comes with Mac and Linux. Install on Windows: https://git-scm.com/download/win )
314
317
 
315
- To obtain JRuby through [RVM](http://rvm.io), you may run:
316
-
317
- ```bash
318
- rvm install jruby-9.2.17.0
319
- ```
320
-
321
318
  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.
322
319
 
320
+ To change the SWT version to a custom `swt.jar` version that you have, simply set the 'SWT_JAR_FILE_PATH' env var.
321
+
323
322
  ## Setup
324
323
 
325
324
  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.
@@ -342,7 +341,7 @@ jgem install glimmer-dsl-swt
342
341
 
343
342
  Or this command if you want a specific version:
344
343
  ```
345
- jgem install glimmer-dsl-swt -v 4.19.0.2
344
+ jgem install glimmer-dsl-swt -v 4.20.0.0
346
345
  ```
347
346
 
348
347
  `jgem` is JRuby's version of `gem` command.
@@ -370,7 +369,7 @@ Note: if you're using activerecord or activesupport, keep in mind that Glimmer u
370
369
 
371
370
  Add the following to `Gemfile`:
372
371
  ```
373
- gem 'glimmer-dsl-swt', '~> 4.19.0.2'
372
+ gem 'glimmer-dsl-swt', '~> 4.20.0.0'
374
373
  ```
375
374
 
376
375
  And, then run:
@@ -391,7 +390,7 @@ glimmer
391
390
  ```
392
391
 
393
392
  ```
394
- Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.19.0.2
393
+ Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v4.20.0.0
395
394
 
396
395
  Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
397
396
 
@@ -682,10 +681,6 @@ You may apply for contributing to any of these Glimmer DSL gems whether you pref
682
681
 
683
682
  [Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-swt/graphs/contributors)
684
683
 
685
- ## Hire Me
686
-
687
- 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/).
688
-
689
684
  ## License
690
685
 
691
686
  [MIT](LICENSE.txt)
data/RUBY_VERSION CHANGED
@@ -1 +1 @@
1
- jruby-9.2.17.0
1
+ jruby-9.2.19.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.19.0.2
1
+ 4.20.0.0
@@ -380,6 +380,7 @@ Shell widget proxy has extra methods specific to SWT Shell:
380
380
  - `#visible?`: Returns whether a shell is visible
381
381
  - `#opened_before?`: Returns whether a shell has been opened at least once before (additionally implying the SWT Event Loop has been started already)
382
382
  - `#visible=`: Setting to true opens/shows shell. Setting to false hides the shell.
383
+ - `#layout`: Lays out contained widgets using SWT's `Shell#layout` method
383
384
  - `#pack`: Packs contained widgets using SWT's `Shell#pack` method
384
385
  - `#pack_same_size`: Packs contained widgets without changing shell's size when widget sizes change
385
386
 
@@ -919,6 +920,7 @@ Example loading a URL (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
919
920
  ```ruby
920
921
  shell {
921
922
  minimum_size 1024, 860
923
+ maximum_size 2000, 1000
922
924
  browser {
923
925
  url 'http://brightonresort.com/about'
924
926
  }
@@ -2230,13 +2232,13 @@ This example adds on the one above it by specifying converters on read and write
2230
2232
 
2231
2233
  `text bind(contact, 'address.street', sync_exec: true)`
2232
2234
 
2233
- **(ALPHA FEATURE)**
2235
+ **(BETA FEATURE)**
2234
2236
 
2235
2237
  This example forces GUI updates via [sync_exec](#sync_exec) assuming they are coming from another thread (different from the GUI thread)
2236
2238
 
2237
2239
  `text bind(contact, 'address.street', async_exec: true)`
2238
2240
 
2239
- **(ALPHA FEATURE)**
2241
+ **(BETA FEATURE)**
2240
2242
 
2241
2243
  This example forces GUI updates via [async_exec](#async_exec) assuming they are coming from another thread (different from the GUI thread)
2242
2244
 
@@ -2248,7 +2250,7 @@ This example also specifies a converter on read of the model property, but via a
2248
2250
 
2249
2251
  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.
2250
2252
 
2251
- `text bind(contact, 'address.street', read_only: true)
2253
+ `text bind(contact, 'address.street', read_only: true)`
2252
2254
 
2253
2255
  This is read-ohly data-binding. It doesn't update contact.address.street when widget text property is changed.
2254
2256
 
@@ -2270,6 +2272,33 @@ This example demonstrates nested indexed computed value data binding whereby the
2270
2272
 
2271
2273
  Example from [samples/hello/hello_combo.rb](samples/hello_combo.rb) sample (you may copy/paste in [`girb`](GLIMMER_GIRB.md)):
2272
2274
 
2275
+ #### Shine
2276
+
2277
+ **(EARLY ALPHA FEATURE)**
2278
+
2279
+ The new Shine syntax for View/Model Attribute Mapping allows data-binding visually with simple arrow operators in Ruby.
2280
+
2281
+ Use `<=> [model, attribute, options]` for bidirectional (two-way) data-binding instead of `bind(model, attribute, options)`.
2282
+ Use `<= [model, attribute, options]` for unidirectional (one-way) data-binding instead of `bind(model, attribute, read_only: true, more_options)`
2283
+
2284
+ Examples:
2285
+
2286
+ ```ruby
2287
+ text <=> [@contact, :first_name]
2288
+ ```
2289
+
2290
+ ```ruby
2291
+ text <=> [@contact, :last_name]
2292
+ ```
2293
+
2294
+ ```ruby
2295
+ text <= [@contact, :name, computed_by: [:first_name, :last_name]]
2296
+ ```
2297
+
2298
+ Note that `table`, `tree`, custom widgets, custom shapes, and animations are not supported by Shine syntax for data-binding yet, so continue to use `bind` with them for the time being.
2299
+
2300
+ Check out [sample code](/samples) for more examples of Shine syntax in action, such as [Hello, Computed!](/docs/reference/GLIMMER_SAMPLES.md#hello-computed).
2301
+
2273
2302
  #### Combo
2274
2303
 
2275
2304
  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.
@@ -3123,8 +3152,6 @@ You may see another example at the [Hello, Radio Group!](GLIMMER_SAMPLES.md#hell
3123
3152
 
3124
3153
  ##### Code Text Custom Widget
3125
3154
 
3126
- **(BETA FEATURE)**
3127
-
3128
3155
  `code_text` is a Glimmer built-in custom widget that displays syntax highlighted Ruby code in a customized SWT [StyledText](https://help.eclipse.org/2020-09/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/StyledText.html) widget.
3129
3156
 
3130
3157
  It is used in the [Glimmer Meta-Sample (The Sample of Samples)](#samples):
@@ -3149,8 +3176,6 @@ To use, simply use `code_text` in place of the `text` or `styled_text` widget. I
3149
3176
  **lines**
3150
3177
  (default: `false`)
3151
3178
 
3152
- **(BETA FEATURE)**
3153
-
3154
3179
  Shows line numbers when set to true.
3155
3180
 
3156
3181
  If set to a hash like `{width: 4}`, it sets the initial width of the line numbers lane in character count (default: 4)
@@ -3188,7 +3213,7 @@ Sets the code language, which can be one of the following [rouge gem](#https://r
3188
3213
  - bibtex
3189
3214
  - biml
3190
3215
  - bpf
3191
- - brainfuck
3216
+ - brainf*ck
3192
3217
  - brightscript
3193
3218
  - bsl
3194
3219
  - c
Binary file
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -19,26 +19,41 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- ## NOTE: Unsupported for now TODO support in the future
23
- #
24
- # require File.dirname(__FILE__) + "/glimmer"
25
- #
26
- # class Array
27
- # include Glimmer
28
- #
29
- # alias original_compare <=>
30
- #
31
- # def <=>(other)
32
- # if (self[0].class.name == "WidgetProxy")
33
- # content(self[0]) {
34
- # if (other.size == 2)
35
- # eval("#{self[1]} bind (other[0], other[1])")
36
- # elsif (other.size == 3)
37
- # eval("#{self[1]} bind (other[0], other[1], other[2])")
38
- # end
39
- # }
40
- # else
41
- # original_compare(other)
42
- # end
43
- # end
44
- # end
22
+ module Glimmer
23
+ module DataBinding
24
+ class Shine
25
+ include Glimmer
26
+
27
+ def initialize(parent, parent_attribute)
28
+ @parent = parent
29
+ @parent_attribute = parent_attribute
30
+ end
31
+
32
+ alias original_compare <=>
33
+
34
+ def <=>(other)
35
+ if other.is_a?(Array)
36
+ @parent.content {
37
+ send(@parent_attribute, bind(*other))
38
+ }
39
+ else # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
40
+ original_compare(other)
41
+ end
42
+ end
43
+
44
+ def <=(other)
45
+ if other.is_a?(Array)
46
+ args_clone = other.clone
47
+ if args_clone.last.is_a?(Hash)
48
+ args_clone.last[:read_only] = true
49
+ else # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
50
+ args_clone << {read_only: true}
51
+ end
52
+ @parent.content {
53
+ send(@parent_attribute, bind(*args_clone))
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -20,7 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/launcher'
23
- require Glimmer::Launcher.swt_jar_file
23
+ require ENV['SWT_JAR_FILE_PATH'] || "#{Glimmer::Launcher.swt_jar_file}#{Glimmer::Launcher.special_cpu_architecture_suffix}"
24
24
  require 'glimmer/dsl/engine'
25
25
  Dir[File.expand_path('../*_expression.rb', __FILE__)].each {|f| require f}
26
26
 
@@ -52,6 +52,7 @@ module Glimmer
52
52
  image
53
53
  multiply
54
54
  property
55
+ shine_data_binding
55
56
  block_property
56
57
  dialog
57
58
  widget
@@ -0,0 +1,49 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/widget_binding'
25
+ require 'glimmer/swt/display_proxy'
26
+ require 'glimmer/data_binding/shine'
27
+
28
+ module Glimmer
29
+ module DSL
30
+ module SWT
31
+ class ShineDataBindingExpression < Expression
32
+ def can_interpret?(parent, keyword, *args, &block)
33
+ args.size == 0 and
34
+ block.nil? and
35
+ parent.respond_to?(:set_attribute) and
36
+ parent.respond_to?(:has_attribute?) and
37
+ parent.has_attribute?(keyword, *args) and
38
+ !parent.is_a?(Glimmer::UI::CustomWidget) and
39
+ !parent.is_a?(Glimmer::UI::CustomShape) and
40
+ !(parent.respond_to?(:swt_widget) && parent.swt_widget.class == org.eclipse.swt.widgets.Canvas && keyword == 'image')
41
+ end
42
+
43
+ def interpret(parent, keyword, *args, &block)
44
+ Glimmer::DataBinding::Shine.new(parent, keyword)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -71,6 +71,12 @@ module Glimmer
71
71
  def platform_os
72
72
  OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")}
73
73
  end
74
+
75
+ def special_cpu_architecture_suffix
76
+ host_cpu = OS.host_cpu.downcase
77
+ special = host_cpu.include?('aarch64') || host_cpu.include?('arm')
78
+ special ? "_aarch64" : ''
79
+ end
74
80
 
75
81
  def swt_jar_file
76
82
  @swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar'))
@@ -124,21 +124,15 @@ module Glimmer
124
124
 
125
125
  @line_numbers_styled_text_proxy = styled_text(swt(swt(swt_style), :h_scroll!, :v_scroll!)) {
126
126
  layout_data(:right, :fill, false, true)
127
- top_pixel_before_read = nil
127
+
128
128
  text bind(self,
129
129
  :styled_text_proxy_text,
130
130
  read_only: true,
131
131
  on_read: lambda { |text_value|
132
- line_count = "#{text_value} ".split("\n").count
133
- line_count = 1 if line_count == 0
134
- lines_text_size = [line_count.to_s.size, @lines_width].max
135
- if lines_text_size > @lines_width
136
- @lines_width = lines_text_size
137
- end
138
- line_count.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n") + "\n"
132
+ line_numbers_text_from(text_value)
139
133
  },
140
134
  after_read: lambda {
141
- @line_numbers_styled_text_proxy&.top_pixel = styled_text_proxy_top_pixel
135
+ @line_numbers_styled_text_proxy&.top_pixel = styled_text_proxy_top_pixel unless styled_text_proxy_top_pixel.nil?
142
136
  }
143
137
  )
144
138
  top_pixel bind(self, :styled_text_proxy_top_pixel, read_only: true)
@@ -151,6 +145,7 @@ module Glimmer
151
145
  left_margin 5
152
146
  editable false
153
147
  caret nil
148
+
154
149
  on_focus_gained {
155
150
  @styled_text_proxy&.setFocus
156
151
  }
@@ -173,6 +168,7 @@ module Glimmer
173
168
  @styled_text_proxy = styled_text(swt_style) {
174
169
  # custom_widget_property_owner # TODO implement to route properties here without declaring method_missing
175
170
  layout_data :fill, :fill, true, true if lines
171
+
176
172
  text bind(self, :styled_text_proxy_text) if lines
177
173
  top_pixel bind(self, :styled_text_proxy_top_pixel) if lines
178
174
  font name: @font_name, height: OS.mac? ? 15 : 12
@@ -291,6 +287,14 @@ module Glimmer
291
287
  new_offset = beginning_of_current_line_offset + current_line.size
292
288
  @styled_text_proxy.setSelection(new_offset, new_offset)
293
289
  end
290
+
291
+ def line_numbers_text_from(text_value)
292
+ line_count = "#{text_value} ".split("\n").count
293
+ line_count = 1 if line_count == 0
294
+ lines_text_size = [line_count.to_s.size, @lines_width].max
295
+ @lines_width = lines_text_size if lines_text_size > @lines_width
296
+ line_count.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n") + "\n"
297
+ end
294
298
  end
295
299
  end
296
300
  end
@@ -51,7 +51,7 @@ class ContactManager
51
51
  }
52
52
  text {
53
53
  layout_data :fill, :center, true, false
54
- text bind(@contact_manager_presenter, :first_name)
54
+ text <=> [@contact_manager_presenter, :first_name]
55
55
  on_key_pressed {|key_event|
56
56
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
57
57
  }
@@ -64,7 +64,7 @@ class ContactManager
64
64
  }
65
65
  text {
66
66
  layout_data :fill, :center, true, false
67
- text bind(@contact_manager_presenter, :last_name)
67
+ text <=> [@contact_manager_presenter, :last_name]
68
68
  on_key_pressed {|key_event|
69
69
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
70
70
  }
@@ -77,7 +77,7 @@ class ContactManager
77
77
  }
78
78
  text {
79
79
  layout_data :fill, :center, true, false
80
- text bind(@contact_manager_presenter, :email)
80
+ text <=> [@contact_manager_presenter, :email]
81
81
  on_key_pressed {|key_event|
82
82
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
83
83
  }
@@ -118,6 +118,7 @@ class ContactManager
118
118
  grab_excess_vertical_space true
119
119
  height_hint 200
120
120
  }
121
+
121
122
  table_column {
122
123
  text "First Name"
123
124
  width 80
@@ -130,8 +131,9 @@ class ContactManager
130
131
  text "Email"
131
132
  width 200
132
133
  }
133
- items bind(@contact_manager_presenter, :results),
134
- column_properties(:first_name, :last_name, :email)
134
+
135
+ items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
136
+
135
137
  on_mouse_up { |event|
136
138
  table_proxy.edit_table_item(event.table_item, event.column_index)
137
139
  }