glimmer-dsl-swt 4.17.6.0 → 4.17.8.3

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -2
  3. data/README.md +211 -82
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +14 -3
  6. data/lib/glimmer/data_binding/tree_items_binding.rb +20 -2
  7. data/lib/glimmer/dsl/swt/checkbox_group_selection_data_binding_expression.rb +61 -0
  8. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -0
  9. data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -0
  10. data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +48 -0
  11. data/lib/glimmer/dsl/swt/dsl.rb +1 -0
  12. data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
  13. data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +3 -3
  14. data/lib/glimmer/dsl/swt/shell_expression.rb +3 -3
  15. data/lib/glimmer/dsl/swt/widget_expression.rb +8 -8
  16. data/lib/glimmer/swt/custom/checkbox_group.rb +181 -0
  17. data/lib/glimmer/swt/custom/code_text.rb +43 -33
  18. data/lib/glimmer/swt/custom/radio_group.rb +94 -19
  19. data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
  20. data/lib/glimmer/swt/expand_item_proxy.rb +0 -1
  21. data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
  22. data/lib/glimmer/swt/menu_proxy.rb +3 -3
  23. data/lib/glimmer/swt/shell_proxy.rb +5 -5
  24. data/lib/glimmer/swt/tab_item_proxy.rb +3 -3
  25. data/lib/glimmer/swt/table_proxy.rb +25 -25
  26. data/lib/glimmer/swt/widget_listener_proxy.rb +4 -4
  27. data/lib/glimmer/swt/widget_proxy.rb +27 -27
  28. data/lib/glimmer/ui/custom_shell.rb +3 -3
  29. data/samples/elaborate/contact_manager.rb +3 -3
  30. data/samples/elaborate/meta_sample.rb +24 -19
  31. data/samples/hello/hello_browser.rb +3 -3
  32. data/samples/hello/hello_checkbox.rb +18 -18
  33. data/samples/hello/hello_checkbox_group.rb +68 -0
  34. data/samples/hello/hello_combo.rb +12 -12
  35. data/samples/hello/hello_directory_dialog.rb +60 -0
  36. data/samples/hello/hello_expand_bar.rb +3 -1
  37. data/samples/hello/hello_file_dialog.rb +60 -0
  38. data/samples/hello/hello_group.rb +104 -0
  39. data/samples/hello/hello_list_multi_selection.rb +23 -23
  40. data/samples/hello/hello_list_single_selection.rb +18 -17
  41. data/samples/hello/hello_menu_bar.rb +3 -3
  42. data/samples/hello/hello_pop_up_context_menu.rb +3 -3
  43. data/samples/hello/hello_radio.rb +20 -20
  44. data/samples/hello/hello_radio_group.rb +25 -25
  45. data/samples/hello/hello_table.rb +130 -0
  46. data/samples/hello/hello_world.rb +3 -3
  47. metadata +13 -2
@@ -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
@@ -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
@@ -26,14 +26,14 @@ module Glimmer
26
26
  class TableProxy < Glimmer::SWT::WidgetProxy
27
27
  include Glimmer
28
28
 
29
- module TableListenerEvent
29
+ module TableListenerEvent
30
30
  def table_item
31
31
  table_item_and_column_index[:table_item]
32
32
  end
33
33
 
34
34
  def column_index
35
35
  table_item_and_column_index[:column_index]
36
- end
36
+ end
37
37
 
38
38
  private
39
39
 
@@ -51,7 +51,7 @@ module Glimmer
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
55
55
  end
56
56
 
57
57
  class << self
@@ -74,9 +74,9 @@ module Glimmer
74
74
  elsif key_event.keyCode == swt(:esc)
75
75
  table_proxy.cancel_edit!
76
76
  end
77
- }
77
+ }
78
78
  }
79
- table_editor_widget_proxy.swt_widget.selectAll
79
+ table_editor_widget_proxy.swt_widget.selectAll
80
80
  table_editor_widget_proxy
81
81
  end,
82
82
  },
@@ -101,8 +101,8 @@ module Glimmer
101
101
  }
102
102
  on_widget_selected {
103
103
  if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
104
- table_proxy.finish_edit!
105
- end
104
+ table_proxy.finish_edit!
105
+ end
106
106
  }
