Skip to content

Commit

Permalink
Fixed specs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Oct 23, 2020
1 parent 33e6cf0 commit b6d19db
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
1 change: 1 addition & 0 deletions lib/glimmer/dsl/swt/widget_expression.rb
Expand Up @@ -57,3 +57,4 @@ def add_content(parent, &block)
require 'glimmer/swt/table_proxy'
require 'glimmer/swt/table_column_proxy'
require 'glimmer/swt/sash_form_proxy'
require 'glimmer/swt/styled_text_proxy'
2 changes: 1 addition & 1 deletion lib/glimmer/swt/sash_form_proxy.rb
Expand Up @@ -32,7 +32,7 @@ def post_add_content
end

def set_attribute(attribute_name, *args)
if attribute_name.to_s == "weights"
if attribute_name.to_s == 'weights'
@weights = args
@weights = @weights.first if @weights.first.is_a?(Array)
else
Expand Down
43 changes: 43 additions & 0 deletions lib/glimmer/swt/styled_text_proxy.rb
@@ -0,0 +1,43 @@
# Copyright (c) 2007-2020 Andy Maleh
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

require 'glimmer/swt/widget_proxy'

module Glimmer
module SWT
# Proxy for org.eclipse.swt.custom.StyledText
#
# Follows the Proxy Design Pattern
class StyledTextProxy < WidgetProxy
def set_attribute(attribute_name, *args)
if attribute_name.to_s == 'selection'
if args.first
async_exec { @swt_widget.setCaretOffset(args.first.x) }
async_exec { @swt_widget.setSelection(args.first) }
end
else
super(attribute_name, *args)
end
end

end
end
end
15 changes: 1 addition & 14 deletions lib/glimmer/swt/widget_proxy.rb
Expand Up @@ -682,19 +682,6 @@ def widget_custom_attribute_mapping
@swt_widget.setSelection(caret_position, caret_position + args.first) if args.first
}},
},
'selection' => {
getter: {name: 'getSelection'},
setter: {name: 'setSelection', invoker: lambda { |widget, args|
if swt_widget.is_a?(StyledText)
if args.first
async_exec { @swt_widget.setCaretOffset(args.first.x) }
async_exec { @swt_widget.setSelection(args.first) }
end
else
@swt_widget.setSelection(args.first)
end
}},
},
}
end

Expand Down Expand Up @@ -733,7 +720,7 @@ def drop_target_effect=(args)
def apply_property_type_converters(attribute_name, args)
value = args
converter = property_type_converters[attribute_name.to_sym]
args[0..-1] = converter.call(*value) if converter
args[0..-1] = [converter.call(*value)] if converter
if args.count == 1 && args.first.is_a?(ColorProxy)
g_color = args.first
args[0] = g_color.swt_color
Expand Down

0 comments on commit b6d19db

Please sign in to comment.