swing 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -33,3 +33,7 @@
33
33
  == 0.1.2 / 2011-05-25
34
34
 
35
35
  * JFrame fixed
36
+
37
+ == 0.1.3 / 2011-05-26
38
+
39
+ * Upgrade Awt::Component
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/lib/awt/component.rb CHANGED
@@ -8,4 +8,28 @@ class Awt::Component
8
8
 
9
9
  include SwingSupport::Extensions::Attributes
10
10
 
11
+ # background Color � �
12
+ # cursor Cursor � � Cursor.DEFAULT_CURSOR
13
+ # enabled boolean � � true
14
+ # font Font � �
15
+ # foreground Color � �
16
+ # layout LayoutManager � � BorderLayout( )
17
+ # locale Locale � �
18
+ # location Point � �
19
+ # locationOnScreen Point � �
20
+ # name String � � ""
21
+ # parent Container � � null
22
+ # size Dimension � �
23
+ # visible boolean � � true
24
+ # ----Getters only - NO Setters!
25
+ # colorModel ColorModel �
26
+ # component (i) Component �
27
+ # componentCount int �
28
+ # components Component[] �
29
+ # insets Insets � Insets(0,0,0,0)
30
+ # showing boolean � true
31
+ # valid boolean �
32
+
33
+ attr_setter :background, :cursor, :enabled, :font, :foreground, :layout, :locale,
34
+ :location, :location_on_screen, :name, :parent, :size, :visible
11
35
  end
@@ -2,7 +2,7 @@ require 'swing'
2
2
 
3
3
  class Swing::JButton
4
4
 
5
- attr_setter :enabled
5
+ attr_setter :tool_tip_text
6
6
 
7
7
  def initialize *args, &block
8
8
  super *args
@@ -3,6 +3,7 @@ require 'swing'
3
3
  class Swing::JCheckBox
4
4
 
5
5
  attr_setter :selected
6
+ attr_setter :tool_tip_text
6
7
 
7
8
  def initialize *args, &block
8
9
  super *args
data/lib/swing/j_frame.rb CHANGED
@@ -1,11 +1,16 @@
1
1
  require 'swing'
2
2
 
3
3
  class Swing::JFrame
4
- # include AttrSetter
5
4
 
6
5
  attr_setter :layout, :background, :size, :title,
7
6
  :default_close_operation => EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
8
7
 
8
+ def attributes
9
+ a = super
10
+ a.delete :tool_tip_text
11
+ a
12
+ end
13
+
9
14
  def initialize *args
10
15
 
11
16
  super *args
data/lib/swing/j_label.rb CHANGED
@@ -2,5 +2,7 @@ require 'swing'
2
2
 
3
3
  class Swing::JLabel
4
4
 
5
+ attr_setter :tool_tip_text
6
+
5
7
  end # class Label
6
8
 
data/lib/swing/j_list.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'swing'
2
2
 
3
3
  class Swing::JList
4
+ attr_setter :tool_tip_text
4
5
 
5
6
  end # class List
6
7
 
data/lib/swing/j_menu.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'swing'
2
2
 
3
3
  class Swing::JMenu
4
+ attr_setter :tool_tip_text
4
5
 
5
6
  end
@@ -4,6 +4,8 @@ require 'swing/j_menu_item'
4
4
 
5
5
  class Swing::JMenuBar
6
6
 
7
+ attr_setter :tool_tip_text
8
+
7
9
  def initialize opts = {}
8
10
  super opts
9
11
 
@@ -1,6 +1,7 @@
1
1
  require 'swing'
2
2
 
3
3
  class Swing::JMenuItem
4
+ attr_setter :tool_tip_text
4
5
 
5
6
  def initialize text, opts = {}, &block
6
7
  super text
data/lib/swing/j_panel.rb CHANGED
@@ -2,5 +2,5 @@ require 'swing'
2
2
 
3
3
  class Swing::JPanel
4
4
 
5
- attr_setter :layout, :background
5
+ attr_setter :tool_tip_text
6
6
  end # class Panel
@@ -3,6 +3,7 @@ require 'swing'
3
3
  # Scroll Pane around given scrollable component
4
4
  class Swing::JScrollPane
5
5
 
6
+ attr_setter :tool_tip_text
6
7
  attr_setter :horizontal_scroll_bar_policy, :vertical_scroll_bar_policy
