glimmer 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +14 -12
- data/lib/glimmer.rb +2 -1
- data/lib/glimmer/command_handler_chain_link.rb +2 -1
- data/lib/glimmer/swt/command_handlers/bind_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/color_command_handler.rb +1 -1
- data/lib/glimmer/swt/command_handlers/combo_selection_data_binding_command_handler.rb +3 -2
- data/lib/glimmer/swt/command_handlers/custom_widget_command_handler.rb +3 -3
- data/lib/glimmer/swt/command_handlers/data_binding_command_handler.rb +4 -35
- data/lib/glimmer/swt/command_handlers/layout_command_handler.rb +1 -1
- data/lib/glimmer/swt/command_handlers/layout_data_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/list_selection_data_binding_command_handler.rb +3 -2
- data/lib/glimmer/swt/command_handlers/tab_item_command_handler.rb +12 -2
- data/lib/glimmer/swt/command_handlers/table_column_properties_data_binding_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/table_items_data_binding_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/tree_items_data_binding_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/tree_properties_data_binding_command_handler.rb +2 -1
- data/lib/glimmer/swt/command_handlers/widget_command_handler.rb +1 -1
- data/lib/glimmer/swt/command_handlers/widget_listener_command_handler.rb +4 -2
- data/lib/glimmer/swt/custom_widget.rb +29 -1
- data/lib/glimmer/swt/g_tab_item_composite.rb +8 -1
- data/lib/glimmer/swt/g_widget.rb +52 -0
- data/lib/glimmer/swt/observable_model.rb +1 -0
- data/lib/glimmer/swt/widget_binding.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f82e6793a331105407650a919d3d973f360c9e0c5e6bd49d185bd44dd9ec745
|
4
|
+
data.tar.gz: 190ea8ddbe57f41100e9fa539f4e9465b9d621418e3f00e291b91103f04484ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57d3b3d4754fc2d5229c3ec2c2e7518336091b1d305a1d4c2d6b1b601a50245f75340ba2dc213168349408389f324afeeeb734ae81faa2045dd6d6e0e5d7da3
|
7
|
+
data.tar.gz: b2fd672bed1bf48b99c7e92ad8b82fb910c0d0330b78152fbf3cbe4a6c33e34dae4a0ed945ab2e646492af2daad1f9a224488ee5064a7d4f6650f6238882f86e
|
data/README.markdown
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# Glimmer (JRuby Desktop UI DSL + Data-Binding)
|
1
|
+
# Glimmer 0.4.7 Beta (JRuby Desktop UI DSL + Data-Binding)
|
2
2
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
|
3
3
|
|
4
4
|
Glimmer is a cross-platform Ruby desktop development library. Glimmer's main innovation is a JRuby DSL that enables easy and efficient authoring of desktop application user-interfaces while relying on the robust platform-independent Eclipse SWT library. Glimmer additionally innovates by having built-in desktop UI data-binding support to greatly facilitate synchronizing the UI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about UI concerns, or alternatively drive development UI-first, and then write clean business components test-first afterward.
|
5
5
|
|
6
|
-
You may learn more by reading this article: [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
7
|
-
|
8
6
|
## Examples
|
9
7
|
|
10
8
|
### Hello World
|
@@ -65,12 +63,7 @@ Glimmer app:
|
|
65
63
|
|
66
64
|
![Tic Tac Toe](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-tic-tac-toe.png)
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
* [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
71
|
-
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
72
|
-
* [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
|
73
|
-
* [Code Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
|
66
|
+
NOTE: Glimmer is in beta mode. Please help make better by adopting for small or low risk projects and providing feedback.
|
74
67
|
|
75
68
|
## Background
|
76
69
|
|
@@ -112,14 +105,14 @@ Please follow these instructions to make the `glimmer` command available on your
|
|
112
105
|
|
113
106
|
Run this command to install directly:
|
114
107
|
```
|
115
|
-
jgem install glimmer -v 0.4.
|
108
|
+
jgem install glimmer -v 0.4.7
|
116
109
|
```
|
117
110
|
|
118
111
|
### Option 2: Bundler
|
119
112
|
|
120
113
|
Add the following to `Gemfile`:
|
121
114
|
```
|
122
|
-
gem 'glimmer', '~> 0.4.
|
115
|
+
gem 'glimmer', '~> 0.4.7'
|
123
116
|
```
|
124
117
|
|
125
118
|
And, then run:
|
@@ -528,7 +521,7 @@ Check out the samples directory for more advanced examples of layouts in Glimmer
|
|
528
521
|
|
529
522
|
Glimmer composites always come with grid_layout by default, but you can still specify explicitly if you'd like to set specific properties on it.
|
530
523
|
|
531
|
-
Glimmer shell always comes
|
524
|
+
Glimmer shell always comes with fill_layout having :horizontal type.
|
532
525
|
|
533
526
|
This is a great guide for learning more about SWT layouts:
|
534
527
|
|
@@ -936,7 +929,9 @@ Definition:
|
|
936
929
|
```ruby
|
937
930
|
class Sandwich
|
938
931
|
include Glimmer::SWT::CustomWidget
|
932
|
+
|
939
933
|
options :orientation, :bg_color
|
934
|
+
|
940
935
|
def body
|
941
936
|
composite(swt_style) { # gets custom widget style
|
942
937
|
fill_layout orientation # using orientation option
|
@@ -1089,6 +1084,13 @@ Example:
|
|
1089
1084
|
jruby -J-XstartOnFirstThread -J-classpath "path_to/swt.jar" -r glimmer -S application.rb
|
1090
1085
|
```
|
1091
1086
|
|
1087
|
+
## Resources
|
1088
|
+
|
1089
|
+
* [Eclipse Zone Tutorial](http://eclipse.dzone.com/articles/an-introduction-glimmer)
|
1090
|
+
* [InfoQ Article](http://www.infoq.com/news/2008/02/glimmer-jruby-swt)
|
1091
|
+
* [RubyConf 2008 Video](https://confreaks.tv/videos/rubyconf2008-desktop-development-with-glimmer)
|
1092
|
+
* [Code Blog](http://andymaleh.blogspot.com/search/label/Glimmer)
|
1093
|
+
|
1092
1094
|
## Feature Suggestions
|
1093
1095
|
|
1094
1096
|
These features have been suggested. You might see them in a future version of Glimmer. You are welcome to contribute more feature suggestions.
|
data/lib/glimmer.rb
CHANGED
@@ -46,6 +46,7 @@ module Glimmer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.dsl(dsl)
|
49
|
+
@@parent_stack = []
|
49
50
|
CommandHandlerChainFactory.select_dsl(dsl)
|
50
51
|
end
|
51
52
|
|
@@ -60,7 +61,7 @@ module Glimmer
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def dsl(dsl)
|
63
|
-
|
64
|
+
Glimmer.dsl(dsl)
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -13,7 +13,8 @@ module Glimmer
|
|
13
13
|
elsif @next_chain_link
|
14
14
|
return @next_chain_link.handle(parent, command_symbol, *args, &block)
|
15
15
|
else
|
16
|
-
|
16
|
+
# TODO see if we need a better response here (e.g. dev mode error raising vs production mode silent failure)
|
17
|
+
Glimmer.logger.error "Command: #{command_symbol} cannot be handled!"
|
17
18
|
return nil
|
18
19
|
end
|
19
20
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../model_binding"
|
4
5
|
|
5
6
|
module Glimmer
|
@@ -17,7 +18,7 @@ module Glimmer
|
|
17
18
|
def can_handle?(parent, command_symbol, *args, &block)
|
18
19
|
# TODO refactor this long condition below
|
19
20
|
(
|
20
|
-
parent.is_a?(GWidget) and
|
21
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
21
22
|
command_symbol.to_s == "bind" and
|
22
23
|
(
|
23
24
|
(
|
@@ -17,7 +17,7 @@ module Glimmer
|
|
17
17
|
def do_handle(parent, command_symbol, *args, &block)
|
18
18
|
if args.first.is_a?(Display) || args.first.nil?
|
19
19
|
display = args.delete_at(0)
|
20
|
-
elsif parent.is_a?(GWidget)
|
20
|
+
elsif parent.is_a?(GWidget) || parent.is_a?(CustomWidget)
|
21
21
|
display = parent.widget.display
|
22
22
|
else
|
23
23
|
display = GDisplay.instance.display
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
|
4
5
|
module Glimmer
|
5
6
|
module SWT
|
@@ -11,7 +12,7 @@ module Glimmer
|
|
11
12
|
include_package 'org.eclipse.swt.widgets'
|
12
13
|
|
13
14
|
def can_handle?(parent, command_symbol, *args, &block)
|
14
|
-
parent.is_a?(GWidget) and
|
15
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
15
16
|
parent.widget.is_a?(Combo) and
|
16
17
|
command_symbol.to_s == "selection" and
|
17
18
|
args.size == 1 and
|
@@ -36,7 +37,7 @@ module Glimmer
|
|
36
37
|
model_binding.call(widget_binding.evaluate_property)
|
37
38
|
}
|
38
39
|
}
|
39
|
-
end
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -9,14 +9,14 @@ module Glimmer
|
|
9
9
|
include CommandHandler
|
10
10
|
|
11
11
|
def can_handle?(parent, command_symbol, *args, &block)
|
12
|
-
(parent.is_a?(GWidget) || parent.is_a?(
|
13
|
-
|
12
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
13
|
+
CustomWidget.for(command_symbol)
|
14
14
|
end
|
15
15
|
|
16
16
|
def do_handle(parent, command_symbol, *args, &block)
|
17
17
|
options = args.pop if args.last.is_a?(Hash)
|
18
18
|
Glimmer.logger.debug "Custom widget #{command_symbol} styles are: [" + args.inspect + "] and options are: #{options}"
|
19
|
-
|
19
|
+
CustomWidget.for(command_symbol).new(parent, *args, options, &block)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../observable_model"
|
4
5
|
require File.dirname(__FILE__) + "/../model_binding"
|
5
6
|
require File.dirname(__FILE__) + "/../widget_binding"
|
@@ -20,40 +21,10 @@ module Glimmer
|
|
20
21
|
|
21
22
|
include_package 'org.eclipse.swt.widgets'
|
22
23
|
|
23
|
-
@@widget_data_binders = {
|
24
|
-
Java::OrgEclipseSwtWidgets::Text => {
|
25
|
-
:text => Proc.new do |g_widget, model_binding|
|
26
|
-
add_contents(g_widget) {
|
27
|
-
on_modify_text { |modify_event|
|
28
|
-
model_binding.call(g_widget.widget.getText)
|
29
|
-
}
|
30
|
-
}
|
31
|
-
end,
|
32
|
-
},
|
33
|
-
Java::OrgEclipseSwtWidgets::Button => {
|
34
|
-
:selection => Proc.new do |g_widget, model_binding|
|
35
|
-
add_contents(g_widget) {
|
36
|
-
on_widget_selected { |selection_event|
|
37
|
-
model_binding.call(g_widget.widget.getSelection)
|
38
|
-
}
|
39
|
-
}
|
40
|
-
end
|
41
|
-
},
|
42
|
-
Java::OrgEclipseSwtWidgets::Spinner => {
|
43
|
-
:selection => Proc.new do |g_widget, model_binding|
|
44
|
-
add_contents(g_widget) {
|
45
|
-
on_widget_selected { |selection_event|
|
46
|
-
model_binding.call(g_widget.widget.getSelection)
|
47
|
-
}
|
48
|
-
}
|
49
|
-
end
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
24
|
def can_handle?(parent, command_symbol, *args, &block)
|
54
|
-
(parent.is_a?(GWidget) and
|
25
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
55
26
|
args.size == 1 and
|
56
|
-
args[0].is_a?(ModelBinding)
|
27
|
+
args[0].is_a?(ModelBinding)
|
57
28
|
end
|
58
29
|
|
59
30
|
def do_handle(parent, command_symbol, *args, &block)
|
@@ -62,9 +33,7 @@ module Glimmer
|
|
62
33
|
widget_binding = WidgetBinding.new(*widget_binding_parameters)
|
63
34
|
widget_binding.call(model_binding.evaluate_property)
|
64
35
|
widget_binding.observe(model_binding)
|
65
|
-
|
66
|
-
widget_data_binder = widget_data_binder_map[command_symbol.to_s.to_sym] if widget_data_binder_map
|
67
|
-
widget_data_binder.call(parent, model_binding) if widget_data_binder
|
36
|
+
parent.add_observer(model_binding, command_symbol.to_s.to_sym) #TODO consider reversing statement
|
68
37
|
end
|
69
38
|
end
|
70
39
|
end
|
@@ -11,7 +11,7 @@ module Glimmer
|
|
11
11
|
include_package 'org.eclipse.swt.layout'
|
12
12
|
|
13
13
|
def can_handle?(parent, command_symbol, *args, &block)
|
14
|
-
parent.is_a?(GWidget) and
|
14
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
15
15
|
parent.widget.is_a?(Composite) and
|
16
16
|
command_symbol.to_s.end_with?('_layout') and
|
17
17
|
GLayout.layout_exists?(command_symbol.to_s)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../g_layout_data"
|
4
5
|
|
5
6
|
module Glimmer
|
@@ -12,7 +13,7 @@ module Glimmer
|
|
12
13
|
include_package 'org.eclipse.swt.layout'
|
13
14
|
|
14
15
|
def can_handle?(parent, command_symbol, *args, &block)
|
15
|
-
parent.is_a?(GWidget) and
|
16
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
16
17
|
command_symbol.to_s == 'layout_data'
|
17
18
|
end
|
18
19
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../list_selection_binding"
|
4
5
|
|
5
6
|
module Glimmer
|
@@ -12,7 +13,7 @@ module Glimmer
|
|
12
13
|
include_package 'org.eclipse.swt.widgets'
|
13
14
|
|
14
15
|
def can_handle?(parent, command_symbol, *args, &block)
|
15
|
-
parent.is_a?(GWidget) and
|
16
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
16
17
|
parent.widget.is_a?(List) and
|
17
18
|
command_symbol.to_s == "selection" and
|
18
19
|
args.size == 1 and
|
@@ -41,7 +42,7 @@ module Glimmer
|
|
41
42
|
model_binding.call(list_selection_binding.evaluate_property)
|
42
43
|
}
|
43
44
|
}
|
44
|
-
end
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -9,9 +9,19 @@ module Glimmer
|
|
9
9
|
include CommandHandler
|
10
10
|
include Glimmer
|
11
11
|
|
12
|
+
include_package 'org.eclipse.swt.widgets'
|
13
|
+
|
12
14
|
def can_handle?(parent, command_symbol, *args, &block)
|
13
|
-
parent.is_a?(GWidget)
|
14
|
-
|
15
|
+
initial_condition = (parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) &&
|
16
|
+
command_symbol.to_s == "tab_item"
|
17
|
+
if initial_condition
|
18
|
+
if parent.widget.is_a?(TabFolder)
|
19
|
+
return true
|
20
|
+
else
|
21
|
+
Glimmer.logger.error "tab_item widget may only be used directly under a tab_folder widget!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
false
|
15
25
|
end
|
16
26
|
|
17
27
|
def do_handle(parent, command_symbol, *args, &block)
|
data/lib/glimmer/swt/command_handlers/table_column_properties_data_binding_command_handler.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
|
4
5
|
module Glimmer
|
5
6
|
module SWT
|
@@ -13,7 +14,7 @@ module Glimmer
|
|
13
14
|
include_package 'org.eclipse.swt.widgets'
|
14
15
|
|
15
16
|
def can_handle?(parent, command_symbol, *args, &block)
|
16
|
-
parent.is_a?(GWidget) and
|
17
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
17
18
|
parent.widget.is_a?(Table) and
|
18
19
|
command_symbol.to_s == "column_properties" and
|
19
20
|
block == nil
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../table_items_binding"
|
4
5
|
|
5
6
|
module Glimmer
|
@@ -12,7 +13,7 @@ module Glimmer
|
|
12
13
|
include_package 'org.eclipse.swt.widgets'
|
13
14
|
|
14
15
|
def can_handle?(parent, command_symbol, *args, &block)
|
15
|
-
parent.is_a?(GWidget) and
|
16
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
16
17
|
parent.widget.is_a?(Table) and
|
17
18
|
command_symbol.to_s == "items" and
|
18
19
|
args.size == 2 and
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
require File.dirname(__FILE__) + "/../tree_items_binding"
|
4
5
|
|
5
6
|
module Glimmer
|
@@ -11,7 +12,7 @@ module Glimmer
|
|
11
12
|
include_package 'org.eclipse.swt.widgets'
|
12
13
|
|
13
14
|
def can_handle?(parent, command_symbol, *args, &block)
|
14
|
-
(parent.is_a?(GWidget)) and
|
15
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
15
16
|
(parent.widget.is_a?(Tree)) and
|
16
17
|
(command_symbol.to_s == "items") and
|
17
18
|
(args.size == 2) and
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
|
4
5
|
module Glimmer
|
5
6
|
module SWT
|
@@ -13,7 +14,7 @@ module Glimmer
|
|
13
14
|
include_package 'org.eclipse.swt.widgets'
|
14
15
|
|
15
16
|
def can_handle?(parent, command_symbol, *args, &block)
|
16
|
-
parent.is_a?(GWidget) and
|
17
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
17
18
|
parent.widget.is_a?(Tree) and
|
18
19
|
command_symbol.to_s == "tree_properties" and
|
19
20
|
block == nil
|
@@ -12,7 +12,7 @@ module Glimmer
|
|
12
12
|
include_package 'org.eclipse.swt.browser'
|
13
13
|
|
14
14
|
def can_handle?(parent, command_symbol, *args, &block)
|
15
|
-
(parent.is_a?(GWidget) || parent.is_a?(
|
15
|
+
(parent.is_a?(GWidget) || parent.is_a?(CustomWidget)) and
|
16
16
|
command_symbol.to_s != "shell" and
|
17
17
|
GWidget.widget_exists?(command_symbol.to_s)
|
18
18
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../command_handler"
|
2
2
|
require File.dirname(__FILE__) + "/../g_widget"
|
3
|
+
require File.dirname(__FILE__) + "/../custom_widget"
|
3
4
|
|
4
5
|
module Glimmer
|
5
6
|
module SWT
|
@@ -10,8 +11,9 @@ module Glimmer
|
|
10
11
|
include_package 'org.eclipse.swt.widgets'
|
11
12
|
|
12
13
|
def can_handle?(parent, command_symbol, *args, &block)
|
13
|
-
|
14
|
-
|
14
|
+
widget_parentage = (parent.is_a?(GWidget) || parent.is_a?(CustomWidget))
|
15
|
+
Glimmer.logger.debug "parent is a widget: #{widget_parentage}"
|
16
|
+
return unless widget_parentage
|
15
17
|
Glimmer.logger.debug "on listener?: " + (command_symbol.to_s[0,3] == "on_").to_s
|
16
18
|
return unless command_symbol.to_s[0,3] == "on_"
|
17
19
|
Glimmer.logger.debug "command symbol is longer than 3: " + (command_symbol.to_s.length > 3).to_s
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
3
|
require_relative 'proc_tracker'
|
4
|
+
require_relative 'observable_model'
|
4
5
|
|
5
6
|
module Glimmer
|
6
7
|
module SWT
|
@@ -8,6 +9,7 @@ module Glimmer
|
|
8
9
|
include SuperModule
|
9
10
|
include Glimmer
|
10
11
|
include Parent
|
12
|
+
include ObservableModel
|
11
13
|
|
12
14
|
class << self
|
13
15
|
def for(underscored_custom_widget_name)
|
@@ -67,6 +69,20 @@ module Glimmer
|
|
67
69
|
raise 'Not implemented!'
|
68
70
|
end
|
69
71
|
|
72
|
+
# TODO consider using delegators
|
73
|
+
|
74
|
+
def can_add_listener?(underscored_listener_name)
|
75
|
+
@body_root.can_add_listener?(underscored_listener_name)
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_listener(underscored_listener_name, &block)
|
79
|
+
@body_root.add_listener(underscored_listener_name, &block)
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_observer(observer, attribute_name)
|
83
|
+
@body_root.add_observer(observer, attribute_name)
|
84
|
+
end
|
85
|
+
|
70
86
|
def has_attribute?(attribute_name, *args)
|
71
87
|
respond_to?(attribute_setter(attribute_name), args) ||
|
72
88
|
@body_root.has_attribute?(attribute_name, *args)
|
@@ -80,12 +96,24 @@ module Glimmer
|
|
80
96
|
end
|
81
97
|
end
|
82
98
|
|
99
|
+
def get_attribute(attribute_name)
|
100
|
+
if respond_to?(attribute_name)
|
101
|
+
send(attribute_name)
|
102
|
+
else
|
103
|
+
@body_root.get_attribute(attribute_name)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
83
107
|
def attribute_setter(attribute_name)
|
84
108
|
"#{attribute_name}="
|
85
109
|
end
|
86
110
|
|
87
111
|
def process_block(block)
|
88
|
-
|
112
|
+
if block.source_location == @content&.__getobj__.source_location
|
113
|
+
@content.call unless @content.called?
|
114
|
+
else
|
115
|
+
block.call
|
116
|
+
end
|
89
117
|
end
|
90
118
|
end
|
91
119
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/g_widget_listener"
|
2
1
|
require File.dirname(__FILE__) + "/g_runnable"
|
3
2
|
|
4
3
|
module Glimmer
|
@@ -29,6 +28,14 @@ module Glimmer
|
|
29
28
|
super(attribute_name, *args)
|
30
29
|
end
|
31
30
|
end
|
31
|
+
|
32
|
+
def get_attribute(attribute_name)
|
33
|
+
if attribute_name.to_s == "text"
|
34
|
+
@tab_item.widget.text
|
35
|
+
else
|
36
|
+
super(attribute_name)
|
37
|
+
end
|
38
|
+
end
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
data/lib/glimmer/swt/g_widget.rb
CHANGED
@@ -13,6 +13,8 @@ module Glimmer
|
|
13
13
|
include_package 'org.eclipse.swt.layout'
|
14
14
|
include_package 'org.eclipse.swt.graphics'
|
15
15
|
include_package 'org.eclipse.swt.browser'
|
16
|
+
|
17
|
+
include Glimmer
|
16
18
|
include Parent
|
17
19
|
|
18
20
|
attr_reader :widget
|
@@ -56,6 +58,10 @@ module Glimmer
|
|
56
58
|
@widget.send(attribute_setter(attribute_name), *args)
|
57
59
|
end
|
58
60
|
|
61
|
+
def get_attribute(attribute_name)
|
62
|
+
@widget.send(attribute_getter(attribute_name))
|
63
|
+
end
|
64
|
+
|
59
65
|
def property_type_converters
|
60
66
|
color_converter = Proc.new do |value|
|
61
67
|
if value.is_a?(Symbol) || value.is_a?(String)
|
@@ -81,6 +87,38 @@ module Glimmer
|
|
81
87
|
}
|
82
88
|
end
|
83
89
|
|
90
|
+
def widget_property_listener_installers
|
91
|
+
@widget_property_listener_installers ||= {
|
92
|
+
Java::OrgEclipseSwtWidgets::Text => {
|
93
|
+
:text => Proc.new do |observer|
|
94
|
+
add_contents(self) {
|
95
|
+
on_modify_text { |modify_event|
|
96
|
+
observer.call(widget.getText)
|
97
|
+
}
|
98
|
+
}
|
99
|
+
end,
|
100
|
+
},
|
101
|
+
Java::OrgEclipseSwtWidgets::Button => {
|
102
|
+
:selection => Proc.new do |observer|
|
103
|
+
add_contents(self) {
|
104
|
+
on_widget_selected { |selection_event|
|
105
|
+
observer.call(widget.getSelection)
|
106
|
+
}
|
107
|
+
}
|
108
|
+
end
|
109
|
+
},
|
110
|
+
Java::OrgEclipseSwtWidgets::Spinner => {
|
111
|
+
:selection => Proc.new do |observer|
|
112
|
+
add_contents(self) {
|
113
|
+
on_widget_selected { |selection_event|
|
114
|
+
observer.call(widget.getSelection)
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
84
122
|
def apply_property_type_converters(attribute_name, args)
|
85
123
|
if args.count == 1
|
86
124
|
value = args.first
|
@@ -194,6 +232,16 @@ module Glimmer
|
|
194
232
|
@widget.dispose
|
195
233
|
end
|
196
234
|
|
235
|
+
def add_observer(observer, property_name)
|
236
|
+
property_listener_installers = widget_property_listener_installers[widget.class]
|
237
|
+
widget_listener_installer = property_listener_installers[property_name.to_s.to_sym] if property_listener_installers
|
238
|
+
widget_listener_installer.call(observer) if widget_listener_installer
|
239
|
+
end
|
240
|
+
|
241
|
+
def remove_observer(observer, property_name)
|
242
|
+
# TODO consider implementing if remove_observer is needed (consumers can remove listener via SWT API)
|
243
|
+
end
|
244
|
+
|
197
245
|
private
|
198
246
|
|
199
247
|
def style(underscored_widget_name, styles)
|
@@ -209,6 +257,10 @@ module Glimmer
|
|
209
257
|
def attribute_setter(attribute_name)
|
210
258
|
"set#{attribute_name.to_s.camelcase(:upper)}"
|
211
259
|
end
|
260
|
+
|
261
|
+
def attribute_getter(attribute_name)
|
262
|
+
"get#{attribute_name.to_s.camelcase(:upper)}"
|
263
|
+
end
|
212
264
|
end
|
213
265
|
end
|
214
266
|
end
|
@@ -13,7 +13,8 @@ module Glimmer
|
|
13
13
|
@widget = model
|
14
14
|
@property = property
|
15
15
|
@translator = translator || proc {|value| value}
|
16
|
-
|
16
|
+
|
17
|
+
add_contents(@widget) { # TODO consider having custom widgets support on_widget_disposed event and any event on their body_root
|
17
18
|
on_widget_disposed { |dispose_event|
|
18
19
|
unregister_all_observables
|
19
20
|
}
|
@@ -24,7 +25,7 @@ module Glimmer
|
|
24
25
|
@widget.set_attribute(@property, converted_value) unless evaluate_property == converted_value
|
25
26
|
end
|
26
27
|
def evaluate_property
|
27
|
-
@widget.
|
28
|
+
@widget.get_attribute(@property)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|