glimmer 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +94 -32
- data/lib/glimmer.rb +4 -6
- data/lib/glimmer/command_handler.rb +10 -0
- data/lib/glimmer/command_handler_chain_factory.rb +32 -0
- data/lib/glimmer/command_handler_chain_link.rb +21 -0
- data/lib/{command_handlers.rb → glimmer/command_handlers.rb} +21 -17
- data/lib/glimmer/command_handlers/bind_command_handler.rb +51 -0
- data/lib/glimmer/command_handlers/color_command_handler.rb +26 -0
- data/lib/glimmer/command_handlers/combo_selection_data_binding_command_handler.rb +40 -0
- data/lib/glimmer/command_handlers/data_binding_command_handler.rb +69 -0
- data/lib/glimmer/command_handlers/display_command_handler.rb +16 -0
- data/lib/glimmer/command_handlers/list_selection_data_binding_command_handler.rb +45 -0
- data/lib/glimmer/command_handlers/models/g_color.rb +34 -0
- data/lib/glimmer/command_handlers/models/g_display.rb +26 -0
- data/lib/glimmer/command_handlers/models/g_font.rb +62 -0
- data/lib/glimmer/command_handlers/models/g_runnable.rb +13 -0
- data/lib/glimmer/command_handlers/models/g_shell.rb +27 -0
- data/lib/glimmer/command_handlers/models/g_swt.rb +22 -0
- data/lib/glimmer/command_handlers/models/g_tab_item_composite.rb +33 -0
- data/lib/glimmer/command_handlers/models/g_widget.rb +199 -0
- data/lib/glimmer/command_handlers/models/g_widget_listener.rb +11 -0
- data/lib/glimmer/command_handlers/models/list_selection_binding.rb +47 -0
- data/lib/glimmer/command_handlers/models/model_binding.rb +206 -0
- data/lib/glimmer/command_handlers/models/observable.rb +11 -0
- data/lib/glimmer/command_handlers/models/observable_array.rb +104 -0
- data/lib/glimmer/command_handlers/models/observable_model.rb +105 -0
- data/lib/glimmer/command_handlers/models/observer.rb +115 -0
- data/lib/glimmer/command_handlers/models/table_items_binding.rb +45 -0
- data/lib/glimmer/command_handlers/models/tree_items_binding.rb +49 -0
- data/lib/glimmer/command_handlers/models/widget_binding.rb +29 -0
- data/lib/glimmer/command_handlers/shell_command_handler.rb +17 -0
- data/lib/glimmer/command_handlers/tab_item_command_handler.rb +21 -0
- data/lib/glimmer/command_handlers/table_column_properties_data_binding_command_handler.rb +25 -0
- data/lib/glimmer/command_handlers/table_items_data_binding_command_handler.rb +30 -0
- data/lib/glimmer/command_handlers/tree_items_data_binding_command_handler.rb +29 -0
- data/lib/glimmer/command_handlers/tree_properties_data_binding_command_handler.rb +25 -0
- data/lib/glimmer/command_handlers/widget_command_handler.rb +22 -0
- data/lib/glimmer/command_handlers/widget_listener_command_handler.rb +39 -0
- data/lib/glimmer/command_handlers/widget_method_command_handler.rb +21 -0
- data/lib/glimmer/parent.rb +7 -0
- data/lib/{shine.rb → glimmer/shine.rb} +1 -1
- data/lib/glimmer/swt_packages.rb +13 -0
- data/lib/{xml_command_handlers.rb → glimmer/xml_command_handlers.rb} +10 -8
- data/lib/glimmer/xml_command_handlers/html_command_handler.rb +47 -0
- data/lib/glimmer/xml_command_handlers/models/depth_first_search_iterator.rb +19 -0
- data/lib/glimmer/xml_command_handlers/models/name_space_visitor.rb +20 -0
- data/lib/glimmer/xml_command_handlers/models/node.rb +82 -0
- data/lib/glimmer/xml_command_handlers/models/node_visitor.rb +11 -0
- data/lib/glimmer/xml_command_handlers/models/xml_visitor.rb +61 -0
- data/lib/glimmer/xml_command_handlers/xml_command_handler.rb +20 -0
- data/lib/glimmer/xml_command_handlers/xml_name_space_command_handler.rb +33 -0
- data/lib/glimmer/xml_command_handlers/xml_tag_command_handler.rb +25 -0
- data/lib/glimmer/xml_command_handlers/xml_text_command_handler.rb +21 -0
- metadata +53 -54
- data/lib/command_handler.rb +0 -8
- data/lib/command_handler_chain_factory.rb +0 -30
- data/lib/command_handler_chain_link.rb +0 -19
- data/lib/command_handlers/bind_command_handler.rb +0 -49
- data/lib/command_handlers/color_command_handler.rb +0 -24
- data/lib/command_handlers/combo_selection_data_binding_command_handler.rb +0 -38
- data/lib/command_handlers/data_binding_command_handler.rb +0 -67
- data/lib/command_handlers/list_selection_data_binding_command_handler.rb +0 -43
- data/lib/command_handlers/models/block_observer.rb +0 -14
- data/lib/command_handlers/models/list_selection_binding.rb +0 -45
- data/lib/command_handlers/models/model_binding.rb +0 -205
- data/lib/command_handlers/models/observable.rb +0 -9
- data/lib/command_handlers/models/observable_array.rb +0 -102
- data/lib/command_handlers/models/observable_model.rb +0 -103
- data/lib/command_handlers/models/observer.rb +0 -88
- data/lib/command_handlers/models/r_color.rb +0 -32
- data/lib/command_handlers/models/r_font.rb +0 -60
- data/lib/command_handlers/models/r_runnable.rb +0 -11
- data/lib/command_handlers/models/r_shell.rb +0 -24
- data/lib/command_handlers/models/r_swt.rb +0 -18
- data/lib/command_handlers/models/r_tab_item_composite.rb +0 -31
- data/lib/command_handlers/models/r_widget.rb +0 -183
- data/lib/command_handlers/models/r_widget_listener.rb +0 -9
- data/lib/command_handlers/models/table_items_binding.rb +0 -43
- data/lib/command_handlers/models/tree_items_binding.rb +0 -47
- data/lib/command_handlers/models/widget_binding.rb +0 -27
- data/lib/command_handlers/shell_command_handler.rb +0 -15
- data/lib/command_handlers/tab_item_command_handler.rb +0 -19
- data/lib/command_handlers/table_column_properties_data_binding_command_handler.rb +0 -23
- data/lib/command_handlers/table_items_data_binding_command_handler.rb +0 -28
- data/lib/command_handlers/tree_items_data_binding_command_handler.rb +0 -27
- data/lib/command_handlers/tree_properties_data_binding_command_handler.rb +0 -23
- data/lib/command_handlers/widget_command_handler.rb +0 -20
- data/lib/command_handlers/widget_listener_command_handler.rb +0 -37
- data/lib/command_handlers/widget_method_command_handler.rb +0 -19
- data/lib/parent.rb +0 -5
- data/lib/string.rb +0 -8
- data/lib/swt_packages.rb +0 -11
- data/lib/symbol.rb +0 -10
- data/lib/xml_command_handlers/html_command_handler.rb +0 -45
- data/lib/xml_command_handlers/models/depth_first_search_iterator.rb +0 -17
- data/lib/xml_command_handlers/models/name_space_visitor.rb +0 -18
- data/lib/xml_command_handlers/models/node.rb +0 -80
- data/lib/xml_command_handlers/models/node_visitor.rb +0 -9
- data/lib/xml_command_handlers/models/xml_visitor.rb +0 -59
- data/lib/xml_command_handlers/xml_command_handler.rb +0 -18
- data/lib/xml_command_handlers/xml_name_space_command_handler.rb +0 -31
- data/lib/xml_command_handlers/xml_tag_command_handler.rb +0 -23
- data/lib/xml_command_handlers/xml_text_command_handler.rb +0 -19
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
require_relative 'observable'
|
4
|
-
|
5
|
-
# TODO prefix utility methods with double-underscore
|
6
|
-
module ObservableArray
|
7
|
-
include Observable
|
8
|
-
|
9
|
-
def add_observer(observer, element_properties=nil)
|
10
|
-
return observer if has_observer?(observer) && element_properties.nil?
|
11
|
-
property_observer_list << observer
|
12
|
-
[element_properties].flatten.compact.each do |property|
|
13
|
-
each do |element|
|
14
|
-
observer.observe(element, property)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
observer
|
18
|
-
end
|
19
|
-
|
20
|
-
def remove_observer(observer, element_properties=nil)
|
21
|
-
property_observer_list.delete(observer)
|
22
|
-
[element_properties].flatten.compact.each do |property|
|
23
|
-
each do |element|
|
24
|
-
observer.unobserve(element, property)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
observer
|
28
|
-
end
|
29
|
-
|
30
|
-
def has_observer?(observer)
|
31
|
-
property_observer_list.include?(observer)
|
32
|
-
end
|
33
|
-
|
34
|
-
def property_observer_list
|
35
|
-
@property_observer_list ||= Set.new
|
36
|
-
end
|
37
|
-
|
38
|
-
def notify_observers
|
39
|
-
property_observer_list.each {|observer| observer.update}
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.extend_object(array)
|
43
|
-
array.instance_eval("alias __original_add <<")
|
44
|
-
array.instance_eval <<-end_eval, __FILE__, __LINE__
|
45
|
-
def <<(value)
|
46
|
-
self.__original_add(value)
|
47
|
-
notify_observers
|
48
|
-
end
|
49
|
-
end_eval
|
50
|
-
|
51
|
-
array.instance_eval("alias __original_set_value []=")
|
52
|
-
array.instance_eval <<-end_eval, __FILE__, __LINE__
|
53
|
-
def []=(index, value)
|
54
|
-
old_value = self[index]
|
55
|
-
unregister_dependent_observers(old_value)
|
56
|
-
self.__original_set_value(index, value)
|
57
|
-
notify_observers
|
58
|
-
end
|
59
|
-
end_eval
|
60
|
-
|
61
|
-
array.instance_eval("alias __original_delete delete")
|
62
|
-
array.instance_eval <<-end_eval, __FILE__, __LINE__
|
63
|
-
def delete(value)
|
64
|
-
unregister_dependent_observers(value)
|
65
|
-
self.__original_delete(value)
|
66
|
-
notify_observers
|
67
|
-
end
|
68
|
-
end_eval
|
69
|
-
|
70
|
-
array.instance_eval("alias __original_delete_at delete_at")
|
71
|
-
array.instance_eval <<-end_eval, __FILE__, __LINE__
|
72
|
-
def delete_at(index)
|
73
|
-
old_value = self[index]
|
74
|
-
unregister_dependent_observers(old_value)
|
75
|
-
self.__original_delete_at(index)
|
76
|
-
notify_observers
|
77
|
-
end
|
78
|
-
end_eval
|
79
|
-
|
80
|
-
array.instance_eval("alias __original_clear clear")
|
81
|
-
array.instance_eval <<-end_eval, __FILE__, __LINE__
|
82
|
-
def clear
|
83
|
-
each do |old_value|
|
84
|
-
unregister_dependent_observers(old_value)
|
85
|
-
end
|
86
|
-
self.__original_clear
|
87
|
-
notify_observers
|
88
|
-
end
|
89
|
-
end_eval
|
90
|
-
|
91
|
-
super
|
92
|
-
end
|
93
|
-
|
94
|
-
def unregister_dependent_observers(old_value)
|
95
|
-
# TODO look into optimizing this
|
96
|
-
return unless old_value.is_a?(ObservableModel) || old_value.is_a?(ObservableArray)
|
97
|
-
property_observer_list.each do |observer|
|
98
|
-
observer.unregister_dependents_with_observable([self, nil], old_value)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
require_relative 'observable'
|
4
|
-
require_relative 'observer'
|
5
|
-
|
6
|
-
# TODO prefix utility methods with double-underscore
|
7
|
-
module ObservableModel
|
8
|
-
include Observable
|
9
|
-
|
10
|
-
class Updater
|
11
|
-
include Observer
|
12
|
-
def initialize(observable_model, property_name)
|
13
|
-
@observable_model = observable_model
|
14
|
-
@property_name = property_name
|
15
|
-
end
|
16
|
-
def update(changed_value=nil)
|
17
|
-
@observable_model.notify_observers(@property_name)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def add_observer(observer, property_name)
|
22
|
-
return observer if has_observer?(observer, property_name)
|
23
|
-
property_observer_list(property_name) << observer
|
24
|
-
add_property_writer_observers(property_name)
|
25
|
-
observer
|
26
|
-
end
|
27
|
-
|
28
|
-
def remove_observer(observer, property_name)
|
29
|
-
property_observer_list(property_name).delete(observer)
|
30
|
-
end
|
31
|
-
|
32
|
-
def has_observer?(observer, property_name)
|
33
|
-
property_observer_list(property_name).include?(observer)
|
34
|
-
end
|
35
|
-
|
36
|
-
def has_observer_for_any_property?(observer)
|
37
|
-
property_observer_hash.values.map(&:to_a).sum.include?(observer)
|
38
|
-
end
|
39
|
-
|
40
|
-
def property_observer_hash
|
41
|
-
@property_observers = Hash.new unless @property_observers
|
42
|
-
@property_observers
|
43
|
-
end
|
44
|
-
|
45
|
-
def property_observer_list(property_name)
|
46
|
-
property_observer_hash[property_name.to_sym] = Set.new unless property_observer_hash[property_name.to_sym]
|
47
|
-
property_observer_hash[property_name.to_sym]
|
48
|
-
end
|
49
|
-
|
50
|
-
def notify_observers(property_name)
|
51
|
-
property_observer_list(property_name).each {|observer| observer.update(send(property_name))}
|
52
|
-
end
|
53
|
-
#TODO upon updating values, make sure dependent observers are cleared (not added as dependents here)
|
54
|
-
|
55
|
-
def add_property_writer_observers(property_name)
|
56
|
-
property_writer_name = "#{property_name}="
|
57
|
-
method(property_writer_name)
|
58
|
-
ensure_array_object_observer(property_name, send(property_name))
|
59
|
-
begin
|
60
|
-
method("__original_#{property_writer_name}")
|
61
|
-
rescue
|
62
|
-
instance_eval "alias __original_#{property_writer_name} #{property_writer_name}"
|
63
|
-
instance_eval <<-end_eval, __FILE__, __LINE__
|
64
|
-
def #{property_writer_name}(value)
|
65
|
-
old_value = self.#{property_name}
|
66
|
-
unregister_dependent_observers('#{property_name}', old_value)
|
67
|
-
self.__original_#{property_writer_name}(value)
|
68
|
-
notify_observers('#{property_name}')
|
69
|
-
ensure_array_object_observer('#{property_name}', value, old_value)
|
70
|
-
end
|
71
|
-
end_eval
|
72
|
-
end
|
73
|
-
rescue => e
|
74
|
-
# ignore writing if no property writer exists
|
75
|
-
Glimmer.logger.debug "No need to observe property writer: #{property_writer_name}\n#{e.message}\n#{e.backtrace.join("\n")}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def unregister_dependent_observers(property_name, old_value)
|
79
|
-
# TODO look into optimizing this
|
80
|
-
return unless old_value.is_a?(ObservableModel) || old_value.is_a?(ObservableArray)
|
81
|
-
property_observer_list(property_name).each do |observer|
|
82
|
-
observer.unregister_dependents_with_observable([self, property_name], old_value)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def ensure_array_object_observer(property_name, object, old_object = nil)
|
87
|
-
return unless object.is_a?(Array)
|
88
|
-
array_object_observer = array_object_observer_for(property_name)
|
89
|
-
array_object_observer.observe(object)
|
90
|
-
property_observer_list(property_name).each do |observer|
|
91
|
-
observer.add_dependent([self, property_name] => [array_object_observer, object, nil])
|
92
|
-
end
|
93
|
-
array_object_observer_for(property_name).unregister(old_object) if old_object.is_a?(ObservableArray)
|
94
|
-
end
|
95
|
-
|
96
|
-
def array_object_observer_for(property_name)
|
97
|
-
@array_object_observers ||= {}
|
98
|
-
unless @array_object_observers.has_key?(property_name)
|
99
|
-
@array_object_observers[property_name] = ObservableModel::Updater.new(self, property_name)
|
100
|
-
end
|
101
|
-
@array_object_observers[property_name]
|
102
|
-
end
|
103
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
# Mixin representing Observer trait from Observer Design Pattern
|
4
|
-
# Allows classes to include without interfering with their
|
5
|
-
# inheritance hierarchy.
|
6
|
-
module Observer
|
7
|
-
def registrations
|
8
|
-
@registrations ||= Set.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def registrations_for(observable, property = nil)
|
12
|
-
registrations.select {|o, p| o == observable && p == property}
|
13
|
-
end
|
14
|
-
|
15
|
-
# mapping of registrations to dependents
|
16
|
-
# {[observable, property] => [[dependent, dependent_observable, dependent_property], ...]}
|
17
|
-
def dependents
|
18
|
-
@dependents ||= Hash.new
|
19
|
-
end
|
20
|
-
|
21
|
-
def dependents_for(registration)
|
22
|
-
dependents[registration] ||= Set.new
|
23
|
-
end
|
24
|
-
|
25
|
-
# registers observer in an observable on a property (optional)
|
26
|
-
# observer maintains registration list to unregister later
|
27
|
-
def register(observable, property = nil)
|
28
|
-
unless observable.is_a?(Observable)
|
29
|
-
# TODO refactor code to be more smart/polymorphic/automated and honor open/closed principle
|
30
|
-
if observable.is_a?(Array)
|
31
|
-
observable.extend(ObservableArray)
|
32
|
-
else
|
33
|
-
observable.extend(ObservableModel)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
observable.add_observer(*[self, property].compact)
|
37
|
-
[observable, property].tap do |registration|
|
38
|
-
self.registrations << registration
|
39
|
-
end
|
40
|
-
end
|
41
|
-
alias observe register
|
42
|
-
|
43
|
-
def unregister(observable, property = nil)
|
44
|
-
observable.remove_observer(*[self, property].compact)
|
45
|
-
registration = [observable, property]
|
46
|
-
dependents_for(registration).each do |dependent|
|
47
|
-
dependent_observer, dependent_observable, dependent_property = dependent
|
48
|
-
dependent_observer.unregister(dependent_observable, dependent_property)
|
49
|
-
remove_dependent(registration => dependent)
|
50
|
-
end
|
51
|
-
registrations.delete(registration)
|
52
|
-
end
|
53
|
-
alias unobserve unregister
|
54
|
-
|
55
|
-
def unregister_dependents_with_observable(registration, dependent_observable)
|
56
|
-
thedependents = dependents_for(registration).select do |d_observer, d_observable, d_property|
|
57
|
-
d_observable == dependent_observable
|
58
|
-
end
|
59
|
-
thedependents.each do |d_observer, d_observable, d_property|
|
60
|
-
d_observer.unregister(d_observable, d_property)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# cleans up all registrations in observables
|
65
|
-
def unregister_all_observables
|
66
|
-
registrations.each do |observable, property|
|
67
|
-
unregister(observable, property)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
alias unobserve_all_observables unregister_all_observables
|
71
|
-
|
72
|
-
# add dependent observer to unregister when unregistering observer
|
73
|
-
def add_dependent(parent_to_dependent_hash)
|
74
|
-
observable, property = registration = parent_to_dependent_hash.keys.first
|
75
|
-
dependent_observer, dependent_observable, dependent_property = dependent = parent_to_dependent_hash.values.first
|
76
|
-
dependents_for(registration) << dependent
|
77
|
-
end
|
78
|
-
|
79
|
-
def remove_dependent(parent_to_dependent_hash)
|
80
|
-
observable, property = registration = parent_to_dependent_hash.keys.first
|
81
|
-
dependent_observer, dependent_observable, dependent_property = dependent = parent_to_dependent_hash.values.first
|
82
|
-
dependents_for(registration).delete(dependent)
|
83
|
-
end
|
84
|
-
|
85
|
-
def update(changed_value)
|
86
|
-
raise 'Not implemented!'
|
87
|
-
end
|
88
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative 'r_swt'
|
2
|
-
|
3
|
-
class RColor
|
4
|
-
attr_reader :display, :red, :green, :blue, :alpha
|
5
|
-
|
6
|
-
include_package 'org.eclipse.swt.graphics'
|
7
|
-
|
8
|
-
class << self
|
9
|
-
include_package 'org.eclipse.swt'
|
10
|
-
|
11
|
-
def for(display, standard_color)
|
12
|
-
display.getSystemColor(RSwt[standard_color])
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(display, red, green, blue, alpha = nil)
|
17
|
-
@display = display
|
18
|
-
@red = red
|
19
|
-
@green = green
|
20
|
-
@blue = blue
|
21
|
-
@alpha = alpha
|
22
|
-
end
|
23
|
-
|
24
|
-
def color
|
25
|
-
@color ||= Color.new(@display, *[@red, @green, @blue, @alpha].compact)
|
26
|
-
end
|
27
|
-
|
28
|
-
def display=(a_display)
|
29
|
-
@display = a_display
|
30
|
-
@color = nil
|
31
|
-
end
|
32
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative 'r_swt'
|
2
|
-
|
3
|
-
class RFont
|
4
|
-
include_package 'org.eclipse.swt.graphics'
|
5
|
-
|
6
|
-
extend Glimmer
|
7
|
-
|
8
|
-
attr_reader :r_widget
|
9
|
-
attr_accessor :display
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def for(r_widget)
|
13
|
-
@instances ||= {}
|
14
|
-
unless @instances[r_widget]
|
15
|
-
@instances[r_widget] = new(r_widget)
|
16
|
-
add_contents(r_widget) {
|
17
|
-
on_widget_disposed { |dispose_event|
|
18
|
-
@instances.delete(r_widget)
|
19
|
-
}
|
20
|
-
}
|
21
|
-
end
|
22
|
-
@instances[r_widget]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def initialize(r_widget, display = nil)
|
27
|
-
@r_widget = r_widget
|
28
|
-
@display = display || @r_widget.widget.display
|
29
|
-
end
|
30
|
-
|
31
|
-
def r_widget=(a_widget)
|
32
|
-
@r_widget = a_widget
|
33
|
-
@font_datum = nil
|
34
|
-
end
|
35
|
-
|
36
|
-
def font_datum
|
37
|
-
@font_datum ||= @r_widget.widget.getFont.getFontData[0]
|
38
|
-
end
|
39
|
-
|
40
|
-
def name
|
41
|
-
font_datum.getName
|
42
|
-
end
|
43
|
-
|
44
|
-
def height
|
45
|
-
font_datum.getHeight
|
46
|
-
end
|
47
|
-
|
48
|
-
def style
|
49
|
-
font_datum.getStyle
|
50
|
-
end
|
51
|
-
|
52
|
-
def font(font_properties)
|
53
|
-
font_properties[:style] = RSwt[*font_properties[:style]]
|
54
|
-
font_data_args = [:name, :height, :style].map do |font_property_name|
|
55
|
-
font_properties[font_property_name] || send(font_property_name)
|
56
|
-
end
|
57
|
-
font_datum = FontData.new(*font_data_args)
|
58
|
-
Font.new(@display, font_datum)
|
59
|
-
end
|
60
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'r_widget'
|
2
|
-
|
3
|
-
class RShell < RWidget
|
4
|
-
include_package 'org.eclipse.swt.layout'
|
5
|
-
include_package 'org.eclipse.swt.widgets'
|
6
|
-
|
7
|
-
attr_reader :display
|
8
|
-
|
9
|
-
def initialize(display = Display.new)
|
10
|
-
@display = display
|
11
|
-
@widget = Shell.new(@display)
|
12
|
-
@widget.setLayout(FillLayout.new)
|
13
|
-
end
|
14
|
-
|
15
|
-
def open
|
16
|
-
@widget.pack
|
17
|
-
@widget.open
|
18
|
-
until @widget.isDisposed
|
19
|
-
@display.sleep unless @display.readAndDispatch
|
20
|
-
end
|
21
|
-
@display.dispose
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class RSwt
|
2
|
-
class << self
|
3
|
-
# Gets SWT constants as if calling SWT::CONSTANT where constant is
|
4
|
-
# passed in as a lower case symbol
|
5
|
-
def [](*symbols)
|
6
|
-
symbols.compact.reduce(0) { |output, symbol| output | constant(symbol) }
|
7
|
-
end
|
8
|
-
|
9
|
-
def constant(symbol)
|
10
|
-
return symbol if symbol.is_a?(Integer)
|
11
|
-
swt_constant_symbol = symbol.to_s.upcase.to_sym
|
12
|
-
org.eclipse.swt.SWT.const_get(swt_constant_symbol)
|
13
|
-
rescue
|
14
|
-
swt_constant_symbol = org.eclipse.swt.SWT.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s}
|
15
|
-
org.eclipse.swt.SWT.const_get(swt_constant_symbol)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|