glimmer-dsl-swt 4.18.5.0 → 4.18.5.1

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.
@@ -1,48 +0,0 @@
1
- # Copyright (c) 2007-2021 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,68 +0,0 @@
1
- # Copyright (c) 2007-2021 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
- auto_exec do
43
- if swt_widget
44
- @swt_widget = swt_widget
45
- else
46
- style_args = args.select {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
47
- if style_args.any?
48
- style_arg_start_index = args.index(style_args.first)
49
- style_arg_last_index = args.index(style_args.last)
50
- args[style_arg_start_index..style_arg_last_index] = SWTProxy[style_args]
51
- end
52
- if args.first.respond_to?(:swt_widget) && args.first.swt_widget.is_a?(Shell)
53
- args[0] = args[0].swt_widget
54
- end
55
- if !args.first.is_a?(Shell)
56
- current_shell = DisplayProxy.instance.swt_display.shells.first
57
- args.unshift(current_shell.nil? ? ShellProxy.new : current_shell)
58
- end
59
- parent = args[0]
60
- @parent_proxy = parent.is_a?(Shell) ? ShellProxy.new(swt_widget: parent) : parent
61
- @swt_widget = FileDialog.new(*args)
62
- end
63
- end
64
- end
65
-
66
- end
67
- end
68
- end