glimmer-dsl-swt 4.17.10.3 → 4.17.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.17.10.3
1
+ 4.17.10.8
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-dsl-swt 4.17.10.3 ruby lib
5
+ # stub: glimmer-dsl-swt 4.17.10.8 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-dsl-swt".freeze
9
- s.version = "4.17.10.3"
9
+ s.version = "4.17.10.8"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-11-24"
15
- s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
14
+ s.date = "2020-12-17"
15
+ s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer".freeze, "girb".freeze]
18
18
  s.extra_rdoc_files = [
@@ -131,6 +131,7 @@ Gem::Specification.new do |s|
131
131
  "samples/elaborate/tic_tac_toe/cell.rb",
132
132
  "samples/elaborate/user_profile.rb",
133
133
  "samples/hello/hello_browser.rb",
134
+ "samples/hello/hello_button.rb",
134
135
  "samples/hello/hello_checkbox.rb",
135
136
  "samples/hello/hello_checkbox_group.rb",
136
137
  "samples/hello/hello_combo.rb",
@@ -144,6 +145,7 @@ Gem::Specification.new do |s|
144
145
  "samples/hello/hello_expand_bar.rb",
145
146
  "samples/hello/hello_file_dialog.rb",
146
147
  "samples/hello/hello_group.rb",
148
+ "samples/hello/hello_link.rb",
147
149
  "samples/hello/hello_list_multi_selection.rb",
148
150
  "samples/hello/hello_list_single_selection.rb",
149
151
  "samples/hello/hello_menu_bar.rb",
@@ -172,17 +174,17 @@ Gem::Specification.new do |s|
172
174
  end
173
175
 
174
176
  if s.respond_to? :add_runtime_dependency then
175
- s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.4"])
176
- s.add_runtime_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
177
- s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
178
- s.add_runtime_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
177
+ s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.6"])
178
+ s.add_runtime_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
179
+ s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
180
+ s.add_runtime_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
179
181
  s.add_runtime_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
180
182
  s.add_runtime_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
181
183
  s.add_runtime_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
182
184
  s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
183
185
  s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
184
186
  s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
185
- s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.25.0", "< 4.0.0"])
187
+ s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.26.0", "< 4.0.0"])
186
188
  s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
187
189
  s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
188
190
  s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
@@ -191,17 +193,17 @@ Gem::Specification.new do |s|
191
193
  s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
192
194
  s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
193
195
  else
194
- s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.4"])
195
- s.add_dependency(%q<super_module>.freeze, ["~> 1.4.1"])
196
- s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, ["~> 0.3.0"])
197
- s.add_dependency(%q<puts_debuggerer>.freeze, ["~> 0.10.2"])
196
+ s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.6"])
197
+ s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
198
+ s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
199
+ s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
198
200
  s.add_dependency(%q<rake-tui>.freeze, [">= 0.2.3", "< 2.0.0"])
199
201
  s.add_dependency(%q<git-glimmer>.freeze, ["= 1.7.0"])
200
202
  s.add_dependency(%q<logging>.freeze, [">= 2.3.0", "< 3.0.0"])
201
203
  s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
202
204
  s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
203
205
  s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
204
- s.add_dependency(%q<rouge>.freeze, [">= 3.25.0", "< 4.0.0"])
206
+ s.add_dependency(%q<rouge>.freeze, [">= 3.26.0", "< 4.0.0"])
205
207
  s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
206
208
  s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
207
209
  s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
@@ -38,16 +38,16 @@ module Glimmer
38
38
  @model_binding = model_binding
39
39
  @table.swt_widget.data = @model_binding
40
40
  @column_properties = column_properties
41
+ @table.on_widget_disposed do |dispose_event|
42
+ unregister_all_observables
43
+ end
41
44
  if @table.respond_to?(:column_properties=)
42
45
  @table.column_properties = @column_properties
43
46
  else # assume custom widget
44
47
  @table.body_root.column_properties = @column_properties
45
48
  end
46
- call(@model_binding.evaluate_property)
47
49
  @table_observer_registration = observe(model_binding)
48
- @table.on_widget_disposed do |dispose_event|
49
- unregister_all_observables
50
- end
50
+ call
51
51
  end
52
52
 
53
53
  def call(new_model_collection=nil)
@@ -65,7 +65,7 @@ module Glimmer
65
65
  end
66
66
 
