glimmer-dsl-opal 0.10.1 → 0.13.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 +29 -0
  3. data/README.md +34 -27
  4. data/VERSION +1 -1
  5. data/lib/display.rb +3 -0
  6. data/lib/glimmer-dsl-opal.rb +1 -1
  7. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +1 -1
  8. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +15 -13
  9. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +55 -28
  10. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +16 -14
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +14 -9
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +5 -5
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +16 -12
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +4 -4
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +6 -6
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +18 -16
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +17 -12
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +4 -4
  25. data/lib/glimmer/data_binding/table_items_binding.rb +3 -2
  26. data/lib/glimmer/dsl/opal/bind_expression.rb +24 -25
  27. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +8 -8
  28. data/lib/glimmer/dsl/opal/dsl.rb +4 -0
  29. data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
  30. data/lib/glimmer/dsl/opal/property_expression.rb +2 -1
  31. data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
  32. data/lib/glimmer/dsl/opal/shell_expression.rb +1 -1
  33. data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +49 -0
  34. data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
  35. data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
  36. data/lib/glimmer/swt/combo_proxy.rb +1 -0
  37. data/lib/glimmer/swt/composite_proxy.rb +2 -0
  38. data/lib/glimmer/swt/dialog_proxy.rb +2 -5
  39. data/lib/glimmer/swt/display_proxy.rb +104 -10
  40. data/lib/glimmer/swt/grid_layout_proxy.rb +17 -17
  41. data/lib/glimmer/swt/layout_proxy.rb +23 -3
  42. data/lib/glimmer/swt/message_box_proxy.rb +4 -4
  43. data/lib/glimmer/swt/row_layout_proxy.rb +12 -3
  44. data/lib/glimmer/swt/table_proxy.rb +19 -3
  45. data/lib/glimmer/swt/widget_proxy.rb +3 -4
  46. data/lib/glimmer/ui/custom_shell.rb +22 -5
  47. data/lib/glimmer/ui/custom_widget.rb +11 -2
  48. data/lib/glimmer/util/proc_tracker.rb +5 -3
  49. metadata +11 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a69a60c500b662de0e458896e7da698a769ed5823c924d591825d3bfd5845605
4
- data.tar.gz: 223e76c5d758d5caecfa9843a491acb23302f9c1f1b3cf592af830bfefa4c114
3
+ metadata.gz: d4c1b8623cfb624fda19e969ff546ad75a41d32331c9c5c3cabd267a74c96b62
4
+ data.tar.gz: 4b84ff762bbc5cecc3eefbf4e0dbd7f95501658523751e2a2936405974a662a6
5
5
  SHA512:
6
- metadata.gz: 79b96f5af0774f9bf5e508af1a67aa6a80cb061f818b295b178dd01e65561003fb573b394f5c21fc03440cfb2f834f95260ae03e5558fb1c24ac9261520fa275
7
- data.tar.gz: c9c643cd2043e1a62db4f7487f2c2a7a447b09ebc7f33d8d255c1cb6daf2ed78b19aab3be25f1efef7408df02ca61f757f455b69552b9ec4f8ac9c7e35b97291
6
+ metadata.gz: da478774923d89f49c1fbc050f9234f24a728781dddc7f38a1790795efdf5f1d9228982859e6027fd4e90d3ad61d8254275df4882a9453c61f0bbfcf16c7e089
7
+ data.tar.gz: f8a46956d0caf08f7ab94bb183e02131acd808f4e17d084d961e15c79ea044c9dc16cb20a436e94ea63a26446cc6ce6b5467878634c04960a8464b38ee26666d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.13.0
4
+
5
+ - Support Shine data-binding syntax in custom widgets
6
+ - Update Hello, Checkbox!, Hello, Checkbox Group!, Hello, Radio! and Hello, Radio Group! to utilize Shine data-binding syntax from latest glimmer-dsl-swt
7
+
8
+ ## 0.12.0
9
+
10
+ - Support CustomShell.launch opening in the same window if no other shell is open or DisplayProxy.open_custom_shells_in_current_window = true is set
11
+ - Support CustomShell.launch opening a new window if a shell is already open
12
+ - Support passing `table` data-binding column properties as `column_properties` or `column_attributes` an extra hash option to `bind` method call
13
+ - Support Shine data-binding syntax in `table`
14
+ - Update Hello, Custom Shell!, Hello, Table!, Contact Manager, and Login samples to use Shine data-binding syntax
15
+
16
+ ## 0.11.0
17
+
18
+ - Upgrade to glimmer 2.0.0
19
+ - Support Shine syntax for basic widgets (no support for table, tree, shapes, custom widgets, or custom shells)
20
+ - Update samples to use Shine syntax
21
+
22
+ ## 0.10.3
23
+
24
+ - Upgrade to glimmer 1.0.10
25
+ - Improvements to row_layout and grid_layout
26
+ - Adding launch/shutdown class methods to Custom Shells
27
+
28
+ ## 0.10.2
29
+
30
+ - Support multiple dialogs/message_box'es opened from a listener, handling correct ordering of display with a queue scheduler
31
+
3
32
  ## 0.10.1
