glimmer 0.5.11 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +129 -15
  3. data/lib/glimmer.rb +13 -1
  4. data/lib/glimmer/css/rule_set.rb +27 -0
  5. data/lib/glimmer/css/style_sheet.rb +20 -0
  6. data/lib/glimmer/dsl/css/css_expression.rb +21 -0
  7. data/lib/glimmer/dsl/css/dsl.rb +10 -0
  8. data/lib/glimmer/dsl/css/p_expression.rb +25 -0
  9. data/lib/glimmer/dsl/css/property_expression.rb +22 -0
  10. data/lib/glimmer/dsl/css/rule_set_expression.rb +25 -0
  11. data/lib/glimmer/dsl/css/s_expression.rb +26 -0
  12. data/lib/glimmer/dsl/engine.rb +90 -18
  13. data/lib/glimmer/dsl/expression.rb +9 -4
  14. data/lib/glimmer/dsl/static_expression.rb +13 -13
  15. data/lib/glimmer/dsl/swt/async_exec_expression.rb +14 -0
  16. data/lib/glimmer/dsl/swt/bind_expression.rb +37 -0
  17. data/lib/glimmer/dsl/swt/color_expression.rb +17 -0
  18. data/lib/glimmer/dsl/swt/column_properties_expression.rb +24 -0
  19. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +42 -0
  20. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +36 -0
  21. data/lib/glimmer/dsl/swt/data_binding_expression.rb +34 -0
  22. data/lib/glimmer/dsl/swt/display_expression.rb +19 -0
  23. data/lib/glimmer/dsl/swt/dsl.rb +26 -0
  24. data/lib/glimmer/dsl/swt/exec_expression.rb +28 -0
  25. data/lib/glimmer/dsl/swt/layout_data_expression.rb +25 -0
  26. data/lib/glimmer/dsl/swt/layout_expression.rb +27 -0
  27. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +44 -0
  28. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +33 -0
  29. data/lib/glimmer/dsl/swt/menu_expression.rb +32 -0
  30. data/lib/glimmer/dsl/swt/observe_expression.rb +32 -0
  31. data/lib/glimmer/dsl/swt/property_expression.rb +22 -0
  32. data/lib/glimmer/dsl/swt/rgb_expression.rb +12 -0
  33. data/lib/glimmer/dsl/swt/rgba_expression.rb +12 -0
  34. data/lib/glimmer/dsl/swt/shell_expression.rb +20 -0
  35. data/lib/glimmer/dsl/swt/swt_expression.rb +25 -0
  36. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +15 -0
  37. data/lib/glimmer/dsl/swt/tab_item_expression.rb +33 -0
  38. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +31 -0
  39. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +31 -0
  40. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +26 -0
  41. data/lib/glimmer/dsl/swt/widget_expression.rb +27 -0
  42. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +32 -0
  43. data/lib/glimmer/dsl/top_level_expression.rb +7 -0
  44. data/lib/glimmer/dsl/xml/dsl.rb +11 -0
  45. data/lib/glimmer/dsl/xml/html_expression.rb +25 -0
  46. data/lib/glimmer/dsl/xml/meta_expression.rb +23 -0
  47. data/lib/glimmer/dsl/xml/name_space_expression.rb +37 -0
  48. data/lib/glimmer/dsl/xml/node_parent_expression.rb +33 -0
  49. data/lib/glimmer/dsl/xml/tag_expression.rb +29 -0
  50. data/lib/glimmer/dsl/xml/text_expression.rb +22 -0
  51. data/lib/glimmer/dsl/xml/xml_expression.rb +21 -0
  52. data/lib/glimmer/rake_task.rb +1 -1
  53. data/lib/glimmer/swt/shell_proxy.rb +1 -2
  54. data/lib/glimmer/swt/widget_proxy.rb +6 -3
  55. data/lib/glimmer/ui/custom_widget.rb +8 -4
  56. data/lib/glimmer/ui/video.rb +31 -28
  57. data/lib/glimmer/xml/depth_first_search_iterator.rb +22 -0
  58. data/lib/glimmer/xml/name_space_visitor.rb +21 -0
  59. data/lib/glimmer/xml/node.rb +75 -0
  60. data/lib/glimmer/xml/node_visitor.rb +13 -0
  61. data/lib/glimmer/xml/xml_visitor.rb +65 -0
  62. data/samples/gladiator.rb +52 -12
  63. metadata +55 -31
  64. data/lib/glimmer/dsl.rb +0 -26
  65. data/lib/glimmer/dsl/async_exec_expression.rb +0 -12
  66. data/lib/glimmer/dsl/bind_expression.rb +0 -35
  67. data/lib/glimmer/dsl/color_expression.rb +0 -22
  68. data/lib/glimmer/dsl/column_properties_expression.rb +0 -22
  69. data/lib/glimmer/dsl/combo_selection_data_binding_expression.rb +0 -40
  70. data/lib/glimmer/dsl/custom_widget_expression.rb +0 -33
  71. data/lib/glimmer/dsl/data_binding_expression.rb +0 -32
  72. data/lib/glimmer/dsl/display_expression.rb +0 -14
  73. data/lib/glimmer/dsl/exec_expression.rb +0 -23
  74. data/lib/glimmer/dsl/layout_data_expression.rb +0 -23
  75. data/lib/glimmer/dsl/layout_expression.rb +0 -25
  76. data/lib/glimmer/dsl/list_selection_data_binding_expression.rb +0 -42
  77. data/lib/glimmer/dsl/menu_bar_expression.rb +0 -31
  78. data/lib/glimmer/dsl/menu_expression.rb +0 -30
  79. data/lib/glimmer/dsl/observe_expression.rb +0 -27
  80. data/lib/glimmer/dsl/property_expression.rb +0 -20
  81. data/lib/glimmer/dsl/shell_expression.rb +0 -16
  82. data/lib/glimmer/dsl/swt_expression.rb +0 -23
  83. data/lib/glimmer/dsl/sync_exec_expression.rb +0 -13
  84. data/lib/glimmer/dsl/tab_item_expression.rb +0 -31
  85. data/lib/glimmer/dsl/table_items_data_binding_expression.rb +0 -29
  86. data/lib/glimmer/dsl/tree_items_data_binding_expression.rb +0 -29
  87. data/lib/glimmer/dsl/tree_properties_expression.rb +0 -24
  88. data/lib/glimmer/dsl/widget_expression.rb +0 -25
  89. data/lib/glimmer/dsl/widget_listener_expression.rb +0 -30