67
67
  def populate_table(model_collection, parent, column_properties)
68
- selected_table_item_models = parent.swt_widget.getSelection.map(&:getData)
68
+ selected_table_item_models = parent.swt_widget.getSelection.map(&:get_data)
69
69
  parent.finish_edit!
70
70
  parent.swt_widget.items.each(&:dispose)
71
71
  parent.swt_widget.removeAll
@@ -74,11 +74,10 @@ module Glimmer
74
74
  for index in 0..(column_properties.size-1)
75
75
  table_item.setText(index, model.send(column_properties[index]).to_s)
76
76
  end
77
- table_item.setData(model)
77
+ table_item.set_data(model)
78
78
  end
79
- selected_table_items = parent.search {|item| selected_table_item_models.include?(item.getData) }
80
- selected_table_items = [parent.swt_widget.getItems.first].to_java(TableItem) if selected_table_items.empty? && !parent.swt_widget.getItems.empty?
81
- parent.swt_widget.setSelection(selected_table_items) unless selected_table_items.empty?
79
+ selected_table_items = parent.search {|item| selected_table_item_models.include?(item.get_data) }
80
+ parent.swt_widget.setSelection(selected_table_items)
82
81
  parent.sort!
83
82
  parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
84
83
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -69,7 +69,7 @@ module Glimmer
69
69
  old_tree_item_expansion_by_data = old_tree_items.reduce({}) {|hash, ti| hash.merge(ti.getData => ti.getExpanded)}
70
70
  old_tree_items.each do |tree_item|
71
71
  tree_item.getData('observer_registrations').each(&:unregister)
72
- end
72
+ end
73
73
  parent.swt_widget.items.each(&:dispose)
74
74
  parent.swt_widget.removeAll
75
75
  populate_tree_node(model_tree_root_node, parent.swt_widget, tree_properties)
@@ -85,9 +85,9 @@ module Glimmer
85
85
  array + [observe(model_tree_node, key_value_pair.last)]
86
86
  end
87
87
 
88
- tree_item.setData('observer_registrations', observer_registrations)
89
- tree_item.setData(model_tree_node)
90
- tree_item.setText((model_tree_node && model_tree_node.send(tree_properties[:text])).to_s)
88
+ tree_item.set_data('observer_registrations', observer_registrations)
89
+ tree_item.set_data(model_tree_node)
90
+ tree_item.text = (model_tree_node && model_tree_node.send(tree_properties[:text])).to_s
91
91
  [model_tree_node && model_tree_node.send(tree_properties[:children])].flatten.to_a.compact.each do |child|
92
92
  populate_tree_node(child, tree_item, tree_properties)
93
93
  end
@@ -66,7 +66,6 @@ module Glimmer
66
66
  else
67
67
  @swt_widget = swt_widget_class.new(parent.swt_widget)
68
68
  end
69
- DEFAULT_INITIALIZERS['menu']&.call(swt_widget)
70
69
 
71
70
  if styles.include?(:bar)
72
71
  parent.swt_widget.setMenuBar(swt_widget)
@@ -245,7 +245,7 @@ module Glimmer
245
245
  end
246
246
  end
247
247
 
248
- attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor, :editable, :initial_sort_property
248
+ attr_reader :table_editor, :table_editor_widget_proxy, :sort_property, :sort_direction, :sort_block, :sort_type, :sort_by_block, :additional_sort_properties, :editor, :editable
249
249
  attr_accessor :column_properties
250
250
  alias editable? editable
251
251
 
@@ -353,19 +353,6 @@ module Glimmer
353
353
  @additional_sort_properties = args unless args.empty?
354
354
  end
355
355
 
356
- def editor=(args)
357
- @editor = args
358
- end
359
-
360
- def cells_for(model)
361
- column_properties.map {|property| model.send(property)}
362
- end
363
-
364
- def cells
365
- column_count = @table.column_properties.size
366
- swt_widget.items.map {|item| column_count.times.map {|i| item.get_text(i)} }
367
- end
368
-
369
356
  def sort!
370
357
  return unless sort_property && (sort_type || sort_block || sort_by_block)
371
358
  array = model_binding.evaluate_property
@@ -395,6 +382,19 @@ module Glimmer
395
382
  model_binding.call(sorted_array)
396
383
  end
397
384
 