4
33
 
5
34
  - Delaying shell rendering till `#open` method is called as per the right expectation
data/README.md CHANGED
@@ -1,16 +1,16 @@
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 Opal 0.10.1 (Pure Ruby Web GUI)
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal 0.13.0 (Pure Ruby Web GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
3
3
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
 
5
- ### You can finally live in pure Ruby land on the web!
5
+ ### You can finally live in pure Rubyland on the web!
6
6
 
7
- [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Opal](https://opalrb.com/) is an **alpha** [gem](https://rubygems.org/gems/glimmer-dsl-opal) that enables building web GUI in pure Ruby via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/).
7
+ [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Opal](https://opalrb.com/) is an **alpha** [gem](https://rubygems.org/gems/glimmer-dsl-opal) that enables building web GUI in pure Ruby via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/) **(now comes with the new Shine data-binding syntax)**.
8
8
 
9
9
  Use in one of two ways:
10
10
  - **Direct:** build the GUI of web apps with the same friendly desktop GUI Ruby syntax as [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt), thus requiring a lot less code than web technologies that is in pure Ruby and avoiding opaque web concepts like 'render' and 'reactive'. No HTML/JS/CSS skills are even required. Web designers may be involved with CSS styling only if needed.
11
11
  - **Adapter:** auto-webify [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)) via [Opal](https://opalrb.com/) on [Rails](https://rubyonrails.org/) without changing a line of code. Just insert them as a single require statement in a Rails app, and BOOM! They're running on the web! Apps may then optionally be custom-styled for the web by web designers with standard CSS if needed.
12
12
 
13
- Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com/AndyObtiva/glimmer) core DSL engine in [Opal Ruby](https://opalrb.com/) inside a web browser, and as such inherits the full range of powerful Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web.
13
+ Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com/AndyObtiva/glimmer) core DSL engine in [Opal Ruby](https://opalrb.com/) inside a web browser, and as such inherits the full range of Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web (including Shine syntax using `<=>` and `<=` for bidirectional [two-way] and unidirectional [one-way] data-binding respectively).
14
14
 
15
15
  #### Hello, Table! Sample
16
16
 
@@ -141,17 +141,17 @@ Hello, Table! Game Booked
141
141
 
142
142
  NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
143
143
 
144
- **Alpha Version** 0.10.1 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
144
+ **Alpha Version** 0.13.0 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
145
145
 
146
146
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
147
147
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
148
148
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
149
149
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
150
- - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
150
+ - [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
151
151
 
152
152
  ## Table of Contents
153
153
 
154
- - [Glimmer DSL for Opal 0.10.1 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0101-pure-ruby-web-gui)
154
+ - [Glimmer DSL for Opal 0.13.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0130-pure-ruby-web-gui)
155
155
  - [Principles](#principles)
156
156
  - [Background](#background)
157
157
  - [Pre-requisites](#pre-requisites)
@@ -199,15 +199,18 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
199
199
 
200
200
  ## Principles
201
201
 
202
+ Please keep in mind this is a live list of innovative ideas, some of which have not been implemented yet. Watch the project on GitHub to stay up to date with its development.
203
+
202
204
  - **Live purely in Rubyland via the Glimmer GUI DSL**, completely oblivious to web browser technologies, thanks to [Opal](https://opalrb.com/).
203
- - **Forget Routers!** Glimmer DSL for Opal supports auto-routing of custom shells (windows), which are opened as separate tabs in a web browser with automatically generated routes and bookmarkable URLs.
204
- - **HTML is strictly made for creating documents not interactive applications**. As such, software engineers can avoid it and focus on creating web applications more productively with Glimmer DSL for Opal in pure Ruby instead (just like they do in desktop development) while content creators and web designers can be the ones responsible for creating HTML documents for web content purposes only as HTML was originally intended. That way, Glimmer web GUI is used and embedded in web pages when providing users with applications while the rest of the web pages are maintained by non-engineers as pure HTML. This achieves a correct separation of responsibilities and better productivity and maintainability.
205
+ - **HTML is for creating documents not interactive applications**. As such, software engineers can avoid it and focus on creating web applications more productively with Glimmer DSL for Opal in pure Ruby instead (just like they do in desktop development) while content creators and web designers can be the ones responsible for creating HTML documents for web content purposes only as HTML was originally intended. That way, Glimmer web GUI is used and embedded in web pages when providing users with applications while the rest of the web pages are maintained by non-engineers as pure HTML. This achieves a correct separation of responsibilities and better productivity and maintainability.
205
206
  - **Approximate styles by developers via the Glimmer GUI DSL. Perfect styles by designers via pure CSS**. Developers can simply build GUI with approximate styling similar to desktop GUI and mockups without worrying about pixel-perfect aesthetics. Web designers can take styling further with pure CSS since every HTML element auto-generated by Glimmer DSL for Opal has a predictable ID and CSS class. This achieves a proper separation of responsibilities between developers and designers.
206
207
  - **Web servers are used just like servers in traditional client/server architecture**, meaning they simply provide RMI services to enable centralizing some of the application logic and data in the cloud to make available everywhere and enable data-sharing with others.
208
+ - **Everybody In!** All JS frameworks sadly suffer from very major software design handicaps because of trying to ensure data security, so you end up with a very strict separation between server data and client data, making your head spin and worrying more about hackers and attackers than serving users. Try again! Thanks to the principle of Everybody In, Glimmer DSL for Opal apps have a very unique software architecture that revolves around the idea of multi-tenancy. Basically, every user gets their own server-side real-estate, that is a fully-secure-and-independent server-side instance that has its own user database, so hackers are not only intentionally allowed in, they are WELCOMED! As such, instead of protecting all users' data with an iron fist over a shared server/database (a terribly insecure architecture no matter how profilerate), you simply provide each user their own fully-independent server/client real-estate, thus be able to focus on serving them in the best way possible by writing code that is so simple it is just like desktop application code, but living in the Cloud on the Web. In summary, just code web as if you're on the desktop and be happy!
209
+ - **Forget Routers!** Glimmer DSL for Opal supports auto-routing of custom shells (windows), which are opened as separate tabs in a web browser with automatically generated routes and bookmarkable URLs.
207
210
 
208
211
  ## Background
209
212
 
210
- The original idea behind Glimmer DSL for Opal (which later evolved) was that you start by having a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) desktop app that communicates with a Rails API for any web/cloud concerns. The pure Ruby [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) is very simple, so it is more productive to build GUI in it since it does not go through a server/client request/response cycle and can be iterated on locally with a much shorter feedback cycle. Once the GUI and the rest of the app is built. You simply embed it in a Rails app as a one line require statement, and BOOM, it just works on the web inside a web browser with the same server/client communication you had in the desktop app (I am working on adding minimal support for net/http in Opal so that desktop apps that use it continue to work in a web browser. Until then, just use [Opal-jQuery](https://github.com/opal/opal-jquery) http support). That way, you get two apps for one: desktop and web.
213
+ The original idea behind Glimmer DSL for Opal (which [later evolved](#principles)) was that you start by having a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) desktop app that communicates with a Rails API for any web/cloud concerns. The pure Ruby [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) is very simple, so it is more productive to build GUI in it since it does not go through a server/client request/response cycle and can be iterated on locally with a much shorter feedback cycle. Once the GUI and the rest of the app is built. You simply embed it in a Rails app as a one line require statement, and BOOM, it just works on the web inside a web browser with the same server/client communication you had in the desktop app (I am working on adding minimal support for net/http in Opal so that desktop apps that use it continue to work in a web browser. Until then, just use [Opal-jQuery](https://github.com/opal/opal-jquery) http support). That way, you get two apps for one: desktop and web.
211
214
 
212
215
  Part of the idea is that web browsers just render GUI widgets similar to those of a desktop app (after all a web browser is a desktop app), so whether you run your GUI on the desktop or on the web should just be a low-level concern, hopefully automated completely with Glimmer DSL for Opal.
213
216
 
@@ -249,9 +252,9 @@ Add the following to `Gemfile`:
249
252
  gem 'opal-rails', '~> 1.1.2'
250
253
  gem 'opal-async', '~> 1.2.0'
251
254
  gem 'opal-jquery', '~> 0.4.4'
252
- gem 'glimmer-dsl-opal', '~> 0.10.1'
253
- gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
254
- gem 'glimmer-dsl-css', '~> 1.1.0', require: false
255
+ gem 'glimmer-dsl-opal', '~> 0.13.0'
256
+ gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
257
+ gem 'glimmer-dsl-css', '~> 1.2.0', require: false
255
258
 
256
259
  ```
257
260
 
@@ -310,7 +313,7 @@ shell {
310
313
 
311
314
  ## Supported Glimmer DSL Keywords
312
315
 
313
- The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have partial support in Opal:
316
+ The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) have fully functional partial support in Opal:
314
317
 
315
318
  Widgets:
316
319
  - `button`: featured in [Hello, Checkbox!](#hello-checkbox) / [Hello, Button!](#hello-button) / [Hello, Table!](#hello-table) / [Hello, Radio Group!](#hello-radio-group) / [Hello, Radio!](#hello-radio) / [Hello, Message Box!](#hello-message-box) / [Hello, List Single Selection!](#hello-list-single-selection) / [Hello, List Multi Selection!](#hello-list-multi-selection) / [Hello, Group!](#hello-group) / [Hello, Combo!](#hello-combo) / [Hello, Checkbox Group!](#hello-checkbox-group) / [Contact Manager](#contact-manager) / [Tic Tac Toe](#tic-tac-toe) / [Login](#login)
@@ -465,7 +468,7 @@ class HelloCombo
465
468
  text 'Hello, Combo!'
466
469
 
467
470
  combo(:read_only) {
468
- selection bind(person, :country)
471
+ selection <=> [person, :country]
469
472
  }
470
473
 
471
474
  button {
@@ -530,9 +533,7 @@ class HelloComputed
530
533
  0
531
534
  end
532
535
  end
533
- end
534
536
 
535
- class HelloComputed
536
537
  include Glimmer
537
538
 
538
539
  def initialize
@@ -546,6 +547,7 @@ class HelloComputed
546
547
  def launch
547
548
  shell {
548
549
  text 'Hello, Computed!'
550
+
549
551
  composite {
550
552
  grid_layout {
551
553
  num_columns 2
@@ -553,41 +555,46 @@ class HelloComputed
553
555
  horizontal_spacing 20
554
556
  vertical_spacing 10
555
557
  }
558
+
556
559
  label {text 'First &Name: '}
557
560
  text {
558
- text bind(@contact, :first_name)
561
+ text <=> [@contact, :first_name]
559
562
  layout_data {
560
563
  horizontal_alignment :fill
561
564
  grab_excess_horizontal_space true
562
565
  }
563
566
  }
567
+
564
568
  label {text '&Last Name: '}
565
569
  text {
566
- text bind(@contact, :last_name)
570
+ text <=> [@contact, :last_name]
567
571
  layout_data {
568
572
  horizontal_alignment :fill
569
573
  grab_excess_horizontal_space true
570
574
  }
571
575
  }
576
+
572
577
  label {text '&Year of Birth: '}
573
578
  text {
574
- text bind(@contact, :year_of_birth)
579
+ text <=> [@contact, :year_of_birth]
575
580
  layout_data {
576
581
  horizontal_alignment :fill
577
582
  grab_excess_horizontal_space true
578
583
  }
579
584
  }
585
+
580
586
  label {text 'Name: '}
581
587
  label {
582
- text bind(@contact, :name, computed_by: [:first_name, :last_name])
588
+ text <= [@contact, :name, computed_by: [:first_name, :last_name]]
583
589
  layout_data {
584
590
  horizontal_alignment :fill
585
591
  grab_excess_horizontal_space true
586
592
  }
587
593
  }
594
+
588
595
  label {text 'Age: '}
589
596
  label {
590
- text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
597
+ text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
591
598
  layout_data {
592
599
  horizontal_alignment :fill
593
600
  grab_excess_horizontal_space true
@@ -1287,7 +1294,7 @@ class HelloRadioGroup
1287
1294
 
1288
1295
  radio_group {
1289
1296
  row_layout :horizontal
1290
- selection bind(person, :gender)
1297
+ selection <=> [person, :gender]
1291
1298
  }
1292
1299
 
1293
1300
  label {
@@ -1297,7 +1304,7 @@ class HelloRadioGroup
1297
1304
 
1298
1305
  radio_group {
1299
1306
  row_layout :horizontal
1300
- selection bind(person, :age_group)
1307
+ selection <=> [person, :age_group]
1301
1308
  }
1302
1309
 
1303
1310
  button {
@@ -1376,12 +1383,12 @@ class HelloGroup
1376
1383
 
1377
1384
  radio {
1378
1385
  text 'Male'
1379
- selection bind(person, :male)
1386
+ selection <=> [person, :male]
1380
1387
  }
1381
1388
 
1382
1389
  radio {
1383
1390
  text 'Female'
1384
- selection bind(person, :female)
1391
+ selection <=> [person, :female]
1385
1392
  }
1386
1393
  }
1387
1394
 
@@ -1578,7 +1585,7 @@ class HelloCheckboxGroup
1578
1585
  }
1579
1586
 
1580
1587
  checkbox_group {
1581
- selection bind(person, :activities)
1588
+ selection <=> [person, :activities]
1582
1589
  }
1583
1590
 
1584
1591
  button {
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.1
1
+ 0.13.0
data/lib/display.rb CHANGED
@@ -24,8 +24,11 @@ class Display
24
24
  def setAppName(app_name)
25
25
  # No Op in Opal
26
26
  end
27
+ alias app_name= setAppName
28
+
27
29
  def setAppVersion(version)
28
30
  # No Op in Opal
29
31
  end
32
+ alias app_version= setAppVersion
30
33
  end
31
34
  end
@@ -84,7 +84,7 @@ if RUBY_ENGINE == 'opal'
84
84
  Element.alias_native :select
85
85
  Element.alias_native :dialog
86
86
 
87
- # Glimmer::Config.loop_max_count = 20 # TODO disable
87
+ Glimmer::Config.loop_max_count = 250 # TODO disable
88
88
 
89
89
  original_logger_level = Glimmer::Config.logger.level
90
90
  Glimmer::Config.logger = Glimmer::Config::OpalLogger.new(STDOUT)
@@ -31,7 +31,7 @@ module Glimmer
31
31
  def interpret_expression(expression, keyword, *args, &block)
32
32
  work = lambda do
33
33
  expression.interpret(parent, keyword, *args, &block).tap do |ui_object|
34
- add_content(ui_object, expression, &block)
34
+ add_content(ui_object, expression, keyword, *args, &block)
35
35
  dsl_stack.pop
36
36
  end
37
37
  end
@@ -1,14 +1,14 @@
1
1
  require_relative "contact_manager/contact_manager_presenter"
2
2
 
3
3
  class ContactManager
4
- include Glimmer
4
+ include Glimmer::UI::CustomShell
5
5
 
6
- def initialize
6
+ before_body {
7
7
  @contact_manager_presenter = ContactManagerPresenter.new
8
8
  @contact_manager_presenter.list
9
- end
9
+ }
10
10
 
11
- def launch
11
+ body {
12
12
  shell {
13
13
  text "Contact Manager"
14
14
  composite {
@@ -28,7 +28,7 @@ class ContactManager
28
28
  }
29
29
  text {
30
30
  layout_data :fill, :center, true, false
31
- text bind(@contact_manager_presenter, :first_name)
31
+ text <=> [@contact_manager_presenter, :first_name]
32
32
  on_key_pressed {|key_event|
33
33
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
34
34
  }
@@ -41,7 +41,7 @@ class ContactManager
41
41
  }
42
42
  text {
43
43
  layout_data :fill, :center, true, false
44
- text bind(@contact_manager_presenter, :last_name)
44
+ text <=> [@contact_manager_presenter, :last_name]
45
45
  on_key_pressed {|key_event|
46
46
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
47
47
  }
@@ -54,7 +54,7 @@ class ContactManager
54
54
  }
55
55
  text {
56
56
  layout_data :fill, :center, true, false
57
- text bind(@contact_manager_presenter, :email)
57
+ text <=> [@contact_manager_presenter, :email]
58
58
  on_key_pressed {|key_event|
59
59
  @contact_manager_presenter.find if key_event.keyCode == swt(:cr)
60
60
  }
@@ -87,7 +87,7 @@ class ContactManager
87
87
  }
88
88
  }
89
89
 
90
- table(:multi) { |table_proxy|
90
+ table(:editable, :multi) { |table_proxy|
91
91
  layout_data {
92
92
  horizontal_alignment :fill
93
93
  vertical_alignment :fill
@@ -95,6 +95,7 @@ class ContactManager
95
95
  grab_excess_vertical_space true
96
96
  height_hint 200
97
97
  }
98
+
98
99
  table_column {
99
100
  text "First Name"
100
101
  width 80
@@ -107,15 +108,16 @@ class ContactManager
107
108
  text "Email"
108
109
  width 200
109
110
  }
110
- items bind(@contact_manager_presenter, :results),
111
- column_properties(:first_name, :last_name, :email)
111
+
112
+ items <=> [@contact_manager_presenter, :results, column_attributes: [:first_name, :last_name, :email]]
113
+
112
114
  on_mouse_up { |event|
113
115
  table_proxy.edit_table_item(event.table_item, event.column_index)
114
116
  }
115
117
  }
116
118
  }
117
- }.open
118
- end
119
+ }
120
+ }
119
121
  end
120
122
 
121
- ContactManager.new.launch
123
+ ContactManager.launch
@@ -1,4 +1,25 @@
1
- require "observer"
1
+ # Copyright (c) 2020-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-swt'
2
23
 
3
24
  class LoginPresenter
4
25
 
@@ -14,29 +35,26 @@ class LoginPresenter
14
35
 
15
36
  def status=(status)
16
37
  @status = status
17
-
18
- notify_observers("logged_in")
19
- notify_observers("logged_out")
20
38
  end
21
39
 
22
40
  def valid?
23
41
  !@user_name.to_s.strip.empty? && !@password.to_s.strip.empty?
24
42
  end
25
43
 
26
- def logged_in
44
+ def logged_in?
27
45
  self.status == "Logged In"
28
46
  end
29
47
 
30
- def logged_out
31
- !self.logged_in
48
+ def logged_out?
49
+ !self.logged_in?
32
50
  end
33
51
 
34
- def login
52
+ def login!
35
53
  return unless valid?
36
54
  self.status = "Logged In"
37
55
  end
38
56
 
39
- def logout
57
+ def logout!
40
58
  self.user_name = ""
41
59
  self.password = ""
42
60
  self.status = "Logged Out"
@@ -45,19 +63,24 @@ class LoginPresenter
45
63
  end
46
64
 
47
65
  class Login
48
- include Glimmer
66
+ include Glimmer::UI::CustomShell
67
+
68
+ before_body {
69
+ @presenter = LoginPresenter.new
70
+ }
49
71
 
50
- def launch
51
- presenter = LoginPresenter.new
52
- @shell = shell {
72
+ body {
73
+ shell {
53
74
  text "Login"
75
+
54
76
  composite {
55
77
  grid_layout 2, false #two columns with differing widths
56
78
 
57
79
  label { text "Username:" } # goes in column 1
58
80
  @user_name_text = text { # goes in column 2
59
- text bind(presenter, :user_name)
60
- enabled bind(presenter, :logged_out)
81
+ text <=> [@presenter, :user_name]
82
+ enabled <= [@presenter, :logged_out?, computed_by: :status]
83
+
61
84
  on_key_pressed { |event|
62
85
  @password_text.set_focus if event.keyCode == swt(:cr)
63
86
  }
@@ -65,40 +88,44 @@ class Login
65
88
 
66
89
  label { text "Password:" }
67
90
  @password_text = text(:password, :border) {
68
- text bind(presenter, :password)
69
- enabled bind(presenter, :logged_out)
91
+ text <=> [@presenter, :password]
92
+ enabled <= [@presenter, :logged_out?, computed_by: :status]
93
+
70
94
  on_key_pressed { |event|
71
- presenter.login if event.keyCode == swt(:cr)
95
+ @presenter.login! if event.keyCode == swt(:cr)
72
96
  }
73
97
  }
74
98
 
75
99
  label { text "Status:" }
76
- label { text bind(presenter, :status) }
100
+ label { text <= [@presenter, :status] }
77
101
 
78
102
  button {
79
103
  text "Login"
80
- enabled bind(presenter, :logged_out)
81
- on_widget_selected { presenter.login }
104
+ enabled <= [@presenter, :logged_out?, computed_by: :status]
105
+
106
+ on_widget_selected { @presenter.login! }
82
107
  on_key_pressed { |event|
83
- presenter.login if event.keyCode == swt(:cr)
108
+ if event.keyCode == swt(:cr)
109
+ @presenter.login!
110
+ end
84
111
  }
85
112
  }
86
113
 
87
114
  button {
88
115
  text "Logout"
89
- enabled bind(presenter, :logged_in)
90
- on_widget_selected { presenter.logout }
116
+ enabled <= [@presenter, :logged_in?, computed_by: :status]
117
+
118
+ on_widget_selected { @presenter.logout! }
91
119
  on_key_pressed { |event|
92
120
  if event.keyCode == swt(:cr)
93
- presenter.logout
121
+ @presenter.logout!
94
122
  @user_name_text.set_focus
95
123
  end
96
124
  }
97
125
  }
98
126
  }
99
127
  }
100
- @shell.open
101
- end
128
+ }
102
129
  end
103
130
 
104
- Login.new.launch
131
+ Login.launch