@@ -0,0 +1,13 @@
1
+ module Glimmer
2
+ module XML
3
+ class NodeVisitor
4
+ def process_before_children
5
+ raise "must be implemented by a class"
6
+ end
7
+
8
+ def process_after_children
9
+ raise "must be implemented by a class"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,65 @@
1
+ require File.dirname(__FILE__) + "/node_visitor"
2
+ require File.dirname(__FILE__) + "/node"
3
+
4
+ module Glimmer
5
+ module XML
6
+ class XmlVisitor < NodeVisitor
7
+
8
+ attr_reader :document
9
+
10
+ def initialize
11
+ @document = ""
12
+ end
13
+
14
+ def process_before_children(node)
15
+ if (!node.is_a?(Glimmer::XML::Node))
16
+ @document << node.to_s
17
+ return
18
+ end
19
+ begin_open_tag(node)
20
+ append_attributes(node) if node.attributes
21
+ end_open_tag(node)
22
+ end
23
+
24
+ def process_after_children(node)
25
+ return if (!node.is_a?(Glimmer::XML::Node))
26
+ append_close_tag(node)
27
+ end
28
+
29
+ def begin_open_tag(node)
30
+ @document << "<"
31
+ @document << "#{node.name_space.name}:" if node.name_space
32
+ @document << node.name
33
+ end
34
+
35
+ def end_open_tag(node)
36
+ if (node.contents)
37
+ @document << ">"
38
+ else
39
+ @document << " " if node.attributes.keys.size > 0
40
+ @document << "/>"
41
+ end
42
+ end
43
+
44
+ def append_close_tag(node)
45
+ if (node.contents)
46
+ @document << "</"
47
+ @document << "#{node.name_space.name}:" if node.name_space
48
+ @document << "#{node.name}>"
49
+ end
50
+ end
51
+
52
+ def append_attributes(node)
53
+ Glimmer.logger&.debug "Take 3"
54
+ Glimmer.logger&.debug(node.attributes)
55
+ node.attributes.each do |attribute, value|
56
+ attribute_name = attribute
57
+ attribute_name = "#{attribute.name_space.name}:#{attribute.name}" if attribute.is_a?(Node)
58
+ @document << " #{attribute_name}"
59
+ @document << "=\"#{value}\"" unless value.nil?
60
+ end
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -10,9 +10,19 @@ class Gladiator
10
10
  include Glimmer
