glimmer-dsl-opal 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +84 -22
- data/VERSION +1 -1
- data/lib/display.rb +3 -0
- data/lib/glimmer-dsl-opal.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +5 -2
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +17 -13
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +55 -28
- data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +5 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +6 -6
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +6 -6
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +2 -2
- data/lib/glimmer/data_binding/table_items_binding.rb +3 -2
- data/lib/glimmer/dsl/opal/bind_expression.rb +24 -25
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -6
- data/lib/glimmer/dsl/opal/dsl.rb +4 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/property_expression.rb +2 -1
- data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
- data/lib/glimmer/swt/combo_proxy.rb +1 -0
- data/lib/glimmer/swt/composite_proxy.rb +18 -2
- data/lib/glimmer/swt/dialog_proxy.rb +47 -32
- data/lib/glimmer/swt/display_proxy.rb +128 -9
- data/lib/glimmer/swt/grid_layout_proxy.rb +28 -33
- data/lib/glimmer/swt/latest_dialog_proxy.rb +3 -1
- data/lib/glimmer/swt/latest_message_box_proxy.rb +3 -1
- data/lib/glimmer/swt/latest_shell_proxy.rb +6 -2
- data/lib/glimmer/swt/layout_proxy.rb +32 -9
- data/lib/glimmer/swt/message_box_proxy.rb +20 -10
- data/lib/glimmer/swt/row_layout_proxy.rb +13 -6
- data/lib/glimmer/swt/shell_proxy.rb +30 -8
- data/lib/glimmer/swt/table_proxy.rb +19 -3
- data/lib/glimmer/swt/widget_proxy.rb +50 -19
- data/lib/glimmer/ui/custom_shell.rb +23 -6
- data/lib/glimmer/util/proc_tracker.rb +16 -5
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5328b8fd90117a9774e990256d5650ab8c15cd2745a29a466384261a1ead8a
|
4
|
+
data.tar.gz: 2cfceae33c796f8aea84036dba490aa55ca94b5f7785c0c2f75dbc5e27535259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e574405ade34c331a168a3dd2814112269dff90a72d58678f06246d94246e2a1c7bfc7e56163df61c2805fc58764a5da48687273ce98ce5c10cf27cf52fb5d51
|
7
|
+
data.tar.gz: 297d37971d6939413fa2dd2535169b486a7c5332395f34b5d2f2c0697f41fce67c61c613dba83575b88e5904ef128354f5846e9e7e96963aa065f93050f2476d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.12.0
|
4
|
+
|
5
|
+
- 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
|
6
|
+
- Support CustomShell.launch opening a new window if a shell is already open
|
7
|
+
- Support passing `table` data-binding column properties as `column_properties` or `column_attributes` an extra hash option to `bind` method call
|
8
|
+
- Support Shine data-binding syntax in `table`
|
9
|
+
- Update Hello, Custom Shell!, Hello, Table!, Contact Manager, and Login samples to use Shine data-binding syntax
|
10
|
+
|
11
|
+
## 0.11.0
|
12
|
+
|
13
|
+
- Upgrade to glimmer 2.0.0
|
14
|
+
- Support Shine syntax for basic widgets (no support for table, tree, shapes, custom widgets, or custom shells)
|
15
|
+
- Update samples to use Shine syntax
|
16
|
+
|
17
|
+
## 0.10.3
|
18
|
+
|
19
|
+
- Upgrade to glimmer 1.0.10
|
20
|
+
- Improvements to row_layout and grid_layout
|
21
|
+
- Adding launch/shutdown class methods to Custom Shells
|
22
|
+
|
23
|
+
## 0.10.2
|
24
|
+
|
25
|
+
- Support multiple dialogs/message_box'es opened from a listener, handling correct ordering of display with a queue scheduler
|
26
|
+
|
27
|
+
## 0.10.1
|
28
|
+
|
29
|
+
- Delaying shell rendering till `#open` method is called as per the right expectation
|
30
|
+
- When nesting dialogs on top of each other, disable all previously opened ones leaving only the top-most dialog active
|
31
|
+
|
3
32
|
## 0.10.0
|
4
33
|
|
5
34
|
- Hello, Dialog! Sample
|
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.
|
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.12.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
|
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
|
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.
|
144
|
+
**Alpha Version** 0.12.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.
|
154
|
+
- [Glimmer DSL for Opal 0.12.0 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0110-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
|
-
- **
|
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.
|
253
|
-
gem 'glimmer-dsl-xml', '~> 1.
|
254
|
-
gem 'glimmer-dsl-css', '~> 1.
|
255
|
+
gem 'glimmer-dsl-opal', '~> 0.12.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
|
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
|
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
|
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
|
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
|
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
|
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
|
@@ -2547,8 +2554,63 @@ require 'glimmer-dsl-opal/samples/hello/hello_dialog'
|
|
2547
2554
|
Or add the Glimmer code directly if you prefer to play around with it:
|
2548
2555
|
|
2549
2556
|
```ruby
|
2557
|
+
include Glimmer
|
2550
2558
|
|
2559
|
+
shell {
|
2560
|
+
row_layout :vertical
|
2561
|
+
|
2562
|
+
text 'Hello, Dialog!'
|
2563
|
+
|
2564
|
+
7.times { |n|
|
2565
|
+
dialog_number = n + 1
|
2566
|
+
|
2567
|
+
button {
|
2568
|
+
layout_data {
|
2569
|
+
width 200
|
2570
|
+
height 50
|
2571
|
+
}
|
2572
|
+
text "Dialog #{dialog_number}"
|
2573
|
+
|
2574
|
+
on_widget_selected {
|
2575
|
+
dialog { |dialog_proxy|
|
2576
|
+
row_layout(:vertical) {
|
2577
|
+
center true
|
2578
|
+
}
|
2579
|
+
|
2580
|
+
text "Dialog #{dialog_number}"
|
2581
|
+
|
2582
|
+
label {
|
2583
|
+
text "Given `dialog` is modal, you cannot interact with the main window till the dialog is closed."
|
2584
|
+
}
|
2585
|
+
composite {
|
2586
|
+
row_layout {
|
2587
|
+
margin_height 0
|
2588
|
+
margin_top 0
|
2589
|
+
margin_bottom 0
|
2590
|
+
}
|
2551
2591
|
|
2592
|
+
label {
|
2593
|
+
text "Unlike `message_box`, `dialog` can contain arbitrary widgets:"
|
2594
|
+
}
|
2595
|
+
radio {
|
2596
|
+
text 'Radio'
|
2597
|
+
}
|
2598
|
+
checkbox {
|
2599
|
+
text 'Checkbox'
|
2600
|
+
}
|
2601
|
+
}
|
2602
|
+
button {
|
2603
|
+
text 'Close'
|
2604
|
+
|
2605
|
+
on_widget_selected {
|
2606
|
+
dialog_proxy.close
|
2607
|
+
}
|
2608
|
+
}
|
2609
|
+
}.open
|
2610
|
+
}
|
2611
|
+
}
|
2612
|
+
}
|
2613
|
+
}.open
|
2552
2614
|
```
|
2553
2615
|
|
2554
2616
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.0
|
data/lib/display.rb
CHANGED
data/lib/glimmer-dsl-opal.rb
CHANGED
@@ -84,7 +84,7 @@ if RUBY_ENGINE == 'opal'
|
|
84
84
|
Element.alias_native :select
|
85
85
|
Element.alias_native :dialog
|
86
86
|
|
87
|
-
|
87
|
+
Glimmer::Config.loop_max_count = 300 # TODO disable
|
88
88
|
|
89
89
|
original_logger_level = Glimmer::Config.logger.level
|
90
90
|
Glimmer::Config.logger = Glimmer::Config::OpalLogger.new(STDOUT)
|
@@ -22,6 +22,7 @@
|
|
22
22
|
require 'glimmer/swt/latest_shell_proxy'
|
23
23
|
require 'glimmer/swt/latest_message_box_proxy'
|
24
24
|
require 'glimmer/swt/latest_dialog_proxy'
|
25
|
+
require 'glimmer/swt/display_proxy'
|
25
26
|
|
26
27
|
module Glimmer
|
27
28
|
module DSL
|
@@ -30,12 +31,14 @@ module Glimmer
|
|
30
31
|
def interpret_expression(expression, keyword, *args, &block)
|
31
32
|
work = lambda do
|
32
33
|
expression.interpret(parent, keyword, *args, &block).tap do |ui_object|
|
33
|
-
add_content(ui_object, expression, &block)
|
34
|
+
add_content(ui_object, expression, keyword, *args, &block)
|
34
35
|
dsl_stack.pop
|
35
36
|
end
|
36
37
|
end
|
37
38
|
if ['shell', 'message_box', 'dialog'].include?(keyword) && Glimmer::SWT::DisplayProxy.instance.shells.empty?
|
38
|
-
Document.ready?
|
39
|
+
Document.ready? do
|
40
|
+
Glimmer::SWT::DisplayProxy.instance.async_exec(&work)
|
41
|
+
end
|
39
42
|
Glimmer::SWT.const_get("Latest#{keyword.camelcase(:upper)}Proxy").new
|
40
43
|
else
|
41
44
|
work.call
|
@@ -1,14 +1,16 @@
|
|
1
|
+
require 'glimmer-dsl-swt'
|
2
|
+
|
1
3
|
require_relative "contact_manager/contact_manager_presenter"
|
2
4
|
|
3
5
|
class ContactManager
|
4
|
-
include Glimmer
|
6
|
+
include Glimmer::UI::CustomShell
|
5
7
|
|
6
|
-
|
8
|
+
before_body {
|
7
9
|
@contact_manager_presenter = ContactManagerPresenter.new
|
8
10
|
@contact_manager_presenter.list
|
9
|
-
|
11
|
+
}
|
10
12
|
|
11
|
-
|
13
|
+
body {
|
12
14
|
shell {
|
13
15
|
text "Contact Manager"
|
14
16
|
composite {
|
@@ -28,7 +30,7 @@ class ContactManager
|
|
28
30
|
}
|
29
31
|
text {
|
30
32
|
layout_data :fill, :center, true, false
|
31
|
-
text
|
33
|
+
text <=> [@contact_manager_presenter, :first_name]
|
32
34
|
on_key_pressed {|key_event|
|
33
35
|
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
34
36
|
}
|
@@ -41,7 +43,7 @@ class ContactManager
|
|
41
43
|
}
|
42
44
|
text {
|
43
45
|
layout_data :fill, :center, true, false
|
44
|
-
text
|
46
|
+
text <=> [@contact_manager_presenter, :last_name]
|
45
47
|
on_key_pressed {|key_event|
|
46
48
|
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
47
49
|
}
|
@@ -54,7 +56,7 @@ class ContactManager
|
|
54
56
|
}
|
55
57
|
text {
|
56
58
|
layout_data :fill, :center, true, false
|
57
|
-
text
|
59
|
+
text <=> [@contact_manager_presenter, :email]
|
58
60
|
on_key_pressed {|key_event|
|
59
61
|
@contact_manager_presenter.find if key_event.keyCode == swt(:cr)
|
60
62
|
}
|
@@ -87,7 +89,7 @@ class ContactManager
|
|
87
89
|
}
|
88
90
|
}
|
89
91
|
|
90
|
-
table(:multi) { |table_proxy|
|
92
|
+
table(:editable, :multi) { |table_proxy|
|
91
93
|
layout_data {
|
92
94
|
horizontal_alignment :fill
|
93
95
|
vertical_alignment :fill
|
@@ -95,6 +97,7 @@ class ContactManager
|
|
95
97
|
grab_excess_vertical_space true
|
96
98
|
height_hint 200
|
97
99
|
}
|
100
|
+
|
98
101
|
table_column {
|
99
102
|
text "First Name"
|
100
103
|
width 80
|
@@ -107,15 +110,16 @@ class ContactManager
|
|
107
110
|
text "Email"
|
108
111
|
width 200
|
109
112
|
}
|
110
|
-
|
111
|
-
|
113
|
+
|
114
|
+
items <=> [@contact_manager_presenter, :results, column_attributes: [:first_name, :last_name, :email]]
|
115
|
+
|
112
116
|
on_mouse_up { |event|
|
113
117
|
table_proxy.edit_table_item(event.table_item, event.column_index)
|
114
118
|
}
|
115
119
|
}
|
116
120
|
}
|
117
|
-
}
|
118
|
-
|
121
|
+
}
|
122
|
+
}
|
119
123
|
end
|
120
124
|
|
121
|
-
ContactManager.
|
125
|
+
ContactManager.launch
|
@@ -1,4 +1,25 @@
|
|
1
|
-
|
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
|
-
|
51
|
-
|
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
|
60
|
-
enabled
|
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
|
69
|
-
enabled
|
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
|
100
|
+
label { text <= [@presenter, :status] }
|
77
101
|
|
78
102
|
button {
|
79
103
|
text "Login"
|
80
|
-
enabled
|
81
|
-
|
104
|
+
enabled <= [@presenter, :logged_out?, computed_by: :status]
|
105
|
+
|
106
|
+
on_widget_selected { @presenter.login! }
|
82
107
|
on_key_pressed { |event|
|
83
|
-
|
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
|
90
|
-
|
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
|
-
|
101
|
-
end
|
128
|
+
}
|
102
129
|
end
|
103
130
|
|
104
|
-
Login.
|
131
|
+
Login.launch
|