glimmer-dsl-swt 4.17.7.0 → 4.17.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -3
- data/README.md +82 -82
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +9 -3
- data/lib/glimmer/data_binding/tree_items_binding.rb +20 -2
- data/lib/glimmer/dsl/swt/dialog_expression.rb +1 -0
- data/lib/glimmer/dsl/swt/directory_dialog_expression.rb +48 -0
- data/lib/glimmer/dsl/swt/file_dialog_expression.rb +48 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +4 -4
- data/lib/glimmer/dsl/swt/widget_expression.rb +9 -9
- data/lib/glimmer/swt/custom/code_text.rb +25 -18
- data/lib/glimmer/swt/directory_dialog_proxy.rb +65 -0
- data/lib/glimmer/swt/file_dialog_proxy.rb +66 -0
- data/lib/glimmer/swt/menu_proxy.rb +4 -4
- data/lib/glimmer/swt/shell_proxy.rb +6 -6
- data/lib/glimmer/swt/widget_proxy.rb +25 -25
- data/lib/glimmer/ui/custom_shell.rb +4 -4
- data/samples/hello/hello_directory_dialog.rb +60 -0
- data/samples/hello/hello_file_dialog.rb +60 -0
- data/samples/hello/hello_list_single_selection.rb +5 -5
- data/samples/hello/hello_world.rb +4 -4
- metadata +8 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.17.
|
1
|
+
4.17.8.0
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.
|
5
|
+
# stub: glimmer-dsl-swt 4.17.8.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.17.
|
9
|
+
s.version = "4.17.8.0"
|
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-
|
14
|
+
s.date = "2020-11-01"
|
15
15
|
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer".freeze, "girb".freeze]
|
@@ -53,11 +53,13 @@ Gem::Specification.new do |s|
|
|
53
53
|
"lib/glimmer/dsl/swt/custom_widget_expression.rb",
|
54
54
|
"lib/glimmer/dsl/swt/data_binding_expression.rb",
|
55
55
|
"lib/glimmer/dsl/swt/dialog_expression.rb",
|
56
|
+
"lib/glimmer/dsl/swt/directory_dialog_expression.rb",
|
56
57
|
"lib/glimmer/dsl/swt/display_expression.rb",
|
57
58
|
"lib/glimmer/dsl/swt/dnd_expression.rb",
|
58
59
|
"lib/glimmer/dsl/swt/dsl.rb",
|
59
60
|
"lib/glimmer/dsl/swt/exec_expression.rb",
|
60
61
|
"lib/glimmer/dsl/swt/expand_item_expression.rb",
|
62
|
+
"lib/glimmer/dsl/swt/file_dialog_expression.rb",
|
61
63
|
"lib/glimmer/dsl/swt/font_expression.rb",
|
62
64
|
"lib/glimmer/dsl/swt/image_expression.rb",
|
63
65
|
"lib/glimmer/dsl/swt/layout_data_expression.rb",
|
@@ -90,9 +92,11 @@ Gem::Specification.new do |s|
|
|
90
92
|
"lib/glimmer/swt/custom/checkbox_group.rb",
|
91
93
|
"lib/glimmer/swt/custom/code_text.rb",
|
92
94
|
"lib/glimmer/swt/custom/radio_group.rb",
|
95
|
+
"lib/glimmer/swt/directory_dialog_proxy.rb",
|
93
96
|
"lib/glimmer/swt/display_proxy.rb",
|
94
97
|
"lib/glimmer/swt/dnd_proxy.rb",
|
95
98
|
"lib/glimmer/swt/expand_item_proxy.rb",
|
99
|
+
"lib/glimmer/swt/file_dialog_proxy.rb",
|
96
100
|
"lib/glimmer/swt/font_proxy.rb",
|
97
101
|
"lib/glimmer/swt/image_proxy.rb",
|
98
102
|
"lib/glimmer/swt/layout_data_proxy.rb",
|
@@ -133,8 +137,10 @@ Gem::Specification.new do |s|
|
|
133
137
|
"samples/hello/hello_computed/contact.rb",
|
134
138
|
"samples/hello/hello_custom_shell.rb",
|
135
139
|
"samples/hello/hello_custom_widget.rb",
|
140
|
+
"samples/hello/hello_directory_dialog.rb",
|
136
141
|
"samples/hello/hello_drag_and_drop.rb",
|
137
142
|
"samples/hello/hello_expand_bar.rb",
|
143
|
+
"samples/hello/hello_file_dialog.rb",
|
138
144
|
"samples/hello/hello_list_multi_selection.rb",
|
139
145
|
"samples/hello/hello_list_single_selection.rb",
|
140
146
|
"samples/hello/hello_menu_bar.rb",
|
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
|
34
34
|
include_package 'org.eclipse.swt'
|
35
35
|
include_package 'org.eclipse.swt.widgets'
|
36
|
-
|
36
|
+
|
37
37
|
def initialize(parent, model_binding, tree_properties)
|
38
38
|
@tree = parent
|
39
39
|
@model_binding = model_binding
|
@@ -53,13 +53,19 @@ module Glimmer
|
|
53
53
|
|
54
54
|
def call(new_value=nil)
|
55
55
|
@model_tree_root_node = @model_binding.evaluate_property
|
56
|
+
old_tree_items = @tree.all_tree_items
|
57
|
+
old_model_tree_nodes = old_tree_items.map(&:get_data)
|
58
|
+
new_model_tree_nodes = []
|
59
|
+
recursive_depth_first_search(@model_tree_root_node, @tree_properties, new_model_tree_nodes)
|
60
|
+
return if old_model_tree_nodes == new_model_tree_nodes && old_tree_items.map(&:text) == new_model_tree_nodes.map {|model_tree_node| model_tree_node.send(@tree_properties[:text])}
|
56
61
|
populate_tree(@model_tree_root_node, @tree, @tree_properties)
|
57
62
|
end
|
58
63
|
|
59
64
|
def populate_tree(model_tree_root_node, parent, tree_properties)
|
65
|
+
# TODO get rid of model_tree_root_node, parent, tree_properties as an argument given it is stored as an instance variable
|
60
66
|
# TODO make it change things by delta instead of removing all
|
61
|
-
selected_tree_item_model = parent.swt_widget.getSelection.map(&:getData).first
|
62
67
|
old_tree_items = parent.all_tree_items
|
68
|
+
selected_tree_item_model = parent.swt_widget.getSelection.map(&:get_data).first
|
63
69
|
old_tree_item_expansion_by_data = old_tree_items.reduce({}) {|hash, ti| hash.merge(ti.getData => ti.getExpanded)}
|
64
70
|
old_tree_items.each do |tree_item|
|
65
71
|
tree_item.getData('observer_registrations').each(&:unregister)
|
@@ -78,6 +84,7 @@ module Glimmer
|
|
78
84
|
observer_registrations = @tree_properties.reduce([]) do |array, key_value_pair|
|
79
85
|
array + [observe(model_tree_node, key_value_pair.last)]
|
80
86
|
end
|
87
|
+
|
81
88
|
tree_item.setData('observer_registrations', observer_registrations)
|
82
89
|
tree_item.setData(model_tree_node)
|
83
90
|
tree_item.setText((model_tree_node && model_tree_node.send(tree_properties[:text])).to_s)
|
@@ -85,6 +92,17 @@ module Glimmer
|
|
85
92
|
populate_tree_node(child, tree_item, tree_properties)
|
86
93
|
end
|
87
94
|
end
|
95
|
+
|
96
|
+
def recursive_depth_first_search(model_tree_node, tree_properties, collection)
|
97
|
+
return if model_tree_node.nil?
|
98
|
+
collection << model_tree_node
|
99
|
+
model_tree_node.send(tree_properties[:children]).to_a.each do |child_model_tree_node|
|
100
|
+
recursive_depth_first_search(child_model_tree_node, tree_properties, collection)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
88
104
|
end
|
105
|
+
|
89
106
|
end
|
107
|
+
|
90
108
|
end
|
@@ -37,6 +37,7 @@ module Glimmer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def interpret(parent, keyword, *args, &block)
|
40
|
+
# TODO reconcile this with the actual org.eclipse.swt.widgets.Dialog widget (maybe rename this as dialog_shell)
|
40
41
|
args = [parent] + args unless parent.nil?
|
41
42
|
args += [:dialog_trim, :application_modal]
|
42
43
|
Glimmer::SWT::ShellProxy.send(:new, *args)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/dsl/top_level_expression'
|
25
|
+
require 'glimmer/swt/directory_dialog_proxy'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module DSL
|
29
|
+
module SWT
|
30
|
+
class DirectoryDialogExpression < StaticExpression
|
31
|
+
include TopLevelExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.widgets'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
keyword == 'directory_dialog' and
|
38
|
+
(parent.nil? or parent.is_a?(Shell) or parent.is_a?(Glimmer::SWT::ShellProxy))
|
39
|
+
end
|
40
|
+
|
41
|
+
def interpret(parent, keyword, *args, &block)
|
42
|
+
args = [parent] + args unless parent.nil?
|
43
|
+
Glimmer::SWT::DirectoryDialogProxy.send(:new, *args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/dsl/top_level_expression'
|
25
|
+
require 'glimmer/swt/file_dialog_proxy'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module DSL
|
29
|
+
module SWT
|
30
|
+
class FileDialogExpression < StaticExpression
|
31
|
+
include TopLevelExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.widgets'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
keyword == 'file_dialog' and
|
38
|
+
(parent.nil? or parent.is_a?(Shell) or parent.is_a?(Glimmer::SWT::ShellProxy))
|
39
|
+
end
|
40
|
+
|
41
|
+
def interpret(parent, keyword, *args, &block)
|
42
|
+
args = [parent] + args unless parent.nil?
|
43
|
+
Glimmer::SWT::FileDialogProxy.send(:new, *args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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
|
@@ -43,4 +43,4 @@ module Glimmer
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
end
|
46
|
+
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
|
@@ -28,24 +28,24 @@ module Glimmer
|
|
28
28
|
module SWT
|
29
29
|
class WidgetExpression < Expression
|
30
30
|
include ParentExpression
|
31
|
-
|
31
|
+
|
32
32
|
EXCLUDED_KEYWORDS = %w[shell display tab_item]
|
33
|
-
|
33
|
+
|
34
34
|
def can_interpret?(parent, keyword, *args, &block)
|
35
35
|
!EXCLUDED_KEYWORDS.include?(keyword) and
|
36
36
|
parent.respond_to?(:swt_widget) and #TODO change to composite?(parent)
|
37
37
|
Glimmer::SWT::WidgetProxy.widget_exists?(keyword)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def interpret(parent, keyword, *args, &block)
|
41
41
|
Glimmer::SWT::WidgetProxy.create(keyword, parent, args)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def add_content(parent, &block)
|
45
45
|
super
|
46
46
|
parent.post_add_content
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -57,4 +57,4 @@ require 'glimmer/swt/tree_proxy'
|
|
57
57
|
require 'glimmer/swt/table_proxy'
|
58
58
|
require 'glimmer/swt/table_column_proxy'
|
59
59
|
require 'glimmer/swt/sash_form_proxy'
|
60
|
-
require 'glimmer/swt/styled_text_proxy'
|
60
|
+
require 'glimmer/swt/styled_text_proxy'
|
@@ -40,21 +40,20 @@ module Glimmer
|
|
40
40
|
|
41
41
|
def syntax_highlighting
|
42
42
|
return [] if text.to_s.strip.empty?
|
43
|
-
|
44
|
-
|
45
|
-
@
|
46
|
-
@lexer
|
47
|
-
|
48
|
-
code_size = 0
|
43
|
+
return @syntax_highlighting if already_syntax_highlighted?
|
44
|
+
@last_text = text
|
45
|
+
@lexer ||= Rouge::Lexer.find_fancy('ruby', text)
|
46
|
+
lex = @lexer.lex(text).to_a
|
47
|
+
text_size = 0
|
49
48
|
lex_hashes = lex.map do |pair|
|
50
49
|
{token_type: pair.first, token_text: pair.last}
|
51
50
|
end.each do |hash|
|
52
|
-
hash[:token_index] =
|
53
|
-
|
51
|
+
hash[:token_index] = text_size
|
52
|
+
text_size += hash[:token_text].size
|
54
53
|
end
|
55
|
-
|
54
|
+
text_lines = text.split("\n")
|
56
55
|
line_index = 0
|
57
|
-
@syntax_highlighting =
|
56
|
+
@syntax_highlighting = text_lines_map = text_lines.reduce({}) do |hash, line|
|
58
57
|
line_hashes = []
|
59
58
|
line_hashes << lex_hashes.shift while lex_hashes.any? && lex_hashes.first[:token_index].between?(line_index, line_index + line.size)
|
60
59
|
hash.merge(line_index => line_hashes).tap do
|
@@ -63,6 +62,10 @@ module Glimmer
|
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
65
|
+
def already_syntax_highlighted?
|
66
|
+
@last_text == text
|
67
|
+
end
|
68
|
+
|
66
69
|
before_body {
|
67
70
|
@swt_style = swt_style == 0 ? [:border, :multi, :v_scroll, :h_scroll] : swt_style
|
68
71
|
}
|
@@ -77,15 +80,19 @@ module Glimmer
|
|
77
80
|
bottom_margin 5
|
78
81
|
|
79
82
|
on_line_get_style { |line_style_event|
|
80
|
-
styles =
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
@styles = {} unless already_syntax_highlighted?
|
84
|
+
if @styles[line_style_event.lineOffset].nil?
|
85
|
+
styles = []
|
86
|
+
syntax_highlighting[line_style_event.lineOffset].to_a.each do |token_hash|
|
87
|
+
start_index = token_hash[:token_index]
|
88
|
+
size = token_hash[:token_text].size
|
89
|
+
token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
|
90
|
+
token_color = color(*token_color).swt_color
|
91
|
+
styles << StyleRange.new(start_index, size, token_color, nil)
|
92
|
+
end
|
93
|
+
@styles[line_style_event.lineOffset] = styles.to_java(StyleRange)
|
87
94
|
end
|
88
|
-
line_style_event.styles = styles.
|
95
|
+
line_style_event.styles = @styles[line_style_event.lineOffset] unless @styles[line_style_event.lineOffset].empty?
|
89
96
|
}
|
90
97
|
}
|
91
98
|
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/swt_proxy'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.widgets.DirectoryDialog
|
29
|
+
#
|
30
|
+
# Automatically uses the current shell if one is open.
|
31
|
+
# Otherwise, it instantiates a new shell parent
|
32
|
+
#
|
33
|
+
# Optionally takes a shell as an argument
|
34
|
+
#
|
35
|
+
# Follows the Proxy Design Pattern
|
36
|
+
class DirectoryDialogProxy < WidgetProxy
|
37
|
+
# TODO write rspec tests
|
38
|
+
include_package 'org.eclipse.swt.widgets'
|
39
|
+
|
40
|
+
def initialize(*args, swt_widget: nil)
|
41
|
+
if swt_widget
|
42
|
+
@swt_widget = swt_widget
|
43
|
+
else
|
44
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
|
45
|
+
if style_args.any?
|
46
|
+
style_arg_start_index = args.index(style_args.first)
|
47
|
+
style_arg_last_index = args.index(style_args.last)
|
48
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
49
|
+
end
|
50
|
+
if !args.first.is_a?(Shell)
|
51
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
52
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
53
|
+
end
|
54
|
+
if args.first.is_a?(ShellProxy)
|
55
|
+
args[0] = args[0].swt_widget
|
56
|
+
end
|
57
|
+
parent = args[0]
|
58
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
59
|
+
@swt_widget = DirectoryDialog.new(*args)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/swt_proxy'
|
23
|
+
require 'glimmer/swt/widget_proxy'
|
24
|
+
require 'glimmer/swt/display_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module SWT
|
28
|
+
# Proxy for org.eclipse.swt.widgets.FileDialog
|
29
|
+
#
|
30
|
+
# Automatically uses the current shell if one is open.
|
31
|
+
# Otherwise, it instantiates a new shell parent
|
32
|
+
#
|
33
|
+
# Optionally takes a shell as an argument
|
34
|
+
#
|
35
|
+
# Follows the Proxy Design Pattern
|
36
|
+
class FileDialogProxy < WidgetProxy
|
37
|
+
# TODO write rspec tests
|
38
|
+
# TODO consider refactoring and sharing code with DirectoryDialogProxy (and do the same with their expressions)
|
39
|
+
include_package 'org.eclipse.swt.widgets'
|
40
|
+
|
41
|
+
def initialize(*args, swt_widget: nil)
|
42
|
+
if swt_widget
|
43
|
+
@swt_widget = swt_widget
|
44
|
+
else
|
45
|
+
style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
|
46
|
+
if style_args.any?
|
47
|
+
style_arg_start_index = args.index(style_args.first)
|
48
|
+
style_arg_last_index = args.index(style_args.last)
|
49
|
+
args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
|
50
|
+
end
|
51
|
+
if !args.first.is_a?(Shell)
|
52
|
+
current_shell = DisplayProxy.instance.swt_display.shells.first
|
53
|
+
args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
|
54
|
+
end
|
55
|
+
if args.first.is_a?(ShellProxy)
|
56
|
+
args[0] = args[0].swt_widget
|
57
|
+
end
|
58
|
+
parent = args[0]
|
59
|
+
@parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
|
60
|
+
@swt_widget = FileDialog.new(*args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|