385
+ def editor=(args)
386
+ @editor = args
387
+ end
388
+
389
+ def cells_for(model)
390
+ column_properties.map {|property| model.send(property)}
391
+ end
392
+
393
+ def cells
394
+ column_count = @table.column_properties.size
395
+ swt_widget.items.map {|item| column_count.times.map {|i| item.get_text(i)} }
396
+ end
397
+
398
398
  # Performs a search for table items matching block condition
399
399
  # If no condition block is passed, returns all table items
400
400
  # Returns a Java TableItem array to easily set as selection on org.eclipse.swt.Table if needed
@@ -69,7 +69,7 @@ module Glimmer
69
69
  }
70
70
 
71
71
  DEFAULT_INITIALIZERS = {
72
- 'composite' => lambda do |composite|
72
+ composite: lambda do |composite|
73
73
  if composite.get_layout.nil?
74
74
  layout = GridLayout.new
75
75
  layout.marginWidth = 15
@@ -77,18 +77,18 @@ module Glimmer
77
77
  composite.layout = layout
78
78
  end
79
79
  end,
80
- 'scrolled_composite' => lambda do |scrolled_composite|
80
+ scrolled_composite: lambda do |scrolled_composite|
81
81
  scrolled_composite.expand_horizontal = true
82
82
  scrolled_composite.expand_vertical = true
83
83
  end,
84
- 'table' => lambda do |table|
84
+ table: lambda do |table|
85
85
  table.setHeaderVisible(true)
86
86
  table.setLinesVisible(true)
87
87
  end,
88
- 'table_column' => lambda do |table_column|
88
+ table_column: lambda do |table_column|
89
89
  table_column.setWidth(80)
90
90
  end,
91
- 'group' => lambda do |group|
91
+ group: lambda do |group|
92
92
  group.layout = GridLayout.new if group.get_layout.nil?
93
93
  end,
94
94
  }
@@ -160,7 +160,7 @@ module Glimmer
160
160
  end
161
161
  if @swt_widget&.get_data('proxy').nil?
162
162
  @swt_widget.set_data('proxy', self)
163
- DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
163
+ DEFAULT_INITIALIZERS[underscored_widget_name.to_s.to_sym]&.call(@swt_widget)
164
164
  @parent_proxy.post_initialize_child(self)
165
165
  end
166
166
  end
@@ -212,6 +212,7 @@ module Glimmer
212
212
  end
213
213
 
214
214
  def set_attribute(attribute_name, *args)
215
+ # TODO Think about widget subclasses overriding set_attribute to add more attributes vs adding as Ruby attributes directly
215
216
  widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
216
217
  if widget_custom_attribute
217
218
  widget_custom_attribute[:setter][:invoker].call(@swt_widget, args)
@@ -857,6 +858,7 @@ module Glimmer
857
858
  !!value
858
859
  end,
859
860
  :foreground => color_converter,
861
+ :link_foreground => color_converter,
860
862
  :font => lambda do |value|
861
863
  if value.is_a?(Hash)
862
864
  font_properties = value
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -19,7 +19,6 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- #Presents login screen data
23
22
  class LoginPresenter
24
23
 
25
24
  attr_accessor :user_name
@@ -35,7 +34,6 @@ class LoginPresenter
35
34
  def status=(status)
36
35
  @status = status
37
36
 
38
- #TODO add feature to bind dependent properties to master property (2017-07-25 nested data binding)
39
37
  notify_observers("logged_in")
40
38
  notify_observers("logged_out")
41
39
  end
@@ -65,7 +63,6 @@ class LoginPresenter
65
63
 
66
64
  end
67
65
 
68
- #Login screen
69
66
  class Login
70
67
  include Glimmer
71
68
 
@@ -77,10 +74,10 @@ class Login
77
74
  grid_layout 2, false #two columns with differing widths
78
75
 
79
76
  label { text "Username:" } # goes in column 1