107
107
  }
108
108
  table_editor_widget_proxy
@@ -117,10 +117,10 @@ module Glimmer
117
117
  selection model.send(property)
118
118
  focus true
119
119
  on_widget_selected {
120
- table_proxy.finish_edit!
120
+ table_proxy.finish_edit!
121
121
  }
122
122
  on_focus_lost {
123
- table_proxy.finish_edit!
123
+ table_proxy.finish_edit!
124
124
  }
125
125
  on_key_pressed { |key_event|
126
126
  if key_event.keyCode == swt(:cr)
@@ -128,7 +128,7 @@ module Glimmer
128
128
  elsif key_event.keyCode == swt(:esc)
129
129
  table_proxy.cancel_edit!
130
130
  end
131
- }
131
+ }
132
132
  }
133
133
  end,
134
134
  },
@@ -141,10 +141,10 @@ module Glimmer
141
141
  selection model.send(property)
142
142
  focus true
143
143
  on_widget_selected {
144
- table_proxy.finish_edit!
144
+ table_proxy.finish_edit!
145
145
  }
146
146
  on_focus_lost {
147
- table_proxy.finish_edit!
147
+ table_proxy.finish_edit!
148
148
  }
149
149
  on_key_pressed { |key_event|
150
150
  if key_event.keyCode == swt(:cr)
@@ -152,11 +152,11 @@ module Glimmer
152
152
  elsif key_event.keyCode == swt(:esc)
153
153
  table_proxy.cancel_edit!
154
154
  end
155
- }
155
+ }
156
156
  }
157
157
  end,
158
- }
159
- }
158
+ }
159
+ }
160
160
  end
161
161
  end
162
162
 
@@ -188,7 +188,7 @@ module Glimmer
188
188
  end
189
189
  end
190
190
 
191
- @sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
191
+ @sort_direction = @sort_direction.nil? || @sort_property != new_sort_property || @sort_direction == :descending ? :ascending : :descending
192
192
  swt_widget.sort_direction = @sort_direction == :ascending ? SWTProxy[:up] : SWTProxy[:down]
193
193
 
194
194
  @sort_property = new_sort_property
@@ -202,7 +202,7 @@ module Glimmer
202
202
  elsif table_column_proxy.sort_block
203
203
  @sort_block = table_column_proxy.sort_block
204
204
  else
205
- detect_sort_type
205
+ detect_sort_type
206
206
  end
207
207
  sort
208
208
  end
@@ -229,7 +229,7 @@ module Glimmer
229
229
 
230
230
  def editor=(args)
231
231
  @editor = args
232
- end
232
+ end
233
233
 
234
234
  def cells_for(model)
235
235
  column_properties.map {|property| model.send(property)}
@@ -248,7 +248,7 @@ module Glimmer
248
248
  if sort_block
249
249
  sorted_array = array.sort(&sort_block)
250
250
  elsif sort_by_block
251
- sorted_array = array.sort_by(&sort_by_block)
251
+ sorted_array = array.sort_by(&sort_by_block)
252
252
  else
253
253
  sorted_array = array.sort_by do |object|
254
254
  sort_property.each_with_index.map do |a_sort_property, i|
@@ -289,7 +289,7 @@ module Glimmer
289
289
  observer.call(@swt_widget.getSelection)
290
290
  }
291
291
  end
292
- },
292
+ },
293
293
  })
294
294
  end
295
295
 
@@ -370,13 +370,13 @@ module Glimmer
370
370
  swt_widget.showItem(edited_table_item)
371
371
  @table_editor_widget_proxy&.swt_widget&.dispose
372
372
  @table_editor_widget_proxy = nil
373
- after_write&.call(edited_table_item)
373
+ after_write&.call(edited_table_item)
374
374
  @edit_in_progress = false
375
375
  end
376
376
  end
377
377
  end
378
378
 
