swt 0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/LICENSE +40 -0
  2. data/README.md +20 -0
  3. data/bin/swt_cucumber +11 -0
  4. data/lib/swt.rb +3 -0
  5. data/lib/swt/cucumber_patches.rb +33 -0
  6. data/lib/swt/cucumber_runner.rb +32 -0
  7. data/lib/swt/event_loop.rb +30 -0
  8. data/lib/swt/full.rb +129 -0
  9. data/lib/swt/grid_data.rb +11 -0
  10. data/lib/swt/jar_loader.rb +36 -0
  11. data/lib/swt/minimal.rb +110 -0
  12. data/lib/swt/swt_bot_extensions.rb +6 -0
  13. data/vendor/jface/org.eclipse.core.commands.jar +0 -0
  14. data/vendor/jface/org.eclipse.core.jobs.jar +0 -0
  15. data/vendor/jface/org.eclipse.core.resources.jar +0 -0
  16. data/vendor/jface/org.eclipse.core.runtime_3.5.0.v20090525.jar +0 -0
  17. data/vendor/jface/org.eclipse.equinox.common.jar +0 -0
  18. data/vendor/jface/org.eclipse.jface.databinding_1.3.0.I20090525-2000.jar +0 -0
  19. data/vendor/jface/org.eclipse.jface.jar +0 -0
  20. data/vendor/jface/org.eclipse.jface.text_3.5.0.jar +0 -0
  21. data/vendor/jface/org.eclipse.osgi.jar +0 -0
  22. data/vendor/jface/org.eclipse.text_3.5.0.v20090513-2000.jar +0 -0
  23. data/vendor/swt/swt-linux32.jar +0 -0
  24. data/vendor/swt/swt-linux64.jar +0 -0
  25. data/vendor/swt/swt-osx32.jar +0 -0
  26. data/vendor/swt/swt-osx64.jar +0 -0
  27. data/vendor/swt/swt-win32.jar +0 -0
  28. data/vendor/swt/swt-win64.jar +0 -0
  29. data/vendor/swtbot/org.apache.log4j_1.2.13.v200903072027.jar +0 -0
  30. data/vendor/swtbot/org.eclipse.swtbot.junit4_x_2.0.4.20110304_0338-e5aff47-dev-e36.jar +0 -0
  31. data/vendor/swtbot/org.eclipse.swtbot.swt.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar +0 -0
  32. data/vendor/swtbot/org.hamcrest.core_1.1.0.v20090501071000.jar +0 -0
  33. data/vendor/swtbot/org.hamcrest.integration_1.1.0.v20090501071000.jar +0 -0
  34. data/vendor/swtbot/org.hamcrest.library_1.1.0.v20090501071000.jar +0 -0
  35. data/vendor/swtbot/org.hamcrest.text_1.1.0.v20090501071000.jar +0 -0
  36. data/vendor/swtbot/org.hamcrest_1.1.0.v20090501071000.jar +0 -0
  37. metadata +84 -0
