glimmer-dsl-swt 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -0
- data/lib/glimmer/dsl/swt/block_property_expression.rb +20 -0
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +21 -0
- data/lib/glimmer/swt/swt_proxy.rb +2 -1
- data/lib/glimmer/swt/table_column_proxy.rb +24 -0
- data/lib/glimmer/swt/table_proxy.rb +65 -2
- data/lib/glimmer/swt/widget_proxy.rb +8 -2
- data/lib/glimmer/ui/custom_widget.rb +5 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33ae73c95946ba7fce0d3dc221cee2ca817968a03bbfe678ff9e0ecfbaf5a65
|
4
|
+
data.tar.gz: c95f41b789e3dee67c94dbf79d6e8367d5ad7a1fb94749e784a8c3b13ef8a4aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4784a352196f496c4fce136da828352c9c92c2f7092e917f9c47a403bd91964566a2d493680b35f13d240a87dd37830153f3a37ea050ea0d84aa8b02071cfdc
|
7
|
+
data.tar.gz: 9080d1bdc15f375db58fa8719d5c6fb8d2017313fe52ea7e2ad7b4dd042f47daa8bf87edecffa819c6e1596839af619f989335839fa757dd2e645ce6c6e13fdb
|
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 /> Glimmer DSL for SWT 0.2.
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 /> Glimmer DSL for SWT 0.2.4 (Desktop GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
3
3
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -15,6 +15,7 @@ module Glimmer
|
|
15
15
|
def initialize(parent, model_binding, column_properties)
|
16
16
|
@table = parent
|
17
17
|
@model_binding = model_binding
|
18
|
+
@table.swt_widget.data = @model_binding
|
18
19
|
@column_properties = column_properties
|
19
20
|
if @table.respond_to?(:column_properties=)
|
20
21
|
@table.column_properties = @column_properties
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module DSL
|
5
|
+
module SWT
|
6
|
+
class BlockPropertyExpression < Expression
|
7
|
+
def can_interpret?(parent, keyword, *args, &block)
|
8
|
+
block_given? and
|
9
|
+
args.size == 0 and
|
10
|
+
parent.respond_to?("#{keyword}_block=")
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpret(parent, keyword, *args, &block)
|
14
|
+
parent.send("#{keyword}_block=", block)
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'glimmer/swt/widget_proxy'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module SWT
|
5
|
+
class ScrolledCompositeProxy < Glimmer::SWT::WidgetProxy
|
6
|
+
def initialize(underscored_widget_name, parent, args)
|
7
|
+
unless args.first.is_a?(Numeric)
|
8
|
+
args.unshift(:h_scroll)
|
9
|
+
args.unshift(:v_scroll)
|
10
|
+
end
|
11
|
+
super
|
12
|
+
swt_widget.expand_horizontal = true
|
13
|
+
swt_widget.expand_vertical = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def post_initialize_child(child)
|
17
|
+
swt_widget.content = child.swt_widget
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'glimmer/swt/widget_proxy'
|
2
|
+
|
3
|
+
module Glimmer
|
4
|
+
module SWT
|
5
|
+
class TableColumnProxy < Glimmer::SWT::WidgetProxy
|
6
|
+
attr_reader :no_sort, :sort_property
|
7
|
+
alias no_sort? no_sort
|
8
|
+
attr_accessor :sort_block, :sort_by_block
|
9
|
+
|
10
|
+
def initialize(underscored_widget_name, parent, args)
|
11
|
+
@no_sort = args.delete(:no_sort)
|
12
|
+
super
|
13
|
+
on_widget_selected do |event|
|
14
|
+
parent.sort_by_column(self)
|
15
|
+
end unless no_sort?
|
16
|
+
end
|
17
|
+
|
18
|
+
def sort_property=(args)
|
19
|
+
@sort_property = args.to_a.first
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
attr_reader :table_editor, :table_editor_text_proxy
|
36
|
+
attr_reader :table_editor, :table_editor_text_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block
|
37
37
|
attr_accessor :column_properties
|
38
38
|
|
39
39
|
def initialize(underscored_widget_name, parent, args)
|
@@ -43,7 +43,70 @@ module Glimmer
|
|
43
43
|
@table_editor.grabHorizontal = true
|
44
44
|
@table_editor.minimumHeight = 20
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
|
+
def model_binding
|
48
|
+
swt_widget.data
|
49
|
+
end
|
50
|
+
|
51
|
+
def sort_by_column(table_column_proxy)
|
52
|
+
index = swt_widget.columns.to_a.index(table_column_proxy.swt_widget)
|
53
|
+
new_sort_property = table_column_proxy.sort_property || column_properties[index]
|
54
|
+
@sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
|
55
|
+
@sort_property = new_sort_property
|
56
|
+
if table_column_proxy.sort_by_block
|
57
|
+
@sort_by_block = table_column_proxy.sort_by_block
|
58
|
+
elsif table_column_proxy.sort_block
|
59
|
+
@sort_block = table_column_proxy.sort_block
|
60
|
+
else
|
61
|
+
detect_sort_type
|
62
|
+
end
|
63
|
+
sort
|
64
|
+
end
|
65
|
+
|
66
|
+
def detect_sort_type
|
67
|
+
@sort_type = String
|
68
|
+
array = model_binding.evaluate_property
|
69
|
+
values = array.map { |object| object.send(sort_property) }
|
70
|
+
value_classes = values.map(&:class).uniq
|
71
|
+
if value_classes.size == 1
|
72
|
+
@sort_type = value_classes.first
|
73
|
+
elsif value_classes.include?(Integer)
|
74
|
+
@sort_type = Integer
|
75
|
+
elsif value_classes.include?(Float)
|
76
|
+
@sort_type = Float
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def sort
|
81
|
+
return unless sort_property && (sort_type || sort_block || sort_by_block)
|
82
|
+
array = model_binding.evaluate_property
|
83
|
+
# Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
|
84
|
+
if sort_block
|
85
|
+
sorted_array = array.sort do |object1, object2|
|
86
|
+
value1 = object1.send(sort_property)
|
87
|
+
value2 = object2.send(sort_property)
|
88
|
+
sort_block.call(value1, value2)
|
89
|
+
end
|
90
|
+
else
|
91
|
+
sorted_array = array.sort_by do |object|
|
92
|
+
value = object.send(sort_property)
|
93
|
+
# handle nil and difficult to compare types gracefully
|
94
|
+
if sort_by_block
|
95
|
+
value = sort_by_block.call(value)
|
96
|
+
elsif sort_type == Integer
|
97
|
+
value = value.to_i
|
98
|
+
elsif sort_type == Float
|
99
|
+
value = value.to_f
|
100
|
+
elsif sort_type == String
|
101
|
+
value = value.to_s
|
102
|
+
end
|
103
|
+
value
|
104
|
+
end
|
105
|
+
end
|
106
|
+
sorted_array = sorted_array.reverse if sort_direction == :descending
|
107
|
+
model_binding.call(sorted_array)
|
108
|
+
end
|
109
|
+
|
47
110
|
# Performs a search for table items matching block condition
|
48
111
|
# If no condition block is passed, returns all table items
|
49
112
|
# Returns a Java TableItem array to easily set as selection on org.eclipse.swt.Table if needed
|
@@ -61,6 +61,12 @@ module Glimmer
|
|
61
61
|
swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
|
62
62
|
@swt_widget = swt_widget_class.new(parent.swt_widget, style(underscored_widget_name, styles), *extra_options)
|
63
63
|
DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
|
64
|
+
parent.post_initialize_child(self)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Subclasses may override to perform post initialization work on an added child
|
68
|
+
def post_initialize_child(child)
|
69
|
+
# No Op by default
|
64
70
|
end
|
65
71
|
|
66
72
|
def extract_args(underscored_widget_name, args)
|
@@ -266,11 +272,11 @@ module Glimmer
|
|
266
272
|
end
|
267
273
|
swt_widget_class
|
268
274
|
rescue NameError => e
|
269
|
-
Glimmer::Config.logger&.debug e.
|
275
|
+
Glimmer::Config.logger&.debug e.full_message
|
270
276
|
# Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
|
271
277
|
nil
|
272
278
|
rescue => e
|
273
|
-
Glimmer::Config.logger&.debug e.
|
279
|
+
Glimmer::Config.logger&.debug e.full_message
|
274
280
|
# Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
|
275
281
|
nil
|
276
282
|
end
|
@@ -137,6 +137,11 @@ module Glimmer
|
|
137
137
|
execute_hooks('after_body')
|
138
138
|
@swt_widget = @body_root.swt_widget
|
139
139
|
end
|
140
|
+
|
141
|
+
# Subclasses may override to perform post initialization work on an added child
|
142
|
+
def post_initialize_child(child)
|
143
|
+
body_root.post_initialize_child(child)
|
144
|
+
end
|
140
145
|
|
141
146
|
def can_handle_observation_request?(observation_request)
|
142
147
|
result = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,6 +285,7 @@ files:
|
|
285
285
|
- lib/glimmer/data_binding/widget_binding.rb
|
286
286
|
- lib/glimmer/dsl/swt/async_exec_expression.rb
|
287
287
|
- lib/glimmer/dsl/swt/bind_expression.rb
|
288
|
+
- lib/glimmer/dsl/swt/block_property_expression.rb
|
288
289
|
- lib/glimmer/dsl/swt/color_expression.rb
|
289
290
|
- lib/glimmer/dsl/swt/column_properties_expression.rb
|
290
291
|
- lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
|
@@ -328,10 +329,12 @@ files:
|
|
328
329
|
- lib/glimmer/swt/menu_proxy.rb
|
329
330
|
- lib/glimmer/swt/message_box_proxy.rb
|
330
331
|
- lib/glimmer/swt/packages.rb
|
332
|
+
- lib/glimmer/swt/scrolled_composite_proxy.rb
|
331
333
|
- lib/glimmer/swt/shell_proxy.rb
|
332
334
|
- lib/glimmer/swt/style_constantizable.rb
|
333
335
|
- lib/glimmer/swt/swt_proxy.rb
|
334
336
|
- lib/glimmer/swt/tab_item_proxy.rb
|
337
|
+
- lib/glimmer/swt/table_column_proxy.rb
|
335
338
|
- lib/glimmer/swt/table_proxy.rb
|
336
339
|
- lib/glimmer/swt/tree_proxy.rb
|
337
340
|
- lib/glimmer/swt/widget_listener_proxy.rb
|