bakkdoor-rswing 0.2.2 → 0.2.3

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.
data/Manifest ADDED
@@ -0,0 +1,38 @@
1
+ examples/combobox_example.rb
2
+ examples/numberconverter.rb
3
+ lib/rswing/components/button.rb
4
+ lib/rswing/components/check_box.rb
5
+ lib/rswing/components/combo_box.rb
6
+ lib/rswing/components/component.rb
7
+ lib/rswing/components/container.rb
8
+ lib/rswing/components/dialog.rb
9
+ lib/rswing/components/events/button_events.rb
10
+ lib/rswing/components/events/component_events.rb
11
+ lib/rswing/components/events/container_events.rb
12
+ lib/rswing/components/events/event.rb
13
+ lib/rswing/components/events/focus_events.rb
14
+ lib/rswing/components/events/hierarchy_bounds_events.rb
15
+ lib/rswing/components/events/hierarchy_changed.rb
16
+ lib/rswing/components/events/input_method_events.rb
17
+ lib/rswing/components/events/key_events.rb
18
+ lib/rswing/components/events/mouse_events.rb
19
+ lib/rswing/components/events/mouse_motion_events.rb
20
+ lib/rswing/components/events/mouse_wheel_events.rb
21
+ lib/rswing/components/events/property_changed.rb
22
+ lib/rswing/components/events/window_events.rb
23
+ lib/rswing/components/events/window_focus.rb
24
+ lib/rswing/components/events/window_state.rb
25
+ lib/rswing/components/frame.rb
26
+ lib/rswing/components/listener.rb
27
+ lib/rswing/components/options.rb
28
+ lib/rswing/components/panel.rb
29
+ lib/rswing/components/text_field.rb
30
+ lib/rswing/components/window.rb
31
+ lib/rswing.rb
32
+ LICENSE
33
+ Manifest
34
+ Rakefile
35
+ README
36
+ test/test_button.rb
37
+ test/test_container.rb
38
+ test/test_helper.rb
data/README CHANGED
@@ -42,7 +42,7 @@ Some examples:
42
42
 
43
43
  # options-dialog
44
44
  options = ["Yes", "No", "Cancel"]