data/LICENSE ADDED
@@ -0,0 +1,40 @@
1
+ All files in the directories "vendor/swt" and "vendor/jface" are provided to
2
+ you under the terms and conditions of the Eclipse Public License Version 1.0
3
+ ("EPL"). A copy of the EPL is available at
4
+ http://www.eclipse.org/legal/epl-v10.html
5
+
6
+ Other files:
7
+
8
+ * All org.eclipse.swtbot.*.jar files are also provided under the EPL.
9
+
10
+ * The file org.apache.log4j.*.jar is provided under the Apache License 2.0,
11
+ a copy of which is available here:
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ * All org.hamcrest.*.jar files are provided under the BSD license, a copy
15
+ of which is available here:
16
+ http://code.google.com/p/hamcrest/source/browse/trunk/hamcrest-java/LICENSE.txt
17
+
18
+ Unless specified in the file itself, the contents of all other files in this
19
+ repository are provided to you under the following license (MIT):
20
+
21
+ Copyright (c) Daniel Lucraft 2011.
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining
24
+ a copy of this software and associated documentation files (the
25
+ 'Software'), to deal in the Software without restriction, including
26
+ without limitation the rights to use, copy, modify, merge, publish,
27
+ distribute, sublicense, and/or sell copies of the Software, and to
28
+ permit persons to whom the Software is furnished to do so, subject to
29
+ the following conditions:
30
+
31
+ The above copyright notice and this permission notice shall be
32
+ included in all copies or substantial portions of the Software.
33
+
34
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
35
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
37
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
38
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
39
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+
2
+ SWT
3
+ ===
4
+
5
+ This gem contains the SWT jars needed to run SWT applications.
6
+
7
+ ## Example
8
+
9
+ Linux / windows:
10
+
11
+ jruby examples/button.rb
12
+
13
+ On OSX:
14
+
15
+ jruby -J-XstartOnFirstThread examples/button.rb
16
+
17
+ ## Usage
18
+
19
+ require 'java'
20
+ require 'swt'
data/bin/swt_cucumber ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'java'
5
+ $:.unshift(File.expand_path("../../lib", __FILE__))
6
+ require 'swt'
7
+
8
+ runner = Swt::CucumberRunner.new
9
+ runner.run_features(ARGV)
10
+ Swt.event_loop { runner.tests_finished? }
11
+ exit(runner.exit_code)
data/lib/swt.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ require 'swt/minimal'
3
+ require 'swt/full'
@@ -0,0 +1,33 @@
1
+
2
+ module Cucumber
3
+ module Ast
4
+ class StepInvocation #:nodoc:#
5
+ class << self
6
+ attr_accessor :wait_time
7
+ end
8
+
9
+ def invoke_with_swt(step_mother, options)
10
+ block = Swt::RRunnable.new { invoke_without_swt(step_mother, options) }
11
+
12
+ Swt.sync_exec(&block)
13
+ sleep ENV["SLOW_CUKES"].to_f if ENV["SLOW_CUKES"]
14
+ sleep(Cucumber::Ast::StepInvocation.wait_time || 0)
15
+ Cucumber::Ast::StepInvocation.wait_time = nil
16
+ end
17
+
18
+ alias_method :invoke_without_swt, :invoke
19
+ alias_method :invoke, :invoke_with_swt
20
+ end
21
+ end
22
+
23
+ module Cli
24
+ class Configuration
25
+ def require_dirs_with_redcar_plugins
26
+ require_dirs_without_redcar_plugins + Dir['plugins/*/features']
27
+ end
28
+
29
+ alias_method :require_dirs_without_redcar_plugins, :require_dirs
30
+ alias_method :require_dirs, :require_dirs_with_redcar_plugins
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ module Swt
2
+ class CucumberRunner
3
+ START_DELAY = 1
4
+
5
+ def tests_finished?
6
+ @tests_finished
7
+ end
8
+
9
+ def exit_code
10
+ @is_fail ? 1 : 0
11
+ end
12
+
13
+ def run_features(args)
14
+ require "cucumber/cli/main"
15
+ require "cucumber"
16
+ require "cucumber/rb_support/rb_language"
17
+ # require "swt/cucumber_patches"
18
+ Thread.new do
19
+ begin
20
+ sleep START_DELAY
21
+ main = Cucumber::Cli::Main.new(args)
22
+ @is_fail = main.execute!
23
+ @tests_finished = true
24
+ Swt.sync_exec {}
25
+ rescue Object => e
26
+ puts e.message
27
+ puts e.backtrace
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+
2
+ module Swt
3
+ class EventLoop
4
+ def initialize
5
+ @running = false
6
+ end
7
+
8
+ # Begins the SWT event loop. Blocks.
9
+ def start
10
+ @running = true
11
+ @display = Swt.display
12
+ while @running and not @display.disposed?
13
+ unless read = @display.read_and_dispatch
14
+ @display.sleep
15
+ end
16
+ end
17
+ @display.dispose
18
+ end
19
+
20
+ # Lets the even loop run until block returns false
21
+ def yield_until
22
+ @display.read_and_dispatch until yield
23
+ end
24
+
25
+ # Halts the SWT event loop.
26
+ def stop
27
+ @running = false
28
+ end
29
+ end
30
+ end
data/lib/swt/full.rb ADDED
@@ -0,0 +1,129 @@
1
+ require 'swt/swt_bot_extensions'
2
+
3
+ module Swt
4
+ import org.eclipse.swt.SWT
5
+
6
+ module Widgets
7
+ import org.eclipse.swt.widgets.Button
8
+ import org.eclipse.swt.widgets.Caret
9
+ import org.eclipse.swt.widgets.Combo
10
+ import org.eclipse.swt.widgets.Composite
11
+ import org.eclipse.swt.widgets.Event
12
+ import org.eclipse.swt.widgets.DirectoryDialog
13
+ import org.eclipse.swt.widgets.FileDialog
14
+ import org.eclipse.swt.widgets.List
15
+ import org.eclipse.swt.widgets.Menu
16
+ import org.eclipse.swt.widgets.MenuItem
17
+ import org.eclipse.swt.widgets.MessageBox
18
+ import org.eclipse.swt.widgets.ToolBar
19
+ import org.eclipse.swt.widgets.ToolItem
20
+ import org.eclipse.swt.widgets.CoolBar
21
+ import org.eclipse.swt.widgets.CoolItem
22
+ import org.eclipse.swt.widgets.Sash
23
+ import org.eclipse.swt.widgets.Slider
24
+ import org.eclipse.swt.widgets.TabFolder
25
+ import org.eclipse.swt.widgets.TabItem
26
+ import org.eclipse.swt.widgets.Text
27
+ import org.eclipse.swt.widgets.ToolTip
28
+ import org.eclipse.swt.widgets.Table
29
+ import org.eclipse.swt.widgets.TableItem
30
+ end
31
+
32
+ module Custom
33
+ import org.eclipse.swt.custom.CTabFolder
34
+ import org.eclipse.swt.custom.CTabItem
35
+ import org.eclipse.swt.custom.SashForm
36
+ import org.eclipse.swt.custom.StackLayout
37
+ import org.eclipse.swt.custom.ST
38
+ import org.eclipse.swt.custom.StyleRange
39
+ import org.eclipse.swt.custom.StyledText
40
+ import org.eclipse.swt.custom.TreeEditor
41
+ end
42
+
43
+ module DND
44
+ import org.eclipse.swt.dnd.DND
45
+
46
+ # Only load Clipboard in full running mode.
47
+ import org.eclipse.swt.dnd.Clipboard
48
+
49
+ import org.eclipse.swt.dnd.Transfer
50
+ import org.eclipse.swt.dnd.TextTransfer
51
+ import org.eclipse.swt.dnd.FileTransfer
52
+ import org.eclipse.swt.dnd.ByteArrayTransfer
53
+
54
+ import org.eclipse.swt.dnd.DropTarget
55
+ import org.eclipse.swt.dnd.DropTargetEvent
56
+ import org.eclipse.swt.dnd.DropTargetListener
57
+
58
+ import org.eclipse.swt.dnd.DragSource
59
+ import org.eclipse.swt.dnd.DragSourceEvent
60
+ import org.eclipse.swt.dnd.DragSourceListener
61
+ end
62
+
63
+ module Layout
64
+ import org.eclipse.swt.layout.FillLayout
65
+ import org.eclipse.swt.layout.GridLayout
66
+ import org.eclipse.swt.layout.GridData
67
+ import org.eclipse.swt.layout.RowLayout
68
+ import org.eclipse.swt.layout.RowData
69
+ end
70
+
71
+ module Graphics
72
+ import org.eclipse.swt.graphics.Color
73
+ import org.eclipse.swt.graphics.Device
74
+ import org.eclipse.swt.graphics.Font
75
+ import org.eclipse.swt.graphics.GC
76
+ import org.eclipse.swt.graphics.Point
77
+ import org.eclipse.swt.graphics.RGB
78
+ end
79
+
80
+ module Events
81
+ import org.eclipse.swt.events.KeyEvent
82
+ import org.eclipse.swt.events.MouseListener
83
+ import org.eclipse.swt.events.MouseTrackListener
84
+ end
85
+
86
+ import org.eclipse.swt.browser.Browser
87
+ class Browser
88
+ import org.eclipse.swt.browser.BrowserFunction
89
+ end
90
+
91
+ def self.bot
92
+ @bot ||= begin
93
+ Dir[File.expand_path("../../../vendor/swtbot", __FILE__) + "/*.jar"].each do |fn|
94
+ require fn
95
+ end
96
+ bot = org.eclipse.swtbot.swt.finder.SWTBot.new
97
+ bot.extend SwtBotExtensions
98
+ bot
99
+ end
100
+ end
101
+ end
102
+
103
+ module JFace
104
+ Dir[File.dirname(__FILE__) + "/../../vendor/jface/*.jar"].each do |jar_fn|
105
+ require jar_fn
106
+ end
107
+
108
+ module Viewers
109
+ import org.eclipse.jface.viewers.ColumnViewerToolTipSupport
110
+ import org.eclipse.jface.viewers.TreeViewer
111
+ import org.eclipse.jface.viewers.ITreeContentProvider
112
+ import org.eclipse.jface.viewers.ILabelProvider
113
+ import org.eclipse.jface.viewers.ILazyTreeContentProvider
114
+ import org.eclipse.jface.viewers.ILabelProvider
115
+ import org.eclipse.jface.viewers.TextCellEditor
116
+ import org.eclipse.jface.viewers.ViewerDropAdapter
117
+ end
118
+
119
+ module Text
120
+ import org.eclipse.jface.text.TextViewerUndoManager
121
+ end
122
+
123
+ module Dialogs
124
+ import org.eclipse.jface.dialogs.Dialog
125
+ import org.eclipse.jface.dialogs.InputDialog
126
+ end
127
+ end
128
+
129
+ require 'swt/grid_data'
@@ -0,0 +1,11 @@
1
+ module Swt
2
+ module Layout
3
+ class GridData
4
+ def self.construct
5
+ layoutData = GridData.new
6
+ yield layoutData
7
+ layoutData
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require 'rbconfig'
2
+
3
+ module Swt
4
+ def self.jar_path
5
+ File.expand_path(relative_jar_path, __FILE__)
6
+ end
7
+
8
+ def self.relative_jar_path
9
+ case Config::CONFIG["host_os"]
10
+ when /darwin/i
11
+ if Config::CONFIG["host_cpu"] == "x86_64"
12
+ '../../../vendor/swt/swt-osx64'
13
+ else
14
+ '../../../vendor/swt/swt-osx32'
15
+ end
16
+ when /linux/i
17
+ if %w(amd64 x84_64).include? Config::CONFIG["host_cpu"]
18
+ '../../../vendor/swt/swt-linux64'
19
+ else
20
+ '../../../vendor/swt/swt-linux32'
21
+ end
22
+ when /windows|mswin/i
23
+ if %w(amd64 x84_64).include? Config::CONFIG["host_cpu"]
24
+ '../../../vendor/swt/swt-win64'
25
+ else
26
+ '../../../vendor/swt/swt-win32'
27
+ end
28
+ end
29
+ end
30
+
31
+ if File.exist?(jar_path + ".jar")
32
+ require jar_path
33
+ else
34
+ raise "swt jar file required: #{jar_path}.jar"
35
+ end
36
+ end
@@ -0,0 +1,110 @@
1
+
2
+ require 'swt/jar_loader'
3
+ require 'swt/event_loop'
4
+ require 'swt/cucumber_runner'
5
+
6
+ module Swt
7
+ VERSION = "0.10" # also change in swt.gemspec
8
+
9
+ import org.eclipse.swt.SWT
10
+
11
+ module Widgets
12
+ import org.eclipse.swt.widgets.Display
13
+ import org.eclipse.swt.widgets.Label
14
+ import org.eclipse.swt.widgets.ProgressBar
15
+ import org.eclipse.swt.widgets.Shell
16
+ end
17
+
18
+ module Custom
19
+ end
20
+
21
+ module DND
22
+ end
23
+
24
+ module Layout
25
+ import org.eclipse.swt.layout.FormAttachment
26
+ import org.eclipse.swt.layout.FormData
27
+ import org.eclipse.swt.layout.FormLayout
28
+ end
29
+
30
+ module Graphics
31
+ import org.eclipse.swt.graphics.Image
32
+ end
33
+
34
+ module Events
35
+ end
36
+
37
+ class RRunnable
38
+ include java.lang.Runnable
39
+
40
+ def initialize(&block)
41
+ @block = block
42
+ end
43
+
44
+ def run
45
+ @block.call
46
+ end
47
+ end
48
+
49
+ # Runs the given block in the SWT Event thread
50
+ def self.sync_exec(&block)
51
+ runnable = Swt::RRunnable.new do
52
+ begin
53
+ block.call
54
+ rescue => e
55
+ puts "error in sync exec"
56
+ puts e.message
57
+ puts e.backtrace
58
+ end
59
+ end
60
+ unless display.is_disposed
61
+ display.syncExec(runnable)
62
+ end
63
+ end
64
+
65
+ # Runs the given block in the SWT Event thread after
66
+ # the given number of milliseconds
67
+ def self.timer_exec(ms, &block)
68
+ runnable = Swt::RRunnable.new(&block)
69
+ display.timerExec(ms, runnable)
70
+ end
71
+
72
+ def self.display
73
+ if defined?(SWT_APP_NAME)
74
+ Swt::Widgets::Display.app_name = SWT_APP_NAME
75
+ end
76
+ @display ||= (Swt::Widgets::Display.getCurrent || Swt::Widgets::Display.new)
77
+ end
78
+
79
+ display # must be created before we import the Clipboard class.
80
+
81
+ def self.event_loop(&stop_condition)
82
+ stop_conditions << stop_condition
83
+ run_event_loop
84
+ end
85
+
86
+ def self.stop_conditions
87
+ @stop_conditions ||= []
88
+ end
89
+
90
+ def self.event_loop_running?
91
+ @event_loop_running
92
+ end
93
+
94
+ def self.run_event_loop
95
+ return if event_loop_running?
96
+ @event_loop_running = true
97
+ display = Swt::Widgets::Display.current
98
+
99
+ until stop_conditions.any? {|c| c[] }
100
+ unless display.read_and_dispatch
101
+ display.sleep
102
+ end
103
+ end
104
+
105
+ display.dispose
106
+ end
107
+ end
108
+
109
+
110
+
@@ -0,0 +1,6 @@
1
+
2
+ module SwtbotExtensions
3
+ def c_tab_folder
4
+ c_tab_item.widget.parent
5
+ end
6
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swt
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.10'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Lucraft
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-10 00:00:00.000000000 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: Includes SWT jars and imports SWT classes into Ruby.
16
+ email:
17
+ - dan@fluentradical.com
18
+ executables:
19
+ - swt_cucumber
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - bin/swt_cucumber
24
+ - lib/swt/cucumber_patches.rb
25
+ - lib/swt/cucumber_runner.rb
26
+ - lib/swt/event_loop.rb
27
+ - lib/swt/full.rb
28
+ - lib/swt/grid_data.rb
29
+ - lib/swt/jar_loader.rb
30
+ - lib/swt/minimal.rb
31
+ - lib/swt/swt_bot_extensions.rb
32
+ - lib/swt.rb
33
+ - LICENSE
34
+ - README.md
35
+ - vendor/jface/org.eclipse.core.commands.jar
36
+ - vendor/jface/org.eclipse.core.jobs.jar
37
+ - vendor/jface/org.eclipse.core.resources.jar
38
+ - vendor/jface/org.eclipse.core.runtime_3.5.0.v20090525.jar
39
+ - vendor/jface/org.eclipse.equinox.common.jar
40
+ - vendor/jface/org.eclipse.jface.databinding_1.3.0.I20090525-2000.jar
41
+ - vendor/jface/org.eclipse.jface.jar
42
+ - vendor/jface/org.eclipse.jface.text_3.5.0.jar
43
+ - vendor/jface/org.eclipse.osgi.jar
44
+ - vendor/jface/org.eclipse.text_3.5.0.v20090513-2000.jar
45
+ - vendor/swt/swt-linux32.jar
46
+ - vendor/swt/swt-linux64.jar
47
+ - vendor/swt/swt-osx32.jar
48
+ - vendor/swt/swt-osx64.jar
49
+ - vendor/swt/swt-win32.jar
50
+ - vendor/swt/swt-win64.jar
51
+ - vendor/swtbot/org.apache.log4j_1.2.13.v200903072027.jar
52
+ - vendor/swtbot/org.eclipse.swtbot.junit4_x_2.0.4.20110304_0338-e5aff47-dev-e36.jar
53
+ - vendor/swtbot/org.eclipse.swtbot.swt.finder_2.0.4.20110304_0338-e5aff47-dev-e36.jar
54
+ - vendor/swtbot/org.hamcrest.core_1.1.0.v20090501071000.jar
55
+ - vendor/swtbot/org.hamcrest.integration_1.1.0.v20090501071000.jar
56
+ - vendor/swtbot/org.hamcrest.library_1.1.0.v20090501071000.jar
57
+ - vendor/swtbot/org.hamcrest.text_1.1.0.v20090501071000.jar
58
+ - vendor/swtbot/org.hamcrest_1.1.0.v20090501071000.jar
59
+ has_rdoc: true
60
+ homepage: http://github.com/danlucraft/swt
61
+ licenses: []
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 1.6.2
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: The SWT library available to JRuby.
84
+ test_files: []