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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e33ae73c95946ba7fce0d3dc221cee2ca817968a03bbfe678ff9e0ecfbaf5a65
4
- data.tar.gz: c95f41b789e3dee67c94dbf79d6e8367d5ad7a1fb94749e784a8c3b13ef8a4aa
3
+ metadata.gz: 1b818d6b949f1a1c4388ecad2f9d6f425afbdf0c772a99031c2ea1cf1276dc1c
4
+ data.tar.gz: 7f9f78326e9a083b170f9606bfb7337963bda57c4648e7f585c435747f77e94a
5
5
  SHA512:
6
- metadata.gz: c4784a352196f496c4fce136da828352c9c92c2f7092e917f9c47a403bd91964566a2d493680b35f13d240a87dd37830153f3a37ea050ea0d84aa8b02071cfdc
7
- data.tar.gz: 9080d1bdc15f375db58fa8719d5c6fb8d2017313fe52ea7e2ad7b4dd042f47daa8bf87edecffa819c6e1596839af619f989335839fa757dd2e645ce6c6e13fdb
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.2.4 (Desktop GUI)
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.2.4
1
+ 0.3.0
@@ -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 = MessageBox.new(swt_widget)
489
- message_box.setText("About")
490
- message = "#{human_name(namespace)} - #{human_name(custom_shell_name)} \#{VERSION}\n\n"
491
- message += LICENSE
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
@@ -16,7 +16,7 @@ module Glimmer
16
16
  end
17
17
 
18
18
  def sort_property=(args)
19
- @sort_property = args.to_a.first
19
+ @sort_property = args unless args.empty?
20
20
  end
21
21
 
22
22
  end
@@ -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
- @sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
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
- 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
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 do |object1, object2|
86
- value1 = object1.send(sort_property)
87
- value2 = object2.send(sort_property)
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
- 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
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.2.4
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-15 00:00:00.000000000 Z
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