379
- content {
379
+ content {
380
380
  @table_editor_widget_proxy = TableProxy::editors.symbolize_keys[editor_widget][:editor_gui].call(editor_widget_args, model, model_editing_property, self)
381
381
  }
382
382
  @table_editor.setEditor(@table_editor_widget_proxy.swt_widget, table_item, column_index)
@@ -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
@@ -40,7 +40,7 @@ module Glimmer
40
40
 
41
41
  def widget_remove_listener_method
42
42
  @widget_add_listener_method.sub('add', 'remove')
43
- end
43
+ end
44
44
 
45
45
  def unregister
46
46
  # TODO consider renaming to deregister (and in Observer too)
@@ -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
@@ -50,6 +50,7 @@ module Glimmer
50
50
  'check' => [:check],
51
51
  'drag_source' => [:drop_copy],
52
52
  'drop_target' => [:drop_copy],
53
+ 'expand_bar' => [:v_scroll],
53
54
  'list' => [:border, :v_scroll],
54
55
  'menu_item' => [:push],
55
56
  'radio' => [:radio],
@@ -61,7 +62,6 @@ module Glimmer
61
62
  'toggle' => [:toggle],
62
63
  'tool_bar' => [:push],
63
64
  'tool_item' => [:push],
64
- 'expand_bar' => [:v_scroll],
65
65
  'tree' => [:virtual, :border, :h_scroll, :v_scroll],
66
66
  }
67
67
 
@@ -91,11 +91,11 @@ module Glimmer
91
91
  }
92
92
 
93
93
  KEYWORD_ALIASES = {
94
- 'radio' => 'button',
94
+ 'arrow' => 'button',
95
95
  'checkbox' => 'button',
96
96
  'check' => 'button',
97
+ 'radio' => 'button',
97
98
  'toggle' => 'button',
98
- 'arrow' => 'button',
99
99
  }
100
100
 
101
101
  class << self
@@ -108,7 +108,7 @@ module Glimmer
108
108
  if init_args.empty?
109
109
  selected_widget_proxy_class.new(swt_widget: swt_widget)
110
110
  else
111
- selected_widget_proxy_class.new(*init_args)
111
+ selected_widget_proxy_class.new(*init_args)
112
112
  end
113
113
  end
114
114
 
@@ -119,11 +119,11 @@ module Glimmer
119
119
  Glimmer::SWT.const_get(class_name)
120
120
  rescue
121
121
  Glimmer::SWT::WidgetProxy
122
- end
122
+ end
123
123
  end
124
124
 
125
125
  def underscored_widget_name(swt_widget)
126
- swt_widget.class.name.split(/::|\./).last.underscore
126
+ swt_widget.class.name.split(/::|\./).last.underscore
127
127
  end
128
128
  end
129
129
 
@@ -131,7 +131,7 @@ module Glimmer
131
131
 
132
132
  # Initializes a new SWT Widget
133
133
  #
134
- # It is preferred to use `::create` method instead since it instantiates the
134
+ # It is preferred to use `::create` method instead since it instantiates the
135
135
  # right subclass per widget keyword
136
136
  #
137
137
  # keyword, parent, swt_widget_args (including styles)
@@ -152,7 +152,7 @@ module Glimmer
152
152
  @parent_proxy = parent.get_data('proxy') || parent_proxy_class.new(swt_widget: parent)
153
153
  end
154
154
  if @swt_widget&.get_data('proxy').nil?
155
- @swt_widget.set_data('proxy', self)
155
+ @swt_widget.set_data('proxy', self)
156
156
  DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
157
157
  @parent_proxy.post_initialize_child(self)
158
158
  end
@@ -376,7 +376,7 @@ module Glimmer
376
376
  observer.call(@last_top_index)
377
377
  end
378
378
  }
379
- end,
379
+ end,
380
380
  :top_pixel => lambda do |observer|
381
381
  @last_top_pixel = @swt_widget.getTopPixel
382
382
  on_paint_control { |event|
@@ -480,13 +480,13 @@ module Glimmer
480
480
  proxy.set_attribute(:transfer, :text)
481
481
  proxy.on_drag_enter { |event|
482
482
  event.detail = DNDProxy[:drop_copy]
483
- }
483
+ }
484
484
  end
485
485
  end
486
486
 
487
487
  # TODO eliminate duplication in the following methods perhaps by relying on exceptions
488
488
 
489
- def can_handle_observation_request?(observation_request)
489
+ def can_handle_observation_request?(observation_request)
490
490
  observation_request = observation_request.to_s
491
491
  if observation_request.start_with?('on_swt_')