45
- selected_value = Dialog.showOption(options.join(" or ") + "?",
45
+ selected_value = Dialog.show_option(options.join(" or ") + "?",
46
46
  :option_values => options,
47
47
  :option_type => :yes_no_cancel,
48
48
  :belongs_to => frame)
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
+ require 'rubygems'
1
2
  require "rake"
2
3
  require "rake/testtask"
3
4
  require "rake/rdoctask"
4
5
  require "rake/clean"
5
6
  require "rake/gempackagetask"
7
+ require 'echoe'
6
8
 
7
9
  task :default => [ :test ]
8
10
  task :test => [ :test_units ]
@@ -20,4 +22,18 @@ rd = Rake::RDocTask.new("doc") do |rd|
20
22
  rd.rdoc_files.include("README", "lib/*.rb")
21
23
  rd.options << "--all"
22
24
  rd.rdoc_dir = "rdoc"
23
- end
25
+ end
26
+
27
+ # echoe-related stuff for building gem & gemspec.
28
+
29
+ Echoe.new('rswing', '0.2.3') do |p|
30
+ p.description = %q{RSwing is a wrapper of the Swing GUI-Framework of the Java Platform for JRuby. The goal is to provide a ruby-ish wrapper library to Swing, which makes it feel more like an actual ruby library rather than just a plain interface to the java classes.}
31
+ p.summary = "RSwing - Ruby-ish wrapper of Swing GUI-Framework for JRuby"
32
+ p.url = "http://github.com/bakkdoor/rswing"
33
+ p.author = "Christopher Bertels"
34
+ p.email = "bakkdoor@flasht.de"
35
+ p.ignore_pattern = ["doc/*"]
36
+ p.development_dependencies = []
37
+ end
38
+
39
+ #Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,53 @@
1
+ module ComboboxExample
2
+ require "rubygems"
3
+ require "rswing"
4
+
5
+ include RSwing::Components
6
+
7
+ GridBagLayout = java.awt.GridBagLayout
8
+
9
+ frame = Frame.new "ComboBox example",
10
+ :size => [400,200],
11
+ :location => :center do |frame|
12
+
13
+ frame.default_close_operation = :exit_on_close
14
+
15
+ Panel.new :name => :panel,
16
+ :belongs_to => frame,
17
+ :layout_manager => GridBagLayout.new do |panel|
18
+
19
+ combobox_items = ["Value 1", "Value 2", "Value 3"]
20
+ ComboBox.new combobox_items,
21
+ :belongs_to => panel,
22
+ :name => :combobox
23
+
24
+ Button.new "OK",
25
+ :belongs_to => panel,
26
+ :name => :ok_button
27
+
28
+ Button.new "Cancel",
29
+ :belongs_to => panel,
30
+ :name => :cancel_button
31
+
32
+ end
33
+
34
+ frame.visible = true
35
+
36
+ end
37
+
38
+ # event handlers
39
+ panel = frame[:panel]
40
+
41
+ panel[:ok_button].on_click do
42
+ selected_item = panel[:combobox].selected_item
43
+ Dialog.show "Value selected: #{selected_item}",
44
+ :dialog_type => :info,
45
+ :title => "You have selected an item.",
46
+ :belongs_to => frame
47
+ end
48
+
49
+ panel[:cancel_button].on_click do
50
+ frame.dispose
51
+ end
52
+
53
+ end
@@ -0,0 +1,56 @@
1
+ module Numberconverter
2
+
3
+ #require "rubygems"
4
+ require "lib/rswing"
5
+
6
+ include RSwing::Components
7
+
8
+ GridBagLayout = java.awt.GridBagLayout
9
+
10
+ frame = Frame.new "Numberconverter",
11
+ :size => [400, 100],
12
+ :location => :center do |frame|
13
+
14
+ frame.default_close_operation = :exit_on_close
15
+
16
+ Panel.new :name => :panel,
17
+ :belongs_to => frame,
18
+ :layout_manager => GridBagLayout.new do |panel|
19
+
20
+ TextField.new :text => "0",
21
+ :columns => 10,
22
+ :belongs_to => panel,
23
+ :name => :entry_field
24
+
25
+ Button.new "Convert",
26
+ :belongs_to => panel,
27
+ :name => :button
28
+
29
+ TextField.new :text => "Output",
30
+ :columns => 10,
31
+ :belongs_to => panel,
32
+ :name => :output_field
33
+ end
34
+
35
+ frame.visible = true
36
+ end
37
+
38
+ # eventhandler code
39
+ panel = frame[:panel]
40
+ panel[:button].on_click do
41
+ result = Dialog.show_option "Please select:",
42
+ :option_type => :yes_no,
43
+ :option_values => ["HEX", "BINARY"],
44
+ :title => "Pick an option!",
45
+ :belongs_to => frame
46
+
47
+ base = 10 # standardwert
48
+ if result == "HEX"
49
+ base = 16
50
+ else
51
+ base = 2
52
+ end
53
+ panel[:output_field].text = panel[:entry_field].text.to_i.to_s(base)
54
+ end
55
+
56
+ end
data/lib/rswing.rb CHANGED
@@ -31,6 +31,7 @@ class Module
31
31
  end
32
32
 
33
33
  # event-modules
34
+ require "events/button_events"
34
35
  require "events/component_events"
35
36
  require "events/container_events"
36
37
  require "events/focus_events"
@@ -53,6 +54,7 @@ require "container"
53
54
  require "window"
54
55
 
55
56
  require "button"
57
+ require "check_box"
56
58
  require "combo_box"
57
59
  require "dialog"
58
60
  require "frame"
@@ -19,12 +19,12 @@
19
19
 
20
20
  module RSwing
21
21
  module Components
22
- ActionListener = java.awt.event.ActionListener
23
22
  JButton = javax.swing.JButton
24
23
 
25
24
  # Button-Class. Wraps JButton-Class.
26
25
  class Button < JButton
27
26
  include Component
27
+ include Events::ButtonEvents
28
28
 
29
29
  # - <tt>text</tt>: The Text to be displayed on the button.
30
30
  # - <tt>options</tt>: Options-Hash with the following valid values:
@@ -46,12 +46,10 @@ module RSwing
46
46
  yield self
47
47
  end
48
48
 
49
- Container.add_if_requested(self, options)
49
+ unless options.empty?
50
+ Container.add_if_requested(self, options)
51
+ end
50
52
  end
51
-
52
- # Eventhandler for clicked (actionPerformed) event.
53
- # Takes a block, which will be executed if this event occurs.
54
- event_for self => :on_click, ActionListener => :actionPerformed
55
53
  end
56
54
  end
57
55
  end
@@ -0,0 +1,55 @@
1
+ ###############################################################################
2
+ # This file is part of RSwing. #
3
+ # RSwing - Swing wrapper for JRuby #
4
+ # (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
5
+ # #
6
+ # RSwing is free software: you can redistribute it and/or modify #
7
+ # it under the terms of the GNU Lesser General Public License as published by #
8
+ # the Free Software Foundation, either version 3 of the License, or #
9
+ # (at your option) any later version. #
10
+ # #
11
+ # RSwing is distributed in the hope that it will be useful, #
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14
+ # GNU Lesser General Public License for more details. #
15
+ # #
16
+ # You should have received a copy of the GNU Lesser General Public License #
17
+ # along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
18
+ ###############################################################################
19
+
20
+ module RSwing
21
+ module Components
22
+ JCheckBox = javax.swing.JCheckBox
23
+
24
+ # CheckBox-Class. Wraps JCheckBox-Class.
25
+ class CheckBox < JCheckBox
26
+ include Component
27
+ include Events::ButtonEvents
28
+
29
+ # - <tt>text</tt>: The Text to be displayed on the checkbox.
30
+ # - <tt>options</tt>: Options-Hash with the following valid values:
31
+ # 1. <tt>:visible => true</tt>
32
+ # 2. <tt>:enabled => true</tt>
33
+ # 3. <tt>:selected => true</tt> # (default: false)
34
+ # 4. <tt>:layout => nil</tt> # Layout-Options (e.g. GridBagContraints-Object) (default: none)
35
+ # 5. <tt>:icon => nil</tt> # Icon-Symbol to be displayed next to/instead of the text on the checkbox (default: none)
36
+ # 6. <tt>:name => :check_box</tt> Name of the checkbox for access via parent-container (default: none)
37
+ def initialize(text, options = {}, &block)
38
+ super(text, Options.value_for(options => :selected))
39
+
40
+ self.visible = Options.value_for(options => :visible)
41
+ self.enabled = Options.value_for(options => :enabled)
42
+ self.icon = Options.value_for(options => :icon)
43
+
44
+ # call block with current object, if given
45
+ if block_given?
46
+ yield self
47
+ end
48
+
49
+ unless options.empty?
50
+ Container.add_if_requested(self, options)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -40,6 +40,8 @@ module RSwing
40
40
  # if :name given, add with name
41
41
  if(name = Options.value_for(options => :name))
42
42
  self.add_with_name(component, name)
43
+ # also set components name attribute, if specified
44
+ component.name = name.to_s
43
45
  end
44
46
 
45
47
  component # return component
@@ -24,7 +24,7 @@ module RSwing
24
24
 
25
25
  # Dialog-Class.
26
26
  # Has static methods to create Message-Dialogs.
27
- # (<tt>show()</tt> and <tt>showOptions</tt>).
27
+ # (<tt>show()</tt> and <tt>show_option</tt>).
28
28
  # Can also be used to create custom dialogs by extending from this class.
29
29
  class Dialog < JDialog
30
30
  include Window
@@ -79,7 +79,7 @@ module RSwing
79
79
  # 4. <tt>:modal => false</tt> (default: <tt>true</tt>)
80
80
  # 5. <tt>:icon => nil</tt> (default: nil)
81
81
  # 6. <tt>:belongs_to => parent</tt> Parent-Container for this dialog (default: nil)
82
- def self.showOption(message, options = {})
82
+ def self.show_option(message, options = {})
83
83
  title = options[:title].nil? ? Options.gui_options[:option_default_title] : options[:title]
84
84
  icon = Options.value_for(options => :icon)
85
85
 
@@ -0,0 +1,36 @@
1
+ ###############################################################################
2
+ # This file is part of RSwing. #
3
+ # RSwing - Swing wrapper for JRuby #
4
+ # (C) 2008 Christopher Bertels (bakkdoor@flasht.de) #
5
+ # #
6
+ # RSwing is free software: you can redistribute it and/or modify #
7
+ # it under the terms of the GNU Lesser General Public License as published by #
8
+ # the Free Software Foundation, either version 3 of the License, or #
9
+ # (at your option) any later version. #
10
+ # #
11
+ # RSwing is distributed in the hope that it will be useful, #
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14
+ # GNU Lesser General Public License for more details. #
15
+ # #
16
+ # You should have received a copy of the GNU Lesser General Public License #
17
+ # along with RSwing. If not, see <http://www.gnu.org/licenses/>. #
18
+ ###############################################################################
19
+
20
+ module RSwing
21
+ module Components
22
+ module Events
23
+ module ButtonEvents
24
+ ActionListener = java.awt.event.ActionListener
25
+ ItemListener = java.awt.event.ItemListener
26
+ ChangeListener = javax.swing.event.ChangeListener
27
+
28
+ # Eventhandler for clicked (actionPerformed) event.
29
+ # Takes a block, which will be executed if this event occurs.
30
+ event_for self => :on_click, ActionListener => :actionPerformed
31
+ event_for self => :on_item_state_changed, ItemListener => :itemStateChanged
32
+ event_for self => :on_state_changed, ChangeListener => :stateChanged
33
+ end
34
+ end
35
+ end
36
+ end
@@ -44,7 +44,8 @@ module RSwing
44
44
  :size => nil,
45
45
  :location => nil,
46
46
  :columns => 10,
47
- :text => ""
47
+ :text => "",
48
+ :selected => false
48
49
  }