11
11
 
12
12
  class Dir
13
+ include Glimmer
14
+
13
15
  class << self
14
16
  def local_dir
15
- @local_dir ||= new(ENV['LOCAL_DIR'] || '.')
17
+ @local_dir ||= new(ENV['LOCAL_DIR'] || '.').tap do |dir|
18
+ dir.refresh
19
+ @filewatcher = Filewatcher.new(dir.path)
20
+ @thread = Thread.new(@filewatcher) do |fw|
21
+ fw.watch do |filename, event|
22
+ dir.refresh if filename != dir.selected_child_path
23
+ end
24
+ end
25
+ end
16
26
  end
17
27
  end
18
28
 
@@ -25,9 +35,26 @@ class Gladiator
25
35
  end
26
36
 
27
37
  def children
38
+ @children ||= retrieve_children
39
+ end
40
+
41
+ def retrieve_children
28
42
  ::Dir.glob(::File.join(@path, '*')).map {|p| ::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)}.sort_by {|c| c.path.to_s.downcase }.sort_by {|c| c.class.name }
29
43
  end
30
44
 
45
+ def refresh
46
+ new_all_children = retrieve_all_children
47
+ new_children = retrieve_children
48
+ async_exec do
49
+ @all_children = new_all_children
50
+ @children ||= []
51
+ @children.clear
52
+ new_children.each do |child|
53
+ @children << child
54
+ end
55
+ end
56
+ end
57
+
31
58
  def filter=(value)
32
59
  if value.to_s.empty?
33
60
  @filter = nil
@@ -41,16 +68,20 @@ class Gladiator
41
68
  return if filter.nil?
42
69
  all_children_files.select do |child|
43
70
  child.path.downcase.include?(filter.downcase) ||
44
- child.path.downcase.gsub('_', '').include?(filter.downcase)
71
+ child.path.downcase.gsub(/[_\/]/, '').include?(filter.downcase)
45
72
  end.sort_by {|c| c.path.to_s.downcase}
46
73
  end
47
74
 
48
75
  def all_children
49
- @all_children ||= ::Dir.glob(::File.join(@path, '**', '*')).map {|p| ::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)}
76
+ @all_children ||= retrieve_all_children
77
+ end
78
+
79
+ def retrieve_all_children
80
+ ::Dir.glob(::File.join(@path, '**', '*')).map {|p| ::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)}
50
81
  end
51
82
 
52
83
  def all_children_files
53
- @all_children_files ||= all_children.select {|child| child.is_a?(Gladiator::File) }
84
+ all_children.select {|child| child.is_a?(Gladiator::File) }
54
85
  end
55
86
 
56
87
  def selected_child_path=(selected_path)
@@ -142,6 +173,10 @@ class Gladiator
142
173
  ::File.write(path, dirty_content) if ::File.exists?(path) && dirty_content.to_s.strip.size > 0
143
174
  end
144
175
 
176
+ def write_raw_dirty_content
177
+ ::File.write(path, dirty_content) if ::File.exists?(path) && dirty_content.to_s.strip.size > 0
178
+ end
179
+
145
180
  def comment_line!
146
181
  old_lines = lines
147
182
  return if old_lines.size < 1
@@ -298,7 +333,7 @@ class Gladiator
298
333
 
299
334
  def ensure_find_next
300
335
  return if find_text.to_s.empty? || dirty_content.to_s.strip.size < 1
301
- find_next unless dirty_content[caret_position, find_text.size] == find_text
336
+ find_next unless dirty_content[caret_position.to_i, find_text.to_s.size] == find_text
302
337
  end
303
338
 
304
339
  def replace_next!