7
8
 
8
9
  end # class JScrollPane
@@ -2,6 +2,7 @@ require 'swing'
2
2
 
3
3
  class Swing::JSplitPane
4
4
 
5
+ attr_setter :tool_tip_text
5
6
  attr_setter :one_touch_expandable, :orientation, :continuous_layout,
6
7
  :divider_size, :divider_location, :resize_weight
7
8
 
data/lib/swing/j_table.rb CHANGED
@@ -37,6 +37,7 @@ class Swing::JTable
37
37
  # scrollableTracksViewportHeighto boolean � false
38
38
  # scrollableTracksViewportWidtho boolean � false
39
39
 
40
+ attr_setter :tool_tip_text
40
41
  attr_setter :auto_create_columns_from_model, :auto_resize_mode, :row_height,
41
42
  :model, :column_model, :selection_model,
42
43
  :drag_enabled, :cell_editor, :grid_color, :intercell_spacing,
data/lib/swing.rb CHANGED
@@ -7,8 +7,21 @@ require 'version'
7
7
  require 'swing_support'
8
8
  require 'awt'
9
9
 
10
- #
10
+ require 'swing/j_button'
11
+ require 'swing/j_check_box'
12
+ require 'swing/j_frame'
13
+ require 'swing/j_label'
14
+ require 'swing/j_list'
15
+ require 'swing/j_menu'
16
+ require 'swing/j_menu_bar'
17
+ require 'swing/j_menu_item'
18
+ require 'swing/j_panel'
19
+ require 'swing/j_scroll_pane'
20
+ require 'swing/j_split_pane'
21
+ require 'swing/j_table'
22
+
11
23
  #module Swing
24
+ # TODO: Impossible to auto-load, this is Swing package, not a Ruby module :(
12
25
  # autoload :JButton, "swing/j_button"
13
26
  # autoload :JCheckBox, "swing/j_check_box"
14
27
  # autoload :JButton, "swing/j_button"
@@ -8,7 +8,7 @@ module SwingSupport
8
8
  def self.included host
9
9
  host.send :extend, ClassMethods
10
10
  host.instance_eval do
11
- attr_setter :font, :tool_tip_text, :enabled
11
+ # attr_setter :font, :tool_tip_text, :enabled
12
12
  alias :new_without_attributes :new
13
13
  alias :new :new_with_attributes
14
14
  end
data/lib/swing_support.rb CHANGED
@@ -2,3 +2,4 @@ module SwingSupport
2
2
  end
3
3
 
4
4
  require 'swing_support/extensions/attributes'
5
+ require 'swing_support/action_listener'
@@ -4,14 +4,13 @@ require 'awt/component'
4
4
  describe 'java.awt.Component' do
5
5
  context 'defining new methods' do
6
6
  it 'changes derived Ruby subclases' do
7
- button = Swing::JButton.new 'Disconnect', :enabled => false
8
- button.should_not be_enabled
7
+ button = Swing::JButton.new 'Disconnect'
9
8
  button.should respond_to :blah
10
9
  button.blah
11
10
  end
12
11
 
13
12
  it 'changes derived pure Java subclases' do
14
- button = javax.swing.JButton.new 'Disconnect' #, :enabled => false
13
+ button = javax.swing.JButton.new 'Disconnect'
15
14
  button.should respond_to :blah
16
15
  button.blah
17
16
  end
@@ -1,8 +1,21 @@
1
1
  require 'spec_helper'
2
+ require 'swing/shared'
2
3
 
3
4
  describe Swing::JButton do
4
- it 'is possible to set :enabled attribute to false' do
5
- button = Swing::JButton.new 'Disconnect', :enabled => false
6
- button.should_not be_enabled
5
+
6
+ context 'creation' do
7
+ let(:new_args) { ['Text'] }
8
+
9
+ it_behaves_like 'enhanced awt component'
10
+
11
+ it 'is possible to set :enabled attribute to false' do
12
+ button = Swing::JButton.new 'Disconnect', :enabled => false
13
+ button.should_not be_enabled
14
+ end
15
+
16
+ it 'is possible to set :tool_tip_text attribute' do
17
+ button = Swing::JButton.new 'Disconnect', :tool_tip_text => 'Blah'
18
+ button.tool_tip_text.should == 'Blah'
19
+ end
7
20
  end