49
50
  end
50
51
 
data/rswing.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{rswing}
3
+ s.version = "0.2.3"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Christopher Bertels"]
7
+ s.date = %q{2008-11-13}
8
+ s.description = %q{RSwing is a wrapper of the Swing GUI-Framework of the Java Platform for JRuby. The goal is to provide a ruby-ish wrapper library to Swing, which makes it feel more like an actual ruby library rather than just a plain interface to the java classes.}
9
+ s.email = %q{bakkdoor@flasht.de}
10
+ s.extra_rdoc_files = ["lib/rswing/components/button.rb", "lib/rswing/components/check_box.rb", "lib/rswing/components/combo_box.rb", "lib/rswing/components/component.rb", "lib/rswing/components/container.rb", "lib/rswing/components/dialog.rb", "lib/rswing/components/events/button_events.rb", "lib/rswing/components/events/component_events.rb", "lib/rswing/components/events/container_events.rb", "lib/rswing/components/events/event.rb", "lib/rswing/components/events/focus_events.rb", "lib/rswing/components/events/hierarchy_bounds_events.rb", "lib/rswing/components/events/hierarchy_changed.rb", "lib/rswing/components/events/input_method_events.rb", "lib/rswing/components/events/key_events.rb", "lib/rswing/components/events/mouse_events.rb", "lib/rswing/components/events/mouse_motion_events.rb", "lib/rswing/components/events/mouse_wheel_events.rb", "lib/rswing/components/events/property_changed.rb", "lib/rswing/components/events/window_events.rb", "lib/rswing/components/events/window_focus.rb", "lib/rswing/components/events/window_state.rb", "lib/rswing/components/frame.rb", "lib/rswing/components/listener.rb", "lib/rswing/components/options.rb", "lib/rswing/components/panel.rb", "lib/rswing/components/text_field.rb", "lib/rswing/components/window.rb", "lib/rswing.rb", "LICENSE", "README"]
11
+ s.files = ["examples/combobox_example.rb", "examples/numberconverter.rb", "lib/rswing/components/button.rb", "lib/rswing/components/check_box.rb", "lib/rswing/components/combo_box.rb", "lib/rswing/components/component.rb", "lib/rswing/components/container.rb", "lib/rswing/components/dialog.rb", "lib/rswing/components/events/button_events.rb", "lib/rswing/components/events/component_events.rb", "lib/rswing/components/events/container_events.rb", "lib/rswing/components/events/event.rb", "lib/rswing/components/events/focus_events.rb", "lib/rswing/components/events/hierarchy_bounds_events.rb", "lib/rswing/components/events/hierarchy_changed.rb", "lib/rswing/components/events/input_method_events.rb", "lib/rswing/components/events/key_events.rb", "lib/rswing/components/events/mouse_events.rb", "lib/rswing/components/events/mouse_motion_events.rb", "lib/rswing/components/events/mouse_wheel_events.rb", "lib/rswing/components/events/property_changed.rb", "lib/rswing/components/events/window_events.rb", "lib/rswing/components/events/window_focus.rb", "lib/rswing/components/events/window_state.rb", "lib/rswing/components/frame.rb", "lib/rswing/components/listener.rb", "lib/rswing/components/options.rb", "lib/rswing/components/panel.rb", "lib/rswing/components/text_field.rb", "lib/rswing/components/window.rb", "lib/rswing.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/test_button.rb", "test/test_container.rb", "test/test_helper.rb", "rswing.gemspec"]
12
+ s.has_rdoc = true
13
+ s.homepage = %q{http://github.com/bakkdoor/rswing}
14
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rswing", "--main", "README"]
15
+ s.require_paths = ["lib"]
16
+ s.rubyforge_project = %q{rswing}
17
+ s.rubygems_version = %q{1.2.0}
18
+ s.summary = %q{RSwing - Ruby-ish wrapper of Swing GUI-Framework for JRuby}
19
+ s.test_files = ["test/test_button.rb", "test/test_container.rb", "test/test_helper.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
24
+
25
+ if current_version >= 3 then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bakkdoor-rswing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Bertels
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-04 00:00:00 -08:00
12
+ date: 2008-11-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,18 +20,47 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
+ - lib/rswing/components/button.rb
24
+ - lib/rswing/components/check_box.rb
25
+ - lib/rswing/components/combo_box.rb
26
+ - lib/rswing/components/component.rb
27
+ - lib/rswing/components/container.rb
28
+ - lib/rswing/components/dialog.rb
29
+ - lib/rswing/components/events/button_events.rb
30
+ - lib/rswing/components/events/component_events.rb
31
+ - lib/rswing/components/events/container_events.rb
32
+ - lib/rswing/components/events/event.rb
33
+ - lib/rswing/components/events/focus_events.rb
34
+ - lib/rswing/components/events/hierarchy_bounds_events.rb
35
+ - lib/rswing/components/events/hierarchy_changed.rb
36
+ - lib/rswing/components/events/input_method_events.rb
37
+ - lib/rswing/components/events/key_events.rb
38
+ - lib/rswing/components/events/mouse_events.rb
39
+ - lib/rswing/components/events/mouse_motion_events.rb
40
+ - lib/rswing/components/events/mouse_wheel_events.rb
41
+ - lib/rswing/components/events/property_changed.rb
42
+ - lib/rswing/components/events/window_events.rb
43
+ - lib/rswing/components/events/window_focus.rb
44
+ - lib/rswing/components/events/window_state.rb
45
+ - lib/rswing/components/frame.rb
46
+ - lib/rswing/components/listener.rb
47
+ - lib/rswing/components/options.rb
48
+ - lib/rswing/components/panel.rb
49
+ - lib/rswing/components/text_field.rb
50
+ - lib/rswing/components/window.rb
51
+ - lib/rswing.rb
52
+ - LICENSE
23
53
  - README
24
54
  files:
25
- - README
26
- - LICENSE
27
- - Rakefile
28
- - lib/rswing.rb
55
+ - examples/combobox_example.rb
56
+ - examples/numberconverter.rb
29
57
  - lib/rswing/components/button.rb
58
+ - lib/rswing/components/check_box.rb
30
59
  - lib/rswing/components/combo_box.rb
31
60
  - lib/rswing/components/component.rb
32
61
  - lib/rswing/components/container.rb
33
62
  - lib/rswing/components/dialog.rb
34
- - lib/rswing/components/events
63
+ - lib/rswing/components/events/button_events.rb
35
64
  - lib/rswing/components/events/component_events.rb
36
65
  - lib/rswing/components/events/container_events.rb
37
66
  - lib/rswing/components/events/event.rb
@@ -53,13 +82,23 @@ files:
53
82
  - lib/rswing/components/panel.rb
54
83
  - lib/rswing/components/text_field.rb
55
84
  - lib/rswing/components/window.rb
85
+ - lib/rswing.rb
86
+ - LICENSE
87
+ - Manifest
88
+ - Rakefile
89
+ - README
56
90
  - test/test_button.rb
57
91
  - test/test_container.rb
58
92
  - test/test_helper.rb
93
+ - rswing.gemspec
59
94
  has_rdoc: true
60
95
  homepage: http://github.com/bakkdoor/rswing
61
96
  post_install_message:
62
97
  rdoc_options:
98
+ - --line-numbers
99
+ - --inline-source
100
+ - --title
101
+ - Rswing
63
102
  - --main
64
103
  - README
65
104
  require_paths:
@@ -74,11 +113,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
113
  requirements:
75
114
  - - ">="
76
115
  - !ruby/object:Gem::Version
77
- version: "0"
116
+ version: "1.2"
78
117
  version:
79
- requirements:
80
- - none
81
- rubyforge_project:
118
+ requirements: []
119
+
120
+ rubyforge_project: rswing
82
121
  rubygems_version: 1.2.0
83
122
  signing_key:
84
123
  specification_version: 2