80
- @user_name_text = text { # goes in column 2
77
+ @user_name_text = text { # goes in column 2
81
78
  text bind(presenter, :user_name)
82
79
  enabled bind(presenter, :logged_out)
83
- on_key_pressed { |event|
80
+ on_key_pressed { |event|
84
81
  @password_text.set_focus if event.keyCode == swt(:cr)
85
82
  }
86
83
  }
@@ -89,7 +86,7 @@ class Login
89
86
  @password_text = text(:password, :border) {
90
87
  text bind(presenter, :password)
91
88
  enabled bind(presenter, :logged_out)
92
- on_key_pressed { |event|
89
+ on_key_pressed { |event|
93
90
  presenter.login if event.keyCode == swt(:cr)
94
91
  }
95
92
  }
@@ -101,21 +98,21 @@ class Login
101
98
  text "Login"
102
99
  enabled bind(presenter, :logged_out)
103
100
  on_widget_selected { presenter.login }
104
- on_key_pressed { |event|
101
+ on_key_pressed { |event|
105
102
  presenter.login if event.keyCode == swt(:cr)
106
- }
103
+ }
107
104
  }
108
105
 
109
106
  button {
110
107
  text "Logout"
111
108
  enabled bind(presenter, :logged_in)
112
109
  on_widget_selected { presenter.logout }
113
- on_key_pressed { |event|
110
+ on_key_pressed { |event|
114
111
  if event.keyCode == swt(:cr)
115
112
  presenter.logout
116
113
  @user_name_text.set_focus
117
114
  end
118
- }
115
+ }
119
116
  }
120
117
  }
121
118
  }
@@ -1,4 +1,8 @@
1
+ require 'fileutils'
2
+
1
3
  class Sample
4
+ include Glimmer::DataBinding::ObservableModel
5
+
2
6
  attr_accessor :sample_directory, :file, :selected
3
7
 
4
8
  def initialize(file, sample_directory: )
@@ -19,12 +23,33 @@ class Sample
19
23
  @name
20
24
  end
21
25
 
22
- def content
23
- @content = File.read(file)
26
+ def code
27
+ reset_code! if @code.nil?
28
+ @code
24
29
  end
25
-
26
- def launch
27
- load file
30
+
31
+ def reset_code!
32
+ @code = File.read(file)
33
+ notify_observers('code')
34
+ end
35
+
36
+ def launch(modified_code)
37
+ modified_file = File.join(File.dirname(file), ".#{File.basename(file)}")
38
+ begin
39
+ File.write(modified_file, modified_code)
40
+ begin
41
+ load(modified_file)
42
+ rescue StandardError, SyntaxError => launch_error
43
+ message_box {
44
+ text 'Error Launching'
45
+ message launch_error.full_message
46
+ }.open
47
+ end
48
+ rescue
49
+ load(file) # load original file if failed to write changes
50
+ ensure
51
+ FileUtils.rm_rf(modified_file)
52
+ end
28
53
  end
29
54
  end
30
55
 
@@ -111,15 +136,17 @@ end
111
136
  class MetaSampleApplication
112
137
  include Glimmer
113
138
 
139
+ def initialize
140
+ selected_sample_directory = SampleDirectory.sample_directories.first
141
+ selected_sample = selected_sample_directory.samples.first
142
+ selected_sample_directory.selected_sample_name = selected_sample.name
143
+ end
144
+
114
145
  def launch
115
146
  shell {
116
147
  minimum_size 1280, 768
117
148
  text 'Glimmer Meta-Sample (The Sample of Samples)'
118
149
 
119
- on_swt_show {
120
- SampleDirectory.selected_sample = SampleDirectory.all_samples.first
121
- }
122
-
123
150
  sash_form {
124
151
  composite {
125
152
  grid_layout 1, false
@@ -144,22 +171,31 @@ class MetaSampleApplication
144
171
  }
145
172
  }
146
173
 
147
- button {
174
+ composite {
175
+ fill_layout
148
176
  layout_data(:fill, :center, true, false) {
149
177
  height_hint 120
150
178
  }
151
- text 'Launch Sample'
152
- font height: 30
153
- on_widget_selected {
154
- SampleDirectory.selected_sample.launch
179
+
180
+ button {
181
+ text 'Launch'
182
+ font height: 30
183
+ on_widget_selected {
184
+ SampleDirectory.selected_sample.launch(@code_text.text)
185
+ }
186
+ }
187
+ button {
188
+ text 'Reset'
189
+ font height: 30
190
+ on_widget_selected {
191
+ SampleDirectory.selected_sample.reset_code!
192
+ }
155
193
  }
156
194
  }
157
195
  }
158
196
 
159
- code_text {
160
- text bind(SampleDirectory, 'selected_sample.content')
161
- editable false
162
- caret nil
197
+ @code_text = code_text {
198
+ text bind(SampleDirectory, 'selected_sample.code', read_only: true)
163
199
  }
164
200
 
165
201
  weights 4, 9