492
492
  constant_name = observation_request.sub(/^on_swt_/, '')
@@ -509,7 +509,7 @@ module Glimmer
509
509
  end
510
510
  rescue => e
511
511
  Glimmer::Config.logger.debug {e.full_message}
512
- false
512
+ false
513
513
  end
514
514
 
515
515
  def can_handle_drop_observation_request?(observation_request)
@@ -547,7 +547,7 @@ module Glimmer
547
547
  end
548
548
 
549
549
  def method_missing(method, *args, &block)
550
- if can_handle_observation_request?(method)
550
+ if can_handle_observation_request?(method)
551
551
  handle_observation_request(method, &block)
552
552
  else
553
553
  swt_widget.send(method, *args, &block)
@@ -559,7 +559,7 @@ module Glimmer
559
559
  end
560
560
 
561
561
  def respond_to?(method, *args, &block)
562
- super ||
562
+ super ||
563
563
  can_handle_observation_request?(method) ||
564
564
  swt_widget.respond_to?(method, *args, &block)
565
565
  end
@@ -567,7 +567,7 @@ module Glimmer
567
567
  private
568
568
 
569
569
  def style(underscored_widget_name, styles)
570
- styles = [styles].flatten.compact
570
+ styles = [styles].flatten.compact
571
571
  styles = default_style(underscored_widget_name) if styles.empty?
572
572
  interpret_style(*styles)
573
573
  end
@@ -603,9 +603,9 @@ module Glimmer
603
603
  end
604
604
 
605
605
  def add_listener(underscored_listener_name, &block)
606
- widget_add_listener_method, listener_class, listener_method = self.class.find_listener(@swt_widget.getClass, underscored_listener_name)
606
+ widget_add_listener_method, listener_class, listener_method = self.class.find_listener(@swt_widget.getClass, underscored_listener_name)
607
607
  widget_listener_proxy = nil
608
- safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
608
+ safe_block = lambda { |*args| block.call(*args) unless @swt_widget.isDisposed }
609
609
  listener = listener_class.new(listener_method => safe_block)
610
610
  @swt_widget.send(widget_add_listener_method, listener)
611
611
  widget_listener_proxy = WidgetListenerProxy.new(swt_widget: @swt_widget, swt_listener: listener, widget_add_listener_method: widget_add_listener_method, swt_listener_class: listener_class, swt_listener_method: listener_method)
@@ -647,7 +647,7 @@ module Glimmer
647
647
  listener_class.define_method('initialize') do |event_method_block_mapping|
648
648
  @event_method_block_mapping = event_method_block_mapping
649
649
  end
650
- listener_type.getMethods.each do |event_method|
650
+ listener_type.getMethods.each do |event_method|
651
651
  listener_class.define_method(event_method.getName) do |*args|
652
652
  @event_method_block_mapping[event_method.getName]&.call(*args)
653
653
  end
@@ -678,9 +678,9 @@ module Glimmer
678
678
  },
679
679
  'selection_count' => {
680
680
  getter: {name: 'getSelectionCount'},
681
- setter: {name: 'setSelection', invoker: lambda { |widget, args|
681
+ setter: {name: 'setSelection', invoker: lambda { |widget, args|
682
682
  caret_position = @swt_widget.respond_to?(:getCaretPosition) ? @swt_widget.getCaretPosition : @swt_widget.getCaretOffset
683
- @swt_widget.setSelection(caret_position, caret_position + args.first) if args.first
683
+ @swt_widget.setSelection(caret_position, caret_position + args.first) if args.first
684
684
  }},
685
685
  },
686
686
  }
@@ -773,13 +773,13 @@ module Glimmer
773
773
  sleep(delayTime)
774
774
  end
775
775
  };
776
- image_proxy = nil
776
+ image_proxy = nil
777
777
  else
778
778
  on_swt_Resize do |resize_event|
779
779
  image_proxy.scale_to(@swt_widget.getSize.x, @swt_widget.getSize.y)
780
- @swt_widget.setBackgroundImage(image_proxy.swt_image)
781
- end
782
- end
780
+ @swt_widget.setBackgroundImage(image_proxy.swt_image)
781
+ end
782
+ end
783
783
 
784
784
  image_proxy&.swt_image
785
785
  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
@@ -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