glimmer-dsl-swt 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/glimmer/scaffold.rb +4 -6
- data/lib/glimmer/swt/table_column_proxy.rb +1 -1
- data/lib/glimmer/swt/table_proxy.rb +50 -29
- 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: 1b818d6b949f1a1c4388ecad2f9d6f425afbdf0c772a99031c2ea1cf1276dc1c
|
4
|
+
data.tar.gz: 7f9f78326e9a083b170f9606bfb7337963bda57c4648e7f585c435747f77e94a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e56deeff2d43d47a8e875ed1e32ba54f6cca9398053afdd5351257a2b0da3326384412635cf0c41529e8d961abab5de32d69cc5b6e23e67f1ebec23bb372b174
|
7
|
+
data.tar.gz: 49dc96a0dc0921bac9b0cd048d9e33d1436dffa09b4bcb48704f162a30209c52209b3ca03318c89e7277835e682821ec89fb4f32f9c26218fb8ed1812a340dcb
|
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.
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 /> Glimmer DSL for SWT 0.3.0 (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)
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
You may find full setup/usage instructions at the main [Glimmer project page](https://github.com/AndyObtiva/glimmer).
|
12
12
|
|
13
|
-
Other Glimmer DSL gems:
|
13
|
+
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
14
14
|
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Web GUI Adapter for Desktop Apps)
|
15
15
|
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
16
16
|
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/glimmer/scaffold.rb
CHANGED
@@ -485,12 +485,10 @@ class Scaffold
|
|
485
485
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
486
486
|
|
487
487
|
def display_about_dialog
|
488
|
-
message_box
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
message_box.setMessage(message)
|
493
|
-
message_box.open
|
488
|
+
message_box(body_root) {
|
489
|
+
text 'About'
|
490
|
+
message "#{human_name(namespace)} - #{human_name(custom_shell_name)} \#{VERSION}\\n\\n\#{LICENSE}"
|
491
|
+
}.open
|
494
492
|
end
|
495
493
|
|
496
494
|
def display_preferences_dialog
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'glimmer/swt/widget_proxy'
|
1
|
+
require 'glimmer/swt/widget_proxy'
|
2
2
|
|
3
3
|
module Glimmer
|
4
4
|
module SWT
|
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
attr_reader :table_editor, :table_editor_text_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block
|
36
|
+
attr_reader :table_editor, :table_editor_text_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties
|
37
37
|
attr_accessor :column_properties
|
38
38
|
|
39
39
|
def initialize(underscored_widget_name, parent, args)
|
@@ -50,9 +50,26 @@ module Glimmer
|
|
50
50
|
|
51
51
|
def sort_by_column(table_column_proxy)
|
52
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
|
-
|
53
|
+
new_sort_property = table_column_proxy.sort_property || [column_properties[index]]
|
54
|
+
if new_sort_property.size == 1 && !additional_sort_properties.to_a.empty?
|
55
|
+
selected_additional_sort_properties = additional_sort_properties.clone
|
56
|
+
if selected_additional_sort_properties.include?(new_sort_property.first)
|
57
|
+
selected_additional_sort_properties.delete(new_sort_property.first)
|
58
|
+
new_sort_property += selected_additional_sort_properties
|
59
|
+
else
|
60
|
+
new_sort_property += additional_sort_properties
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
@sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
|
65
|
+
swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]
|
66
|
+
|
55
67
|
@sort_property = new_sort_property
|
68
|
+
swt_widget.sort_column = table_column_proxy.swt_widget
|
69
|
+
|
70
|
+
@sort_by_block = nil
|
71
|
+
@sort_block = nil
|
72
|
+
@sort_type = nil
|
56
73
|
if table_column_proxy.sort_by_block
|
57
74
|
@sort_by_block = table_column_proxy.sort_by_block
|
58
75
|
elsif table_column_proxy.sort_block
|
@@ -64,43 +81,47 @@ module Glimmer
|
|
64
81
|
end
|
65
82
|
|
66
83
|
def detect_sort_type
|
67
|
-
@sort_type = String
|
84
|
+
@sort_type = sort_property.size.times.map { String }
|
68
85
|
array = model_binding.evaluate_property
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
86
|
+
sort_property.each_with_index do |a_sort_property, i|
|
87
|
+
values = array.map { |object| object.send(a_sort_property) }
|
88
|
+
value_classes = values.map(&:class).uniq
|
89
|
+
if value_classes.size == 1
|
90
|
+
@sort_type[i] = value_classes.first
|
91
|
+
elsif value_classes.include?(Integer)
|
92
|
+
@sort_type[i] = Integer
|
93
|
+
elsif value_classes.include?(Float)
|
94
|
+
@sort_type[i] = Float
|
95
|
+
end
|
77
96
|
end
|
78
97
|
end
|
79
98
|
|
99
|
+
def additional_sort_properties=(args)
|
100
|
+
@additional_sort_properties = args unless args.empty?
|
101
|
+
end
|
102
|
+
|
80
103
|
def sort
|
81
104
|
return unless sort_property && (sort_type || sort_block || sort_by_block)
|
82
105
|
array = model_binding.evaluate_property
|
83
106
|
# Converting value to_s first to handle nil cases. Should work with numeric, boolean, and date fields
|
84
107
|
if sort_block
|
85
|
-
sorted_array = array.sort
|
86
|
-
|
87
|
-
|
88
|
-
sort_block.call(value1, value2)
|
89
|
-
end
|
108
|
+
sorted_array = array.sort(&sort_block)
|
109
|
+
elsif sort_by_block
|
110
|
+
sorted_array = array.sort_by(&sort_by_block)
|
90
111
|
else
|
91
112
|
sorted_array = array.sort_by do |object|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
113
|
+
sort_property.each_with_index.map do |a_sort_property, i|
|
114
|
+
value = object.send(a_sort_property)
|
115
|
+
# handle nil and difficult to compare types gracefully
|
116
|
+
if sort_type[i] == Integer
|
117
|
+
value = value.to_i
|
118
|
+
elsif sort_type[i] == Float
|
119
|
+
value = value.to_f
|
120
|
+
elsif sort_type[i] == String
|
121
|
+
value = value.to_s
|
122
|
+
end
|
123
|
+
value
|
102
124
|
end
|
103
|
-
value
|
104
125
|
end
|
105
126
|
end
|
106
127
|
sorted_array = sorted_array.reverse if sort_direction == :descending
|
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.
|
4
|
+
version: 0.3.0
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|