8
21
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'swing/shared'
3
+
4
+ describe Swing::JCheckBox do
5
+
6
+ context 'creation' do
7
+ let(:new_args) { ['Text'] }
8
+
9
+ it_behaves_like 'enhanced awt component'
10
+
11
+ it 'is possible to set :selected attribute' do
12
+ box = Swing::JCheckBox.new 'Disconnect', :selected => true
13
+ box.should be_selected
14
+ end
15
+
16
+ it 'is possible to set :tool_tip_text attribute' do
17
+ box = Swing::JCheckBox.new 'Disconnect', :tool_tip_text => 'Blah'
18
+ box.tool_tip_text.should == 'Blah'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'swing/shared'
3
+
4
+ describe Swing::JLabel do
5
+
6
+ context 'creation' do
7
+ let(:new_args) { ['Text'] }
8
+
9
+ it_behaves_like 'enhanced awt component'
10
+
11
+ it 'is possible to set :tool_tip_text attribute' do
12
+ label = Swing::JLabel.new 'Disconnect', :tool_tip_text => 'Blah'
13
+ label.tool_tip_text.should == 'Blah'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ shared_examples_for 'enhanced awt component' do
2
+
3
+ context 'new with common options' do
4
+ it 'is possible to create components with settable attribute' do
5
+ p described_class.attributes
6
+ background = Awt::Color.new(1, 2, 3)
7
+ cursor = Awt::Cursor.new Awt::Cursor::HAND_CURSOR #DEFAULT_CURSOR
8
+ enabled = false
9
+ font = Awt::Font.new("Trebuchet", Awt::Font::PLAIN, 11)
10
+ new_args.push :background => background, :cursor => cursor, :enabled => enabled,
11
+ :font => font, :name => 'Blah'
12
+ component = described_class.new *new_args
13
+ component.background.should == background
14
+ component.cursor.should == cursor
15
+ component.enabled?.should == false
16
+ component.font.should == font
17
+ component.name.should == 'Blah'
18
+ component.parent.should == nil
19
+ end
20
+ end
21
+
22
+ # context 'new with options (without parent)' do
23
+ # {Swing::JLabel => 'Text', Swing::JButton => 'Text', Swing::JCheckBox => 'Text',
24
+ # Swing::JFrame => 'Text', Swing::JList => [], Swing::JMenu => [], Swing::JMenuBar=> [],
25
+ # Swing::JMenuItem => [], Swing::JPanel => [], Swing::JScrollPane => [],
26
+ # Swing::JSplitPane => [], Swing::JTable => [2, 2]}.each do |klass, args|
27
+ # it 'is possible to create components with settable attribute' do
28
+ # p klass.attributes
29
+ # constructor_args.push constructor_options
30
+ # component = klass.new(*args, :name => 'Blah')
31
+ # component.name.should == 'Blah'
32
+ # component.parent.should == nil
33
+ # end
34
+ # end
35
+ # end
36
+ end
37
+ #{Swing::JLabel => 'Text', Swing::JButton => 'Text', Swing::JCheckBox => 'Text',
38
+ # Swing::JFrame => 'Text', Swing::JList => [], Swing::JMenu => [], Swing::JMenuBar=> [],
39
+ # Swing::JMenuItem => [], Swing::JPanel => [], Swing::JScrollPane => [],
40
+ # Swing::JSplitPane => [], Swing::JTable => [2, 2]}.each do |klass, args|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: swing
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-25 00:00:00 +04:00
13
+ date: 2011-05-26 00:00:00 +04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,9 @@ files:
87
87
  - spec/swing_spec.rb
88
88
  - spec/awt/component_spec.rb
89
89
  - spec/swing/j_button_spec.rb
90
+ - spec/swing/j_check_box_spec.rb
91
+ - spec/swing/j_label_spec.rb
92
+ - spec/swing/shared.rb
90
93
  - features/swing.feature
91
94
  - features/step_definitions/swing_steps.rb
92
95
  - features/support/env.rb
@@ -141,3 +144,6 @@ test_files:
141
144
  - spec/swing_spec.rb
142
145
  - spec/awt/component_spec.rb
143
146
  - spec/swing/j_button_spec.rb
147
+ - spec/swing/j_check_box_spec.rb
148
+ - spec/swing/j_label_spec.rb
149
+ - spec/swing/shared.rb