@@ -507,7 +542,7 @@ class Gladiator
507
542
  @filter_text = text {
508
543
  layout_data :fill, :center, true, false
509
544
  text bind(Gladiator::Dir.local_dir, 'filter')
510
- on_key_pressed { |key_event|
545
+ on_key_pressed { |key_event|
511
546
  if key_event.keyCode == swt(:tab) ||
512
547
  key_event.keyCode == swt(:cr) ||
513
548
  key_event.keyCode == swt(:lf) ||
@@ -546,6 +581,12 @@ class Gladiator
546
581
  on_widget_selected {
547
582
  Gladiator::Dir.local_dir.selected_child_path = @tree.swt_widget.getSelection.first.getText
548
583
  }
584
+ on_key_pressed { |key_event|
585
+ if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr) || Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :lf)
586
+ Gladiator::Dir.local_dir.selected_child_path = @tree.swt_widget.getSelection.first.getText
587
+ @text.swt_widget.setFocus
588
+ end
589
+ }
549
590
  on_paint_control {
550
591
  root_item = @tree.swt_widget.getItems.first
551
592
  if root_item && !root_item.getExpanded
@@ -580,7 +621,7 @@ class Gladiator
580
621
  }
581
622
  @line_number_text = text {
582
623
  layout_data(:fill, :fill, true, false) {
583
- minimum_width 200
624
+ minimum_width 300
584
625
  }
585
626
  text bind(Gladiator::Dir.local_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
586
627
  on_key_pressed { |key_event|
@@ -715,11 +756,10 @@ class Gladiator
715
756
  end
716
757
  end
717
758
 
718
- include Glimmer
759
+ @gladiator = Gladiator.new
760
+
719
761
  at_exit do
720
- async_exec do
721
- Gladiator::Dir.local_dir.selected_child&.write_dirty_content
722
- end
762
+ Gladiator::Dir.local_dir.selected_child&.write_raw_dirty_content
723
763
  end
724
764
 
725
- Gladiator.new.launch
765
+ @gladiator.launch
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.6.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-04-26 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -220,9 +220,9 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: 0.8.1
223
- description: JRuby Desktop UI DSL + Data-Binding cross-platform library that enables
224
- productive and efficient authoring of desktop user-interfaces using the robust platform-native
225
- Eclipse SWT library
223
+ description: JRuby Desktop UI DSL + Data-Binding native-UI cross-platform library
224
+ that enables productive and efficient authoring of desktop user-interfaces using
225
+ the robust Eclipse SWT library
226
226
  email: andy.am@gmail.com
227
227
  executables:
228
228
  - glimmer
@@ -240,6 +240,8 @@ files:
240
240
  - bin/gladiator
241
241
  - bin/glimmer
242
242
  - lib/glimmer.rb
243
+ - lib/glimmer/css/rule_set.rb
244
+ - lib/glimmer/css/style_sheet.rb
243
245
  - lib/glimmer/data_binding/list_selection_binding.rb
244
246
  - lib/glimmer/data_binding/model_binding.rb
245
247
  - lib/glimmer/data_binding/observable.rb
@@ -251,37 +253,54 @@ files:
251
253
  - lib/glimmer/data_binding/table_items_binding.rb
252
254
  - lib/glimmer/data_binding/tree_items_binding.rb
253
255
  - lib/glimmer/data_binding/widget_binding.rb
254
- - lib/glimmer/dsl.rb
255
- - lib/glimmer/dsl/async_exec_expression.rb
256
- - lib/glimmer/dsl/bind_expression.rb
257
- - lib/glimmer/dsl/color_expression.rb
258
- - lib/glimmer/dsl/column_properties_expression.rb
259
- - lib/glimmer/dsl/combo_selection_data_binding_expression.rb
260
- - lib/glimmer/dsl/custom_widget_expression.rb
261
- - lib/glimmer/dsl/data_binding_expression.rb
262
- - lib/glimmer/dsl/display_expression.rb
256
+ - lib/glimmer/dsl/css/css_expression.rb
257
+ - lib/glimmer/dsl/css/dsl.rb
258
+ - lib/glimmer/dsl/css/p_expression.rb
259
+ - lib/glimmer/dsl/css/property_expression.rb
260
+ - lib/glimmer/dsl/css/rule_set_expression.rb
261
+ - lib/glimmer/dsl/css/s_expression.rb
263
262
  - lib/glimmer/dsl/engine.rb
264
- - lib/glimmer/dsl/exec_expression.rb
265
263
  - lib/glimmer/dsl/expression.rb
266
264
  - lib/glimmer/dsl/expression_handler.rb
267
- - lib/glimmer/dsl/layout_data_expression.rb
268
- - lib/glimmer/dsl/layout_expression.rb
269
- - lib/glimmer/dsl/list_selection_data_binding_expression.rb
270
- - lib/glimmer/dsl/menu_bar_expression.rb
271
- - lib/glimmer/dsl/menu_expression.rb
272
- - lib/glimmer/dsl/observe_expression.rb
273
265
  - lib/glimmer/dsl/parent_expression.rb
274
- - lib/glimmer/dsl/property_expression.rb
275
- - lib/glimmer/dsl/shell_expression.rb
276
266
  - lib/glimmer/dsl/static_expression.rb
277
- - lib/glimmer/dsl/swt_expression.rb
278
- - lib/glimmer/dsl/sync_exec_expression.rb
279
- - lib/glimmer/dsl/tab_item_expression.rb
280
- - lib/glimmer/dsl/table_items_data_binding_expression.rb
281
- - lib/glimmer/dsl/tree_items_data_binding_expression.rb
282
- - lib/glimmer/dsl/tree_properties_expression.rb
283
- - lib/glimmer/dsl/widget_expression.rb
284
- - lib/glimmer/dsl/widget_listener_expression.rb
267
+ - lib/glimmer/dsl/swt/async_exec_expression.rb
268
+ - lib/glimmer/dsl/swt/bind_expression.rb
269
+ - lib/glimmer/dsl/swt/color_expression.rb
270
+ - lib/glimmer/dsl/swt/column_properties_expression.rb
271
+ - lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
272
+ - lib/glimmer/dsl/swt/custom_widget_expression.rb
273
+ - lib/glimmer/dsl/swt/data_binding_expression.rb
274
+ - lib/glimmer/dsl/swt/display_expression.rb
275
+ - lib/glimmer/dsl/swt/dsl.rb
276
+ - lib/glimmer/dsl/swt/exec_expression.rb
277
+ - lib/glimmer/dsl/swt/layout_data_expression.rb
278
+ - lib/glimmer/dsl/swt/layout_expression.rb
279
+ - lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
280
+ - lib/glimmer/dsl/swt/menu_bar_expression.rb
281
+ - lib/glimmer/dsl/swt/menu_expression.rb
282
+ - lib/glimmer/dsl/swt/observe_expression.rb
283
+ - lib/glimmer/dsl/swt/property_expression.rb
284
+ - lib/glimmer/dsl/swt/rgb_expression.rb
285
+ - lib/glimmer/dsl/swt/rgba_expression.rb
286
+ - lib/glimmer/dsl/swt/shell_expression.rb
287
+ - lib/glimmer/dsl/swt/swt_expression.rb
288
+ - lib/glimmer/dsl/swt/sync_exec_expression.rb
289
+ - lib/glimmer/dsl/swt/tab_item_expression.rb
290
+ - lib/glimmer/dsl/swt/table_items_data_binding_expression.rb
291
+ - lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb
292
+ - lib/glimmer/dsl/swt/tree_properties_expression.rb
293
+ - lib/glimmer/dsl/swt/widget_expression.rb
294
+ - lib/glimmer/dsl/swt/widget_listener_expression.rb
295
+ - lib/glimmer/dsl/top_level_expression.rb
296
+ - lib/glimmer/dsl/xml/dsl.rb
297
+ - lib/glimmer/dsl/xml/html_expression.rb
298
+ - lib/glimmer/dsl/xml/meta_expression.rb
299
+ - lib/glimmer/dsl/xml/name_space_expression.rb
300
+ - lib/glimmer/dsl/xml/node_parent_expression.rb
301
+ - lib/glimmer/dsl/xml/tag_expression.rb
302
+ - lib/glimmer/dsl/xml/text_expression.rb
303
+ - lib/glimmer/dsl/xml/xml_expression.rb
285
304
  - lib/glimmer/error.rb
286
305
  - lib/glimmer/invalid_keyword_error.rb
287
306
  - lib/glimmer/launcher.rb
@@ -303,6 +322,11 @@ files:
303
322
  - lib/glimmer/ui/custom_widget.rb
304
323
  - lib/glimmer/ui/video.rb
305
324
  - lib/glimmer/util/proc_tracker.rb
325
+ - lib/glimmer/xml/depth_first_search_iterator.rb
326
+ - lib/glimmer/xml/name_space_visitor.rb
327
+ - lib/glimmer/xml/node.rb
328
+ - lib/glimmer/xml/node_visitor.rb
329
+ - lib/glimmer/xml/xml_visitor.rb
306
330
  - samples/gladiator.rb
307
331
  - vendor/swt/linux/swt.jar
308
332
  - vendor/swt/mac/swt.jar
@@ -1,26 +0,0 @@
1
- require 'glimmer/dsl/engine'
2
-
3
- module Glimmer
4
- # Glimmer DSL expression configuration module
5
- #
6
- # When DSL engine interprets an expression, it attempts to handle
7
- # with expressions listed here in the order specified.
8
- module DSL
9
- # Every expression has a corresponding AbstractExpression subclass
10
- # in glimmer/dsl
11
- # TODO rename to dynamic_expressions in the future when supporting static expressions
12
- Engine.dynamic_expressions = %w[
13
- layout
14
- widget_listener
15
- combo_selection_data_binding
16
- list_selection_data_binding
17
- tree_items_data_binding
18
- table_items_data_binding
19
- data_binding
20
- color
21
- property
22
- widget
23
- custom_widget
24
- ]
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- require 'glimmer/dsl/static_expression'
2
- require 'glimmer/dsl/exec_expression'
3
-
4
- module Glimmer
5
- module DSL
6
- # Asynchronously executes code block against the SWT Event Loop
7
- # to manipulate SWT UI objects on the UI thread safely
8
- class AsyncExecExpression < StaticExpression
9
- include ExecExpression
10
- end
11
- end
12
- end
@@ -1,35 +0,0 @@
1
- require 'glimmer/dsl/static_expression'
2
- require 'glimmer/data_binding/model_binding'
3
-
4
- module Glimmer
5
- module DSL
6
- # Responsible for setting up the return value of the bind keyword (command symbol)
7
- # as a ModelBinding. It is then used by another command handler like
8
- # DataBindingCommandHandler for text and selection properties on Text and Spinner
9
- # or TableItemsDataBindingCommandHandler for items in a Table
10
- class BindExpression < StaticExpression
11
- def can_interpret?(parent, keyword, *args, &block)
12
- (
13
- keyword == 'bind' and
14
- (
15
- (
16
- (args.size == 2) and
17
- textual?(args[1])
18
- ) ||
19
- (
20
- (args.size == 3) and
21
- textual?(args[1]) and
22
- (args[2].is_a?(Hash))
23
- )
24
- )
25
- )
26
- end
27
-
28
- def interpret(parent, keyword, *args, &block)
29
- binding_options = args[2] || {}
30
- binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
31
- DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
32
- end
33
- end
34
- end
35
- end
@@ -1,22 +0,0 @@
1
- require 'glimmer/dsl/expression'
2
- require 'glimmer/swt/color_proxy'
3
- require 'glimmer/swt/display_proxy'
4
-
5
- # TODO consider turning in static expressions rgb/rgba/color
6
-
7
- module Glimmer
8
- module DSL
9
- class ColorExpression < Expression
10
- include_package 'org.eclipse.swt.widgets'
11
-
12
- def can_interpret?(parent, keyword, *args, &block)
13
- ['color', 'rgba', 'rgb'].include?(keyword) and
14
- (1..4).include?(args.count)
15
- end
16
-
17
- def interpret(parent, keyword, *args, &block)
18
- SWT::ColorProxy.new(*args)
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- require 'glimmer/dsl/static_expression'
2
-
3
- module Glimmer
4
- module DSL
5
- # Responsible for providing a readable keyword (command symbol) to capture
6
- # and return column properties for use in TreeItemsDataBindingCommandHandler
7
- class ColumnPropertiesExpression < StaticExpression
8
- include_package 'org.eclipse.swt.widgets'
9
-
10
- def can_interpret?(parent, keyword, *args, &block)
11
- keyword == 'column_properties' and
12
- block.nil? and
13
- widget?(parent) and
14
- parent.swt_widget.is_a?(Table)
15
- end
16
-
17
- def interpret(parent, keyword, *args, &block)
18
- args
19
- end
20
- end
21
- end
22
- end